Localsolver
6.0
|
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 | |
LSModel | GetModel () |
Returns the model object associated to this expression. | |
LocalSolver | GetLocalSolver () |
Returns the LocalSolver object associated to this expression. | |
LSOperator | GetOperator () |
Gets the operator of this expression. | |
int | GetIndex () |
Gets the index of this expression in the model. | |
bool | IsConstant () |
Returns true if this expression is typed as constant in the model, false otherwise. | |
bool | IsDecision () |
Returns true if this expression is typed as decision in the model, false otherwise. | |
bool | IsConstraint () |
Returns true if this expression is tagged as constraint in the model, false otherwise. | |
bool | IsObjective () |
Returns true if this expression is tagged as objective in the model, false otherwise. | |
bool | IsDouble () |
Returns true if this expression is a double, false otherwise. | |
bool | IsInt () |
Returns true if this expression is an integer, false otherwise. | |
bool | IsBool () |
Returns true if this expression is a boolean (ie 0 or 1), false otherwise. | |
bool | IsArray () |
Returns true if this expression is an array, false otherwise. | |
bool | IsCollection () |
Returns true if this expression is a collection, false otherwise. | |
bool | IsFunction () |
Returns true if this expression is a function, false otherwise. | |
void | AddOperand (LSExpression expr) |
Adds the given operand to this expression. | |
void | AddOperand (long constant) |
Add the given constant operand to this expression. | |
void | AddOperand (double constant) |
Add the given constant operand to this expression. | |
void | AddOperands (IEnumerable< LSExpression > operands) |
Add the given operands to the expression. | |
void | AddOperands (IEnumerable< long > operands) |
Add the given constant integer operands to the expression. | |
void | AddOperands (IEnumerable< double > operands) |
Add the given constant double operands to the expression. | |
void | AddOperands (params LSExpression[] operands) |
Add the given operands to the expression. | |
void | AddOperands (params double[] operands) |
Add the given constant double operands to the expression. | |
void | AddOperands (params long[] operands) |
Add the given constant integer operands to the expression. | |
LSExpression | GetOperand (int operandIndex) |
Gets the operand with the given index. | |
void | SetOperand (int operandIndex, LSExpression operand) |
Replaces the operand of the given index. | |
void | SetOperand (int operandIndex, long constant) |
Replaces the operand of the given index. | |
void | SetOperand (int operandIndex, double constant) |
Replaces the operand of the given index. | |
int | GetNbOperands () |
Gets the number of operands of this expression. | |
void | SetValue (long value) |
Sets the value of this expression in the current solution found by the solver. | |
void | SetValue (double value) |
Sets the value of this expression in the current solution found by the solver. | |
void | SetIntValue (long value) |
Sets the value of this expression in the current solution found by the solver. | |
void | SetDoubleValue (double value) |
Sets the value of this expression in the current solution found by the solver. | |
long | GetValue () |
Gets the value of this expression in the best solution found by the solver. | |
long | GetIntValue () |
Gets the value of this expression in the best solution found by the solver. | |
double | GetDoubleValue () |
Gets the value of this expression in the best solution found by the solver. | |
LSCollection | GetCollectionValue () |
Gets the value of this expression in the best solution found by the solver. | |
bool | IsViolated () |
Returns true if the given expression is violated in the best solution found by the solver. | |
void | SetName (string name) |
Sets the name of this expression. | |
bool | IsNamed () |
Returns true if this expression has a name, and false otherwise. | |
string | GetName () |
Gets the name of this expression or the empty string if no name has been set. | |
override string | ToString () |
Returns a string representation of this expression. | |
string | GetInfo () |
Returns useful info about this expression (according to the state of LocalSolver). |
LSModel localsolver.LSExpression.GetModel | ( | ) |
Returns the model object associated to this expression.
LocalSolver localsolver.LSExpression.GetLocalSolver | ( | ) |
Returns the LocalSolver object associated to this expression.
LSOperator localsolver.LSExpression.GetOperator | ( | ) |
Gets the operator of this expression.
int localsolver.LSExpression.GetIndex | ( | ) |
Gets the index of this expression in the model.
bool localsolver.LSExpression.IsConstant | ( | ) |
Returns true if this expression is typed as constant in the model, false otherwise.
bool localsolver.LSExpression.IsDecision | ( | ) |
Returns true if this expression is typed as decision in the model, false otherwise.
bool localsolver.LSExpression.IsConstraint | ( | ) |
Returns true if this expression is tagged as constraint in the model, false otherwise.
bool localsolver.LSExpression.IsObjective | ( | ) |
Returns true if this expression is tagged as objective in the model, false otherwise.
bool localsolver.LSExpression.IsDouble | ( | ) |
Returns true if this expression is a double, false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped.
Since version 3.0
bool localsolver.LSExpression.IsInt | ( | ) |
Returns true if this expression is an integer, false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped. Note that a boolean is also an integer.
Since version 3.0
bool localsolver.LSExpression.IsBool | ( | ) |
Returns true if this expression is a boolean (ie 0 or 1), false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped.
Since version 3.0
bool localsolver.LSExpression.IsArray | ( | ) |
Returns true if this expression is an array, false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped.
Since version 3.1
bool localsolver.LSExpression.IsCollection | ( | ) |
Returns true if this expression is a collection, false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped.
Since version 5.5
bool localsolver.LSExpression.IsFunction | ( | ) |
Returns true if this expression is a function, false otherwise.
Only allowed in states LSState::Paused or LSState::Stopped.
Since version 6.0
void localsolver.LSExpression.AddOperand | ( | LSExpression | expr | ) |
Adds the given operand to this expression.
Only allowed in state LSState::Modeling.
expr | Operand to add. |
void localsolver.LSExpression.AddOperand | ( | long | constant | ) |
Add the given constant operand to this expression.
Only allowed in state LSState::Modeling.
constant | Constant operand to add. |
void localsolver.LSExpression.AddOperand | ( | double | constant | ) |
Add the given constant operand to this expression.
Only allowed in state LSState::Modeling.
constant | Constant operand to add. |
void localsolver.LSExpression.AddOperands | ( | IEnumerable< LSExpression > | operands | ) |
Add the given operands to the expression.
operands | The operands to be added. |
void localsolver.LSExpression.AddOperands | ( | IEnumerable< long > | operands | ) |
Add the given constant integer operands to the expression.
operands | The operands to be added. |
void localsolver.LSExpression.AddOperands | ( | IEnumerable< double > | operands | ) |
Add the given constant double operands to the expression.
operands | The operands to be added. |
void localsolver.LSExpression.AddOperands | ( | params LSExpression[] | operands | ) |
Add the given operands to the expression.
operands | The operands to be added. |
void localsolver.LSExpression.AddOperands | ( | params double[] | operands | ) |
Add the given constant double operands to the expression.
operands | The operands to be added. |
void localsolver.LSExpression.AddOperands | ( | params long[] | operands | ) |
Add the given constant integer operands to the expression.
operands | The operands to be added. |
LSExpression localsolver.LSExpression.GetOperand | ( | int | operandIndex | ) |
Gets the operand with the given index.
operandIndex | Index of the operand. |
void localsolver.LSExpression.SetOperand | ( | int | operandIndex, |
LSExpression | operand | ||
) |
Replaces the operand of the given index.
operandIndex | Index of the operand to change |
operand | New operand |
void localsolver.LSExpression.SetOperand | ( | int | operandIndex, |
long | constant | ||
) |
Replaces the operand of the given index.
operandIndex | Index of the operand to change. |
constant | New constant operand. |
void localsolver.LSExpression.SetOperand | ( | int | operandIndex, |
double | constant | ||
) |
Replaces the operand of the given index.
operandIndex | Index of the operand to change. |
constant | New constant operand. |
Since version 3.0
int localsolver.LSExpression.GetNbOperands | ( | ) |
Gets the number of operands of this expression.
void localsolver.LSExpression.SetValue | ( | long | value | ) |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state LSState::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, long) and has the same behavior as LSExpression::SetIntValue(long).
value | Value assigned to this expression. |
void localsolver.LSExpression.SetValue | ( | double | value | ) |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state LSState.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, double) and has the same behavior as LSExpression::SetDoubleValue(double).
value | Value assigned to this expression. |
void localsolver.LSExpression.SetIntValue | ( | long | value | ) |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state LSState::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, long).
value | Value assigned to this expression. |
Since version 3.0
void localsolver.LSExpression.SetDoubleValue | ( | double | value | ) |
Sets the value of this expression in the current solution found by the solver.
Only allowed for decisions. Only allowed in state LSState::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, double).
value | Value assigned to this expression. |
Since version 3.0
long localsolver.LSExpression.GetValue | ( | ) |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states LSState::Paused or LSState::Stopped. Only allowed if this expression is an integer or a boolean. This method is a shortcut for LSSolution::GetValue(LSExpression).
long localsolver.LSExpression.GetIntValue | ( | ) |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states LSState::Paused or LSState::Stopped. Only allowed if this expression is an integer or a boolean. This method is a shortcut for LSSolution::GetIntValue(LSExpression).
Since version 3.0
double localsolver.LSExpression.GetDoubleValue | ( | ) |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states LSState::Paused or LSState::Stopped. Only allowed if this expression is a double. This method is a shortcut for LSSolution::GetDoubleValue(LSExpression).
Since version 3.0
LSCollection localsolver.LSExpression.GetCollectionValue | ( | ) |
Gets the value of this expression in the best solution found by the solver.
Only allowed in states LSState::Paused or LSState::Stopped. Only allowed if this expression is a collection (list). This method is a shortcut for LSSolution::GetCollectionValue(LSExpression).
Since version 5.5
bool localsolver.LSExpression.IsViolated | ( | ) |
Returns true if the given expression is violated in the best solution found by the solver.
An expression can be violated in 3 cases:
Only allowed in states LSState::Paused or LSState::Stopped. This method is a shortcut for LSSolution::IsViolated(LSExpression).
Since version 5.5
void localsolver.LSExpression.SetName | ( | string | name | ) |
Sets the name of this expression.
Only allowed in state LSState::Modeling. The name cannot be empty. Two operators of the model cannot share the same name. Useful for debugging or logging purposes.
name | Name. |
bool localsolver.LSExpression.IsNamed | ( | ) |
Returns true if this expression has a name, and false otherwise.
string localsolver.LSExpression.GetName | ( | ) |
Gets the name of this expression or the empty string if no name has been set.
override string localsolver.LSExpression.ToString | ( | ) |
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.
string localsolver.LSExpression.GetInfo | ( | ) |
Returns useful info about this expression (according to the state of LocalSolver).
Useful for debugging or logging purposes.