Skip to main content

Type Alias: Parameters

Parameters: {absoluteGapTolerance: number;color: "Never" | "Auto" | "Always";cumulPropagationLevel: number;fdsAdditionalStepRatio: number;fdsBothFailRewardFactor: number;fdsBranchOnObjective: boolean;fdsEpsilon: number;fdsEventTimeInfluence: number;fdsFixedAlpha: number;fdsInitialRating: number;fdsInitialRestartLimit: number;fdsLBResetRatings: boolean;fdsLBStrategy: "Minimum" | "Random" | "Split";fdsLengthStepRatio: number;fdsMaxCounterAfterRestart: number;fdsMaxCounterAfterSolution: number;fdsMaxInitialChoicesPerVariable: number;fdsMaxInitialIntVarChoiceStep: number;fdsPresenceStatusChoices: boolean;fdsRatingAverageComparison: "Off" | "Global" | "Depth";fdsRatingAverageLength: number;fdsReductionFactor: "Normal" | "Zero" | "Random";fdsReductionWeight: number;fdsResetRestartsAfterSolution: boolean;fdsRestartGrowthFactor: number;fdsRestartStrategy: "Geometric" | "Nested" | "Luby";fdsReuseClosing: boolean;fdsStrongBranchingCriterion: "Both" | "Left" | "Right";fdsStrongBranchingDepth: number;fdsStrongBranchingSize: number;fdsUniformChoiceStep: boolean;fdsUseNogoods: boolean;infoTraceLevel: number;logLevel: number;logPeriod: number;nbWorkers: number;noOverlapPropagationLevel: number;propagationTraceLevel: number;randomSeed: number;relativeGapTolerance: number;reservoirPropagationLevel: number;searchTraceLevel: number;searchType: "LNS" | "FDS" | "FDSLB" | "SetTimes";simpleLBMaxIterations: number;simpleLBShavingRounds: number;simpleLBWorker: number;solutionLimit: number;solverPath: string;stepFunctionSumPropagationLevel: number;timeLimit: number;usage: string;usePrecedenceEnergy: number;verifySolutions: boolean;version: string;warningLevel: number;workers: WorkerParameters[]; }

Parameters allow to specify how the solver should behave. For example, the number of workers (threads) to use, the time limit, etc.

Parameters can be passed to the solver using function solve or by constructor of the class Solver.

Type declaration

absoluteGapTolerance?

optional absoluteGapTolerance: number

Stop the search when gap is below the tolerance.

The search is stopped if the absolute difference between the current solution value and current lower/upper bound is not bigger than the specified value. Note that parameters AbsoluteGapTolerance and RelativeGapTolerance are considered independently, i.e., the search stops if at least one of the conditions apply.

The parameter takes a floating point value. The default value is 0.

color?

optional color: "Never" | "Auto" | "Always"

Whether to colorize output to the terminal.

This parameter controls when terminal output is colorized. Possible values are:

  • never: don't colorize the output.
  • auto: colorize if the output is a supported terminal.
  • always: always colorize the output.

The default value is Auto.

cumulPropagationLevel?

optional cumulPropagationLevel: number

How much to propagate constraints on cumul functions.

This parameter controls the amount of propagation done for Model.cumulLe constraint when used with a sum of pulses. The bigger the value, the more algorithms are used for propagation. It means that more time is spent by the propagation, and possibly more values are removed from domains. More propagation doesn't necessarily mean better performance. FDS search (see searchType) usually benefits from higher propagation levels.

The parameter takes an unsigned integer value in range 1..3. The default value is 1.

fdsAdditionalStepRatio?

optional fdsAdditionalStepRatio: number

Domain split ratio when run out of choices.

When all choices are decided, and a greedy algorithm cannot find a solution, then more choices are generated by splitting domains into the specified number of pieces.

The parameter takes a floating point value in range 2.000000..Infinity. The default value is 7.

fdsBothFailRewardFactor?

optional fdsBothFailRewardFactor: number

How much to improve rating when both branches fail immediately.

This parameter sets a bonus reward given to a choice when both left and right branches fail immediately. Current rating of both branches is multiplied by the specified value.

The parameter takes a floating point value in range 0..1. The default value is 0.98.

fdsBranchOnObjective?

optional fdsBranchOnObjective: boolean

Whether to generate choices for objective expression/variable.

This option controls the generation of choices on the objective. It works regardless of the objective is given by an expression or a variable.

The default value is false.

fdsEpsilon?

optional fdsEpsilon: number

How often to chose a choice randomly.

