This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

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

lsexpression

Summary

Attributes

expressions

This field returns a readonly map-like structure containing all expressions added to this model.

decisions

This field returns a readonly map-like structure containing all decisions added to this model.

constraints

This field returns a readonly map-like structure containing all constraints added to this model.

objectives

This field returns a readonly map-like structure containing all objectives added to this model.

objectiveDirections

This field returns a readonly map-like structure containing the directions of the objectives expressed as strings (MINIMIZE or MAXIMIZE).

nbExpressions

Number of expressions added to this model so far.

nbDecisions

Number of decisions added to this model so far.

nbConstraints

Number of constraints added to this model so far.

nbObjectives

Number of objectives added to this model so far.

nbOperands

Number of operands added to this model so far.

Functions

isClosed

Returns true if the model is closed, false otherwise.

close

Closes the model.

open

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 between 0 and expressions.count() - 1. Accessing a value outside these bounds throws an exception.

  • An overloaded iterator operator to iterate over the expressions with a for 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 between 0 and decisions.count() - 1. Accessing a value outside these bounds throws an exception.

  • An overloaded iterator operator to iterate over the decisions with a for 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 between 0 and constraints.count() - 1. Accessing a value outside these bounds throws an exception.

  • An overloaded iterator operator to iterate over the constraints with a for 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 between 0 and objectives.count() - 1. Accessing a value outside these bounds throws an exception.

  • An overloaded iterator operator to iterate over the objectives with a for 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 or MAXIMIZE). 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 between 0 and objectiveDirections.count() - 1. Accessing a value outside these bounds throws an exception.

  • An overloaded iterator operator to iterate over the objective directions with a for statement.

Return type

map-like structure containing strings MINIMIZE or MAXIMIZE.

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 state STOPPED.

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

open()

lsmodel.open()

Reopens the model. Only allowed in state STOPPED. When this method is called, the solver is placed in state MODELING.

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

close()