Localsolver
5.5
|
Mathematical modeling expression.
Expressions are used to build the mathematical optimization model associated to LocalSolver. An expression is composed of an operator (which corresponds to its type) and its operands (which are other expressions of the model).
Public Member Functions | |
LSOperator | getOperator () const |
Gets the operator of this expression. | |
int | getIndex () const |
Gets the index of this expression in the model. | |
bool | isConstant () const |
Returns true if this expression is typed as constant in the model, false otherwise. | |
bool | isDecision () const |
Returns true if this expression is typed as decision in the model, false otherwise. | |
bool | isConstraint () const |
Returns true if this expression is tagged as constraint in the model, false otherwise. | |
bool | isObjective () const |
Returns true if this expression is tagged as objective in the model, false otherwise. | |
bool | isDouble () const |
Returns true if this expression is a double, false otherwise. | |
bool | isInt () const |
Returns true if this expression is an integer, false otherwise. | |
bool | isBool () const |
Returns true if this expression is a boolean (ie 0 or 1), false otherwise. | |
bool | isArray () const |
Returns true if this expression is an array, false otherwise. | |
bool | isCollection () const |
Returns true if this expression is a collection, false otherwise. | |
void | addOperand (const LSExpression &expr) |
Adds the given operand to this expression. | |
void | addOperand (int constant) |
Add the given constant operand to this expression. | |
void | addOperand (lsint constant) |
Add the given constant operand to this expression. | |
void | addOperand (lsdouble constant) |
Add the given constant operand to this expression. | |
template<typename T0 , typename T1 > | |
void | addOperands (T0 begin, T1 end) |
Add the given operands to this expression. | |
LSExpression | getOperand (int operandIndex) const |
Gets the operand with the given index. | |
void | setOperand (int operandIndex, LSExpression operand) |
Replaces the operand of the given index. | |
void | setOperand (int operandIndex, lsint constant) |
Replaces the operand of the given index. | |
void | setOperand (int operandIndex, lsdouble constant) |
Replaces the operand of the given index. | |
int | getNbOperands () const |
Gets the number of operands of this expression. | |
void | setValue (lsint value) |
Sets the value of this expression in the current solution found by the solver. | |
void | setValue (lsdouble value) |
Sets the value of this expression in the current solution found by the solver. | |
void | setIntValue (lsint value) |
Sets the value of this expression in the current solution found by the solver. | |
void | setDoubleValue (lsdouble value) |
Sets the value of this expression in the current solution found by the solver. | |
lsint | getValue () const |
Gets the value of this expression in the best solution found by the solver. | |
lsint | getIntValue () const |
Gets the value of this expression in the best solution found by the solver. | |
lsdouble | getDoubleValue () const |
Gets the value of this expression in the best solution found by the solver. | |
bool | isViolated () const |
Returns true if the given expression is violated in the best solution found by the solver. | |
LSCollection | getCollectionValue () const |
Gets the value of this expression in the best solution found by the solver. | |
void | setName (const std::string &name) |
Sets the name of this expression. | |
bool | isNamed () const |
Returns true if this expression has a name, and false otherwise. | |
const std::string | getName () const |
Gets the name of this expression or the empty string if no name has been set. | |
std::string | toString () const |
Returns a string representation of this expression. | |
std::string | getInfo () const |
Returns useful info about this expression (according to the state of LocalSolver). |
|
inline |
Gets the operator of this expression.
|
inline |
Gets the index of this expression in the model.
|
inline |
Returns true if this expression is typed as constant in the model, false otherwise.
|
inline |
Returns true if this expression is typed as decision in the model, false otherwise.
|
inline |
Returns true if this expression is tagged as constraint in the model, false otherwise.
|
inline |
Returns true if this expression is tagged as objective in the model, false otherwise.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Adds the given operand to this expression.
Only allowed in state S_Modeling.
expr | Operand to add. |
|
inline |
Add the given constant operand to this expression.
Only allowed in state S_Modeling.
constant | Constant operand to add. |
|
inline |
Add the given constant operand to this expression.
Only allowed in state S_Modeling.
constant | Constant operand to add. |
|
inline |
Add the given constant operand to this expression.
Only allowed in state S_Modeling.
constant | Constant operand to add. |
|
inline |
Add the given operands to this expression.
Only allowed in state S_Modeling.
begin | iterator to the initial position of the operands to add. |
end | iterator to the final position of the operands to add. |
|
inline |
Gets the operand with the given index.
operandIndex | Index of the operand. |
|
inline |
Replaces the operand of the given index.
operandIndex | Index of the operand to change |
operand | New operand |
|
inline |
Replaces the operand of the given index.
operandIndex | Index of the operand to change. |
constant | New constant operand. |
|
inline |
Replaces the operand of the given index.
operandIndex | Index of the operand to change. |
constant | New constant operand. |
|
inline |
Gets the number of operands of this expression.
|
inline |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state S_Stopped. Only allowed if this expression is an integer or a boolean. If the solver was not launched, this value will be used as an initial value for the decision. This method is a shortcut for LSSolution#setValue(LSExpression, lsint) and has the same behavior as setIntValue(lsint).
value | Value assigned to this expression. |
|
inline |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state #S_Stopped. Only allowed if this expression is an integer or a boolean. If the solver was not launched, this value will be used as an initial value for the decision. This method is a shortcut for LSSolution#setValue(LSExpression, lsdouble) and has the same behavior as setDoubleValue(lsdouble).
value | Value assigned to this expression. |
|
inline |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state S_Stopped. Only allowed if this expression is an integer or a boolean. If the solver was not launched, this value will be used as an initial value for the decision. This method is a shortcut for LSSolution#setValue(LSExpression, lsint).
value | Value assigned to this expression. |
|
inline |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state S_Stopped. Only allowed if this expression is a double. If the solver was not launched, this value will be used as an initial value for the decision. This method is a shortcut for LSSolution#setValue(LSExpression, lsdouble).
value | Value assigned to this expression. |
|
inline |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean. This method is a shortcut for LSSolution#getValue(LSExpression).
|
inline |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean. This method is a shortcut for LSSolution#getIntValue(LSExpression).
|
inline |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is a double. This method is a shortcut for LSSolution#getDoubleValue(LSExpression).
|
inline |
Returns true if the given expression is violated in the best solution found by the solver.
An expression can be violated in 3 cases:
|
inline |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is a collection (list). This method is a shortcut for LSSolution#getCollectionValue(LSExpression).
|
inline |
Sets the name of this expression.
Only allowed in state S_Modeling. The name cannot be empty. Two operators of the model cannot share the same name. Useful for debugging or logging purposes.
name | Name. |
|
inline |
Returns true if this expression has a name, and false otherwise.
|
inline |
Gets the name of this expression or the empty string if no name has been set.
|
inline |
Returns a string representation of this expression.
This representation provides the index of the expression, its type, and its name (if any). Useful for debugging or logging purposes.
|
inline |
Returns useful info about this expression (according to the state of LocalSolver).
Useful for debugging or logging purposes.