Probability that a choice is taken randomly. A randomly selected choice is not added into the search tree automatically. Instead, the choice is tried, its rating is updated, but it is added into the search tree only if one of the branches fails. The mechanism is similar to strong branching.

The parameter takes a floating point value in range 0.000000..0.999990. The default value is 0.1.

fdsEventTimeInfluence?

optional fdsEventTimeInfluence: number

Influence of event time to initial choice rating.

When non-zero, then the initial choice rating is influenced by the date of the choice. This way, very first choices in the search should be taken chronologically.

The parameter takes a floating point value in range 0..1. The default value is 0.

fdsFixedAlpha?

optional fdsFixedAlpha: number

When non-zero, alpha factor for rating updates.

When this parameter is set to a non-zero, then parameter FDSRatingAverageLength is ignored. Instead, the rating of a branch is computed as an exponential moving average with the given parameter alpha.

The parameter takes a floating point value in range 0..1. The default value is 0.

fdsInitialRating?

optional fdsInitialRating: number

Initial rating for newly created choices.

Default rating for newly created choices. Both left and right branches get the same rating. Choice is initially permuted so that bigger domain change is the left branch.

The parameter takes a floating point value in range 0.000000..2.000000. The default value is 0.5.

fdsInitialRestartLimit?

optional fdsInitialRestartLimit: number

Fail limit for the first restart.

Failure-directed search is periodically restarted: explored part of the current search tree is turned into a no-good constraint, and the search starts again in the root node. This parameter specifies the size of the very first search tree (measured in number of failures).

The parameter takes an unsigned integer value in range 1..9223372036854775807. The default value is 100.

fdsLBResetRatings?

optional fdsLBResetRatings: boolean

Whether to reset ratings when a new LB is proved.

When this parameter is on, and FDSLB proves a new lower bound then all ratings are reset to default values.

The default value is false.

fdsLBStrategy?

optional fdsLBStrategy: "Minimum" | "Random" | "Split"

A strategy to choose objective cuts during FDSLB search..

Possible values are:

  • Minimum: Always change the cut by the minimum amount. The default value.
  • Random: At each restart, randomly choose a value in range LB..UB.
  • Split: Always split the current range LB..UB in half.

The default value is Minimum.

fdsLengthStepRatio?

optional fdsLengthStepRatio: number

Choice step relative to average length.

Ratio of initial choice step size to the minimum length of interval variable.When FDSUniformChoiceStep is set, this ratio is used to compute global choice step using the average of interval var length.When FDSUniformChoiceStep is not set, this ratio is used to compute the choice step for every interval var individually.

The parameter takes a floating point value in range 0.000000..Infinity. The default value is 0.699999988079071.

fdsMaxCounterAfterRestart?

optional fdsMaxCounterAfterRestart: number

Truncate choice use counts after a restart to this value.

The idea is that ratings learned in the previous restart are less valid in the new restart. Using this parameter, it is possible to truncate use counts on choices so that new local ratings will have bigger weights (when FDSFixedAlpha is not used).

The parameter takes an unsigned integer value. The default value is 255.

fdsMaxCounterAfterSolution?

optional fdsMaxCounterAfterSolution: number

Truncate choice use counts after a solution is found.

Similar to FDSMaxCounterAfterRestart, this parameter allows truncating use counts on choices when a solution is found.

The parameter takes an unsigned integer value. The default value is 255.

fdsMaxInitialChoicesPerVariable?

optional fdsMaxInitialChoicesPerVariable: number

Maximum number of choices generated initially per a variable.

Initial domains are often very large (e.g., 0..IntervalMax). Therefore initial number of generated choices is limited: only choices near startMin are kept.

The parameter takes an unsigned integer value in range 2..2147483647. The default value is 90.

fdsMaxInitialIntVarChoiceStep?

optional fdsMaxInitialIntVarChoiceStep: number

Maximum step when generating initial choices for integer variables..

For a variable with big initial domains, choices are generated only around min value considering the given step.

The parameter takes an unsigned integer value in range 1..1073741823. The default value is 107374182.

fdsPresenceStatusChoices?

optional fdsPresenceStatusChoices: boolean

Whether to generate choices on presence status.

Choices on start time also include a choice on presence status. Therefore, dedicated choices on presence status only are not mandatory.

The default value is true.

fdsRatingAverageComparison?

optional fdsRatingAverageComparison: "Off" | "Global" | "Depth"

Whether to compare the local rating with the average.

Possible values are:

  • Off (the default): No comparison is done.
  • Global: Compare with the global average.
  • Depth: Compare with the average on the current search depth

Arithmetic average is used for global and depth averages.

The default value is Off.

fdsRatingAverageLength?

