qiskit.optimization.problems.QuadraticObjective
class QuadraticObjective(quadratic_program, constant=0.0, linear=None, quadratic=None, sense=<ObjSense.MINIMIZE: 1>)
Representation of quadratic objective function of the form: constant + linear * x + x * quadratic * x.
Constructs a quadratic objective function.
Parameters
- quadratic_program (
Any
) – The parent quadratic program. - constant (
float
) – The constant offset of the objective. - linear (
Union
[ndarray
,spmatrix
,List
[float
],Dict
[Union
[int
,str
],float
],None
]) – The coefficients of the linear part of the objective. - quadratic (
Union
[ndarray
,spmatrix
,List
[List
[float
]],Dict
[Tuple
[Union
[int
,str
],Union
[int
,str
]],float
],None
]) – The coefficients of the quadratic part of the objective. - sense (
ObjSense
) – The optimization sense of the objective.
__init__
__init__(quadratic_program, constant=0.0, linear=None, quadratic=None, sense=<ObjSense.MINIMIZE: 1>)
Constructs a quadratic objective function.
Parameters
- quadratic_program (
Any
) – The parent quadratic program. - constant (
float
) – The constant offset of the objective. - linear (
Union
[ndarray
,spmatrix
,List
[float
],Dict
[Union
[int
,str
],float
],None
]) – The coefficients of the linear part of the objective. - quadratic (
Union
[ndarray
,spmatrix
,List
[List
[float
]],Dict
[Tuple
[Union
[int
,str
],Union
[int
,str
]],float
],None
]) – The coefficients of the quadratic part of the objective. - sense (
ObjSense
) – The optimization sense of the objective.
Methods
__init__ (quadratic_program[, constant, …]) | Constructs a quadratic objective function. |
evaluate (x) | Evaluate the quadratic objective for given variable values. |
evaluate_gradient (x) | Evaluate the gradient of the quadratic objective for given variable values. |
Attributes
constant | Returns the constant part of the objective function. |
linear | Returns the linear part of the objective function. |
quadratic | Returns the quadratic part of the objective function. |
quadratic_program | Returns the parent QuadraticProgram. |
sense | Returns the sense of the objective function. |
Sense
alias of ObjSense
constant
Returns the constant part of the objective function.
Return type
float
Returns
The constant part of the objective function.
evaluate
evaluate(x)
Evaluate the quadratic objective for given variable values.
Parameters
x (Union
[ndarray
, List
, Dict
[Union
[int
, str
], float
]]) – The values of the variables to be evaluated.
Return type
float
Returns
The value of the quadratic objective given the variable values.
evaluate_gradient
evaluate_gradient(x)
Evaluate the gradient of the quadratic objective for given variable values.
Parameters
x (Union
[ndarray
, List
, Dict
[Union
[int
, str
], float
]]) – The values of the variables to be evaluated.
Return type
ndarray
Returns
The value of the gradient of the quadratic objective given the variable values.
linear
Returns the linear part of the objective function.
Return type
LinearExpression
Returns
The linear part of the objective function.
quadratic
Returns the quadratic part of the objective function.
Return type
QuadraticExpression
Returns
The quadratic part of the objective function.
quadratic_program
Returns the parent QuadraticProgram.
Return type
Any
Returns
The parent QuadraticProgram.
sense
Returns the sense of the objective function.
Return type
ObjSense
Returns
The sense of the objective function.