qiskit_addon_opt_mapper.problems.Constraint

class Constraint(optimization_problem, name, sense, rhs)[source]

Bases: OptimizationProblemElement

Abstract Constraint Class.

Initializes the constraint.

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

  • name (str) – The name of the constraint.

  • sense (ConstraintSense) – The sense of the constraint.

  • rhs (float) – The right-hand-side of the constraint.

__init__(optimization_problem, name, sense, rhs)[source]

Initializes the constraint.

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

  • name (str) – The name of the constraint.

  • sense (ConstraintSense) – The sense of the constraint.

  • rhs (float) – The right-hand-side of the constraint.

Return type:

None

Methods

__init__(optimization_problem, name, sense, rhs)

Initializes the constraint.

evaluate(x)

Evaluate left-hand-side of constraint for given values of variables.

Attributes

name

Returns the name of the constraint.

optimization_problem

Returns the parent OptimizationProblem.

rhs

Returns the right-hand-side of the constraint.

sense

Returns the sense of the constraint.

Sense[source]

alias of ConstraintSense

abstract evaluate(x)[source]

Evaluate left-hand-side of constraint for given values of variables.

Parameters:

x (ndarray | list | dict[str | int, float]) – The values to be used for the variables.

Returns:

The left-hand-side of the constraint.

Return type:

float

property name: str

Returns the name of the constraint.

Returns:

The name of the constraint.

property optimization_problem: OptimizationProblem

Returns the parent OptimizationProblem.

Returns:

The parent OptimizationProblem.

property rhs: float

Returns the right-hand-side of the constraint.

Returns:

The right-hand-side of the constraint.

property sense: ConstraintSense

Returns the sense of the constraint.

Returns:

The sense of the constraint.