optional fdsRatingAverageLength: number

Length of average rating computed for choices.

For the computation of rating of a branch. Arithmetic average is used until the branch is taken at least FDSRatingAverageLength times. After that exponential moving average is used with parameter alpha = 1 - 1 / FDSRatingAverageLength.

The parameter takes an integer value in range 0..254. The default value is 25.

fdsReductionFactor?

optional fdsReductionFactor: "Normal" | "Zero" | "Random"

Reduction factor R for rating computation.

Possible values are:

  • Normal (the default): Normal reduction factor.
  • Zero: Factor is not used (it is 0 all the time).
  • Random: A random number in the range [0,1] is used instead.

The default value is Normal.

fdsReductionWeight?

optional fdsReductionWeight: number

Weight of the reduction factor in rating computation.

When computing the local rating of a branch, multiply reduction factor by the given weight.

The parameter takes a floating point value in range 0.000000..Infinity. The default value is 1.

fdsResetRestartsAfterSolution?

optional fdsResetRestartsAfterSolution: boolean

Reset restart size after a solution is found (ignored in Luby).

When this parameter is set (the default), then restart limit is set back to FDSInitialRestartLimit when a solution is found.

The default value is true.

fdsRestartGrowthFactor?

optional fdsRestartGrowthFactor: number

Growth factor for fail limit after each restart.

After each restart, the fail limit for the restart is multiplied by the specified factor. This parameter is ignored when fdsRestartStrategy is Luby.

The parameter takes a floating point value in range 1.000000..Infinity. The default value is 1.15.

fdsRestartStrategy?

optional fdsRestartStrategy: "Geometric" | "Nested" | "Luby"

Restart strategy to use.

This parameter specifies how the restart limit (maximum number of failures) changes from restart to restart. Possible values are:

  • Geometric (the default): After each restart, restart limit is multiplied by fdsRestartGrowthFactor.
  • Nested: Similar to Geometric but the limit is changed back to fdsInitialRestartLimit each time a new maximum limit is reached.
  • Luby: Luby restart strategy is used. Parameter fdsRestartGrowthFactor is ignored.

The default value is Geometric.

fdsReuseClosing?

optional fdsReuseClosing: boolean

Whether always reuse closing choice.

Most of the time, FDS reuses closing choice automatically. This parameter enforces it all the time.

The default value is false.

fdsStrongBranchingCriterion?

optional fdsStrongBranchingCriterion: "Both" | "Left" | "Right"

How to choose the best choice in strong branching.

Possible values are:

  • Both: Choose the the choice with best combined rating.
  • Left (the default): Choose the choice with the best rating of the left branch.
  • Right: Choose the choice with the best rating of the right branch.

The default value is Left.

fdsStrongBranchingDepth?

optional fdsStrongBranchingDepth: number

Up-to what search depth apply strong branching.

Strong branching is typically used in the root node. This parameter controls the maximum search depth when strong branching is used.

The parameter takes an unsigned integer value. The default value is 6.

fdsStrongBranchingSize?

optional fdsStrongBranchingSize: number

Number of choices to try in strong branching.

Strong branching means that instead of taking a choice with the best rating, we take the specified number (FDSStrongBranchingSize) of best choices, try them in dry-run mode, measure their local rating, and then chose the one with the best local rating.

The parameter takes an unsigned integer value. The default value is 10.

fdsUniformChoiceStep?

optional fdsUniformChoiceStep: boolean

Whether all initial choices have the same step length.

When set then initial choices generated on interval variables have all the same step size.

The default value is true.

fdsUseNogoods?

optional fdsUseNogoods: boolean

Whether to use or not nogood constraints.

By default, no-good constraint is generated after each restart. This parameter allows to turn no-good constraints off.

The default value is true.

infoTraceLevel?

optional infoTraceLevel: number

Level of information trace.

This parameter is available only in the development edition of the solver.

When set to a value bigger than zero, the solver prints various high-level information. The higher the value, the more information is printed.

The parameter takes an unsigned integer value in range 0..5. The default value is 0.

logLevel?

optional logLevel: number

Level of the log.

This parameter controls the amount of text the solver writes on standard output. The solver is completely silent when this option is set to 0.

The parameter takes an unsigned integer value in range 0..3. The default value is 2.

logPeriod?

optional logPeriod: number

How often to print log messages (in seconds).

When logLevel ≥ 2 then solver writes a log message every logPeriod seconds. The log message contains the current statistics about the solve: number of branches, number of fails, memory used, etc.

The parameter takes a floating point value in range 0.010000..Infinity. The default value is 2.

