Optimizers#
- class staliro.optimizers.ObjFunc(*args, **kwargs)#
Representation of a function that can be optimized by an optimizer.
An objective function evaluates samples generated by the optimizer and returns a scalar cost value for each sample. The objective function is capable of evaluating one or more samples at once.
- eval_sample(sample)#
Evaluate a single sample.
- class staliro.optimizers.Optimizer.Params(seed, budget, input_bounds)#
The parameters for an optimization attempt.
- Attribute seed:
The value to use to seed a random number generator for reproducibility
- Attribute budget:
The maximum number of samples to evaluate
- Attribute input_bounds:
The search range to for each input variable
- Parameters:
- class staliro.optimizers.Optimizer#
An optimizer selects samples to be evaluated by the cost function.
This class is parameterized by two type variables,
CandR.Cis the type of the cost value that the optimizer expects to receive from the cost function, andRrepresents the type that the optimizer will return at the end of an optimization attempt.- abstract optimize(func, params)#
Evaluate samples and use the result to select more samples until the budget is reached.
The optimize method is responsible for generating samples that will be evaluated by the cost function into cost values that can be used to inform the selection of subsequent samples. In order to receive cost values, implementations must call either the
eval_sampleoreval_samplesmethods on thefuncvalue.
Implementations#
- class staliro.optimizers.UniformRandom(min_cost=None, max_cost=None)#
Optimizer that samples the input space uniformly.
This optimizer will exhaust the sample budget unless the
min_costargument is provided. If a minimum cost is indicated then the optimizer will terminate early if a cost is found below that value.- Parameters:
min_cost (CT | None) – The minimum cost that will cause the optimize to terminate
max_cost (CT | None) –
- class staliro.optimizers.DualAnnealing(min_cost=None)#
Optimizer implementing generalized simulated annealing.
The simulated annealing implementation is provided by the SciPy library dual_annealing function with the no_local_search parameter set to True. This optimizer will exhaust the sample budget unless the
min_costargument is provided in the constructor. Ifmin_costis provided, then the optimizer will exit if a cost value is found that is less than the value.- Parameters:
min_cost (float | None) – The minimum cost to use as a termination condition