qiskit_addon_opt_mapper.problems.LinearExpression¶
- class LinearExpression(optimization_problem, coefficients)[source]¶
 Bases:
OptimizationProblemElementRepresentation 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:
 
- __init__(optimization_problem, coefficients)[source]¶
 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.
Methods
__init__(optimization_problem, coefficients)Creates a new linear expression.
evaluate(x)Evaluate the linear expression for given variables.
Evaluate the gradient of the linear expression for given variables.
to_array()Returns the coefficients of the linear expression as array.
to_dict([use_name])Returns the coefficients of the linear expression as dictionary.
Attributes
Returns the lower bound and the upper bound of the linear expression.
Returns the coefficients of the linear expression.
Returns the parent OptimizationProblem.
- property bounds: ExpressionBounds¶
 Returns the lower bound and the upper bound of the linear expression.
- Returns:
 The lower bound and the upper bound of the linear expression
- Raises:
 OptimizationError – if the linear expression contains any unbounded variable
- property coefficients: dok_matrix¶
 Returns the coefficients of the linear expression.
- Returns:
 The coefficients of the linear expression.
- property optimization_problem: OptimizationProblem¶
 Returns the parent OptimizationProblem.
- Returns:
 The parent OptimizationProblem.
- to_array()[source]¶
 Returns the coefficients of the linear expression as array.
- Returns:
 An array with the coefficients corresponding to the linear expression.
- Return type: