LinearExpression¶
- class LinearExpression(quadratic_program, coefficients)[source]¶
Representation of a linear expression by its coefficients.
Creates a new linear expression.
The linear expression can be defined via an array, a list, a sparse matrix, or a dictionary that uses variable names or indices as keys and stores the values internally as a dok_matrix.
- Parameters
quadratic_program (
Any
) – The parent QuadraticProgram.coefficients (
Union
[ndarray
,spmatrix
,List
[float
],Dict
[Union
[int
,str
],float
]]) – The (sparse) representation of the coefficients.
Attributes
Returns the coefficients of the linear expression.
Returns the parent QuadraticProgram.
Methods
Returns the i-th coefficient where i can be a variable name or index.
Evaluate the linear expression for given variables.
Returns the coefficients of the linear expression as array.
LinearExpression.to_dict
([use_name])Returns the coefficients of the linear expression as dictionary, either using variable names or indices as keys.