Localsolver  5.5
localsolver::LSPhase Class Reference

Detailed Description

Optimization phase.

Since LocalSolver allows lexicographic multiobjective optimization, we allow you to parameterize the time or the number of iterations to spend in optimizing each objective. When multiple objectives are declared, these objectives are optimized in lexicographic order (in the order of their declaration in the model). Thus, if k objectives 0, ..., k-1 are declared, each objective i can be optimized while maintaining the values of objectives 0, ..., i-1 previously obtained and ignoring the values of objectives i+1, ..., k-1. During such an optimization phase, objective i is called the optimized objective.

At least one phase must be created to launch the solver. If you have only one objective to optimize, then create a phase, set the time or the number of iterations, and run the solver. By default, the optimized objective of a phase corresponds to the last objective declared in the model (in this case, all objectives of the model are optimized together).

Public Member Functions

void setTimeLimit (int timeLimit)
 Sets the time limit of this phase in seconds.
int getTimeLimit () const
 Gets the time limit of this phase in seconds.
void setIterationLimit (long long iterationLimit)
 Sets the number of iterations of this phase.
long long getIterationLimit () const
 Gets the number of iterations of this phase.
void setOptimizedObjective (int objectiveIndex)
 Sets the optimized objective of this phase.
int getOptimizedObjective () const
 Gets the index of the optimized objective.
void setEnabled (bool enabled)
 Sets the enabled status of this phase.
bool isEnabled () const
 Returns true if the phase is enabled, False otherwise.
LSStatistics getStatistics () const
 Gets the statistics of this phase.
std::string toString () const
 Returns a string representation of this phase.
 ~LSPhase ()
 LSPhase ()
 LSPhase (const LSPhase &other)
LSPhaseoperator= (const LSPhase &other)

Constructor & Destructor Documentation

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

Member Function Documentation

void localsolver::LSPhase::setTimeLimit ( int  timeLimit)
inline

Sets the time limit of this phase in seconds.

Note that the "real" time (that is, total time) spent to resolve the model is considered here (and not only the CPU time). The default time limit is set to the largest positive integer on 32 bits, that is 2^31-1 = 2,147,483,647 > 10^9. Only allowed in state S_Stopped.

Parameters
timeLimitTime limit in seconds.
int localsolver::LSPhase::getTimeLimit ( ) const
inline

Gets the time limit of this phase in seconds.

Only allowed in states S_Paused or S_Stopped.

Returns
Time limit in seconds.
See Also
setTimeLimit(int)
void localsolver::LSPhase::setIterationLimit ( long long  iterationLimit)
inline

Sets the number of iterations of this phase.

Fixing the seed and the number of iterations of all phases ensures the reproducibility of results over several runs. The default number of iterations is set to the largest positive integer on 64 bits, that is 2^63-1 = 9,223,372,036,854,775,807 > 10^18. Only allowed in state S_Stopped.

Parameters
iterationLimitIteration limit.
long long localsolver::LSPhase::getIterationLimit ( ) const
inline

Gets the number of iterations of this phase.

Only allowed in states S_Paused or S_Stopped.

Returns
Iteration limit.
See Also
setIterationLimit
void localsolver::LSPhase::setOptimizedObjective ( int  objectiveIndex)
inline

Sets the optimized objective of this phase.

When multiple objectives are declared, these objectives are optimized in lexicographic order (in the order of their declaration in the model). Thus, if k objectives 0, ..., k-1 are declared, each objective i can be optimized while maintaining the values of objectives 0, ..., i-1 previously obtained and ignoring the values of objectives i+1, ..., k-1. By default, the optimized objective corresponds to the last objective declared in the model. Only allowed in state S_Stopped.

Parameters
objectiveIndexIndex of the optimized objective.
int localsolver::LSPhase::getOptimizedObjective ( ) const
inline

Gets the index of the optimized objective.

Only allowed in states S_Paused or S_Stopped.

Returns
Index of the optimized objective.
See Also
setOptimizedObjective(int)
void localsolver::LSPhase::setEnabled ( bool  enabled)
inline

Sets the enabled status of this phase.

The solver only optimize enabled phases. Disabling a phase can be useful when an objective has been removed from the model by LSModel#removeObjective. By default, a phase is enabled. Only allowed in state S_Stopped.

Parameters
enabledTrue to enable the phase, False to disable it
Since
5.0
bool localsolver::LSPhase::isEnabled ( ) const
inline

Returns true if the phase is enabled, False otherwise.

Only allowed in states S_Paused or S_Stopped.

Returns
True if phase is enabled
Since
5.0
LSStatistics localsolver::LSPhase::getStatistics ( ) const
inline

Gets the statistics of this phase.

Statistics are reset to zero before each resolution. Only allowed in states S_Paused or S_Stopped. Note that for performance reasons, this function always returns the same object.

Returns
Statistics.
See Also
LSStatistics
std::string localsolver::LSPhase::toString ( ) const
inline

Returns a string representation of this phase.

Useful for debugging or logging purposes.

Returns
String representation.
LSPhase& localsolver::LSPhase::operator= ( const LSPhase other)
inline