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 ()
 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 ()
 Gets the number of threads.
void SetAnnealingLevel (int annealingLevel)
 Sets the simulated annealing level.
int GetAnnealingLevel ()
 Gets the simulated annealing level.
void SetVerbosity (int verbosity)
 Sets the verbosity level of the solver.
int GetVerbosity ()
 Gets the verbosity level of the solver.
void SetObjectiveBound (int objectiveIndex, long bound)
 Sets the bound of the objective with the given index.
void SetObjectiveBound (int objectiveIndex, double bound)
 Sets the bound of the objective with the given index.
void SetIntObjectiveBound (int objectiveIndex, long bound)
 Sets the bound of the objective with the given index.
void SetDoubleObjectiveBound (int objectiveIndex, double bound)
 Sets the bound of the objective with the given index.
long GetObjectiveBound (int objectiveIndex)
 Gets the bound of the objective with the given index.
long GetIntObjectiveBound (int objectiveIndex)
 Gets the bound of the objective with the given index.
double GetDoubleObjectiveBound (int objectiveIndex)
 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 ()
 Gets the time in seconds between two consecutive displays in console while the solver is running.
void SetLogFile (string path)
 Sets the path of the LocalSolver log file.
string GetLogFile ()
 Returns the path of the LocalSolver log file.
void SetAdvancedParam (string key, int value)
 Sets the value of an advanced parameter.
int GetAdvancedParam (string key)
 Returns the value of an advanced parameter.
int GetAdvancedParam (string key, int defaultValue)
 Returns the value of an advanced parameter.
void SetAdvancedParam (string key, string value)
 Sets the value of an advanced parameter.
string GetAdvancedParam (string key, string defaultValue)
 Returns the value of an advanced parameter.
override string ToString ()
 Returns a string representation of these parameters.

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 LSState.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 ( )
inline

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

Only allowed in states LSState.Paused or LSState.Stopped.

Returns
Seed of the pseudo-random number generator.

LSParam.SetSeed

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 LSState.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 ( )
inline

Gets the number of threads.

Only allowed in states LSState.Paused or LSState.Stopped.

Returns
Number of threads.

LSParam.SetNbThreads

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 LSState.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 ( )
inline

Gets the simulated annealing level.

Only allowed in states LSState.Paused or LSState.Stopped.

Returns
Simulated annealing level.

LSParam.SetAnnealingLevel

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 ( )
inline

Gets the verbosity level of the solver.

Returns
verbosity Verbosity level: 0, 1 or 2.

LSParam.SetVerbosity

void localsolver.LSParam.SetObjectiveBound ( int  objectiveIndex,
long  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 LSState.Stopped. This method has the same behavior as SetIntObjectiveBound.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.

LSExpression.IsObjective LSExpression.IsInt

void localsolver.LSParam.SetObjectiveBound ( int  objectiveIndex,
double  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 LSState.Stopped. This method has the same behavior as SetDoubleObjectiveBound.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.

LSExpression.IsObjective LSExpression.IsDouble Since version 3.1

void localsolver.LSParam.SetIntObjectiveBound ( int  objectiveIndex,
long  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 LSState.Stopped.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.

LSExpression.IsObjective LSExpression.IsInt Since version 3.0

void localsolver.LSParam.SetDoubleObjectiveBound ( int  objectiveIndex,
double  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 LSState.Stopped.

Parameters
objectiveIndexIndex of the objective.
boundObjective bound.

LSExpression.IsObjective LSExpression.IsDouble Since version 3.0

long localsolver.LSParam.GetObjectiveBound ( int  objectiveIndex)
inline

Gets the bound of the objective with the given index.

Only allowed in states LSState.Paused or LSState.Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.

LSParam.SetObjectiveBound

long localsolver.LSParam.GetIntObjectiveBound ( int  objectiveIndex)
inline

Gets the bound of the objective with the given index.

Only allowed in states LSState.Paused or LSState.Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.

LSParam.SetObjectiveBound Since version 3.O

double localsolver.LSParam.GetDoubleObjectiveBound ( int  objectiveIndex)
inline

Gets the bound of the objective with the given index.

Only allowed in states LSState.Paused or LSState.Stopped.

Parameters
objectiveIndexIndex of the objective.
Returns
Objective bound.

LSParam.SetObjectiveBound Since version 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 LSState.Stopped.

Parameters
timeBetweenDisplaysTime in seconds between displays.
int localsolver.LSParam.GetTimeBetweenDisplays ( )
inline

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

Only allowed in states LSState.Paused or LSState.Stopped.

Returns
Time in seconds between displays.

LSParam.SetTimeBetweenDisplays

void localsolver.LSParam.SetLogFile ( 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 LSState.Stopped or LSState.Modeling.

Parameters
pathPath of the log file. Leave empty to disable the logging mechanism.

LSParam.SetVerbosity LSParam.GetLogFile

string localsolver.LSParam.GetLogFile ( )
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.

LSParam.SetLogFile

void localsolver.LSParam.SetAdvancedParam ( 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 LSState.Stopped.

Parameters
keyName of the parameter.
valueValue of the parameter.
int localsolver.LSParam.GetAdvancedParam ( string  key)
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 LSState.Paused or LSState.Stopped.

Parameters
keyName of the parameter.
Returns
Value of the parameter.

LSParam.SetAdvancedParam

int localsolver.LSParam.GetAdvancedParam ( string  key,
int  defaultValue 
)
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.

LSParam.SetAdvancedParam

void localsolver.LSParam.SetAdvancedParam ( string  key,
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 LSState.Stopped.

Parameters
keyName of the parameter.
valueValue of the parameter.
string localsolver.LSParam.GetAdvancedParam ( string  key,
string  defaultValue 
)
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.

LSParam.SetAdvancedParam

override string localsolver.LSParam.ToString ( )
inline

Returns a string representation of these parameters.

Useful for debugging or logging purposes.

Returns
String representation.