Algorithms
Every algorithm inherits from the abstract
Algorithm,
which provides the parameters common to every solver — evaluation budget, time
limits, stopping criteria, restart count, and PRNG seed.
Numeric algorithm parameters accept either a plain number or a
NumericExpression, which lets values scale with
the problem size at runtime.
Algorithm base
Abstract Algorithm base class for optimisation solver configurations.
Subclasses define their own key and parameter dict; common stopping criteria
(evaluation budget, time limits, restart count, PRNG seed) live on the base.
Numeric parameters accept a plain number, a
NumericExpression, or a model
Parameter/Calculation.
- class Algorithm(log_info=False, evaluations=100000, max_evaluations_without_improvement=10000, max_time_without_improvement=300, min_improvement=1e-06, max_restart_count=0, prng_seed=None, time_limit=60)[source]
Abstract base for optimisation algorithm configurations.
- evaluations: int | NumericExpression | Parameter | Calculation = 100000
Maximum total evaluations before the run terminates.
- max_evaluations_without_improvement: int | NumericExpression | Parameter | Calculation = 10000
Stop after this many consecutive evaluations with no improvement.
- max_time_without_improvement: int | NumericExpression | Parameter | Calculation = 300
Stop after this many seconds with no improvement.
- min_improvement: float | NumericExpression | Parameter | Calculation = 1e-06
Smallest objective change counted as an improvement.
- max_restart_count: int | NumericExpression | Parameter | Calculation = 0
Maximum number of restarts after stagnation.
- time_limit: int | NumericExpression | Parameter | Calculation = 60
Hard wall-clock limit in seconds.
NumericExpression
Symbolic numeric expression that may depend on the NUM_VARIABLES variable.
Use this where an algorithm parameter should scale with the problem dimension; the
NUM_VARIABLES token is replaced at runtime with the number of decision variables.
- class NumericExpression(value)[source]
Symbolic numeric value supporting
+,-,*,/operators.Wraps a numeric literal or an expression in the special variable
NUM_VARIABLES. Operators return a newNumericExpression, so expressions compose naturally:evals = 100_000 * NumericExpression("NUM_VARIABLES") rate = 1 / NumericExpression("NUM_VARIABLES")
- is_expression()[source]
Return True if the expression contains a variable rather than a numeric literal.
- Return type: