Skip to main content

Evolutionary Computations in Python

Project description

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. Please see the full documentation for more information.

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ecspy, version 0.6
Filename, size File type Python version Upload date Hashes
Filename, size ecspy-0.6-py2.6.egg (75.4 kB) File type Egg Python version 2.6 Upload date Hashes View
Filename, size ecspy-0.6.win32.exe (232.7 kB) File type Windows Installer Python version 2.6 Upload date Hashes View
Filename, size ecspy-0.6.zip (107.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page