Base classes¶
Problem ¶
Abstract class for optimization problems.
Subclasses implement eval to compute the fitness of a population and
sample to draw a solution from the search space. sample is commonly used
to obtain the example solution required by the algorithm constructors.
init ¶
Initialize the problem state.
Parameters:
-
key(Array) –PRNG key.
Returns:
-
State–The initial problem state.
eval ¶
Evaluate a population of solutions.
Parameters:
-
key(Array) –PRNG key.
-
solutions(Population) –Population to evaluate, a PyTree with a leading population axis on every leaf.
-
state(State) –Current problem state.
Returns:
-
tuple[Fitness, State, Metrics]–A tuple
(fitness, state, info)with one fitness value per population member, the updated problem state and a dictionary of additional information.
sample ¶
Sample a solution from the search space.
Parameters:
-
key(Array) –PRNG key.
Returns:
-
Solution–A single solution PyTree.
MetaProblem ¶
Bases: Problem
Abstract class for meta-optimization problems.
Unlike Problem, init and eval take an additional params argument that
selects the problem instance. Use sample_params to draw an instance.
sample_params ¶
Sample the parameters of a problem instance.
Parameters:
-
key(Array) –PRNG key.
Returns:
-
Params–Parameters identifying one problem instance.
init ¶
Initialize the problem state for a problem instance.
Parameters:
-
key(Array) –PRNG key.
-
params(Params) –Parameters of the problem instance.
Returns:
-
State–The initial problem state.
eval ¶
eval(key: Array, solutions: Population, state: State, params: Params) -> tuple[Fitness, State, Metrics]
Evaluate a population of solutions on a problem instance.
Parameters:
-
key(Array) –PRNG key.
-
solutions(Population) –Population to evaluate, a PyTree with a leading population axis on every leaf.
-
state(State) –Current problem state.
-
params(Params) –Parameters of the problem instance.
Returns:
-
tuple[Fitness, State, Metrics]–A tuple
(fitness, state, info)with one fitness value per population member, the updated problem state and a dictionary of additional information.