public class LSExpression
extends java.lang.Object
LSModel
,
LSOperator
Modifier and Type | Method and Description |
---|---|
void |
addOperand(double constant)
Adds the given constant operand to this expression.
|
void |
addOperand(long constant)
Adds the given constant operand to this expression.
|
void |
addOperand(LSExpression expr)
Adds the given operand to this expression.
|
void |
addOperands(double... operands)
Adds the given constant double operands to this expression.
|
void |
addOperands(java.lang.Iterable<LSExpression> operands)
Adds the given operands to this expression.
|
void |
addOperands(long... operands)
Adds the given constant integer operands to this expression.
|
void |
addOperands(LSExpression... operands)
Adds the given operands to this expression.
|
boolean |
equals(java.lang.Object obj) |
LSArray |
getArrayValue()
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.
|
double |
getDoubleValue()
Gets the value of this expression in the best solution found by the
solver.
|
LSExternalContext |
getExternalContext()
Gets the native function context of this expression.
|
int |
getIndex()
Gets the index of this expression in the model.
|
LSInterval |
getIntervalValue()
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.
|
LocalSolver |
getLocalSolver() |
LSModel |
getModel() |
java.lang.String |
getName()
Gets the name of this expression or the empty String if no name has been
set.
|
int |
getNbOperands()
Gets the number of operands of this expression.
|
LSExpression |
getOperand(int operandIndex)
Gets the operand with the given index.
|
LSOperator |
getOperator()
Gets the operator of this expression.
|
long |
getValue()
Gets the value of this expression in the best solution found by the
solver.
|
int |
hashCode() |
boolean |
isArray()
Returns true if this expression is an array, false otherwise.
|
boolean |
isBool()
Returns true if this expression is a boolean (ie 0 or 1), false
otherwise.
|
boolean |
isCollection()
Returns true if this expression is a collection (list or set), false otherwise.
|
boolean |
isConstant()
Returns true if this expression is typed as constant in the model, false
otherwise.
|
boolean |
isConstraint()
Returns true if this expression is tagged as constraint in the model,
false otherwise.
|
boolean |
isDecision()
Returns true if this expression is typed as decision in the model, false
otherwise.
|
boolean |
isDouble()
Returns true if this expression is a double, false otherwise.
|
boolean |
isFunction()
Returns true if this expression is a function, false otherwise.
|
boolean |
isInt()
Returns true if this expression is an integer, false otherwise.
|
boolean |
isInterval()
Returns true if this expression is an interval, false otherwise.
|
boolean |
isNamed()
Returns true if this expression has a name, and false otherwise.
|
boolean |
isObjective()
Returns true if this expression is tagged as objective in the model,
false otherwise.
|
boolean |
isUndefined()
Returns true if the given expression has an undefined value in the best solution found by the solver.
|
boolean |
isViolated()
Returns true if the given expression is violated in the best solution
found by the solver.
|
void |
setDoubleValue(double value)
Sets the value of this expression in the current solution found by the
solver.
|
void |
setIntervalValue(LSInterval 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 |
setName(java.lang.String name)
Sets the name of this expression.
|
void |
setOperand(int operandIndex,
double constant)
Replaces the operand of the given index.
|
void |
setOperand(int operandIndex,
long constant)
Replaces the operand of the given index.
|
void |
setOperand(int operandIndex,
LSExpression operand)
Replaces the operand of the given index.
|
void |
setValue(double value)
Sets the value of this expression in the current solution found by the
solver.
|
void |
setValue(long value)
Sets the value of this expression in the current solution found by the
solver.
|
void |
setValue(LSInterval value)
Sets the value of this expression in the current solution found by the
solver.
|
java.lang.String |
toString() |
public LSModel getModel()
public LocalSolver getLocalSolver()
public LSOperator getOperator()
public int getIndex()
public boolean isConstant()
public boolean isDecision()
public boolean isConstraint()
public boolean isObjective()
public boolean isDouble()
LSState.Paused
or LSState.Stopped
.public boolean isInt()
LSState.Paused
or LSState.Stopped
. Note
that a boolean is also an integer.public boolean isBool()
LSState.Paused
or
LSState.Stopped
.public boolean isInterval()
LSState.Paused
or LSState.Stopped
.public boolean isArray()
LSState.Paused
or LSState.Stopped
.public boolean isCollection()
LSState.Paused
or LSState.Stopped
.public boolean isFunction()
LSState.Paused
or LSState.Stopped
.public void addOperand(LSExpression expr)
LSState.Modeling
.expr
- Operand to add.public void addOperand(long constant)
LSState.Modeling
.constant
- Constant operand to add.public void addOperand(double constant)
LSState.Modeling
.constant
- Constant operand to add.public void addOperands(java.lang.Iterable<LSExpression> operands)
LSState.Modeling
.operands
- The iterable collection of operands to be added.public void addOperands(long... operands)
LSState.Modeling
.operands
- The constant integer operands to be added.public void addOperands(double... operands)
LSState.Modeling
.operands
- The constant double operands to be added.public void addOperands(LSExpression... operands)
LSState.Modeling
.operands
- The operands to be added.public LSExpression getOperand(int operandIndex)
operandIndex
- Index of the operand.public void setOperand(int operandIndex, LSExpression operand)
operandIndex
- Index of the operand to changeoperand
- New operandpublic void setOperand(int operandIndex, long constant)
operandIndex
- Index of the operand to change.constant
- New constant operand.public void setOperand(int operandIndex, double constant)
operandIndex
- Index of the operand to change.constant
- New constant operand.public int getNbOperands()
public void setValue(long value)
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 setIntValue(long)
.value
- Value assigned to this expression.LSSolution.setValue(LSExpression, long)
,
isInt()
,
isBool()
public void setValue(double value)
LSSolution.setValue(LSExpression, double)
and has the same
behavior as setDoubleValue(double)
.value
- Value assigned to this expression.LSSolution.setValue(LSExpression expr, double value)
,
isDouble()
public void setValue(LSInterval value)
LSState.Stopped
. Only allowed if this expression is an interval.
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, LSInterval)
and has the same behavior
as setIntervalValue(LSInterval)
.value
- Value assigned to this expression.LSSolution.setValue(LSExpression, long)
,
isInterval()
public void setIntValue(long value)
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.LSSolution.setIntValue(LSExpression, long)
,
isInt()
,
isBool()
public void setDoubleValue(double value)
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.LSSolution.setDoubleValue(LSExpression, double)
,
isDouble()
public void setIntervalValue(LSInterval value)
LSState.Stopped
. Only allowed if this expression is an interval. 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, LSInterval)
.value
- Value assigned to this expression.LSSolution.setIntervalValue(LSExpression, LSInterval)
,
isInterval()
public long getValue()
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)
.LSSolution.getValue(LSExpression)
,
isInt()
,
isBool()
public long getIntValue()
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)
.LSSolution.getIntValue(LSExpression)
,
isInt()
,
isBool()
public double getDoubleValue()
LSState.Paused
or
LSState.Stopped
. Only allowed if this expression is a double.
This method is a shortcut for
LSSolution.getDoubleValue(LSExpression)
.LSSolution.getDoubleValue(LSExpression)
,
isDouble()
public LSInterval getIntervalValue()
LSState.Paused
or
LSState.Stopped
. Only allowed if this expression is an interval.
This method is a shortcut for
LSSolution.getIntervalValue(LSExpression)
.LSSolution.getIntervalValue(LSExpression)
,
isInterval()
public LSCollection getCollectionValue()
LSState.Paused
or
LSState.Stopped
. Only allowed if this expression is a collection
(list or set). This method is a shortcut for
LSSolution.getCollectionValue(LSExpression)
.LSSolution.getCollectionValue(LSExpression)
,
isCollection()
public LSArray getArrayValue()
LSState.Paused
or LSState.Stopped
.
Only allowed if this expression is an array.
This method is a shortcut for LSSolution.getArrayValue(LSExpression)
.LSSolution.getArrayValue(LSExpression)
,
isArray()
public LSExternalContext getExternalContext()
LSExternalContext
public boolean isViolated()
LSState.Paused
or LSState.Stopped
.
This method is a shortcut for LSSolution.isViolated(LSExpression)
.public boolean isUndefined()
LSState.Paused
or LSState.Stopped
.
This method is a shortcut for LSSolution.isUndefined(LSExpression)
.public void setName(java.lang.String name)
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.public boolean isNamed()
public java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object