Package localsolver

Class LSParam


  • public class LSParam
    extends java.lang.Object
    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.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      int getAdvancedParam​(java.lang.String key)
      Returns the value of an advanced parameter.
      double getAdvancedParam​(java.lang.String key, double defaultValue)
      Reserved for maintenance purpose.
      int getAdvancedParam​(java.lang.String key, int defaultValue)
      Reserved for maintenance purpose.
      java.lang.String getAdvancedParam​(java.lang.String key, java.lang.String defaultValue)
      Reserved for maintenance purpose.
      int getAnnealingLevel()
      Deprecated.
      As of 8.5, this parameter doesn't have a significant influence on the search anymore.
      double getDoubleObjectiveThreshold​(int objectiveIndex)
      Gets the threshold of the objective with the given index.
      long getIntObjectiveThreshold​(int objectiveIndex)
      Gets the threshold of the objective with the given index.
      long getIterationBetweenTicks()
      Gets the number of iterations between two events of type LSCallbackType.IterationTicked.
      long getIterationLimit()
      Gets the maximum number of iterations.
      LocalSolver getLocalSolver()
      Returns the LocalSolver object associated to these parameters.
      java.lang.String getLogFile()
      Returns the path of the LocalSolver log file.
      java.io.PrintStream getLogWriter()
      Returns the stream used by LocalSolver for its logging.
      int getNbThreads()
      Gets the number of threads (0 coding for automatic setting).
      long getObjectiveThreshold​(int objectiveIndex)
      Gets the threshold of the objective with the given index.
      int getSeed()
      Gets the seed of the pseudo-random number generator used by the solver.
      int getTimeBetweenDisplays()
      Gets the time in seconds between two consecutive displays in console while the solver is running.
      int getTimeBetweenTicks()
      Gets the time in seconds between two events of type LSCallbackType.TimeTicked.
      int getTimeLimit()
      Gets the time limit in seconds.
      int getVerbosity()
      Gets the verbosity level of the solver.
      int hashCode()  
      void setAdvancedParam​(java.lang.String key, double value)
      Reserved for maintenance purpose.
      void setAdvancedParam​(java.lang.String key, int value)
      Sets the value of an advanced parameter.
      void setAdvancedParam​(java.lang.String key, java.lang.String value)
      Reserved for maintenance purpose.
      void setAnnealingLevel​(int annealingLevel)
      Deprecated.
      As of 8.5, this parameter doesn't have a significant influence on the search anymore.
      void setDoubleObjectiveThreshold​(int objectiveIndex, double threshold)
      Sets the threshold of the objective with the given index.
      void setIntObjectiveThreshold​(int objectiveIndex, long threshold)
      Sets the threshold of the objective with the given index.
      void setIterationBetweenTicks​(long iterationBetweenTicks)
      Sets the number of iterations between two events of type LSCallbackType.IterationTicked.
      void setIterationLimit​(long iterationLimit)
      Sets the maximum number of iterations.
      void setLogFile​(java.lang.String path)
      Sets the path of the LocalSolver log file.
      void setLogWriter​(java.io.PrintStream stream)
      Sets the stream used by LocalSolver for its logging.
      void setNbThreads​(int nbThreads)
      Sets the number of threads used to parallelize the search.
      void setObjectiveThreshold​(int objectiveIndex, double threshold)
      Sets the threshold of the objective with the given index.
      void setObjectiveThreshold​(int objectiveIndex, long threshold)
      Sets the threshold of the objective with the given index.
      void setSeed​(int seed)
      Sets the seed of the pseudo-random number generator used by the solver.
      void setTimeBetweenDisplays​(int timeBetweenDisplays)
      Sets the time in seconds between two consecutive displays in console while the solver is running.
      void setTimeBetweenTicks​(int timeBetweenTicks)
      Sets the time in seconds between two events of type LSCallbackType.TimeTicked.
      void setTimeLimit​(int timeLimit)
      Sets the time limit in seconds.
      void setVerbosity​(int verbosity)
      Sets the verbosity level of the solver.
      java.lang.String toString()
      Returns a String representation of these parameters.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • 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 states LSState.Modeling or LSState.Stopped.
        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 states LSState.Modeling or LSState.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 states LSState.Modeling or LSState.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.
        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 states LSState.Modeling or LSState.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.
        Only allowed in states LSState.Modeling or LSState.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 states LSState.Modeling or LSState.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 type LSCallbackType.TimeTicked. The default time between ticks is set to 1 second. Only allowed in states LSState.Modeling or LSState.Stopped.
        Parameters:
        timeBetweenTicks - Time in seconds between ticks.
        Since:
        6.0
      • setIterationBetweenTicks

        public 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 states LSState.Modeling or LSState.Stopped.
        Parameters:
        iterationBetweenTicks - Number of iterations between ticks.
        Since:
        6.0
      • 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, see setVerbosity(int). The verbosity is common to both the standard output and the log file. Only allowed in states LSState.Stopped or LSState.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, see setVerbosity(int). Note that you can specify both the log writer and the log file by using the method setLogFile(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 with System.out. To tune the logging verbosity of the output, see setVerbosity(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 states LSState.Stopped. This method has the same behavior as setIntObjectiveThreshold(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 states LSState.Stopped. This method has the same behavior as setDoubleObjectiveThreshold(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 states LSState.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 states LSState.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 states LSState.Paused or LSState.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 states LSState.Paused or LSState.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 states LSState.Paused or LSState.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 states LSState.Modeling or LSState.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 states LSState.Modeling or LSState.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 states LSState.Modeling or LSState.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:
        toString in class java.lang.Object
        Returns:
        String representation.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object