LSModel Type¶
- type lsmodel¶
Mathematical optimization model. A model is composed of expressions (some of which are decisions), organized as a tree. Then, some expressions of the model can be constrained or optimized. Once your optimization model is created and closed, the solver can be launched to resolve it. Note that you cannot modify a model which has been closed: you must reopen it (with
open()
) or instantiate another LocalSolver environment to optimize another model.- See
Summary¶
This field returns a readonly map-like structure containing all expressions added to this model. |
|
This field returns a readonly map-like structure containing all decisions added to this model. |
|
This field returns a readonly map-like structure containing all constraints added to this model. |
|
This field returns a readonly map-like structure containing all objectives added to this model. |
|
This field returns a readonly map-like structure containing the directions of the objectives expressed as strings (MINIMIZE or MAXIMIZE). |
|
Number of expressions added to this model so far. |
|
Number of decisions added to this model so far. |
|
Number of constraints added to this model so far. |
|
Number of objectives added to this model so far. |
|
Number of operands added to this model so far. |
Returns true if the model is closed, false otherwise. |
|
Closes the model. |
|
Reopens the model. |
Attributes¶
- lsmodel.expressions¶
This field returns a readonly map-like structure containing all expressions added to this model. The returned structure has the following features:
A count field to get the number of expressions, e.g.
expressions.count()
.An overloaded index
[]
operator to get a specific expression, e.g.expressions[0]
. The index must be between0
andexpressions.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the expressions with afor
statement.
- Return type
map-like structure containing objects of
lsexpression
.
- lsmodel.decisions¶
This field returns a readonly map-like structure containing all decisions added to this model. The returned structure has the following features:
A count field to get the number of decisions, e.g.
decisions.count()
.An overloaded index
[]
operator to get a specific decision, e.g.decisions[0]
. The index must be between0
anddecisions.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the decisions with afor
statement.
- Return type
map-like structure containing objects of
lsexpression
.
- lsmodel.constraints¶
This field returns a readonly map-like structure containing all constraints added to this model. The returned structure has the following features:
A count field to get the number of constraints, e.g.
constraints.count()
.An overloaded index
[]
operator to get a specific constraint, e.g.constraints[0]
. The index must be between0
andconstraints.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the constraints with afor
statement.
- Return type
map-like structure containing objects of
lsexpression
.
- lsmodel.objectives¶
This field returns a readonly map-like structure containing all objectives added to this model. The returned structure has the following features:
A count field to get the number of objectives, e.g.
objectives.count()
.An overloaded index
[]
operator to get a specific objective, e.g.objectives[0]
. The index must be between0
andobjectives.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the objectives with afor
statement.
- Return type
map-like structure containing objects of
lsexpression
.
- lsmodel.objectiveDirections¶
This field returns a readonly map-like structure containing the directions of the objectives expressed as strings (
MINIMIZE
orMAXIMIZE
). The returned structure has the following features:A count field to get the number of objectives, e.g.
objectiveDirections.count()
.An overloaded index
[]
operator to get a specific objective direction, e.g.objectiveDirections[0]
. The index must be between0
andobjectiveDirections.count() - 1
. Accessing a value outside these bounds throws an exception.An overloaded
iterator
operator to iterate over the objective directions with afor
statement.
- Return type
map-like structure containing strings
MINIMIZE
orMAXIMIZE
.
- lsmodel.nbExpressions¶
Number of expressions added to this model so far.
- lsmodel.nbDecisions¶
Number of decisions added to this model so far.
- lsmodel.nbConstraints¶
Number of constraints added to this model so far.
- lsmodel.nbObjectives¶
Number of objectives added to this model so far.
- lsmodel.nbOperands¶
Number of operands added to this model so far. This corresponds to the number of operands for all expressions declared in the model. It is an analog of the number of non zeros in matrix model encountered in mathematical programming: it gives an hint about the size and the density of your model.
Functions¶
- lsmodel.isClosed()¶
Returns true if the model is closed, false otherwise.
- Return type
bool
- lsmodel.close()¶
Closes the model. Only allowed in state
MODELING
. When this method is called, the solver is placed in stateSTOPPED
.Once the model is closed, no expressions, constraints or objectives can be added or removed unless the model is reopened. The model must be closed before starting its resolution.
- See
- lsmodel.open()¶
Reopens the model. Only allowed in state
STOPPED
. When this method is called, the solver is placed in stateMODELING
.In this state, the model can be modified: it is possible to add new expressions, constraints or objectives, modify expression operands, and remove existing constraints and objectives. However, existing expressions cannot be deleted.
- See