Localsolver  5.5
localsolver::LSParam Class Reference

Detailed Description

Solving parameters.

This class contains some methods allowing you to parameterize the resolution of the model. For the sake of simplicity, only a few parameters are actually offered to tune the search.

Public Member Functions

void setSeed (int seed)
 Sets the seed of the pseudo-random number generator used by the solver.
int getSeed () const
 Gets the seed of the pseudo-random number generator used by the solver.
void setNbThreads (int nbThreads)
 Sets the number of threads used to parallelize the search.
int getNbThreads () const
 Gets the number of threads.
void setAnnealingLevel (int annealingLevel)
 Sets the simulated annealing level.
int getAnnealingLevel () const
 Gets the simulated annealing level.
void setVerbosity (int verbosity)
 Sets the verbosity level of the solver.
int getVerbosity () const
 Gets the verbosity level of the solver.
void setObjectiveBound (int objectiveIndex, lsint bound)
 Sets the bound of the objective with the given index.
void setObjectiveBound (int objectiveIndex, lsdouble bound)
 Sets the bound of the objective with the given index.
void setIntObjectiveBound (int objectiveIndex, lsint bound)
 Sets the bound of the objective with the given index.
void setDoubleObjectiveBound (int objectiveIndex, lsdouble bound)
 Sets the bound of the objective with the given index.
lsint getObjectiveBound (int objectiveIndex) const
 Gets the bound of the objective with the given index.
lsint getIntObjectiveBound (int objectiveIndex) const
 Gets the bound of the objective with the given index.
lsdouble getDoubleObjectiveBound (int objectiveIndex) const
 Gets the bound of the objective with the given index.
void setTimeBetweenDisplays (int timeBetweenDisplays)
 Sets the time in seconds between two consecutive displays in console while the solver is running.
int getTimeBetweenDisplays () const
 Gets the time in seconds between two consecutive displays in console while the solver is running.
void setLogFile (const std::string &path)
 Sets the path of the LocalSolver log file.
std::string getLogFile () const
 Returns the path of the LocalSolver log file.
void setAdvancedParam (const std::string &key, int value)
 Sets the value of an advanced parameter.
void setAdvancedParam (const std::string &key, const std::string &value)
 Sets the value of an advanced parameter.
int getAdvancedParam (const std::string &key) const
 Returns the value of an advanced parameter.
int getAdvancedParam (const std::string &key, int defaultValue) const
 Returns the value of an advanced parameter.
std::string getAdvancedParam (const std::string &key, const std::string &defaultValue) const
 Returns the value of an advanced parameter.
std::string toString () const
 Returns a string representation of these parameters.
 ~LSParam ()
 LSParam (const LSParam &other)
LSParamoperator= (const LSParam &other)

Constructor & Destructor Documentation

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

Member Function Documentation

void localsolver::LSParam::setSeed ( int  seed)
inline

Sets the seed of the pseudo-random number generator used by the solver.

The seed must be a positive integer. The default seed is set to 0. Only allowed in state S_Stopped.

The search for solutions is highly randomized. Fixing the seed and the number of iterations of the solver allows you to reproduce exactly its results over several runs.

Parameters
seedSeed of the pseudo-random number generator.
int localsolver::LSParam::getSeed ( ) const
inline

Gets the seed of the pseudo-random number generator used by the solver.

Only allowed in states S_Paused or S_Stopped.

Returns
Seed of the pseudo-random number generator.
See Also
setSeed(int)
void localsolver::LSParam::setNbThreads ( int  nbThreads)
inline

Sets the number of threads used to parallelize the search.

The number of threads must be a strictly positive integer. The default number of threads is set to 2. Only allowed in state S_Stopped.

By increasing the number of threads, you increase the robustness of the solver (that is, the chance to find better solutions). However, we recommend you to avoid running a number of threads which exceeds the number of cores available on your machine. Since the performance of the solver is sensible to the number of cache misses, the recommended ratio for maximizing its efficiency is to launch at most k/2 searches with k the number of cores of your hardware.

Parameters
nbThreadsNumber of threads.
int localsolver::LSParam::getNbThreads ( ) const
inline

Gets the number of threads.

Only allowed in states S_Paused or S_Stopped.

Returns
Number of threads.
See Also
setNbThreads(int)
void localsolver::LSParam::setAnnealingLevel ( int  annealingLevel)
inline

Sets the simulated annealing level.

The level must be an integer between 0 and 9. The default simulated annealing level is set to 1. Only allowed in state S_Stopped.

If set to 0, the search heuristic is equivalent to a standard descent: moves deteriorating the current solution are rejected. By increasing this parameter, you increase the number of uphill moves (that is, moves deteriorating the objective value of the current solution): this increases chances to reach better solutions (diversification), but slows the convergence of the search.

Parameters
annealingLevelSimulated annealing level.
int localsolver::LSParam::getAnnealingLevel ( ) const
inline

Gets the simulated annealing level.

Only allowed in states S_Paused or S_Stopped.

Returns
Simulated annealing level.
See Also
setAnnealingLevel(int)
void localsolver::LSParam::setVerbosity ( int  verbosity)
inline

Sets the verbosity level of the solver.

The default verbosity is set to 1. There are 3 defined verbosity levels :

  • 0 : All the traces are disabled.
  • 1 : Normal verbosity. This is the default level.
  • 2 : Detailed verbosity. Displays statistics during the search.
Parameters
verbosityVerbosity level: 0, 1, 2.
int localsolver::LSParam::getVerbosity ( ) const
inline

Gets the verbosity level of the solver.

