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.

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.

setAnnealingLevel

Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore.

getAnnealingLevel

Deprecated since version 8.5: This parameter does not have a significant influence on the search anymore.

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. 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::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::setAnnealingLevel(int annealingLevel)

Deprecated since version 8.5: This parameter does not 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 S_Modeling or S_Stopped.

Parameters:

annealingLevel – Simulated annealing level.

int HxParam::getAnnealingLevel() const

Deprecated since version 8.5: This parameter does not 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:

HxParam::setAnnealingLevel()

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.