compete the "evolution" and evolve the "competition"!
Generate benchmark functions to differ a pair of evolutionary algorithms based on genetic programming algorithm.
- Python 3.9 (tested, other version should also work)
- deap
- scipy
- matplotlib
- pygraphviz
Install Python and Graphviz, then install the library in this repo.
pip install git+https://github.com/Y1fanHE/evolutionary-competition.gitCreate a tuple for DE.
from evocomp.evo import de_rand_1_bin
de = (
de_rand_1_bin, # de
dict(n_eval = 2000, # parameters
n_pop = 20,
F = 0.5,
CR = 0.5),
"DE" # alias
)Create a tuple for PSO.
from evocomp.evo import particle_swarm_optimization
pso = (
particle_swarm_optimization, # pso
dict(n_eval = 2000, # parameters
n_pop = 20,
w1 = 0.5,
w2 = 0.5,
c = 0.1),
"PSO" # alias
)Create a Competition using wasserstein_distance.
from evocomp.comp import Competition
from evocomp.comp.metrics import wasserstein_distance
comp = Competition(
metric = wasserstein_distance, # distance metric
algorithm1 = de, # two eas
algorithm2 = pso,
lower_bound = -5, # bounds of search space
upper_bound = 5,
dimension = 2, # dimension of search space
repetition = 1, # repetition of ea runs
mode = "differ" # mode: differ/match
)Evolve the Competition by simple EA.
from evocomp.comp.gp import simple
comp.evolve( # gp parameters
method = simple,
population_size = 10,
max_generation = 6,
tournament_size = 7,
crossover_rate = 0.8,
mutation_rate = 0.1,
seed = 1000,
verbose = True
)Plot the results.
comp.plot_space(target="out.png") # contor plot
comp.plot_tree(target="out_tree.png") # tree plot
comp.save(target="out.sol") # text fileAlso see example.py for a multiprocessing example.
python -W ignore example.pyCheck the following functions generated by GP!
- random search
- simple
- map-elites
- random search
- differential evolution
- particle swarm optimization
- cuckoo search
- wasserstein distance
- write README file
- check high dimension cases
- add multiprocessing
- implement map-elite gp
- add more eas
- add new metrics