LSParam Class¶
-
class
localsolver::
LSParam
¶ 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.
Summary¶
setSeed |
Sets the seed of the pseudo-random number generator used by the solver. |
getSeed |
Gets the seed of the pseudo-random number generator used by the solver. |
setNbThreads |
Sets the number of threads used to parallelize the search. |
getNbThreads |
Gets the number of threads requested by the user. |
setTimeLimit |
Sets the time limit in seconds. |
getTimeLimit |
Gets the time limit in seconds. |
setIterationLimit |
Sets the maximum number of iterations. |
getIterationLimit |
Gets the maximum number of iterations. |
setAnnealingLevel |
DEPRECATED since 8. |
getAnnealingLevel |
DEPRECATED since 8. |
setVerbosity |
Sets the verbosity level of the solver. |
getVerbosity |
Gets the verbosity level of the solver. |
setObjectiveThreshold |
Sets the threshold of the objective with the given index. |
setIntObjectiveThreshold |
Sets the threshold of the objective with the given index. |
setDoubleObjectiveThreshold |
Sets the threshold of the objective with the given index. |
getObjectiveThreshold |
Gets the threshold of the objective with the given index. |
getIntObjectiveThreshold |
Gets the threshold of the objective with the given index. |
getDoubleObjectiveThreshold |
Gets the threshold of the objective with the given index. |
setTimeBetweenDisplays |
Sets the time in seconds between two consecutive displays in console while the solver is running. |
getTimeBetweenDisplays |
Gets the time in seconds between two consecutive displays in console while the solver is running. |
setTimeBetweenTicks |
Sets the time in seconds between two events of type CT_TimeTicked. |
getTimeBetweenTicks |
Gets the time in seconds between two events of type CT_TimeTicked. |
setIterationBetweenTicks |
Sets the number of iterations between two events of type CT_IterationTicked. |
getIterationBetweenTicks |
Gets the number of iterations between two events of type CT_IterationTicked. |
setLogFile |
Sets the path of the LocalSolver log file. |
getLogFile |
Returns the path of the LocalSolver log file. |
setAdvancedParam |
Reserved for maintenance purpose. |
getAdvancedParam |
Reserved for maintenance purpose. |
toString |
Returns a string representation of these parameters. |
Functions¶
-
void
setSeed
(int seed)¶ 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: seed - Seed of the pseudo-random number generator.
-
int
getSeed
() const¶ Gets the seed of the pseudo-random number generator used by the solver.
Only allowed in states S_Paused or S_Stopped.
Return: Seed of the pseudo-random number generator. See: setSeed(int)
-
void
setNbThreads
(int nbThreads)¶ 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. This parameter is indicative, if needed LocalSolver may use more threads. The actual number of threads can also vary during the search.
Parameters: nbThreads - Number of threads.
-
int
getNbThreads
() const¶ Gets the number of threads requested by the user.
Only allowed in states S_Paused or S_Stopped.
Return: Number of threads. See: setNbThreads(int)
-
void
setTimeLimit
(int timeLimit)¶ Sets the time limit in seconds.
Only allowed in state S_Stopped.
This is not allowed if you have defined multiple phases. Use LSPhase#setTimeLimit to set the limit for each phase instead.
See: LSPhase Parameters: timeLimit - Time limit in seconds.
-
int
getTimeLimit
()¶ Gets the time limit in seconds.
Only allowed in states S_Paused or S_Stopped.
This is not allowed if you have defined multiple phases. Use LSPhase#getTimeLimit instead.
Return: Time limit in seconds. See: setTimeLimit(int) See: LSPhase
-
void
setIterationLimit
(long long iterationLimit)¶ Sets the maximum number of iterations.
Fixing the seed and the number of iterations ensures the reproducibility of results over several runs. Only allowed in state S_Stopped.
This is not allowed if you have defined multiple phases. Use LSPhase#setIterationLimit to set the limit for each phase instead instead.
See: LSPhase Parameters: iterationLimit - Iteration limit.
-
long long
getIterationLimit
()¶ Gets the maximum number of iterations.
Only allowed in states S_Paused or S_Stopped.
This is not allowed if you have defined multiple phases. Use LSPhase#getIterationLimit instead.
Return: Iteration limit. See: setIterationLimit(long long) See: LSPhase
-
void
setAnnealingLevel
(int annealingLevel)¶ DEPRECATED since 8.5: This parameter doesn’t have a significant influence on the search anymore.
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.
The tuning of this parameter won’t be allowed in a future version.
Parameters: annealingLevel - Simulated annealing level.
-
int
getAnnealingLevel
() const¶ DEPRECATED since 8.5: This parameter doesn’t have a significant influence on the search anymore.
Gets the simulated annealing level. Only allowed in states S_Paused or S_Stopped.
The tuning of this parameter won’t be allowed in a future version.
Return: Simulated annealing level. See: setAnnealingLevel(int)
-
void
setVerbosity
(int verbosity)¶ 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: verbosity - Verbosity level: 0, 1, 2.
-
int
getVerbosity
() const¶ Gets the verbosity level of the solver.
Return: verbosity Verbosity level: 0, 1 or 2. See: setVerbosity(int)
-
void
setObjectiveThreshold
(int objectiveIndex, lsint threshold)¶ Sets the threshold 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) threshold is reached. It can be useful for goal programming. Only allowed in states S_Stopped. This method has the same behavior as setIntObjectiveThreshold.
See: See: Since: 8.5
Parameters: - objectiveIndex - Index of the objective.
- threshold - Objective threshold.
-
void
setObjectiveThreshold
(int objectiveIndex, lsdouble threshold)¶ Sets the threshold 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) threshold is reached. It can be useful for goal programming. Only allowed in states S_Stopped. This method has the same behavior as setDoubleObjectiveThreshold.
See: See: Since: 8.5
Parameters: - objectiveIndex - Index of the objective.
- threshold - Objective threshold.
-
void
setIntObjectiveThreshold
(int objectiveIndex, lsint threshold)¶ Sets the threshold 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) threshold is reached. It can be useful for goal programming. Only allowed in states S_Stopped.
See: See: Since: 8.5
Parameters: - objectiveIndex - Index of the objective.
- threshold - Objective threshold.
-
void
setDoubleObjectiveThreshold
(int objectiveIndex, lsdouble threshold)¶ Sets the threshold 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) threshold is reached. It can be useful for goal programming. Only allowed in states S_Stopped.
See: See: Since: 8.5
Parameters: - objectiveIndex - Index of the objective.
- threshold - Objective threshold.
-
lsint
getObjectiveThreshold
(int objectiveIndex) const¶ Gets the threshold of the objective with the given index.
Only allowed in states S_Paused or S_Stopped.
Return: Objective threshold. See: setObjectiveThreshold(int, lsint) Since: 8.5 Parameters: objectiveIndex - Index of the objective.
-
lsint
getIntObjectiveThreshold
(int objectiveIndex) const¶ Gets the threshold of the objective with the given index.
Only allowed in states S_Paused or S_Stopped.
Return: Objective threshold. See: setIntObjectiveThreshold(int, lsint) Since: 8.O Parameters: objectiveIndex - Index of the objective.
-
lsdouble
getDoubleObjectiveThreshold
(int objectiveIndex) const¶ Gets the threshold of the objective with the given index.
Only allowed in states S_Paused or S_Stopped.
Return: Objective threshold. See: setObjectiveThreshold(int, lsint) Since: 3.0 Parameters: objectiveIndex - Index of the objective.
-
void
setTimeBetweenDisplays
(int timeBetweenDisplays)¶ 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: timeBetweenDisplays - Time in seconds between displays.
-
int
getTimeBetweenDisplays
() const¶ 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.
Return: Time in seconds between displays. See: setTimeBetweenDisplays(int)
-
void
setTimeBetweenTicks
(int timeBetweenTicks)¶ Sets the time in seconds between two events of type CT_TimeTicked.
The default time between ticks is set to 1 second. Only allowed in state S_Stopped.
Since: 6.0 Parameters: timeBetweenTicks - Time in seconds between ticks.
-
int
getTimeBetweenTicks
() const¶ Gets the time in seconds between two events of type CT_TimeTicked.
Only allowed in states S_Paused or S_Stopped.
Return: Time in seconds between ticks. See: setTimeBetweenTicks(int) Since: 6.0
-
void
setIterationBetweenTicks
(long long iterationBetweenTicks)¶ Sets the number of iterations between two events of type CT_IterationTicked.
The default number of iterations between ticks is set to 10,000. Only allowed in state S_Stopped.
Since: 6.0 Parameters: iterationBetweenTicks - Number of iterations between ticks.
-
long long
getIterationBetweenTicks
() const¶ Gets the number of iterations between two events of type CT_IterationTicked.
Only allowed in states S_Paused or S_Stopped.
Return: Number of iterations between ticks. See: setIterationBetweenTicks(long long) Since: 6.0
-
void
setLogFile
(const std::string &path)¶ 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.
See: setVerbosity(int) See: getLogFile() Parameters: path - Path of the log file. Leave empty to disable the logging mechanism.
-
std::string
getLogFile
() const¶ Returns the path of the LocalSolver log file.
If no log file was specified, an empty string is returned.
Return: The path of the log file or an empty string. See: setLogFile
-
void
setAdvancedParam
(const std::string &key, int value)¶ Reserved for maintenance purpose.
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: - key - Name of the parameter.
- value - Value of the parameter.
-
void
setAdvancedParam
(const std::string &key, double value)¶ Reserved for maintenance purpose.
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: - key - Name of the parameter.
- value - Value of the parameter.
-
void
setAdvancedParam
(const std::string &key, const std::string &value)¶ Reserved for maintenance purpose.
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: - key - Name of the parameter.
- value - Value of the parameter.
-
int
getAdvancedParam
(const std::string &key) const¶ Reserved for maintenance purpose.
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.
Return: Value of the parameter. See: setAdvancedParam(const std::string&, int) Parameters: key - Name of the parameter.
-
int
getAdvancedParam
(const std::string &key, int defaultValue) const¶ Reserved for maintenance purpose.
Returns the value of an advanced parameter. Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. The default value is returned if the parameter does not exist or if no value is defined for this parameter. Only allowed in states S_Paused or S_Stopped.
See: Parameters: - key - Name of the parameter.
- defaultValue - Default value.
-
double
getAdvancedParam
(const std::string &key, double defaultValue) const¶ Reserved for maintenance purpose.
Returns the value of an advanced parameter. Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. The default value is returned if the parameter does not exist or if no value is defined for this parameter. Only allowed in states S_Paused or S_Stopped.
See: Parameters: - key - Name of the parameter.
- defaultValue - Default value.
-
std::string
getAdvancedParam
(const std::string &key, const std::string &defaultValue) const¶ Reserved for maintenance purpose.
Returns the value of an advanced parameter. Advanced parameters are reserved for fine tuning or debugging and should not be used by end-users. The default value is returned if the parameter does not exist or if no value is defined for this parameter. Only allowed in states S_Paused or S_Stopped.
See: Parameters: - key - Name of the parameter.
- defaultValue - Default value of the parameter.
-
std::string
toString
() const¶ Returns a string representation of these parameters.
Useful for debugging or logging purposes.
Return: String representation.