Returns
verbosity Verbosity level: 0, 1 or 2.
See Also
setVerbosity(int)
void localsolver::LSParam::setObjectiveBound ( int  objectiveIndex,
lsint  bound 
)
inline

Sets the bound of the objective with the given index.

If the objective is minimized (resp. maximized), then the optimization of this objective is stopped as soon as this lower (resp. upper) bound is reached. It can be useful for goal programming. Only allowed in states S_Stopped. This method has the same behavior as setIntObjectiveBound.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.
See Also
LSExpression::isObjective()
LSExpression::isInt()
void localsolver::LSParam::setObjectiveBound ( int  objectiveIndex,
lsdouble  bound 
)
inline

Sets the bound of the objective with the given index.

If the objective is minimized (resp. maximized), then the optimization of this objective is stopped as soon as this lower (resp. upper) bound is reached. It can be useful for goal programming. Only allowed in states S_Stopped. This method has the same behavior as setDoubleObjectiveBound.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.
See Also
LSExpression::isObjective()
LSExpression::isDouble()
Since
3.1
void localsolver::LSParam::setIntObjectiveBound ( int  objectiveIndex,
lsint  bound 
)
inline

Sets the bound of the objective with the given index.

If the objective is minimized (resp. maximized), then the optimization of this objective is stopped as soon as this lower (resp. upper) bound is reached. It can be useful for goal programming. Only allowed in states S_Stopped.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.
See Also
LSExpression::isObjective()
LSExpression::isInt()
Since
3.0
void localsolver::LSParam::setDoubleObjectiveBound ( int  objectiveIndex,
lsdouble  bound 
)
inline

Sets the bound of the objective with the given index.

If the objective is minimized (resp. maximized), then the optimization of this objective is stopped as soon as this lower (resp. upper) bound is reached. It can be useful for goal programming. Only allowed in states S_Stopped.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.
See Also
LSExpression::isObjective()
LSExpression::isDouble()
Since
3.0
lsint localsolver::LSParam::getObjectiveBound ( int  objectiveIndex) const
inline

Gets the bound of the objective with the given index.

Only allowed in states S_Paused or S_Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.
See Also
setObjectiveBound(int, lsint)
lsint localsolver::LSParam::getIntObjectiveBound ( int  objectiveIndex) const
inline

Gets the bound of the objective with the given index.

Only allowed in states S_Paused or S_Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.
See Also
setObjectiveBound(int, lsint)
Since
3.O
lsdouble localsolver::LSParam::getDoubleObjectiveBound ( int  objectiveIndex) const
inline

Gets the bound of the objective with the given index.

Only allowed in states S_Paused or S_Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.
See Also
setObjectiveBound(int, lsint)
Since
3.0
void localsolver::LSParam::setTimeBetweenDisplays ( int  timeBetweenDisplays)
inline

Sets the time in seconds between two consecutive displays in console while the solver is running.

The default time between displays is set to 1 second. Only allowed in state S_Stopped.

Parameters
timeBetweenDisplaysTime in seconds between displays.
int localsolver::LSParam::getTimeBetweenDisplays ( ) const
inline

Gets the time in seconds between two consecutive displays in console while the solver is running.

Only allowed in states S_Paused or S_Stopped.

Returns
Time in seconds between displays.
See Also
setTimeBetweenDisplays(int)
void localsolver::LSParam::setLogFile ( const std::string &  path)
inline

Sets the path of the LocalSolver log file.

If the path is empty, no log will be saved. To tune the logging verbosity, see setVerbosity. Only allowed in states S_Stopped or S_Modeling.

Parameters
pathPath of the log file. Leave empty to disable the logging mechanism.
See Also
setVerbosity(int)
getLogFile()
std::string localsolver::LSParam::getLogFile ( ) const
inline

Returns the path of the LocalSolver log file.

If no log file was specified, an empty string is returned.

Returns
The path of the log file or an empty string.
See Also
setLogFile
void localsolver::LSParam::setAdvancedParam ( const std::string &  key,
int  value 
)
inline

Sets the value of an advanced parameter.

Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. Only allowed in states S_Stopped.

Parameters
keyName of the parameter.
valueValue of the parameter.
void localsolver::LSParam::setAdvancedParam ( const std::string &  key,
const std::string &  value 
)
inline

Sets the value of an advanced parameter.

Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. Only allowed in states S_Stopped.

Parameters
keyName of the parameter.
valueValue of the parameter.
int localsolver::LSParam::getAdvancedParam ( const std::string &  key) const
inline

Returns the value of an advanced parameter.

Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. Throws an exception if the parameter does not exist. Only allowed in states S_Paused or S_Stopped.

Parameters
keyName of the parameter.
Returns
Value of the parameter.
See Also
setAdvancedParam(const std::string&, int)
int localsolver::LSParam::getAdvancedParam ( const std::string &  key,
int  defaultValue 
) const
inline

Returns the value of an advanced parameter.

Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. A default value is returned if the parameter does not exist or if no value was set for this one.

Parameters
keyName of the parameter.
defaultValueDefault value of the parameter.
See Also
setAdvancedParam(const std::string&, int)
std::string localsolver::LSParam::getAdvancedParam ( const std::string &  key,
const std::string &  defaultValue 
) const
inline

Returns the value of an advanced parameter.

Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. A default value is returned if the parameter does not exist or if no value was set for this one.

Parameters
keyName of the parameter.
defaultValueDefault value of the parameter.
See Also
setAdvancedParam(const std::string&, const std::string&)
std::string localsolver::LSParam::toString ( ) const
inline

Returns a string representation of these parameters.

Useful for debugging or logging purposes.

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