Visualization

Being able to visualize a running evolutionary algorithm is important. Here we describe special pipeline operators that use matplotlib to visualize the state of the population.

Prebuilt Algorithms

LEAP’s “prebuilt” algorithms (also sometimes referred to as “monolithic functions”) have optional support for visualizations.

leap_ec.simple.ea_solve has two optional arguments that control visualization: viz and viz_ylim. viz is a boolean that controls whether or not to display the visualization; if True a matplot lib window will appear and update during a run with the . viz_ylim is used to supply the initial bounds for the y-axis of the visualization. The plotting is carried out via an instance of leap_ec.probe.FitnessPlotProbe, and which is added as a last pipeline operator; this means that it will be plotting the created offspring with each iteration.

The other monolithic function, leap_ec.algorithm.generational_ea, offers more fine-tuned control over visualization. Since the user specifies the pipeline, a visualization pipeline operator can be added anywhere in the pipeline. Moreover, since the user is specifying the visualization operator, they’re free to tailor how the visualization is done. For example, the user can specify a custom title and the update frequency.

Tailored evolutionary algorithms

Of course many practitioners will want to build their own evolutionary algorithms and forgo the use of the aforementioned monolithic functions. For these users, LEAP offers a number of pipeline operators that can be used to visualize the state of the population merely by inserting an instance of one of these into the pipeline. A full list of such operators is in the next section.

Visualization Pipeline Operators

Examples

You can find examples on how to use these probes in the following:

  • examples/advanced/custom_stopping_condition.py

  • examples/advanced/neural_network_cartpole.py

  • examples/advanced/island_model.py

  • examples/advanced/cgp_images.py

  • examples/advanced/cgp.py

  • examples/advanced/real_rep_with_diversity_metrics.py

  • examples/advanced/multitask_island_model.py

  • examples/advanced/external_simulation.py

  • examples/advanced/pitt_rules_cartpole.py

  • examples/distributed/simple_sync_distributed.py

  • examples/simple/int_rep.py

  • examples/simple/one+one_es.py

  • examples/simple/onemax_style_problems.py

  • examples/simple/real_rep_genewise_mutation.py