Darwin Neuroevolution Framework
Public Member Functions | List of all members
cart_pole::CartPole Class Reference

Domain: Cart-Pole. More...

#include <cart_pole.h>

Inheritance diagram for cart_pole::CartPole:
darwin::Domain core::NonCopyable

Public Member Functions

size_t inputs () const override
 Number of inputs to a Brain.
 
size_t outputs () const override
 Number of outputs from a Brain.
 
bool evaluatePopulation (darwin::Population *population) const override
 Assigns fitness values to every genotype. More...
 
- Public Member Functions inherited from darwin::Domain
virtual unique_ptr< core::PropertySetcalibrateGenotype ([[maybe_unused]] const Genotype *genotype) const
 Optional: additional fitness metrics (normally not used in the population evaluation, ie a test set)
 

Detailed Description

Domain: Cart-Pole.

The classic cart-pole (also known as "pole balancing" or "inverted pendulum") problem: Wikipedia

cart_pole_sandbox.png

The cart starts in the middle (x = 0) and the initial pole angle is a random value in the [-max_initial_angle, +max_initial_angle] range. An episode is successful if the pole remains between -max_angle and +max_angle for at least max_steps. The cart position must also be maintained between [-max_distance, +max_distance].

Inputs

The inputs are configurable by individually selecting at least one of:

Input Value
0 pole_angle
1 angular_velocity
2 cart_distance
3 cart_velocity

Outputs

The single output indicates the horizontal force to be applied to the cart. This can be discrete (fixed +/-discrete_force_magnitude depending on the sign of the output) or can be continuous (the output value maps directly to the force magnitude)

Output Value
0 force

Member Function Documentation

◆ evaluatePopulation()

bool cart_pole::CartPole::evaluatePopulation ( darwin::Population population) const
overridevirtual

Assigns fitness values to every genotype.

Having a good fitness function is a key part of evolutionary algorithms:

  • Perhaps obvious, the fitness value should accurately estimate the quality of a particular solution
  • A "smooth" distribution is preferable since it provides a gradient which can guide the incremental search in the solutions space. (ex. if most fitness values are 1.0 or 0.0 it's hard to know which genotypes are good candidates for reproduction)
Returns
true if the evolution goal was reached

Implements darwin::Domain.


The documentation for this class was generated from the following files: