HxParam Class

class HxParam

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 optimizer.
getSeed Gets the seed of the pseudo-random number generator used by the optimizer.
setNbThreads Sets the number of threads used to parallelize the search.
getNbThreads Gets the number of threads requested by the user.
setNbDisplayedObjectives Sets the maximum number of objectives to display.
getNbDisplayedObjectives Gets the maximum number of objectives to display.
setNbDisplayedViolatedConstraints Sets the maximum number of violated constraints to display.
getNbDisplayedViolatedConstraints Gets the maximum number of violated constraints to display.
setWarningLevel Sets the warning level.
getWarningLevel Gets the warning level.
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.
setGapLimit Sets the optimality gap used as a termination criterion.
getGapLimit Gets the optimality gap used as a termination criterion.
setVerbosity Sets the verbosity level of the optimizer.
getVerbosity Gets the verbosity level of the optimizer.
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 optimizer is running.
getTimeBetweenDisplays Gets the time in seconds between two consecutive displays in console while the optimizer 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 Hexaly Optimizer for its logging.
getLogWriter Returns the writer used by Hexaly Optimizer for its logging.
setLogFile Sets the path of the Hexaly Optimizer log file.
getLogFile Returns the path of the Hexaly Optimizer 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 HxParam::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 S_Modeling or S_Stopped.

Parameters:seed – Seed of the pseudo-random number generator.
int HxParam::getSeed() const

Gets the seed of the pseudo-random number generator used by the optimizer.

Returns:Seed of the pseudo-random number generator.
See:HxParam::setSeed()
void HxParam::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 S_Modeling or S_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.
int HxParam::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:HxParam::setNbThreads()
void HxParam::setNbDisplayedObjectives(int nbDisplayedObjectives)

Sets the maximum number of objectives to display. Only allowed in states S_Modeling or S_Stopped.

Parameters:nbDisplayedObjectives – Maximum number of objectives to display.
int HxParam::getNbDisplayedObjectives() const

Gets the maximum number of objectives to display.

Returns:Maximum number of objectives to display.
See:HxParam::setNbDisplayedObjectives()
void HxParam::setNbDisplayedViolatedConstraints(int nbDisplayedViolatedConstraints)

Sets the maximum number of violated constraints to display. Only allowed in states S_Modeling or S_Stopped.

Parameters:nbDisplayedViolatedConstraints – Maximum number of violated constraints to display.
int HxParam::getNbDisplayedViolatedConstraints() const

Gets the maximum number of violated constraints to display.

Returns:Maximum number of violated constraints to display.
See:HxParam::setNbDisplayedViolatedConstraints()
void HxParam::setWarningLevel(int warningLevel)

Sets the warning level. The default warning level is set to 1. Only allowed in states S_Modeling or S_Stopped.

There are 3 defined warning levels:

  • 0: Disable warning computation.
  • 1: Automatic behavior (default) - warnings related to the solver configuration are displayed by default. Modeling warnings are not computed.
  • 2: Compute all warnings, including modeling warnings.

Modeling warnings are raised when a constraint or objective cannot be proven to be well defined. If such a warning appears, it indicates a modeling issue in the formulation. In cases where this kind of warning should not appear, it may be because Hexaly does not have sufficient tools to prove it.

For more information about modeling warnings, please refer to the warning section of Debugging a Model.

Parameters:warningLevel – Warning level: 0, 1, 2.
int HxParam::getWarningLevel() const

Gets the warning level.

Returns:Warning level: 0, 1 or 2.
See:HxParam::setWarningLevel()
void HxParam::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:HxPhase
int HxParam::getTimeLimit()

Gets the time limit in seconds.

Returns:Time limit in seconds.
See:HxParam::setTimeLimit()
See:HxPhase
void HxParam::setIterationLimit(long long iterationLimit)

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

Parameters:iterationLimit – Iteration limit.
See:HxPhase
long long HxParam::getIterationLimit()

Gets the maximum number of iterations.

Returns:Iteration limit.
See:HxParam::setIterationLimit()
See:HxPhase
void HxParam::setGapLimit(double gapLimit)

Sets the optimality gap used as a termination criterion. When the solver detects that the current gap is below this limit, the current solution is considered optimal. Only allowed in states S_Modeling or S_Stopped.

Parameters:gapLimit – Gap limit.
double HxParam::getGapLimit()

Gets the optimality gap used as a termination criterion. When the solver detects that the current gap is below this limit, the current solution is considered optimal.

Returns:Gap limit.
See:HxParam::setGapLimit()
void HxParam::setVerbosity(int verbosity)

Sets the verbosity level of the optimizer. 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 HxParam::getVerbosity() const

Gets the verbosity level of the optimizer.

Returns:verbosity Verbosity level: 0, 1 or 2.
See:HxParam::setVerbosity()
void HxParam::setObjectiveThreshold(int objectiveIndex, hxint 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 HxParam::setIntObjectiveThreshold().

Parameters:
  • objectiveIndex – Index of the objective.
  • threshold – Objective threshold.
See:

HxExpression::isObjective()

See:

HxExpression::isInt()

Since:

8.5

void HxParam::setObjectiveThreshold(int objectiveIndex, hxdouble 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 HxParam::setDoubleObjectiveThreshold().

Parameters:
  • objectiveIndex – Index of the objective.
  • threshold – Objective threshold.
See:

HxExpression::isObjective()

See:

HxExpression::isDouble()

Since:

8.5

void HxParam::setIntObjectiveThreshold(int objectiveIndex, hxint 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:

HxExpression::isObjective()

See:

HxExpression::isInt()

Since:

8.5

void HxParam::setDoubleObjectiveThreshold(int objectiveIndex, hxdouble 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:

HxExpression::isObjective()

See:

HxExpression::isDouble()

Since:

8.5

hxint HxParam::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:HxParam::setObjectiveThreshold() hxint)
Since:8.5
hxint HxParam::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:HxParam::setIntObjectiveThreshold() hxint)
Since:8.5
hxdouble HxParam::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:HxParam::setObjectiveThreshold() hxint)
Since:3.0
void HxParam::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 S_Modeling or S_Stopped.

Parameters:timeBetweenDisplays – Time in seconds between displays.
int HxParam::getTimeBetweenDisplays() const

Gets the time in seconds between two consecutive displays in console while the optimizer is running.

Returns:Time in seconds between displays.
See:HxParam::setTimeBetweenDisplays()
void HxParam::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 HxParam::getTimeBetweenTicks() const

Gets the time in seconds between two events of type CT_TimeTicked.

Returns:Time in seconds between ticks.
See:HxParam::setTimeBetweenTicks()
Since:6.0
void HxParam::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 HxParam::getIterationBetweenTicks() const

Gets the number of iterations between two events of type CT_IterationTicked.

Returns:Number of iterations between ticks.
See:HxParam::setIterationBetweenTicks()
Since:6.0
void HxParam::setLogWriter(std::streambuf *writer)

Sets the writer used by Hexaly Optimizer 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 HxParam::setVerbosity(). Note that you can specify both the log writer and the log file by using the method HxParam::setLogFile().

Parameters:writer – Writer to use for the logging or null to restore the default writer.
Since:9.5
std::streambuf *HxParam::getLogWriter() const

Returns the writer used by Hexaly Optimizer 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 HxParam::setVerbosity().

Returns:The writer used by Hexaly Optimizer for its logging.
See:HxParam::setLogWriter().
Since:9.5
void HxParam::setLogFile(const std::string &path)

Sets the path of the Hexaly Optimizer log file. If the path is empty, no log wil be saved. To tune the logging verbosity, see HxParam::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:HxParam::setVerbosity()
See:HxParam::getLogFile()
std::string HxParam::getLogFile() const

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:HxParam::setLogFile()
void HxParam::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 HxParam::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 HxParam::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 HxParam::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:HxParam::setAdvancedParam()
int HxParam::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:

HxParam::setAdvancedParam()

double HxParam::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:

HxParam::setAdvancedParam()

std::string HxParam::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:

HxParam::setAdvancedParam()

std::string HxParam::toString() const

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

Returns:String representation.