Open-source ESP implementation for Project Resilience
The evolutionary step assumes it is given a sorted, evaluated population.
- (Optional) Elites are taken from the population and used to update the evaluator (full ESP loop).
- The next population is created using crossover/mutation of the current population.
- The next population is evaluated and sorted.
The Evolution class is the core of the library and takes in many evolution parameters as well as the Evaluator and the PrescriptorFactory.
3 things have to be implemented to use the library: the Evaluator, the Prescriptor, and the PrescriptorFactory.
- The
Prescriptoris an individual in the population whoseforwardfunction must be implemented for use the in theEvaluator. - The
PrescriptorFactorymust implement crossover/mutation for evolution. - The
Evaluatortakes in a population ofPrescriptors and attaches metrics to each individual.
A basic example would look like this:
from presp.evolution import Evolution
from examples.evaluator import ImplementedEvaluator
from examples.prescriptor import ImplementedFactory
config = {...}
evaluator = ImplementedEvaluator(**config["eval_params"])
prescriptor_factory = ImplementedFactory(**config["prescriptor_params"])
evolution = Evolution(**config["evolution_params"], evaluator=evaluator, prescriptor_factory=prescriptor_factory)
evolution.run_evolution()For a more full-fledged example see examples/cartpole for a simple implementation of direct evolution (not ESP) on the CartPole gymnasium environment.
See examples/bnh for a simple example of directly evolving the parameters of the BNH function.