# LSParam Class¶

class

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. setLogWriter Sets the writer used by LocalSolver for its logging. getLogWriter Returns the writer used by LocalSolver for its logging. setLogFile Sets the path of the LocalSolver log file. getLogFile Returns the path of the LocalSolver log file. setAdvancedParam Sets the value of an advanced parameter. getAdvancedParam Returns the value of an advanced parameter. toString Returns a string representation of these parameters.

## Functions¶

void localsolver::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 or 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 localsolver::LSParam::getSeed()
const

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

Return: Seed of the pseudo-random number generator. setSeed(int)

void localsolver::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 or S_Stopped. This parameter is indicative, if needed LocalSolver may use more threads. The actual number of threads can also vary during the search.

int localsolver::LSParam::getNbThreads()
const

Gets the number of threads requested by the user.

void localsolver::LSParam::setTimeLimit(int timeLimit)

Sets the time limit in seconds.

Only allowed in states S_Modeling or S_Stopped.

See: LSPhase timeLimit - Time limit in seconds.

int localsolver::LSParam::getTimeLimit()

Gets the time limit in seconds.

Return: Time limit in seconds. setTimeLimit(int) LSPhase

void localsolver::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 or S_Stopped.

See: LSPhase iterationLimit - Iteration limit.

long long localsolver::LSParam::getIterationLimit()

Gets the maximum number of iterations.

Return: Iteration limit. setIterationLimit(long long) LSPhase

void localsolver::LSParam::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 states S_Modeling or S_Stopped.

The tuning of this parameter won’t be allowed in a future version.

Parameters: annealingLevel - Simulated annealing level.

int localsolver::LSParam::getAnnealingLevel()
const

DEPRECATED since 8.5: This parameter doesn’t have a significant influence on the search anymore.

Gets the simulated annealing level.

The tuning of this parameter won’t be allowed in a future version.

Return: Simulated annealing level. setAnnealingLevel(int)

void localsolver::LSParam::setVerbosity(int verbosity)

Sets the verbosity level of the solver.

The default verbosity is set to 1. Only allowed in states S_Modeling or S_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 localsolver::LSParam::getVerbosity()
const

Gets the verbosity level of the solver.

Return: verbosity Verbosity level: 0, 1 or 2. setVerbosity(int)

void localsolver::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 as setIntObjectiveThreshold.

See: 8.5 objectiveIndex - Index of the objective. threshold - Objective threshold.

void localsolver::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 as setDoubleObjectiveThreshold.

See: 8.5 objectiveIndex - Index of the objective. threshold - Objective threshold.

void localsolver::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.

See: 8.5 objectiveIndex - Index of the objective. threshold - Objective threshold.

void localsolver::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.

See: 8.5 objectiveIndex - Index of the objective. threshold - Objective threshold.

lsint localsolver::LSParam::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. setObjectiveThreshold(int, lsint) 8.5 objectiveIndex - Index of the objective.

lsint localsolver::LSParam::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. setIntObjectiveThreshold(int, lsint) 8.5 objectiveIndex - Index of the objective.

lsdouble localsolver::LSParam::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. setObjectiveThreshold(int, lsint) 3.0 objectiveIndex - Index of the objective.

void localsolver::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 or S_Stopped.

Parameters: timeBetweenDisplays - Time in seconds between displays.

int localsolver::LSParam::getTimeBetweenDisplays()
const

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

Return: Time in seconds between displays. setTimeBetweenDisplays(int)

void localsolver::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 states S_Modeling or S_Stopped.

Since: 6.0 timeBetweenTicks - Time in seconds between ticks.

int localsolver::LSParam::getTimeBetweenTicks()
const

Gets the time in seconds between two events of type CT_TimeTicked.

Return: Time in seconds between ticks. setTimeBetweenTicks(int) 6.0

void localsolver::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 states S_Modeling or S_Stopped.

Since: 6.0 iterationBetweenTicks - Number of iterations between ticks.

long long localsolver::LSParam::getIterationBetweenTicks()
const

Gets the number of iterations between two events of type CT_IterationTicked.

Return: Number of iterations between ticks. setIterationBetweenTicks(long long) 6.0

void localsolver::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 setVerbosity. Note that you can specify both the log writer and the log file by using the method setLogFile.

Since: 9.5 writer - Writer to use for the logging or null to restore the default writer.

std::streambuf *localsolver::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 setVerbosity.

Return: The writer used by LocalSolver for its logging. setLogWriter 9.5

void localsolver::LSParam::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_Modeling or S_Stopped.

See: setVerbosity(int) getLogFile() path - Path of the log file. Leave empty to disable the logging mechanism.

std::string localsolver::LSParam::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. setLogFile

void localsolver::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 or S_Stopped.

Parameters: key - Name of the parameter. value - Value of the parameter.

void localsolver::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 or S_Stopped.

Parameters: key - Name of the parameter. value - Value of the parameter.

void localsolver::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 or S_Stopped.

Parameters: key - Name of the parameter. value - Value of the parameter.

int localsolver::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.

Return: Value of the parameter. setAdvancedParam(const std::string&, int) key - Name of the parameter.

int localsolver::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.

See: key - Name of the parameter. defaultValue - Default value.

double localsolver::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.

See: key - Name of the parameter. defaultValue - Default value.

std::string localsolver::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.

See: key - Name of the parameter. defaultValue - Default value of the parameter.

std::string localsolver::LSParam::toString()
const

Returns a string representation of these parameters.

Useful for debugging or logging purposes.

Return: String representation.