LSParam Class¶
-
class 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¶
Sets the seed of the pseudo-random number generator used by the solver. |
|
Gets the seed of the pseudo-random number generator used by the solver. |
|
Sets the number of threads used to parallelize the search. |
|
Gets the number of threads requested by the user. |
|
Sets the time limit in seconds. |
|
Gets the time limit in seconds. |
|
Sets the maximum number of iterations. |
|
Gets the maximum number of iterations. |
|
Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore. |
|
Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore. |
|
Sets the verbosity level of the solver. |
|
Gets the verbosity level of the solver. |
|
Sets the threshold of the objective with the given index. |
|
Sets the threshold of the objective with the given index. |
|
Sets the threshold of the objective with the given index. |
|
Sets the threshold of the objective with the given index. |
|
Gets the threshold of the objective with the given index. |
|
Gets the threshold of the objective with the given index. |
|
Gets the threshold of the objective with the given index. |
|
Sets the time in seconds between two consecutive displays in console while the solver is running. |
|
Gets the time in seconds between two consecutive displays in console while the solver is running. |
|
Sets the time in seconds between two events of type CT_TimeTicked. |
|
Gets the time in seconds between two events of type CT_TimeTicked. |
|
Sets the number of iterations between two events of type CT_IterationTicked. |
|
Gets the number of iterations between two events of type CT_IterationTicked. |
|
Sets the writer used by LocalSolver for its logging. |
|
Returns the writer used by LocalSolver for its logging. |
|
Sets the path of the LocalSolver log file. |
|
Returns the path of the LocalSolver log file. |
|
Sets the value of an advanced parameter. |
|
Sets the value of an advanced parameter. |
|
Sets the value of an advanced parameter. |
|
Returns the value of an advanced parameter. |
|
Returns the value of an advanced parameter. |
|
Returns the value of an advanced parameter. |
|
Returns the value of an advanced parameter. |
|
Returns a string representation of these parameters. |
Functions¶
-
void LSParam::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 states
S_Modeling
orS_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 LSParam::getSeed() const¶
Gets the seed of the pseudo-random number generator used by the solver.
- Returns
Seed of the pseudo-random number generator.
- See
-
void LSParam::setNbThreads(int nbThreads)¶
Sets the number of threads used to parallelize the search. The number of threads must be a positive integer. The default number of threads is set to 0 which means that the number of threads is automatically adapted to your computer and to your optimization model. Only allowed in states
S_Modeling
orS_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 LSParam::getNbThreads() const¶
Gets the number of threads requested by the user.
- Returns
Number of threads (by convention, 0 means that the number of threads is automatically adapted to your computer and to your optimization model).
- See
-
void LSParam::setTimeLimit(int timeLimit)¶
Sets the time limit in seconds. Only allowed in states
S_Modeling
orS_Stopped
.- Parameters
timeLimit – Time limit in seconds.
- See
-
void LSParam::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 states
S_Modeling
orS_Stopped
.- Parameters
iterationLimit – Iteration limit.
- See
-
long long LSParam::getIterationLimit()¶
Gets the maximum number of iterations.
- Returns
Iteration limit.
- See
- See
-
void LSParam::setAnnealingLevel(int annealingLevel)¶
Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore. The tuning of this parameter won’t be allowed in a future version.
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 states
S_Modeling
orS_Stopped
.- Parameters
annealingLevel – Simulated annealing level.
-
int LSParam::getAnnealingLevel() const¶
Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore. The tuning of this parameter won’t be allowed in a future version.
Gets the simulated annealing level.
- Returns
Simulated annealing level.
- See
-
void LSParam::setVerbosity(int verbosity)¶
Sets the verbosity level of the solver. The default verbosity is set to 1. Only allowed in states
S_Modeling
orS_Stopped
. 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 LSParam::getVerbosity() const¶
Gets the verbosity level of the solver.
- Returns
verbosity Verbosity level: 0, 1 or 2.
- See
-
void LSParam::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 state
S_Stopped
. This method has the same behavior asLSParam::setIntObjectiveThreshold()
.- Parameters
objectiveIndex – Index of the objective.
threshold – Objective threshold.
- See
- See
- Since
8.5
-
void LSParam::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 state
S_Stopped
. This method has the same behavior asLSParam::setDoubleObjectiveThreshold()
.- Parameters
objectiveIndex – Index of the objective.
threshold – Objective threshold.
- See
- See
- Since
8.5
-
void LSParam::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 state
S_Stopped
.- Parameters
objectiveIndex – Index of the objective.
threshold – Objective threshold.
- See
- See
- Since
8.5
-
void LSParam::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 state
S_Stopped
.- Parameters
objectiveIndex – Index of the objective.
threshold – Objective threshold.
- See
- See
- Since
8.5
-
lsint LSParam::getObjectiveThreshold(int objectiveIndex) const¶
Gets the threshold of the objective with the given index. Only allowed in states
S_Paused
orS_Stopped
.- Parameters
objectiveIndex – Index of the objective.
- Returns
Objective threshold.
- See
- Since
8.5
-
lsint LSParam::getIntObjectiveThreshold(int objectiveIndex) const¶
Gets the threshold of the objective with the given index. Only allowed in states
S_Paused
orS_Stopped
.- Parameters
objectiveIndex – Index of the objective.
- Returns
Objective threshold.
- See
- Since
8.5
-
lsdouble LSParam::getDoubleObjectiveThreshold(int objectiveIndex) const¶
Gets the threshold of the objective with the given index. Only allowed in states
S_Paused
orS_Stopped
.- Parameters
objectiveIndex – Index of the objective.
- Returns
Objective threshold.
- See
- Since
3.0
-
void LSParam::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 states
S_Modeling
orS_Stopped
.- Parameters
timeBetweenDisplays – Time in seconds between displays.
-
int LSParam::getTimeBetweenDisplays() const¶
Gets the time in seconds between two consecutive displays in console while the solver is running.
- Returns
Time in seconds between displays.
- See
-
void LSParam::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 statesS_Modeling
orS_Stopped
.- Parameters
timeBetweenTicks – Time in seconds between ticks.
- Since
6.0
-
int LSParam::getTimeBetweenTicks() const¶
Gets the time in seconds between two events of type
CT_TimeTicked
.- Returns
Time in seconds between ticks.
- See
- Since
6.0
-
void LSParam::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 statesS_Modeling
orS_Stopped
.- Parameters
iterationBetweenTicks – Number of iterations between ticks.
- Since
6.0
-
long long LSParam::getIterationBetweenTicks() const¶
Gets the number of iterations between two events of type
CT_IterationTicked
.- Returns
Number of iterations between ticks.
- See
- Since
6.0
-
void LSParam::setLogWriter(std::streambuf *writer)¶
Sets the writer used by LocalSolver for its logging. The default is to log to the standard output. To tune the logging verbosity of the output or to disable logging, see
LSParam::setVerbosity()
. Note that you can specify both the log writer and the log file by using the methodLSParam::setLogFile()
.- Parameters
writer – Writer to use for the logging or null to restore the default writer.
- Since
9.5
-
std::streambuf *LSParam::getLogWriter() const¶
Returns the writer used by LocalSolver for its logging. The default value is null and means “logging to the standard output”. To tune the logging verbosity of the output or to disable logging, see
LSParam::setVerbosity()
.- Returns
The writer used by LocalSolver for its logging.
- See
- Since
9.5
-
void LSParam::setLogFile(const std::string &path)¶
Sets the path of the LocalSolver log file. If the path is empty, no log wil be saved. To tune the logging verbosity, see
LSParam::setVerbosity()
. Only allowed in statesS_Modeling
orS_Stopped
.- Parameters
path – Path of the log file. Leave empty to disable the logging mechanism.
- See
- See
-
std::string LSParam::getLogFile() const¶
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
-
void LSParam::setAdvancedParam(const std::string &key, int value)¶
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_Modeling
orS_Stopped
.- Parameters
key – Name of the parameter.
value – Value of the parameter.
-
void LSParam::setAdvancedParam(const std::string &key, double value)¶
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_Modeling
orS_Stopped
.- Parameters
key – Name of the parameter.
value – Value of the parameter.
-
void LSParam::setAdvancedParam(const std::string &key, const std::string &value)¶
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_Modeling
orS_Stopped
.- Parameters
key – Name of the parameter.
value – Value of the parameter.
-
int LSParam::getAdvancedParam(const std::string &key) const¶
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.
- Parameters
key – Name of the parameter.
- Returns
Value of the parameter.
- See
-
int LSParam::getAdvancedParam(const std::string &key, int defaultValue) const¶
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.
- Parameters
key – Name of the parameter.
defaultValue – Default value.
- See
-
double LSParam::getAdvancedParam(const std::string &key, double defaultValue) const¶
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.
- Parameters
key – Name of the parameter.
defaultValue – Default value.
- See
-
std::string LSParam::getAdvancedParam(const std::string &key, const std::string &defaultValue) const¶
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.
- Parameters
key – Name of the parameter.
defaultValue – Default value of the parameter.
- See