skip to navigation
skip to content

ecspy 1.0

Evolutionary Computations in Python

Downloads ↓ | Package Documentation

Latest Version: 1.1

ECsPy (Evolutionary Computations in Python) is a free, open source framework for creating evolutionary computations in Python. Additionally, ECsPy provides an easy-to-use canonical genetic algorithm (GA), evolution strategy (ES), estimation of distribution algorithm (EDA), differential evolution algorithm (DEA), and particle swarm optimizer (PSO) for users who don't need much customization. For more information, please see the documentation listed below or available for download as a PDF file.

For Windows users, a Windows installer is available.

Usage Example

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):
    bits = args.get('num_bits', 8)
    return [random.choice([0, 1]) for i in xrange(bits)]

def evaluate_binary(candidates, args):
    fitness = []
    base = args.get('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
ga.terminator = terminators.evaluation_termination
final_population = ga.evolve(evaluator=evaluate_binary,
                             generator=generate_binary,
                             max_evaluations=1000,
                             num_elites=1,
                             pop_size=100,
                             num_bits=10)
for individual in final_population:
    print(individual)
 
File Type Py Version Uploaded on Size # downloads
ecspy-1.0-py2.6.egg (md5) Python Egg 2.6 2011-12-06 122KB 294
ecspy-1.0-py2.7.egg (md5) Python Egg 2.7 2011-12-06 121KB 303
ecspy-1.0.tar.gz (md5) Source 2011-12-06 166KB 313