nbWorkers?

optional nbWorkers: number

Number of threads dedicated to search.

When this parameter is 0 (the default), the number of workers is determined the following way:

  • If environment variable OPTALCP_NB_WORKERS is set, its value is used.
  • Otherwise, all available cores are used.

The parameter takes an unsigned integer value. The default value is 0.

noOverlapPropagationLevel?

optional noOverlapPropagationLevel: number

How much to propagate noOverlap constraints.

This parameter controls the amount of propagation done for noOverlap constraints. The bigger the value, the more algorithms are used for propagation. It means that more time is spent by the propagation, and possibly more values are removed from domains. More propagation doesn't necessarily mean better performance. FDS search (see searchType) usually benefits from higher propagation levels.

The parameter takes an unsigned integer value in range 1..4. The default value is 2.

propagationTraceLevel?

optional propagationTraceLevel: number

Level of propagation trace.

This parameter is available only in the development edition of the solver.

When set to a value bigger than zero, the solver prints a trace of the propagation, that is a line for every domain change. The higher the value, the more information is printed.

The parameter takes an unsigned integer value in range 0..5. The default value is 0.

randomSeed?

optional randomSeed: number

Random seed.

The solver breaks ties randomly using a pseudorandom number generator. This parameter sets the seed of the generator.

Note that when Parameters.nbWorkers is more than 1 then there is also another source of randomness: the time it takes for a message to pass from one worker to another. Therefore with Parameters.nbWorkers=1 the solver is deterministic (random behavior depends only on random seed). With Parameters.nbWorkers>1 the solver is not deterministic.

Even with NbSeeds=1 and the same random seed, the solver may behave differently on different platforms. This can be due to different implementations of certain functions such as std::sort.

The parameter takes an unsigned integer value. The default value is 1.

relativeGapTolerance?

optional relativeGapTolerance: number

Stop the search when gap is below the tolerance.

The search is stopped if the relative difference between the current solution value and current lower/upper bound is not bigger than the specified value. Note that parameters AbsoluteGapTolerance and RelativeGapTolerance are considered independently, i.e., the search stops if at least one of the conditions apply.

The parameter takes a floating point value. The default value is 0.0001.

reservoirPropagationLevel?

optional reservoirPropagationLevel: number

How much to propagate constraints on cumul functions.

This parameter controls the amount of propagation done for Model.cumulLe and Model.cumulGe when used together with steps (Model.stepAtStart, Model.stepAtEnd, Model.stepAt). The bigger the value, the more algorithms are used for propagation. It means that more time is spent by the propagation, and possibly more values are removed from domains. More propagation doesn't necessarily mean better performance. FDS search (see searchType) usually benefits from higher propagation levels.

The parameter takes an unsigned integer value in range 1..2. The default value is 1.

searchTraceLevel?

optional searchTraceLevel: number

Level of search trace.

This parameter is available only in the development edition of the solver.

When set to a value bigger than zero, the solver prints a trace of the search. The trace contains information about every choice taken by the solver. The higher the value, the more information is printed.

The parameter takes an unsigned integer value in range 0..5. The default value is 0.

searchType?

optional searchType: "LNS" | "FDS" | "FDSLB" | "SetTimes"

Type of search to use.

Possible values are:

  • LNS: Large Neighborhood Search
  • FDS: Failure-Directed Search
  • FDSLB: Failure-Directed Searching working on lower bound
  • SetTimes: Depth-first set-times search (not restarted)

The default value is LNS.

simpleLBMaxIterations?

optional simpleLBMaxIterations: number

Maximum number of feasibility checks.

Simple lower bound is computed by binary search for the best objective value that is not infeasible by propagation. This parameter limits the maximum number of iterations of the binary search.

The parameter takes an unsigned integer value in range 1..2147483647. The default value is 2147483647.

simpleLBShavingRounds?

optional simpleLBShavingRounds: number

Number of shaving rounds.

When non-zero, the solver will use shaving on variable domains to improve the lower bound. This parameter controls the number of shaving rounds.

The parameter takes an unsigned integer value in range 0..2147483647. The default value is 0.

simpleLBWorker?

optional simpleLBWorker: number

Which worker computes simple lower bound.

Simple lower bound is a bound such that infeasibility of a better objective can be proved by propagation only (without the search). Simple lower bound is computed by the given worker before its start normal search. If worker with the given number doesn't exist then the lower bound is not computed.

The parameter takes an integer value in range -1..2147483647. The default value is 0.

solutionLimit?

optional solutionLimit: number

Stop the search after the given number of solutions.

blah blah blah

