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

Functions

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 version 8.5: This parameter does not have a significant influence on the search anymore.

getAnnealingLevel

Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore.

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.

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.

setAdvancedParam

Sets the value of an advanced parameter.

setAdvancedParam

Sets the value of an advanced parameter.

getAdvancedParam

Returns the value of an advanced parameter.

getAdvancedParam

Returns the value of an advanced parameter.

getAdvancedParam

Returns the value of an advanced parameter.

getAdvancedParam

Returns the value of an advanced parameter.

toString

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 or S_Stopped.

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:

LSParam::setSeed()

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 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.

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:

LSParam::setNbThreads()

void LSParam::setTimeLimit(int timeLimit)

Sets the time limit in seconds. Only allowed in states S_Modeling or S_Stopped.

Parameters:

timeLimit – Time limit in seconds.

See:

LSPhase

int LSParam::getTimeLimit()

Gets the time limit in seconds.

Returns:

Time limit in seconds.

See:

LSParam::setTimeLimit()

See:

LSPhase

void LSParam::setIterationLimit(long long iterationLimit)

Sets the maximum number of iterations. Only allowed in states S_Modeling or S_Stopped.

Parameters:

iterationLimit – Iteration limit.

See:

LSPhase

long long LSParam::getIterationLimit()

Gets the maximum number of iterations.

Returns:

Iteration limit.

See:

LSParam::setIterationLimit()

See:

LSPhase

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 or S_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:

LSParam::setAnnealingLevel()

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 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 LSParam::getVerbosity() const

Gets the verbosity level of the solver.

Returns:

verbosity Verbosity level: 0, 1 or 2.

See:

LSParam::setVerbosity()

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 as LSParam::setIntObjectiveThreshold().

Parameters:
  • objectiveIndex – Index of the objective.

  • threshold – Objective threshold.

See:

LSExpression::isObjective()

See:

LSExpression::isInt()

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 as LSParam::setDoubleObjectiveThreshold().

Parameters:
  • objectiveIndex – Index of the objective.

  • threshold – Objective threshold.

See:

LSExpression::isObjective()

See:

LSExpression::isDouble()

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:

LSExpression::isObjective()

See:

LSExpression::isInt()

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:

LSExpression::isObjective()

See:

LSExpression::isDouble()

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 or S_Stopped.

Parameters:

objectiveIndex – Index of the objective.

Returns:

Objective threshold.

See:

LSParam::setObjectiveThreshold() lsint)

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 or S_Stopped.

Parameters:

objectiveIndex – Index of the objective.

Returns:

Objective threshold.

See:

LSParam::setIntObjectiveThreshold() lsint)

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 or S_Stopped.

Parameters:

objectiveIndex – Index of the objective.

Returns:

Objective threshold.

See:

LSParam::setObjectiveThreshold() lsint)

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 or S_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:

LSParam::setTimeBetweenDisplays()

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 states S_Modeling or S_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:

LSParam::setTimeBetweenTicks()

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 states S_Modeling or S_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:

LSParam::setIterationBetweenTicks()

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 method LSParam::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:

LSParam::setLogWriter().

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

Parameters:

path – Path of the log file. Leave empty to disable the logging mechanism.

See:

LSParam::setVerbosity()

See:

LSParam::getLogFile()

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:

LSParam::setLogFile()

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 or S_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 or S_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 or S_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:

LSParam::setAdvancedParam()

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:

LSParam::setAdvancedParam()

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:

LSParam::setAdvancedParam()

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:

LSParam::setAdvancedParam()

std::string LSParam::toString() const

Returns a string representation of these parameters. Useful for debugging or logging purposes.

Returns:

String representation.