Package localsolver
Class LSParam
- java.lang.Object
-
- localsolver.LSParam
-
public class LSParam extends java.lang.ObjectSolving 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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)intgetAdvancedParam(java.lang.String key)Returns the value of an advanced parameter.doublegetAdvancedParam(java.lang.String key, double defaultValue)Reserved for maintenance purpose.intgetAdvancedParam(java.lang.String key, int defaultValue)Reserved for maintenance purpose.java.lang.StringgetAdvancedParam(java.lang.String key, java.lang.String defaultValue)Reserved for maintenance purpose.intgetAnnealingLevel()Deprecated.As of 8.5, this parameter doesn't have a significant influence on the search anymore.doublegetDoubleObjectiveThreshold(int objectiveIndex)Gets the threshold of the objective with the given index.longgetIntObjectiveThreshold(int objectiveIndex)Gets the threshold of the objective with the given index.longgetIterationBetweenTicks()Gets the number of iterations between two events of typeLSCallbackType.IterationTicked.longgetIterationLimit()Gets the maximum number of iterations.LocalSolvergetLocalSolver()Returns the LocalSolver object associated to these parameters.java.lang.StringgetLogFile()Returns the path of the LocalSolver log file.java.io.PrintStreamgetLogWriter()Returns the stream used by LocalSolver for its logging.intgetNbThreads()Gets the number of threads (0 coding for automatic setting).longgetObjectiveThreshold(int objectiveIndex)Gets the threshold of the objective with the given index.intgetSeed()Gets the seed of the pseudo-random number generator used by the solver.intgetTimeBetweenDisplays()Gets the time in seconds between two consecutive displays in console while the solver is running.intgetTimeBetweenTicks()Gets the time in seconds between two events of typeLSCallbackType.TimeTicked.intgetTimeLimit()Gets the time limit in seconds.intgetVerbosity()Gets the verbosity level of the solver.inthashCode()voidsetAdvancedParam(java.lang.String key, double value)Reserved for maintenance purpose.voidsetAdvancedParam(java.lang.String key, int value)Sets the value of an advanced parameter.voidsetAdvancedParam(java.lang.String key, java.lang.String value)Reserved for maintenance purpose.voidsetAnnealingLevel(int annealingLevel)Deprecated.As of 8.5, this parameter doesn't have a significant influence on the search anymore.voidsetDoubleObjectiveThreshold(int objectiveIndex, double threshold)Sets the threshold of the objective with the given index.voidsetIntObjectiveThreshold(int objectiveIndex, long threshold)Sets the threshold of the objective with the given index.voidsetIterationBetweenTicks(long iterationBetweenTicks)Sets the number of iterations between two events of typeLSCallbackType.IterationTicked.voidsetIterationLimit(long iterationLimit)Sets the maximum number of iterations.voidsetLogFile(java.lang.String path)Sets the path of the LocalSolver log file.voidsetLogWriter(java.io.PrintStream stream)Sets the stream used by LocalSolver for its logging.voidsetNbThreads(int nbThreads)Sets the number of threads used to parallelize the search.voidsetObjectiveThreshold(int objectiveIndex, double threshold)Sets the threshold of the objective with the given index.voidsetObjectiveThreshold(int objectiveIndex, long threshold)Sets the threshold of the objective with the given index.voidsetSeed(int seed)Sets the seed of the pseudo-random number generator used by the solver.voidsetTimeBetweenDisplays(int timeBetweenDisplays)Sets the time in seconds between two consecutive displays in console while the solver is running.voidsetTimeBetweenTicks(int timeBetweenTicks)Sets the time in seconds between two events of typeLSCallbackType.TimeTicked.voidsetTimeLimit(int timeLimit)Sets the time limit in seconds.voidsetVerbosity(int verbosity)Sets the verbosity level of the solver.java.lang.StringtoString()Returns a String representation of these parameters.
-
-
-
Method Detail
-
getLocalSolver
public LocalSolver getLocalSolver()
Returns the LocalSolver object associated to these parameters.- Returns:
- LocalSolver object.
-
setSeed
public 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 statesLSState.ModelingorLSState.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.
-
getSeed
public int getSeed()
Gets the seed of the pseudo-random number generator used by the solver.- Returns:
- Seed of the pseudo-random number generator.
- See Also:
setSeed(int)
-
setNbThreads
public void 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 statesLSState.ModelingorLSState.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.
-
getNbThreads
public int getNbThreads()
Gets the number of threads (0 coding for automatic setting).- Returns:
- Number of threads.
- See Also:
setNbThreads(int)
-
setTimeLimit
public void setTimeLimit(int timeLimit)
Sets the time limit in seconds. Only allowed in statesLSState.ModelingorLSState.Stopped.- Parameters:
timeLimit- Time limit in seconds.- See Also:
LSPhase
-
getTimeLimit
public int getTimeLimit()
Gets the time limit in seconds.- Returns:
- Time limit in seconds.
- See Also:
setTimeLimit(int),LSPhase
-
setIterationLimit
public void setIterationLimit(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 statesLSState.ModelingorLSState.Stopped.- Parameters:
iterationLimit- Iteration limit.- See Also:
LSPhase
-
getIterationLimit
public long getIterationLimit()
Gets the maximum number of iterations.- Returns:
- Iteration limit.
- See Also:
setIterationLimit(long),LSPhase
-
setAnnealingLevel
@Deprecated public void setAnnealingLevel(int annealingLevel)
Deprecated.As of 8.5, this parameter doesn't 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 statesLSState.ModelingorLSState.Stopped.- Parameters:
annealingLevel- Simulated annealing level.
-
getAnnealingLevel
@Deprecated public int getAnnealingLevel()
Deprecated.As of 8.5, this parameter doesn't 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 Also:
setAnnealingLevel(int)
-
setVerbosity
public 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.
LSState.ModelingorLSState.Stopped.- Parameters:
verbosity- Verbosity level: 0, 1, 2.
-
getVerbosity
public int getVerbosity()
Gets the verbosity level of the solver.- Returns:
- verbosity Verbosity level: 0, 1 or 2.
- See Also:
setVerbosity(int)
-
setTimeBetweenDisplays
public 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 statesLSState.ModelingorLSState.Stopped.- Parameters:
timeBetweenDisplays- Time in seconds between displays.
-
getTimeBetweenDisplays
public int getTimeBetweenDisplays()
Gets the time in seconds between two consecutive displays in console while the solver is running.- Returns:
- Time in seconds between displays.
- See Also:
setTimeBetweenDisplays(int)
-
setTimeBetweenTicks
public void setTimeBetweenTicks(int timeBetweenTicks)
Sets the time in seconds between two events of typeLSCallbackType.TimeTicked. The default time between ticks is set to 1 second. Only allowed in statesLSState.ModelingorLSState.Stopped.- Parameters:
timeBetweenTicks- Time in seconds between ticks.- Since:
- 6.0
-
getTimeBetweenTicks
public int getTimeBetweenTicks()
Gets the time in seconds between two events of typeLSCallbackType.TimeTicked.- Returns:
- Time in seconds between ticks.
- Since:
- 6.0
- See Also:
setTimeBetweenTicks(int)
-
setIterationBetweenTicks
public void setIterationBetweenTicks(long iterationBetweenTicks)
Sets the number of iterations between two events of typeLSCallbackType.IterationTicked. The default number of iterations between ticks is set to 10,000. Only allowed in statesLSState.ModelingorLSState.Stopped.- Parameters:
iterationBetweenTicks- Number of iterations between ticks.- Since:
- 6.0
-
getIterationBetweenTicks
public long getIterationBetweenTicks()
Gets the number of iterations between two events of typeLSCallbackType.IterationTicked.- Returns:
- Number of iterations between ticks.
- Since:
- 6.0
- See Also:
setIterationBetweenTicks(long)
-
getLogFile
public java.lang.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 Also:
setLogFile(java.lang.String)
-
setLogFile
public void setLogFile(java.lang.String path)
Sets the path of the LocalSolver log file. The log file is used to duplicate the standard output of LocalSolver. If the specified path is empty or null, no log file will be used. To tune the logging verbosity of the output, seesetVerbosity(int). The verbosity is common to both the standard output and the log file. Only allowed in statesLSState.StoppedorLSState.Modeling.- Parameters:
path- Path of the log file. Leave empty to disable the logging mechanism.- See Also:
setVerbosity(int),getLogFile(),setLogWriter(java.io.PrintStream)
-
setLogWriter
public void setLogWriter(java.io.PrintStream stream)
Sets the stream used by LocalSolver for its logging. The default is to log to the standard output. To tune the logging verbosity of the output, seesetVerbosity(int). Note that you can specify both the log writer and the log file by using the methodsetLogFile(java.lang.String).- Parameters:
stream- Stream to use for the logging or null to disable logging.- Since:
- 9.5
-
getLogWriter
public java.io.PrintStream getLogWriter()
Returns the stream used by LocalSolver for its logging. The default value is initialized to the standard output, retrieved withSystem.out. To tune the logging verbosity of the output, seesetVerbosity(int).- Returns:
- The stream used by LocalSolver for its logging or null if logging is disabled.
- Since:
- 9.5
- See Also:
setLogWriter(java.io.PrintStream)
-
setObjectiveThreshold
public void setObjectiveThreshold(int objectiveIndex, long 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 statesLSState.Stopped. This method has the same behavior assetIntObjectiveThreshold(int, long).- Parameters:
objectiveIndex- Index of the objective.threshold- Objective threshold.- Since:
- 8.5
- See Also:
LSExpression.isObjective(),LSExpression.isInt()
-
setObjectiveThreshold
public void setObjectiveThreshold(int objectiveIndex, double 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 statesLSState.Stopped. This method has the same behavior assetDoubleObjectiveThreshold(int, double).- Parameters:
objectiveIndex- Index of the objective.threshold- Objective threshold.- Since:
- 8.5
- See Also:
LSExpression.isObjective(),LSExpression.isDouble()
-
setIntObjectiveThreshold
public void setIntObjectiveThreshold(int objectiveIndex, long 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 statesLSState.Stopped.- Parameters:
objectiveIndex- Index of the objective.threshold- Objective threshold.- Since:
- 8.5
- See Also:
LSExpression.isObjective(),LSExpression.isInt()
-
setDoubleObjectiveThreshold
public void setDoubleObjectiveThreshold(int objectiveIndex, double 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 statesLSState.Stopped.- Parameters:
objectiveIndex- Index of the objective.threshold- Objective threshold.- Since:
- 8.5
- See Also:
LSExpression.isObjective(),LSExpression.isDouble()
-
getObjectiveThreshold
public long getObjectiveThreshold(int objectiveIndex)
Gets the threshold of the objective with the given index. Only allowed in statesLSState.PausedorLSState.Stopped.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Objective threshold.
- Since:
- 8.5
- See Also:
setObjectiveThreshold(int, long)
-
getIntObjectiveThreshold
public long getIntObjectiveThreshold(int objectiveIndex)
Gets the threshold of the objective with the given index. Only allowed in statesLSState.PausedorLSState.Stopped.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Objective threshold.
- Since:
- 8.5
- See Also:
setObjectiveThreshold(int, long)
-
getDoubleObjectiveThreshold
public double getDoubleObjectiveThreshold(int objectiveIndex)
Gets the threshold of the objective with the given index. Only allowed in statesLSState.PausedorLSState.Stopped.- Parameters:
objectiveIndex- Index of the objective.- Returns:
- Objective threshold.
- Since:
- 8.5
- See Also:
setObjectiveThreshold(int, double)
-
setAdvancedParam
public void setAdvancedParam(java.lang.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 statesLSState.ModelingorLSState.Stopped.- Parameters:
key- Name of the parameter.value- Value of the parameter.
-
getAdvancedParam
public int getAdvancedParam(java.lang.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.- Parameters:
key- Name of the parameter.- Returns:
- Value of the parameter.
- See Also:
setAdvancedParam(String, int)
-
getAdvancedParam
public int getAdvancedParam(java.lang.String key, int defaultValue)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 was set for this one.- Parameters:
key- Name of the parameter.defaultValue- Default value of the parameter.- See Also:
setAdvancedParam(String, int)
-
setAdvancedParam
public void setAdvancedParam(java.lang.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 statesLSState.ModelingorLSState.Stopped.- Parameters:
key- Name of the parameter.value- Value of the parameter.
-
getAdvancedParam
public double getAdvancedParam(java.lang.String key, double defaultValue)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 was set for this one.- Parameters:
key- Name of the parameter.defaultValue- Default value of the parameter.- See Also:
setAdvancedParam(String, double)
-
setAdvancedParam
public void setAdvancedParam(java.lang.String key, java.lang.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 statesLSState.ModelingorLSState.Stopped.- Parameters:
key- Name of the parameter.value- Value of the parameter.
-
getAdvancedParam
public java.lang.String getAdvancedParam(java.lang.String key, java.lang.String defaultValue)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 was set for this one.- Parameters:
key- Name of the parameter.defaultValue- Default value of the parameter.- See Also:
setAdvancedParam(String, String)
-
toString
public java.lang.String toString()
Returns a String representation of these parameters. Useful for debugging or logging purposes.- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-