Class HxParam

java.lang.Object
com.hexaly.optimizer.HxParam

public class HxParam extends 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 Details

    • getOptimizer

      public HexalyOptimizer getOptimizer()
      Returns the Hexaly Optimizer object associated to these parameters.
      Returns:
      Hexaly Optimizer object.
    • setSeed

      public void setSeed(int seed)
      Sets the seed of the pseudo-random number generator used by the optimizer. The seed must be a positive integer. The default seed is set to 0. Only allowed in states HxState.Modeling or HxState.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 optimizer.
      Returns:
      Seed of the pseudo-random number generator.
      See Also:
    • 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. When set to 0, the system will create at least 4 threads by default, as it is recommended to have at least 4 physical cores for nominal performance. Only allowed in states HxState.Modeling or HxState.Stopped. This parameter is indicative, if needed Hexaly Optimizer 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:
    • setNbDisplayedObjectives

      public void setNbDisplayedObjectives(int nbDisplayedObjectives)
      Sets the number of displayed objectives. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      nbDisplayedObjectives - Number of displayed objectives.
    • getNbDisplayedObjectives

      public int getNbDisplayedObjectives()
      Gets the number of displayed objectives.
      Returns:
      Number of displayed objectives.
      See Also:
    • setNbDisplayedViolatedConstraints

      public void setNbDisplayedViolatedConstraints(int nbDisplayedViolatedConstraints)
      Sets the maximum number of violated constraints to display. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      nbDisplayedViolatedConstraints - Maximum number of violated constraints to display.
    • getNbDisplayedViolatedConstraints

      public int getNbDisplayedViolatedConstraints()
      Gets the maximum number of violated constraints to display.
      Returns:
      Maximum number of violated constraints to display.
      See Also:
    • setWarningLevel

      public void setWarningLevel(int warningLevel)
      Sets the warning level. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      warningLevel - Warning level.
    • getWarningLevel

      public int getWarningLevel()
      Gets the warning level.
      Returns:
      Warning level.
      See Also:
    • setTimeLimit

      public void setTimeLimit(int timeLimit)
      Sets the time limit in seconds. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      timeLimit - Time limit in seconds.
      See Also:
    • getTimeLimit

      public int getTimeLimit()
      Gets the time limit in seconds.
      Returns:
      Time limit in seconds.
      See Also:
    • setIterationLimit

      public void setIterationLimit(long iterationLimit)
      Sets the maximum number of iterations.
      Parameters:
      iterationLimit - Iteration limit.
      See Also:
    • getIterationLimit

      public long getIterationLimit()
      Gets the maximum number of iterations.
      Returns:
      Iteration limit.
      See Also:
    • setVerbosity

      public void setVerbosity(int verbosity)
      Sets the verbosity level of the optimizer. 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 HxState.Modeling or HxState.Stopped.
      Parameters:
      verbosity - Verbosity level: 0, 1, 2.
    • getVerbosity

      public int getVerbosity()
      Gets the verbosity level of the optimizer.
      Returns:
      verbosity Verbosity level: 0, 1 or 2.
      See Also:
    • setTimeBetweenDisplays

      public void setTimeBetweenDisplays(int timeBetweenDisplays)
      Sets the time in seconds between two consecutive displays in console while the optimizer is running. The default time between displays is set to 1 second. Only allowed in states HxState.Modeling or HxState.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 optimizer is running.
      Returns:
      Time in seconds between displays.
      See Also:
    • setTimeBetweenTicks

      public void setTimeBetweenTicks(int timeBetweenTicks)
      Sets the time in seconds between two events of type HxCallbackType.TimeTicked. The default time between ticks is set to 1 second. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      timeBetweenTicks - Time in seconds between ticks.
      Since:
      6.0
    • getTimeBetweenTicks

      public int getTimeBetweenTicks()
      Gets the time in seconds between two events of type HxCallbackType.TimeTicked.
      Returns:
      Time in seconds between ticks.
      Since:
      6.0
      See Also:
    • setIterationBetweenTicks

      public void setIterationBetweenTicks(long iterationBetweenTicks)
      Sets the number of iterations between two events of type HxCallbackType.IterationTicked. The default number of iterations between ticks is set to 10,000. Only allowed in states HxState.Modeling or HxState.Stopped.
      Parameters:
      iterationBetweenTicks - Number of iterations between ticks.
      Since:
      6.0
    • getIterationBetweenTicks

      public long getIterationBetweenTicks()
      Gets the number of iterations between two events of type HxCallbackType.IterationTicked.
      Returns:
      Number of iterations between ticks.
      Since:
      6.0
      See Also:
    • getLogFile

      public String getLogFile()
      Returns the path of the Hexaly Optimizer 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

      public void setLogFile(String path)
      Sets the path of the Hexaly Optimizer log file. The log file is used to duplicate the standard output of Hexaly Optimizer. 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 HxState.Stopped or HxState.Modeling.
      Parameters:
      path - Path of the log file. Leave empty to disable the logging mechanism.
      See Also:
    • setLogWriter

      public void setLogWriter(PrintStream stream)
      Sets the stream used by Hexaly Optimizer 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 PrintStream getLogWriter()
      Returns the stream used by Hexaly Optimizer 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 Hexaly Optimizer for its logging or null if logging is disabled.
      Since:
      9.5
      See Also:
    • 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 HxState.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:
    • 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 HxState.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:
    • 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 HxState.Stopped.
      Parameters:
      objectiveIndex - Index of the objective.
      threshold - Objective threshold.
      Since:
      8.5
      See Also:
    • 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 HxState.Stopped.
      Parameters:
      objectiveIndex - Index of the objective.
      threshold - Objective threshold.
      Since:
      8.5
      See Also:
    • getObjectiveThreshold

      public long getObjectiveThreshold(int objectiveIndex)
      Gets the threshold of the objective with the given index. Only allowed in states HxState.Paused or HxState.Stopped.
      Parameters:
      objectiveIndex - Index of the objective.
      Returns:
      Objective threshold.
      Since:
      8.5
      See Also:
    • getIntObjectiveThreshold

      public long getIntObjectiveThreshold(int objectiveIndex)
      Gets the threshold of the objective with the given index. Only allowed in states HxState.Paused or HxState.Stopped.
      Parameters:
      objectiveIndex - Index of the objective.
      Returns:
      Objective threshold.
      Since:
      8.5
      See Also:
    • getDoubleObjectiveThreshold

      public double getDoubleObjectiveThreshold(int objectiveIndex)
      Gets the threshold of the objective with the given index. Only allowed in states HxState.Paused or HxState.Stopped.
      Parameters:
      objectiveIndex - Index of the objective.
      Returns:
      Objective threshold.
      Since:
      8.5
      See Also:
    • setAdvancedParam

      public 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 HxState.Modeling or HxState.Stopped.
      Parameters:
      key - Name of the parameter.
      value - Value of the parameter.
    • getAdvancedParam

      public 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.
      Parameters:
      key - Name of the parameter.
      Returns:
      Value of the parameter.
      See Also:
    • getAdvancedParam

      public int getAdvancedParam(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

      public void setAdvancedParam(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 HxState.Modeling or HxState.Stopped.
      Parameters:
      key - Name of the parameter.
      value - Value of the parameter.
    • getAdvancedParam

      public double getAdvancedParam(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

      public void setAdvancedParam(String key, 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 HxState.Modeling or HxState.Stopped.
      Parameters:
      key - Name of the parameter.
      value - Value of the parameter.
    • getAdvancedParam

      public String getAdvancedParam(String key, 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:
    • toString

      public String toString()
      Returns a String representation of these parameters. Useful for debugging or logging purposes.
      Overrides:
      toString in class Object
      Returns:
      String representation.
    • hashCode

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object