This page is for an old version of Hexaly Optimizer. We recommend that you update your version and read the documentation for the latest stable release.

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

Methods
GetLocalSolver Returns the LocalSolver object associated to these parameters.
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.
SetAnnealingLevel Sets the simulated annealing level.
GetAnnealingLevel Gets the simulated annealing level.
SetVerbosity Sets the verbosity level of the solver.
GetVerbosity Gets the verbosity level of the solver.
SetObjectiveBound Sets the bound of the objective with the given index.
SetIntObjectiveBound Sets the bound of the objective with the given index.
SetDoubleObjectiveBound Sets the bound of the objective with the given index.
GetObjectiveBound Gets the bound of the objective with the given index.
GetIntObjectiveBound Gets the bound of the objective with the given index.
GetDoubleObjectiveBound Gets the bound 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 LSCallbackType.TimeTicked.
GetTimeBetweenTicks Gets the time in seconds between two events of type LSCallbackType.TimeTicked.
SetIterationBetweenTicks Sets the number of iterations between two events of type LSCallbackType.IterationTicked.
GetIterationBetweenTicks Gets the number of iterations between two events of type LSCallbackType.IterationTicked.
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.

Instance methods

LocalSolver GetLocalSolver()

Returns the LocalSolver object associated to these parameters.

Returns:LocalSolver object
Return type:LocalSolver
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 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.

Arguments:seed (int) – Seed of the pseudo-random number generator.
int GetSeed()

Gets the seed of the pseudo-random number generator used by the solver. Only allowed in states Paused or Stopped.

Returns:Seed of the pseudo-random number generator.
See:LSParam.SetSeed
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 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.

Arguments:nbThreads (int) – Number of threads.
int GetNbThreads()

Gets the number of threads. Only allowed in states Paused or Stopped.

Returns:Number of threads.
See:LSParam.SetNbThreads
void SetAnnealingLevel(int annealingLevel)

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

Arguments:annealongLevel (int) – Simulated annealing level.
int GetAnnealingLevel()

Gets the simulated annealing level. Only allowed in states Paused or Stopped.

Returns:Simulated annealing level.
See:LSParam.SetAnnealingLevel
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.
Arguments:verbosity (int) – Verbosity level: 0, 1, 2.
int GetVerbosity()

Gets the verbosity level of the solver.

Returns:verbosity Verbosity level: 0, 1 or 2.
See:LSParam.SetVerbosity
void SetObjectiveBound(int objectiveIndex, long bound)

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

This method has the same behavior as LSParam.SetIntObjectiveBound.

Arguments:
  • objectiveIndex (int) – Index of the objective.
  • bound (long) – Objective bound.
See:

LSExpression.IsObjective

See:

LSExpression.IsInt

void SetObjectiveBound(int objectiveIndex, double bound)

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

This method has the same behavior as LSParam.SetDoubleObjectiveBound.

Since:

3.1

Arguments:
  • objectiveIndex (int) – Index of the objective.
  • bound (double) – Objective bound.
See:

LSExpression.IsObjective

See:

LSExpression.IsDouble

void SetIntObjectiveBound(int objectiveIndex, long bound)

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

Since:

3.0

Arguments:
  • objectiveIndex (int) – Index of the objective.
  • bound (long) – Objective bound.
See:

LSExpression.IsObjective

See:

LSExpression.IsInt

void SetDoubleObjectiveBound(int objectiveIndex, double bound)

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

Since:

3.0

Arguments:
  • objectiveIndex (int) – Index of the objective.
  • bound (double) – Objective bound.
See:

LSExpression.IsObjective

See:

LSExpression.IsDouble

long GetObjectiveBound(int objectiveIndex)

Gets the bound of the objective with the given index. Only allowed in states Paused or Stopped.

Arguments:objectiveIndex (int) – Index of the objective.
Returns:Objective bound.
Return type:long
See:LSParam.SetObjectiveBound(int, long)
long GetIntObjectiveBound(int objectiveIndex)

Gets the bound of the objective with the given index. Only allowed in states Paused or Stopped.

Since:3.0
Arguments:objectiveIndex (int) – Index of the objective.
Returns:Objective bound.
Return type:long
See:LSParam.SetIntObjectiveBound
double GetDoubleObjectiveBound(int objectiveIndex)

Gets the bound of the objective with the given index. Only allowed in states Paused or Stopped.

Since:3.0
Arguments:objectiveIndex (int) – Index of the objective.
Returns:Objective bound.
Return type:double
See:LSParam.SetDoubleObjectiveBound
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 Stopped.

Arguments:timeBetweenDisplays (int) – Time in seconds between displays.
int GetTimeBetweenDisplays()

Gets the time in seconds between two consecutive displays in console while the solver is running. Only allowed in states Paused or Stopped.

Returns:Time in seconds between displays.
Return type:int
See:LSParam.SetTimeBetweenDisplays
void SetTimeBetweenTicks(int timeBetweenTicks)

Sets the time in seconds between two events of type LSCallbackType.TimeTicked. The default time between ticks is set to 1 second. Only allowed in state Stopped.

Since:6.0
Arguments:timeBetweenTicks (int) – Time in seconds between ticks.
int GetTimeBetweenTicks()

Gets the time in seconds between two events of type LSCallbackType.TimeTicked. Only allowed in states Paused or Stopped.

Since:6.0
Returns:Time in seconds between ticks.
See:LSParam.SetTimeBetweenTicks
void SetIterationBetweenTicks(long iterationBetweenTicks)

Sets the number of iterations between two events of type LSCallbackType.IterationTicked. The default number of iterations between ticks is set to 10,000. Only allowed in state Stopped.

Since:6.0
Arguments:iterationBetweenTicks (long) – Number of iterations between ticks.
long GetIterationBetweenTicks()

Gets the number of iterations between two events of type LSCallbackType.IterationTicked. Only allowed in states Paused or Stopped.

Since:6.0
Returns:Number of iterations between ticks.
See:LSParam.SetIterationBetweenTicks
void SetLogFile(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 LSParam.SetVerbosity. Only allowed in states Stopped or Modeling.

Arguments:path (string) – Path of the log file. Leave empty to disable the logging mechanism.
See:LSParam.SetVerbosity
See:LSParam.GetLogFile
string GetLogFile()

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 SetAdvancedParam(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 Stopped.

Arguments:
  • key – Name of the parameter.
  • value – Value of the parameter.
int GetAdvancedParam(string key)

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 Paused or Stopped.

Arguments:key – Name of the parameter.
Returns:Value of the parameter.
See:LSParam.SetAdvancedParam(string, int)
int GetAdvancedParam(string key, int defaultValue)

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 was set for this one.

Arguments:
  • key (string) – Name of the parameter.
  • defaultValue (int) – Default value of the parameter.
See:

LSParam.SetAdvancedParam(string, int)

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

Arguments:
  • key – Name of the parameter.
  • value – Value of the parameter.
double GetAdvancedParam(string key, double defaultValue)

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 was set for this one.

Arguments:
  • key (string) – Name of the parameter.
  • defaultValue (double) – Default value of the parameter.
See:

LSParam.SetAdvancedParam(string, double)

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

Arguments:
  • key (string) – Name of the parameter.
  • value (string) – Value of the parameter.
string GetAdvancedParam(string key, string defaultValue)

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 was set for this one.

Arguments:
  • key (string) – Name of the parameter.
  • defaultValue (string) – Default value of the parameter.
See:

LSParam.SetAdvancedParam(string, string)

string ToString()

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

Returns:String representation.