|
Project Information
Featured
Downloads
Links
|
ECsPy Has Been Deprecated; Use inspyred InsteadAs of April 3, 2012, ECsPy has been deprecated. New users should instead use the inspyred library, available on PyPI or at http://inspyred.github.com. ECsPy will no longer be maintained. 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. The full documentation can be found at http://packages.python.org/ecspy/.
Requirements
LicenseThis package is distributed under the GNU General Public License version 3.0 (GPLv3). This license can be found online at The Open Source Initiative.
BackgroundAn 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 in the sidebar. Package StructureECsPy consists of the following modules:
ExampleThe following example illustrates the basics of the ECsPy package. In this example, candidate solutions are 10-bit binary strings whose decimal values should be maximized. import random
import time
import ecspy
def generate_binary(random, args):
bits = args.get('num_bits', 8)
return [random.choice([0, 1]) for i in range(bits)]
@ecspy.evaluators.evaluator
def evaluate_binary(candidate, args):
return int("".join([str(c) for c in candidate]), 2)
rand = random.Random()
rand.seed(int(time.time()))
ga = ecspy.ec.GA(rand)
ga.observer = ecspy.observers.screen_observer
ga.terminator = ecspy.terminators.evaluation_termination
final_pop = ga.evolve(evaluator=evaluate_binary,
generator=generate_binary,
max_evaluations=1000,
num_elites=1,
pop_size=100,
num_bits=10)
final_pop.sort(reverse=True)
for ind in final_pop:
print(str(ind))
|