DEAP Documentation

DEAP Documentation

Release 0.9.0 DEAP Project

March 01, 2013

CONTENTS

1 Tutorial

1

1.1 Where to Start? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Creating Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Next Step Toward Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.4 Genetic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

1.5 Speed up the evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.6 Using Multiple Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

1.7 Benchmarking Against the Best (BBOB) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2 Examples

25

2.1 Genetic Algorithm (GA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

2.2 Genetic Programming (GP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

2.3 Evolution Strategy (ES) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

2.4 Particle Swarm Optimization (PSO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

2.5 Estimation of Distribution Algorithms (EDA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

2.6 Distributed Task Manager (DTM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

3 API

57

3.1 Core Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

3.2 Evolutionary Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

3.3 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

3.4 Covariance Matrix Adaptation Evolution Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

3.5 Genetic Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

3.6 Distributed Task Manager Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

3.7 Benchmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

4 What's New?

103

4.1 Release 0.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

4.2 Release 0.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

4.3 Release 0.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

4.4 Release 0.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

4.5 Release 0.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

5 Reporting a Bug

107

6 Contributing

109

6.1 Reporting a bug . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

6.2 Retrieving the latest code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

6.3 Contributing code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

6.4 Coding guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

i

Bibliography

111

Python Module Index

113

ii

CHAPTER

ONE

TUTORIAL

Although this tutorial doesn't make reference directly to the complete API of the framework, we think it is the place to start to understand the principles of DEAP. The core of the architecture is based on the creator and the Toolbox. Their usage to create types is shown in the first part of this tutorial. Then, a next step is taken in the direction of building generic algorithms by showing how to use the different tools present in the framework. Finally, we conclude on how those algorithms can be made parallel with minimal changes to the overall code (generally, adding a single line of code will do the job).

1.1 Where to Start?

If your are used to an other evolutionary algorithm framework, you'll notice we do things differently with DEAP. Instead of limiting you with predefined types, we provide ways of creating the appropriate ones. Instead of providing closed initializers, we enable you to customize them as you wish. Instead of suggesting unfit operators, we explicitly ask you to choose them wisely. Instead of implementing many sealed algorithms, we allow you to write the one that fit all your needs. This tutorial will present a quick overview of what DEAP is all about along with what every DEAP program is made of.

1.1.1 Types

The first thing to do is to think of the appropriate type for your problem. Then, instead of looking in the list of available types, DEAP enables you to build your own. This is done with the creator module. Creating an appropriate type might seems overwhelming but the creator makes it very easy. In fact, this is usually done in a single line. For example, the following creates a FitnessMin class for a minimization problem and an Individual class that is derived from a list with a fitness attribute set to the just created fitness. from deap import base, creator creator.create("FitnessMin", base.Fitness, weights=(-1.0,)) creator.create("Individual", list, fitness=creator.FitnessMin) That's it. More on creating types can be found in the Creating Types tutorial.

1.1.2 Initialization

Once the types are created you need to fill them with sometimes random values, sometime guessed ones. Again, DEAP provides an easy mechanism to do just that. The Toolbox is a container for tools of all sorts including initializers that can do what is needed of them. The following takes on the last lines of code to create the initializers for individuals containing random floating point numbers and for a population that contains them.

1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download