Variable

class Variable(quadratic_program, name, lowerbound=0, upperbound=1e+20, vartype=VarType.CONTINUOUS)[source]

Representation of a variable.

Creates a new Variable.

The variables is exposed by the top-level QuadraticProgram class in QuadraticProgram.variables. This constructor is not meant to be used externally.

Parameters
  • quadratic_program (Any) – The parent QuadraticProgram.

  • name (str) – The variable name.

  • lowerbound (Union[float, int]) – The variable lowerbound.

  • upperbound (Union[float, int]) – The variable upperbound.

  • vartype (VarType) – The variable type.

Raises

QiskitOptimizationError – if lowerbound is greater than upperbound.

Attributes

Variable.lowerbound

Returns the lowerbound of the variable.

Variable.name

Returns the name of the variable.

Variable.quadratic_program

Returns the parent QuadraticProgram.

Variable.upperbound

Returns the upperbound of the variable.

Variable.vartype

Returns the type of the variable.

Methods

Variable.as_tuple()

Returns a tuple corresponding to this variable.