The parameter takes an unsigned integer value. The default value is 18446744073709551615.

solverPath?

optional solverPath: string

Path to the solver executable. If not specified then the solver is searched as described in function calcSolverPath.

Solver is an executable that is used to solve the model. It is a separate process that is started by the JavaScript API.

stepFunctionSumPropagationLevel?

optional stepFunctionSumPropagationLevel: number

How much to propagate stepFunctionSum expression.

This parameter controls the amount of propagation done for Model.stepFunctionSum expressions. In particular, it controls whether the propagation also affects the minimum and the maximum length of the associated interval variable:

  • 1: The length is updated only once during initial constraint propagation.
  • 2: The length is updated every time the expression is propagated.

The parameter takes an unsigned integer value in range 1..2. The default value is 1.

timeLimit?

optional timeLimit: number

Wall clock limit for execution.

blah blah blah

The parameter takes a floating point value in range 0.000000..Infinity. The default value is Infinity.

usage?

optional usage: string

The value of usage parameter is printed on standard output by functions parseParameters, parseSomeParameters, parseBenchmarkParameters and parseSomeBenchmarkParameters when the user specifies --help or -h on the command line. The usage is followed by the list of recognized parameters of the given function.

usePrecedenceEnergy?

optional usePrecedenceEnergy: number

Whether to use precedence energy propagation algorithm.

Precedence energy algorithm improves propagation of precedence constraints when an interval has multiple predecessors (or successors). which use the same resource (noOverlap or cumulative constraint). In this case, the predecessors (or successors) may be in disjunction. Precedence energy algorithm can leverage this information and propagate the precedence constraint more aggressively.

The parameter takes an unsigned integer value in range 0..1. The default value is 0.

verifySolutions?

optional verifySolutions: boolean

When on, the correctness of solutions is verified.

Verification is an independent algorithm that checks whether all constraints in the model are satisfied (or absent), and that objective value was computed correctly. Verification is a somewhat redundant process as all solutions should be correct. Its purpose is to double-check and detect bugs in the solver.

The default value is false.

version?

optional version: string

Version information. If specified then the version is printed by functions parseParameters, parseSomeParameters, parseBenchmarkParameters and parseSomeBenchmarkParameters when the user specifies --version on the command line. The version is followed by the version of the solver.

warningLevel?

optional warningLevel: number

Level of warnings.

This parameter controls the types of warnings the solver emits. When this parameter is set to 0 then no warnings are emitted. blah blah blah

The parameter takes an unsigned integer value in range 0..3. The default value is 2.

workers?

optional workers: WorkerParameters[]

An array of worker-specific parameters. Each worker can have its own parameters. If a parameter is not specified for a worker then the global value is used.

Note that parameter nbWorkers specifies the number of workers, regardless of the length of the array.

Examples

In the following example, we are using the TimeLimit parameter to specify that the solver should stop after 5 minutes. We also specify that the solver should use 4 threads. Finally, we specify that the solver should use FDS search (in all threads).

let params = {
timeLimit: 300, // In seconds, i.e. 5 minutes
nbWorkers: 4, // Use 4 threads
searchType: "FDS"
};
let result = await CP.solve(myModel, params);

Worker-specific parameters

Some parameters can be specified differently for each worker. For example, some workers may use LNS search while others use FDS search. To specify worker-specific parameters, use the workers parameter and pass an array of WorkerParameters.

Not all parameters can be specified per worker, for example TimeLimit is a global parameter. See WorkerParameters for the list of parameters that can be specified per worker.

If a parameter is not set specifically for a worker, the global value is used.

In the following example, we are going to use 4 workers, two of them will run FDS search and the remaining two will run LNS search. In addition, workers that use FDS search will use increased propagation levels.

// Parameters for a worker that uses FDS search.
// FDS works best with increased propagation levels, so set them:
let fdsWorker: CP.WorkerParameters = {
searchType: "FDS",
noOverlapPropagationLevel: 4,
cumulPropagationLevel: 3,
reservoirPropagationLevel: 2
};
// Global parameters:
let params = {
timeLimit: 60, // In seconds, i.e. 1 minute
searchType: "LNS", // The default search type. Not necessary as "LNS" is the default value.
nbWorkers: 4, // Use 4 threads
// The first two workers will use FDS search.
// The remaining two workers will use the defaults, i.e. LNS search with default propagation levels.
workers = [fdsWorker, fdsWorker];
};
let result = await CP.solve(myModel, params);

See

  • WorkerParameters for worker-specific parameters.
  • BenchmarkParameters are an extension of Parameters to simplify benchmarking (e.g. run the same model multiple times with different random seeds).