Bardo.Examples.Benchmarks.Dpb (Bardo v0.1.0)
View SourceDouble Pole Balancing (DPB) benchmark for neuroevolution algorithms.
This module provides functionality for running and testing the Double Pole Balancing benchmark problem, a common benchmark for testing the efficacy of neural network controllers evolved through neuroevolution.
The benchmark consists of balancing a double pole system attached to a cart that can move horizontally back and forth. The cart must balance two poles of different lengths by applying a horizontal force to keep them upright.
Two versions of the benchmark are available:
- DPB With Damping - Velocities are provided to the agent
- DPB Without Damping - A harder task where velocities are not provided
This module provides functionality for both versions, and includes features for:
- Running a complete evolutionary experiment with the DPB benchmark
- Testing evolved controllers
- Visualizing the behavior of the controllers
Summary
Functions
Creates a configuration for a DPB experiment with damping.
Creates a configuration for a DPB experiment without damping.
Run the Double Pole Balancing benchmark with damping forces.
Run the Double Pole Balancing benchmark without damping forces.
Test the best solution from an experiment.
Functions
@spec configure_with_damping(atom(), pos_integer(), pos_integer(), pos_integer()) :: map()
Creates a configuration for a DPB experiment with damping.
Parameters
id
- Identifier for this experimentpopulation_size
- Number of individuals per generation (default: 100)iterations
- Maximum number of generations to evolve (default: 50)max_steps
- Maximum simulation steps in fitness evaluation (default: 100000)
Returns
- Map with experiment configuration
@spec configure_without_damping(atom(), pos_integer(), pos_integer(), pos_integer()) :: map()
Creates a configuration for a DPB experiment without damping.
Parameters
id
- Identifier for this experimentpopulation_size
- Number of individuals per generation (default: 100)iterations
- Maximum number of generations to evolve (default: 50)max_steps
- Maximum simulation steps in fitness evaluation (default: 100000)
Returns
- Map with experiment configuration
@spec run_with_damping(atom(), pos_integer(), pos_integer(), pos_integer(), boolean()) :: :ok | {:error, term()}
Run the Double Pole Balancing benchmark with damping forces.
This runs the simpler variant of DPB where velocities are provided to the neural network. This variant is helpful for verifying that the system works as expected before moving to more difficult versions.
Parameters
experiment_id
- Identifier for this experimentpopulation_size
- Number of individuals per generationgenerations
- Maximum number of generations to evolvemax_steps
- Maximum simulation steps in fitness evaluation (default: 1000)visualize
- Whether to visualize best agent after evolution (default: false)
Returns
:ok
- Experiment started successfully{:error, reason}
- If there was an error starting the experiment
@spec run_without_damping( atom(), pos_integer(), pos_integer(), pos_integer(), boolean() ) :: :ok | {:error, term()}
Run the Double Pole Balancing benchmark without damping forces.
This runs the harder variant of DPB where velocities are not provided to the neural network. The agent must approximate the velocities through the use of recurrent connections.
Parameters
experiment_id
- Identifier for this experimentpopulation_size
- Number of individuals per generationgenerations
- Maximum number of generations to evolvemax_steps
- Maximum simulation steps in fitness evaluation (default: 1000)visualize
- Whether to visualize best agent after evolution (default: false)
Returns
:ok
- Experiment started successfully{:error, reason}
- If there was an error starting the experiment
Test the best solution from an experiment.
This function loads the best genotype from a completed experiment and tests it by running a simulation with the neural network controller.
Parameters
experiment_id
- The ID of the experiment to testmax_steps
- Maximum steps to run the simulation (default: 100000)visualize
- Whether to visualize the run (default: false)
Returns
- Map of test results if successful
{:error, reason}
- If there was an error during testing
Returns results of the test run.