qiskit_addon_opt_mapper.problems.HigherOrderConstraint¶
- class HigherOrderConstraint(optimization_problem, name, linear=None, quadratic=None, higher_order=None, sense=ConstraintSense.LE, rhs=0.0)[source]¶
 Bases:
ConstraintConstraint in higher order form.
e.g.
linear(x) + x^T Q x + sum_{k>=3} sum_{|t|=k} C_k[t] * prod_{i in t} x[i]senserhswheresenseis one of the ConstraintSense values (e.g., LE, <=) andrhsis a float.Supports both a single higher-order term (order+coeffs) and multiple via higher_orders={k: coeffs}.
Construct a higher-order constraint with linear, quadratic, and optional higher-order parts.
- Parameters:
 optimization_problem (Any) – The optimization problem this constraint belongs to.
name (str) – The name of the constraint.
linear (ndarray | spmatrix | list[float] | dict[str | int, float] | None) – Coefficients for the linear part.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[int | str, int | str], float] | None) – Coefficients for the quadratic part.
higher_order (dict[int, ndarray | dict[tuple[str | int, ...], float] | list] | None) – A single higher-order expression or a dictionary of {order: coeffs} for multiple orders (k≥3).
sense (ConstraintSense) – The sense of the constraint (e.g., LE, <=).
rhs (float) – The right-hand-side value of the constraint.
- __init__(optimization_problem, name, linear=None, quadratic=None, higher_order=None, sense=ConstraintSense.LE, rhs=0.0)[source]¶
 Construct a higher-order constraint with linear, quadratic, and optional higher-order parts.
- Parameters:
 optimization_problem (Any) – The optimization problem this constraint belongs to.
name (str) – The name of the constraint.
linear (ndarray | spmatrix | list[float] | dict[str | int, float] | None) – Coefficients for the linear part.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[int | str, int | str], float] | None) – Coefficients for the quadratic part.
higher_order (dict[int, ndarray | dict[tuple[str | int, ...], float] | list] | None) – A single higher-order expression or a dictionary of {order: coeffs} for multiple orders (k≥3).
sense (ConstraintSense) – The sense of the constraint (e.g., LE, <=).
rhs (float) – The right-hand-side value of the constraint.
- Return type:
 None
Methods
__init__(optimization_problem, name[, ...])Construct a higher-order constraint with linear, quadratic, and optional higher-order parts.
evaluate(x)Evaluate the left-hand-side of the constraint.
Attributes
HigherOrderExpression}.
Returns the linear expression corresponding to the left-hand-side of the constraint.
Returns the name of the constraint.
Returns the parent OptimizationProblem.
Returns the quadratic expression corresponding to the left-hand-side of the constraint.
Returns the right-hand-side of the constraint.
Returns the sense of the constraint.
- property higher_order: dict[int, HigherOrderExpression]¶
 HigherOrderExpression}.
- Returns:
 A dictionary mapping order (k>=3) to HigherOrderExpression.
- Type:
 Return a shallow copy of {order
- property linear: LinearExpression¶
 Returns the linear expression corresponding to the left-hand-side of the constraint.
- Returns:
 The left-hand-side linear expression.
- property optimization_problem: OptimizationProblem¶
 Returns the parent OptimizationProblem.
- Returns:
 The parent OptimizationProblem.
- property quadratic: QuadraticExpression¶
 Returns the quadratic expression corresponding to the left-hand-side of the constraint.
- Returns:
 The left-hand-side quadratic expression.
- 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.