ECsPy is a free and open source framework for creating evolutionary computations in Python. Additionally, ECsPy provides an easy-to-use canonical genetic algorithm (GA), evolution strategy (ES), and particle swarm optimizer (PSO) for users who don't need much customization.
Background
An extensive background on evolutionary computation, including references to the relevant academic literature, can be found in the Project Wiki. You can also find a great deal of information from the Wikipedia links on the right.
Package Structure
ECsPy consists of the following 6 modules:
* ec.py -- provides the basic framework for the Evolution Engine and specific ECs
* observers.py -- defines a few built-in (screen and file) observers
* replacers.py -- defines standard replacement schemes such as generational and steady-state replacement
* selectors.py -- defines standard selectors (e.g., tournament)
* terminators.py -- defines standard terminators (e.g., exceeding a maximum number of generations)
* variators.py -- defines standard variators (crossover and mutation schemes such as n-point crossover)
Example
The following example illustrates the basics of the ECsPy package. Additional examples can be found under the Examples wiki.
from random import Random
from time import time
from ecspy import ec
from ecspy import terminators
from ecspy import observers
def generate_binary(random, args):
try:
bits = args['num_bits']
except KeyError:
bits = 8
return [random.choice([0, 1]) for i in xrange(bits)]
def evaluate_binary(candidates, args):
fitness = []
try:
base = args['base']
except KeyError:
base = 2
for cand in candidates:
num = 0
exp = len(cand) - 1
for c in cand:
num += c * (base ** exp)
exp -= 1
fitness.append(num)
return fitness
rand = Random()
rand.seed(int(time()))
ga = ec.GA(rand)
ga.observer = observers.screen_observer
final_pop = ga.evolve(evaluator=evaluate_binary,
generator=generate_binary,
terminator=terminators.fun_eval_termination,
max_fun_evals=1000,
num_elites=1,
pop_size=100,
num_bits=10)
for ind in final_pop:
print(str(ind))
Product's homepage
Requirements:
· Python