Localsolver  5.5
localsolver::LSSolution Class Reference

Detailed Description

Solution to the optimization model.

A solution carries the values of all expressions in the model. It is used to retrieve the values of all expressions (getting the solution), or to set the values of some decisions (setting the solution).

See Also
LSSolutionStatus

Public Member Functions

void setValue (LSExpression expr, lsint value)
 Sets the value of the given expression in this solution.
void setValue (LSExpression expr, lsdouble value)
 Sets the value of the given expression in this solution.
void setIntValue (LSExpression expr, lsint value)
 Sets the value of the given expression in this solution.
void setDoubleValue (LSExpression expr, lsdouble value)
 Sets the value of the given expression in this solution.
lsint getValue (const LSExpression expr)
 Returns the value of the given expression in this solution.
lsdouble getDoubleValue (const LSExpression expr)
 Returns the value of the given expression in this solution.
bool isViolated (const LSExpression expr)
 Returns true if the given expression is violated in this solution.
lsint getIntValue (const LSExpression expr)
 Returns the value of the given expression in this solution.
LSCollection getCollectionValue (const LSExpression expr)
 Returns the value of the given expression in this solution.
LSSolutionStatus getStatus ()
 Returns the status of the solution.
void clear ()
 Clear the solution and set all decisions to zero.
 ~LSSolution ()
 LSSolution ()
 LSSolution (const LSSolution &other)
LSSolutionoperator= (const LSSolution &other)

Constructor & Destructor Documentation

localsolver::LSSolution::~LSSolution ( )
inline
localsolver::LSSolution::LSSolution ( )
inline
localsolver::LSSolution::LSSolution ( const LSSolution other)
inline

Member Function Documentation

void localsolver::LSSolution::setValue ( LSExpression  expr,
lsint  value 
)
inline

Sets the value of the given expression in this solution.

Only decisions can be set. Only allowed in state S_Paused or 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 has the same behavior as setIntValue.

Parameters
exprDecision.
valueValue assigned to the decision in this solution.
See Also
LSExpression::isDecision()
LSExpression::isInt()
LSExpression::isBool()
void localsolver::LSSolution::setValue ( LSExpression  expr,
lsdouble  value 
)
inline

Sets the value of the given expression in this solution.

Only decisions can be set. Only allowed in state S_Paused or 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 has the same behavior as setDoubleValue.

Parameters
exprDecision.
valueValue assigned to the decision in this solution.
See Also
LSExpression::isDecision()
LSExpression::isDouble()
void localsolver::LSSolution::setIntValue ( LSExpression  expr,
lsint  value 
)
inline

Sets the value of the given expression in this solution.

Only decisions can be set. Only allowed in state S_Paused or 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.

Parameters
exprDecision.
valueValue assigned to the decision in this solution.
See Also
LSExpression::isDecision()
LSExpression::isInt()
Since
3.0
void localsolver::LSSolution::setDoubleValue ( LSExpression  expr,
lsdouble  value 
)
inline

Sets the value of the given expression in this solution.

Only decisions can be set. Only allowed in state S_Paused or S_Stopped. If the solver was not launched, this value will be used as an initial value for the decision. Only allowed if this expression is a double.

Parameters
exprDecision.
valueValue assigned to the decision in this solution.
See Also
LSExpression::isDecision()
LSExpression::isDouble()
Since
3.0
lsint localsolver::LSSolution::getValue ( const LSExpression  expr)
inline

Returns the value of the given expression in this solution.

Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean.

Parameters
exprExpression.
See Also
LSExpression::isInt()
LSExpression::isBool()
Returns
Value of the expression in this solution.
lsdouble localsolver::LSSolution::getDoubleValue ( const LSExpression  expr)
inline

Returns the value of the given expression in this solution.

Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is a double.

Parameters
exprExpression.
See Also
LSExpression::isDouble()
Returns
Value of the expression in this solution.
Since
3.0
bool localsolver::LSSolution::isViolated ( const LSExpression  expr)
inline

Returns true if the given expression is violated in this solution.

An expression can be violated in 3 cases:

  1. it is a constraint and its value is 0
  2. it is a a double and its value is NaN (NotANumber)
  3. it is an integer or boolean with no valid value (arithmetic or out of bounds exception). Only allowed in states S_Paused or S_Stopped.
Parameters
exprExpression.
Returns
True if this expression is violated in this solution.
Since
5.5
lsint localsolver::LSSolution::getIntValue ( const LSExpression  expr)
inline

Returns the value of the given expression in this solution.

Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an integer or a boolean.

Parameters
exprExpression.
See Also
LSExpression::isInt()
LSExpression::isBool()
Returns
Value of the expression in this solution.
Since
3.0
LSCollection localsolver::LSSolution::getCollectionValue ( const LSExpression  expr)
inline

Returns the value of the given expression in this solution.

Only allowed in states S_Paused or S_Stopped. Only allowed if this expression is an collection (list).

Parameters
exprExpression.
See Also
LSExpression::isCollection()
Returns
Value of the expression in this solution.
Since
5.5
LSSolutionStatus localsolver::LSSolution::getStatus ( )
inline

Returns the status of the solution.

Only allowed in states S_Paused or S_Stopped.

Returns
Status of the solution.
See Also
LSSolutionStatus
void localsolver::LSSolution::clear ( )
inline

Clear the solution and set all decisions to zero.

Only allowed in state S_Stopped.

LSSolution& localsolver::LSSolution::operator= ( const LSSolution other)
inline