qiskit_addon_opt_mapper.problems.Variable

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

Bases: OptimizationProblemElement

Representation of a variable.

Creates a new Variable.

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

Parameters:
  • optimization_problem (Any) – The parent OptimizationProblem.

  • name (str) – The variable name.

  • lowerbound (float | int) – The variable lowerbound.

  • upperbound (float | int) – The variable upperbound.

  • vartype (VarType) – The variable type.

Raises:

OptimizationError – if lowerbound is greater than upperbound.

__init__(optimization_problem, name, lowerbound=0, upperbound=1e+20, vartype=VarType.CONTINUOUS)[source]

Creates a new Variable.

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

Parameters:
  • optimization_problem (Any) – The parent OptimizationProblem.

  • name (str) – The variable name.

  • lowerbound (float | int) – The variable lowerbound.

  • upperbound (float | int) – The variable upperbound.

  • vartype (VarType) – The variable type.

Raises:

OptimizationError – if lowerbound is greater than upperbound.

Return type:

None

Methods

__init__(optimization_problem, name[, ...])

Creates a new Variable.

as_tuple()

Returns a tuple corresponding to this variable.

Attributes

lowerbound

Returns the lowerbound of the variable.

name

Returns the name of the variable.

optimization_problem

Returns the parent OptimizationProblem.

upperbound

Returns the upperbound of the variable.

vartype

Returns the type of the variable.

Type[source]

alias of VarType

as_tuple()[source]

Returns a tuple corresponding to this variable.

Returns:

A tuple corresponding to this variable consisting of name, lowerbound, upperbound and variable type.

Return type:

tuple[str, float | int, float | int, VarType]

property lowerbound: float | int

Returns the lowerbound of the variable.

Returns:

The lower bound of the variable.

property name: str

Returns the name of the variable.

Returns:

The name of the variable.

property optimization_problem: OptimizationProblem

Returns the parent OptimizationProblem.

Returns:

The parent OptimizationProblem.

property upperbound: float | int

Returns the upperbound of the variable.

Returns:

The upperbound of the variable.

property vartype: VarType

Returns the type of the variable.

Returns:

The variable type.