Skip to content

Nathaniel-Rodriguez/evostrat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A package with evolutionary strategy and genetic algorithms for Python3.4+.

Requires mpi4py to be installed. Suggest installing it prior so that it is configured properly with your installation of MPI (else it will be installed automatically when installing dependencies).

The code uses modified versions of the core algorithms for the evolutionary strategies from Evolution Strategies as a Scalable Alternative to Reinforcement Learning. While the core algorithms for the genetic algorithms are from Deep Neuroevolution: Genetic Algorithms Are a Competitive Alternative for Training Deep Neural Networks for Reinforcement Learning. The versions in evostrat.py and genalg.py were modified to improve performance and be easily distributed over MPI using mpi4py. These algorithms were tested out to around 6 million parameters and take-up virtually none of the wall-time, which is almost entirely loaded on the objective function.

An example evolutionary run may look like:

from evostrat import BoundedRandNumTableES

# <insert code for guess, bounds and objective>

es = BoundedRandNumTableES(xo=initial_guess,
                           step_size=1.0,
                           bounds=bounds,
                           objective=objective_function,
                           seed=1,
                           verbose=True,
                           rand_num_table_size=20000000)
es.run(num_iterations=150)
es.save("test_run.es")

Scripts should be run through MPI like so:

mpiexec -n 1000 python es_run.py

Runs are pickled and saved (except for the objective). They can be reloaded and ran further like so:

es = BoundedRandNumTableES.load("test_run.es")
es(num_iterations=50, objective=objective_function)
es.save("test_run.es")

When running outside of MPI, the output can be plotted and the best members can be printed:

es = BoundedRandNumTableES.load("test_run.es")
es.plot_cost_over_time("test", savefile=True, logy=False)
print(es.best)
print(es.centroid)

See additional documentation via help in python for parameters and usage of the various algorithms.

About

A Python 3 package for implementing distributed evolutionary strategies and genetic algorithms via MPI. Scales to millions of parameters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages