qiskit_addon_opt_mapper.problems.OptimizationObjective¶
- class OptimizationObjective(optimization_problem, constant=0.0, linear=None, quadratic=None, higher_order=None, sense=ObjSense.MINIMIZE)[source]¶
 Bases:
OptimizationProblemElementOptimization objective element.
- Follows:
 constant + linear(x) + x^T Q x + sum_{k>=3} H_k(x).
Construct an objective with linear, quadratic, and optional higher-order parts.
- Parameters:
 optimization_problem (Any) – The optimization problem this objective belongs to.
constant (float) – The constant part of the objective function.
linear (ndarray | spmatrix | list[float] | dict[int | str, float] | None) – The coefficients for the linear part of the objective function.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[int | str, int | str], float] | None) – The coefficients for the quadratic part of the objective function.
higher_order (dict[int, ndarray | dict[tuple[int | str, ...], float] | list] | None) – A single higher-order expression or a dictionary of {order: coeffs} for multiple orders (k>=3).
sense (ObjSense) – The sense of the objective function (e.g., MINIMIZE, MAXIMIZE).
- __init__(optimization_problem, constant=0.0, linear=None, quadratic=None, higher_order=None, sense=ObjSense.MINIMIZE)[source]¶
 Construct an objective with linear, quadratic, and optional higher-order parts.
- Parameters:
 optimization_problem (Any) – The optimization problem this objective belongs to.
constant (float) – The constant part of the objective function.
linear (ndarray | spmatrix | list[float] | dict[str | int, float] | None) – The coefficients for the linear part of the objective function.
quadratic (ndarray | spmatrix | list[list[float]] | dict[tuple[int | str, int | str], float] | None) – The coefficients for the quadratic part of the objective function.
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 (ObjSense) – The sense of the objective function (e.g., MINIMIZE, MAXIMIZE).
- Return type:
 None
Methods
__init__(optimization_problem[, constant, ...])Construct an objective with linear, quadratic, and optional higher-order parts.
evaluate(x)Evaluate objective value at x.
Evaluate gradient of the objective at x.
Attributes
Returns the constant part of the objective function.
HigherOrderExpression}.
Returns the linear expression corresponding to the left-hand-side of the constraint.
Returns the parent OptimizationProblem.
Returns the quadratic expression corresponding to the left-hand-side of the constraint.
Returns the sense of the objective function.
- property constant: float¶
 Returns the constant part of the objective function.
- Returns:
 The constant part of the objective function.
- 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 sense: ObjSense¶
 Returns the sense of the objective function.
- Returns:
 The sense of the objective function (e.g., MINIMIZE, MAXIMIZE).