[Python-modules-commits] [deap] 01/17: Import deap_1.0.2.post2.orig.tar.xz
Daniel Stender
danstender-guest at moszumanska.debian.org
Sun Mar 20 01:33:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
danstender-guest pushed a commit to branch master
in repository deap.
commit 72cb7e0658016b4a9c8d8a04f82635936819320e
Author: Daniel Stender <stender at debian.org>
Date: Sun Mar 20 01:41:28 2016 +0100
Import deap_1.0.2.post2.orig.tar.xz
---
PKG-INFO | 146 +++++++++++++++++++--
README.md | 133 +++++++++++++++++++
README.txt | 9 --
deap/__init__.py | 2 +-
deap/algorithms.py | 92 ++++++++-----
deap/benchmarks/__init__.py | 7 +-
deap/cma.py | 4 +-
deap/gp.py | 31 +++--
doc/_templates/indexsidebar.html | 2 +-
.../tutorials/part_2/2_3_5_seeding_a_population.py | 3 +-
doc/code/tutorials/part_3/logbook.py | 3 +-
doc/conf.py | 7 +-
doc/releases.rst | 12 ++
doc/tutorials/advanced/checkpoint.rst | 7 +-
doc/tutorials/basic/part3.rst | 12 +-
examples/ga/evoknn.py | 10 +-
examples/ga/knn.py | 10 +-
examples/ga/nsga2.py | 3 +-
examples/ga/test.py | 12 --
examples/ga/tsp.py | 4 +-
examples/gp/ant.py | 6 +-
examples/gp/spambase.py | 7 +-
setup.py | 12 +-
23 files changed, 415 insertions(+), 119 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 130a613..03353cb 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,20 +1,144 @@
Metadata-Version: 1.1
Name: deap
-Version: 1.0.1
+Version: 1.0.2
Summary: Distributed Evolutionary Algorithms in Python
-Home-page: http://deap.googlecode.com
+Home-page: https://www.github.com/deap
Author: deap Development Team
Author-email: deap-users at googlegroups.com
License: LGPL
-Description: DEAP stands for Distributed Evolutionary Algorithm in Python, it is dedicated to people who
- wish to learn how to use evolutionary algorithms and to those who wish to
- rediscover evolutionary algorithms. DEAP is the proof that evolutionary
- algorithms do **not** need to be neither complex or complicated.
-
- DEAP is a novel evolutionary computation framework for rapid prototyping and testing
- of ideas. It seeks to make algorithms explicit and data structures transparent. It
- works in perfect harmony with parallelisation mechanism such as multiprocessing
- and SCOOP (http://scoop.googlecode.com/).
+Description: # DEAP
+
+ DEAP is a novel evolutionary computation framework for rapid prototyping and testing of
+ ideas. It seeks to make algorithms explicit and data structures transparent. It works in perfect harmony with parallelisation mechanism such as multiprocessing and [SCOOP](http://scoop.googlecode.com).
+
+ DEAP includes the following features:
+
+ * Genetic algorithm using any imaginable representation
+ * List, Array, Set, Dictionary, Tree, Numpy Array, etc.
+ * Genetic programing using prefix trees
+ * Loosely typed, Strongly typed
+ * Automatically defined functions
+ * Evolution strategies (including CMA-ES)
+ * Multi-objective optimisation (NSGA-II, SPEA-II)
+ * Co-evolution (cooperative and competitive) of multiple populations
+ * Parallelization of the evaluations (and more)
+ * Hall of Fame of the best individuals that lived in the population
+ * Checkpoints that take snapshots of a system regularly
+ * Benchmarks module containing most common test functions
+ * Genealogy of an evolution (that is compatible with [NetworkX](http://networkx.lanl.gov))
+ * Examples of alternative algorithms : Particle Swarm Optimization, Differential Evolution, Estimation of Distribution Algorithm
+
+ ## Downloads
+
+ Following acceptation of [PEP 438](http://www.python.org/dev/peps/pep-0438/) by the Python community, we have moved DEAP's source releases on [PyPI](https://pypi.python.org).
+
+ You can find the most recent releases at: https://pypi.python.org/pypi/deap/.
+
+ ## Documentation
+ See the [DEAP User's Guide](http://deap.readthedocs.org/en/1.0.x/) for DEAP documentation.
+
+ In order to get the tip documentation, change directory to the `doc` subfolder and type in `make html`, the documentation will be under `_build/html`. You will need [Sphinx](http://sphinx.pocoo.org) to build the documentation.
+
+ ### Notebooks
+ Also checkout our new [notebook examples](https://github.com/DEAP/notebook). Using [IPython's](http://ipython.org/) notebook feature you'll be able to navigate and execute each block of code individually and fell what every line is doing. Either, look at the notebooks online using the notebook viewer links at the botom of the page or download the notebooks, navigate to the you download directory and run
+
+ ```bash
+ ipython notebook --pylab inline
+ ```
+
+ ## Installation
+ We encourage you to use easy_install or pip to install DEAP on your system. Other installation procedure like apt-get, yum, etc. usually provide an outdated version.
+
+ ```bash
+ pip install deap
+ ```
+
+ If you wish to build from sources, download or clone the repository and type
+
+ ```bash
+ python setup.py install
+ ```
+
+ ## Requirements
+ The most basic features of DEAP requires Python2.6. In order to combine the toolbox and the multiprocessing module Python2.7 is needed for its support to pickle partial functions. CMA-ES requires Numpy, and we recommend matplotlib for visualization of results as it is fully compatible with DEAP's API.
+
+ Since version 0.8, DEAP is compatible out of the box with Python 3. The installation procedure automatically translates the source to Python 3 with 2to3.
+
+ ## Example
+
+ The following code gives a quick overview how simple it is to implement the Onemax problem optimization with genetic algorithm using DEAP. More examples are provided [here](http://deap.gel.ulaval.ca/doc/default/examples/index.html).
+
+ ```python
+ import array, random
+ from deap import creator, base, tools, algorithms
+
+ creator.create("FitnessMax", base.Fitness, weights=(1.0,))
+ creator.create("Individual", array.array, typecode='b', fitness=creator.FitnessMax)
+
+ toolbox = base.Toolbox()
+
+ toolbox.register("attr_bool", random.randint, 0, 1)
+ toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_bool, 100)
+ toolbox.register("population", tools.initRepeat, list, toolbox.individual)
+
+ def evalOneMax(individual):
+ return sum(individual),
+
+ toolbox.register("evaluate", evalOneMax)
+ toolbox.register("mate", tools.cxTwoPoint)
+ toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
+ toolbox.register("select", tools.selTournament, tournsize=3)
+
+ population = toolbox.population(n=300)
+
+ NGEN=40
+ for gen in range(NGEN):
+ offspring = algorithms.varAnd(population, toolbox, cxpb=0.5, mutpb=0.1)
+ fits = toolbox.map(toolbox.evaluate, offspring)
+ for fit, ind in zip(fits, offspring):
+ ind.fitness.values = fit
+ population = offspring
+ ```
+
+ ## How to cite DEAP
+ Authors of scientific papers including results generated using DEAP are encouraged to cite the following paper.
+
+ ```xml
+ @article{DEAP_JMLR2012,
+ author = " F\'elix-Antoine Fortin and Fran\c{c}ois-Michel {De Rainville} and Marc-Andr\'e Gardner and Marc Parizeau and Christian Gagn\'e ",
+ title = { {DEAP}: Evolutionary Algorithms Made Easy },
+ pages = { 2171--2175 },
+ volume = { 13 },
+ month = { jul },
+ year = { 2012 },
+ journal = { Journal of Machine Learning Research }
+ }
+ ```
+
+ ## Publications on DEAP
+
+ * François-Michel De Rainville, Félix-Antoine Fortin, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP -- Enabling Nimbler Evolutions", SIGEVOlution, vol. 6, no 2, pp. 17-26, February 2014. [Paper](http://goo.gl/tOrXTp)
+ * Félix-Antoine Fortin, François-Michel De Rainville, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP: Evolutionary Algorithms Made Easy", Journal of Machine Learning Research, vol. 13, pp. 2171-2175, jul 2012. [Paper](http://goo.gl/amJ3x)
+ * François-Michel De Rainville, Félix-Antoine Fortin, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP: A Python Framework for Evolutionary Algorithms", in !EvoSoft Workshop, Companion proc. of the Genetic and Evolutionary Computation Conference (GECCO 2012), July 07-11 2012. [Paper](http://goo.gl/pXXug)
+
+ ## Projects using DEAP
+
+ * Macret, M. and Pasquier, P. (2013). Automatic Tuning of the OP-1 Synthesizer Using a Multi-objective Genetic Algorithm. In Proceedings of the 10th Sound and Music Computing Conference (SMC). (pp 614-621).
+ * Fortin, F. A., Grenier, S., & Parizeau, M. (2013, July). Generalizing the improved run-time complexity algorithm for non-dominated sorting. In Proceeding of the fifteenth annual conference on Genetic and evolutionary computation conference (pp. 615-622). ACM.
+ * Fortin, F. A., & Parizeau, M. (2013, July). Revisiting the NSGA-II crowding-distance computation. In Proceeding of the fifteenth annual conference on Genetic and evolutionary computation conference (pp. 623-630). ACM.
+ * Marc-André Gardner, Christian Gagné, and Marc Parizeau. Estimation of Distribution Algorithm based on Hidden Markov Models for Combinatorial Optimization. in Comp. Proc. Genetic and Evolutionary Computation Conference (GECCO 2013), July 2013.
+ * J. T. Zhai, M. A. Bamakhrama, and T. Stefanov. "Exploiting Just-enough Parallelism when Mapping Streaming Applications in Hard Real-time Systems". Design Automation Conference (DAC 2013), 2013.
+ * V. Akbarzadeh, C. Gagné, M. Parizeau, M. Argany, M. A Mostafavi, "Probabilistic Sensing Model for Sensor Placement Optimization Based on Line-of-Sight Coverage", Accepted in IEEE Transactions on Instrumentation and Measurement, 2012.
+ * M. Reif, F. Shafait, and A. Dengel. "Dataset Generation for Meta-Learning". Proceedings of the German Conference on Artificial Intelligence (KI'12). 2012.
+ * M. T. Ribeiro, A. Lacerda, A. Veloso, and N. Ziviani. "Pareto-Efficient Hybridization for Multi-Objective Recommender Systems". Proceedings of the Conference on Recommanders Systems (!RecSys'12). 2012.
+ * M. Pérez-Ortiz, A. Arauzo-Azofra, C. Hervás-Martínez, L. García-Hernández and L. Salas-Morera. "A system learning user preferences for multiobjective optimization of facility layouts". Pr,oceedings on the Int. Conference on Soft Computing Models in Industrial and Environmental Applications (SOCO'12). 2012.
+ * Lévesque, J.C., Durand, A., Gagné, C., and Sabourin, R., Multi-Objective Evolutionary Optimization for Generating Ensembles of Classifiers in the ROC Space, Genetic and Evolutionary Computation Conference (GECCO 2012), 2012.
+ * Marc-André Gardner, Christian Gagné, and Marc Parizeau, "Bloat Control in Genetic Programming with Histogram-based Accept-Reject Method", in Proc. Genetic and Evolutionary Computation Conference (GECCO 2011), 2011.
+ * Vahab Akbarzadeh, Albert Ko, Christian Gagné, and Marc Parizeau, "Topography-Aware Sensor Deployment Optimization with CMA-ES", in Proc. of Parallel Problem Solving from Nature (PPSN 2010), Springer, 2010.
+ * DEAP is also used in ROS as an optimization package http://www.ros.org/wiki/deap.
+ * DEAP is an optional dependency for [PyXRD](https://github.com/mathijs-dumon/PyXRD), a Python implementation of the matrix algorithm developed for the X-ray diffraction analysis of disordered lamellar structures.
+
+ If you want your project listed here, send us a link and a brief description and we'll be glad to add it.
Keywords: evolutionary algorithms,genetic algorithms,genetic programming,cma-es,ga,gp,es,pso
Platform: any
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..838df4c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,133 @@
+# DEAP
+
+DEAP is a novel evolutionary computation framework for rapid prototyping and testing of
+ideas. It seeks to make algorithms explicit and data structures transparent. It works in perfect harmony with parallelisation mechanism such as multiprocessing and [SCOOP](http://scoop.googlecode.com).
+
+DEAP includes the following features:
+
+ * Genetic algorithm using any imaginable representation
+ * List, Array, Set, Dictionary, Tree, Numpy Array, etc.
+ * Genetic programing using prefix trees
+ * Loosely typed, Strongly typed
+ * Automatically defined functions
+ * Evolution strategies (including CMA-ES)
+ * Multi-objective optimisation (NSGA-II, SPEA-II)
+ * Co-evolution (cooperative and competitive) of multiple populations
+ * Parallelization of the evaluations (and more)
+ * Hall of Fame of the best individuals that lived in the population
+ * Checkpoints that take snapshots of a system regularly
+ * Benchmarks module containing most common test functions
+ * Genealogy of an evolution (that is compatible with [NetworkX](http://networkx.lanl.gov))
+ * Examples of alternative algorithms : Particle Swarm Optimization, Differential Evolution, Estimation of Distribution Algorithm
+
+## Downloads
+
+Following acceptation of [PEP 438](http://www.python.org/dev/peps/pep-0438/) by the Python community, we have moved DEAP's source releases on [PyPI](https://pypi.python.org).
+
+You can find the most recent releases at: https://pypi.python.org/pypi/deap/.
+
+## Documentation
+See the [DEAP User's Guide](http://deap.readthedocs.org/en/1.0.x/) for DEAP documentation.
+
+In order to get the tip documentation, change directory to the `doc` subfolder and type in `make html`, the documentation will be under `_build/html`. You will need [Sphinx](http://sphinx.pocoo.org) to build the documentation.
+
+### Notebooks
+Also checkout our new [notebook examples](https://github.com/DEAP/notebook). Using [IPython's](http://ipython.org/) notebook feature you'll be able to navigate and execute each block of code individually and fell what every line is doing. Either, look at the notebooks online using the notebook viewer links at the botom of the page or download the notebooks, navigate to the you download directory and run
+
+```bash
+ipython notebook --pylab inline
+```
+
+## Installation
+We encourage you to use easy_install or pip to install DEAP on your system. Other installation procedure like apt-get, yum, etc. usually provide an outdated version.
+
+```bash
+pip install deap
+```
+
+If you wish to build from sources, download or clone the repository and type
+
+```bash
+python setup.py install
+```
+
+## Requirements
+The most basic features of DEAP requires Python2.6. In order to combine the toolbox and the multiprocessing module Python2.7 is needed for its support to pickle partial functions. CMA-ES requires Numpy, and we recommend matplotlib for visualization of results as it is fully compatible with DEAP's API.
+
+Since version 0.8, DEAP is compatible out of the box with Python 3. The installation procedure automatically translates the source to Python 3 with 2to3.
+
+## Example
+
+The following code gives a quick overview how simple it is to implement the Onemax problem optimization with genetic algorithm using DEAP. More examples are provided [here](http://deap.gel.ulaval.ca/doc/default/examples/index.html).
+
+```python
+import array, random
+from deap import creator, base, tools, algorithms
+
+creator.create("FitnessMax", base.Fitness, weights=(1.0,))
+creator.create("Individual", array.array, typecode='b', fitness=creator.FitnessMax)
+
+toolbox = base.Toolbox()
+
+toolbox.register("attr_bool", random.randint, 0, 1)
+toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr_bool, 100)
+toolbox.register("population", tools.initRepeat, list, toolbox.individual)
+
+def evalOneMax(individual):
+ return sum(individual),
+
+toolbox.register("evaluate", evalOneMax)
+toolbox.register("mate", tools.cxTwoPoint)
+toolbox.register("mutate", tools.mutFlipBit, indpb=0.05)
+toolbox.register("select", tools.selTournament, tournsize=3)
+
+population = toolbox.population(n=300)
+
+NGEN=40
+for gen in range(NGEN):
+ offspring = algorithms.varAnd(population, toolbox, cxpb=0.5, mutpb=0.1)
+ fits = toolbox.map(toolbox.evaluate, offspring)
+ for fit, ind in zip(fits, offspring):
+ ind.fitness.values = fit
+ population = offspring
+```
+
+## How to cite DEAP
+Authors of scientific papers including results generated using DEAP are encouraged to cite the following paper.
+
+```xml
+ at article{DEAP_JMLR2012,
+ author = " F\'elix-Antoine Fortin and Fran\c{c}ois-Michel {De Rainville} and Marc-Andr\'e Gardner and Marc Parizeau and Christian Gagn\'e ",
+ title = { {DEAP}: Evolutionary Algorithms Made Easy },
+ pages = { 2171--2175 },
+ volume = { 13 },
+ month = { jul },
+ year = { 2012 },
+ journal = { Journal of Machine Learning Research }
+}
+```
+
+## Publications on DEAP
+
+ * François-Michel De Rainville, Félix-Antoine Fortin, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP -- Enabling Nimbler Evolutions", SIGEVOlution, vol. 6, no 2, pp. 17-26, February 2014. [Paper](http://goo.gl/tOrXTp)
+ * Félix-Antoine Fortin, François-Michel De Rainville, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP: Evolutionary Algorithms Made Easy", Journal of Machine Learning Research, vol. 13, pp. 2171-2175, jul 2012. [Paper](http://goo.gl/amJ3x)
+ * François-Michel De Rainville, Félix-Antoine Fortin, Marc-André Gardner, Marc Parizeau and Christian Gagné, "DEAP: A Python Framework for Evolutionary Algorithms", in !EvoSoft Workshop, Companion proc. of the Genetic and Evolutionary Computation Conference (GECCO 2012), July 07-11 2012. [Paper](http://goo.gl/pXXug)
+
+## Projects using DEAP
+
+ * Macret, M. and Pasquier, P. (2013). Automatic Tuning of the OP-1 Synthesizer Using a Multi-objective Genetic Algorithm. In Proceedings of the 10th Sound and Music Computing Conference (SMC). (pp 614-621).
+ * Fortin, F. A., Grenier, S., & Parizeau, M. (2013, July). Generalizing the improved run-time complexity algorithm for non-dominated sorting. In Proceeding of the fifteenth annual conference on Genetic and evolutionary computation conference (pp. 615-622). ACM.
+ * Fortin, F. A., & Parizeau, M. (2013, July). Revisiting the NSGA-II crowding-distance computation. In Proceeding of the fifteenth annual conference on Genetic and evolutionary computation conference (pp. 623-630). ACM.
+ * Marc-André Gardner, Christian Gagné, and Marc Parizeau. Estimation of Distribution Algorithm based on Hidden Markov Models for Combinatorial Optimization. in Comp. Proc. Genetic and Evolutionary Computation Conference (GECCO 2013), July 2013.
+ * J. T. Zhai, M. A. Bamakhrama, and T. Stefanov. "Exploiting Just-enough Parallelism when Mapping Streaming Applications in Hard Real-time Systems". Design Automation Conference (DAC 2013), 2013.
+ * V. Akbarzadeh, C. Gagné, M. Parizeau, M. Argany, M. A Mostafavi, "Probabilistic Sensing Model for Sensor Placement Optimization Based on Line-of-Sight Coverage", Accepted in IEEE Transactions on Instrumentation and Measurement, 2012.
+ * M. Reif, F. Shafait, and A. Dengel. "Dataset Generation for Meta-Learning". Proceedings of the German Conference on Artificial Intelligence (KI'12). 2012.
+ * M. T. Ribeiro, A. Lacerda, A. Veloso, and N. Ziviani. "Pareto-Efficient Hybridization for Multi-Objective Recommender Systems". Proceedings of the Conference on Recommanders Systems (!RecSys'12). 2012.
+ * M. Pérez-Ortiz, A. Arauzo-Azofra, C. Hervás-Martínez, L. García-Hernández and L. Salas-Morera. "A system learning user preferences for multiobjective optimization of facility layouts". Pr,oceedings on the Int. Conference on Soft Computing Models in Industrial and Environmental Applications (SOCO'12). 2012.
+ * Lévesque, J.C., Durand, A., Gagné, C., and Sabourin, R., Multi-Objective Evolutionary Optimization for Generating Ensembles of Classifiers in the ROC Space, Genetic and Evolutionary Computation Conference (GECCO 2012), 2012.
+ * Marc-André Gardner, Christian Gagné, and Marc Parizeau, "Bloat Control in Genetic Programming with Histogram-based Accept-Reject Method", in Proc. Genetic and Evolutionary Computation Conference (GECCO 2011), 2011.
+ * Vahab Akbarzadeh, Albert Ko, Christian Gagné, and Marc Parizeau, "Topography-Aware Sensor Deployment Optimization with CMA-ES", in Proc. of Parallel Problem Solving from Nature (PPSN 2010), Springer, 2010.
+ * DEAP is also used in ROS as an optimization package http://www.ros.org/wiki/deap.
+ * DEAP is an optional dependency for [PyXRD](https://github.com/mathijs-dumon/PyXRD), a Python implementation of the matrix algorithm developed for the X-ray diffraction analysis of disordered lamellar structures.
+
+If you want your project listed here, send us a link and a brief description and we'll be glad to add it.
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 0420bb1..0000000
--- a/README.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-DEAP stands for Distributed Evolutionary Algorithm in Python, it is dedicated to people who
-wish to learn how to use evolutionary algorithms and to those who wish to
-rediscover evolutionary algorithms. DEAP is the proof that evolutionary
-algorithms do **not** need to be neither complex or complicated.
-
-DEAP is a novel evolutionary computation framework for rapid prototyping and testing
-of ideas. It seeks to make algorithms explicit and data structures transparent. It
-works in perfect harmony with parallelisation mechanism such as multiprocessing
-and SCOOP (http://scoop.googlecode.com/).
diff --git a/deap/__init__.py b/deap/__init__.py
index 3c34f6b..7561f2b 100644
--- a/deap/__init__.py
+++ b/deap/__init__.py
@@ -14,4 +14,4 @@
# License along with DEAP. If not, see <http://www.gnu.org/licenses/>.
__author__ = "DEAP Team"
__version__ = "1.0"
-__revision__ = "1.0.1"
+__revision__ = "1.0.2"
diff --git a/deap/algorithms.py b/deap/algorithms.py
index 92ccc9d..4b38e18 100644
--- a/deap/algorithms.py
+++ b/deap/algorithms.py
@@ -46,7 +46,7 @@ def varAnd(population, toolbox, cxpb, mutpb):
The variation goes as follow. First, the parental population
:math:`P_\mathrm{p}` is duplicated using the :meth:`toolbox.clone` method
and the result is put into the offspring population :math:`P_\mathrm{o}`.
- A first loop over :math:`P_\mathrm{o}` is executed to mate consecutive
+ A first loop over :math:`P_\mathrm{o}` is executed to mate pairs of consecutive
individuals. According to the crossover probability *cxpb*, the
individuals :math:`\mathbf{x}_i` and :math:`\mathbf{x}_{i+1}` are mated
using the :meth:`toolbox.mate` method. The resulting children
@@ -95,30 +95,44 @@ def eaSimple(population, toolbox, cxpb, mutpb, ngen, stats=None,
:param halloffame: A :class:`~deap.tools.HallOfFame` object that will
contain the best individuals, optional.
:param verbose: Whether or not to log the statistics.
- :returns: The final population.
-
- It uses :math:`\lambda = \kappa = \mu` and goes as follow.
- It first initializes the population (:math:`P(0)`) by evaluating
- every individual presenting an invalid fitness. Then, it enters the
- evolution loop that begins by the selection of the :math:`P(g+1)`
- population. Then the crossover operator is applied on a proportion of
- :math:`P(g+1)` according to the *cxpb* probability, the resulting and the
- untouched individuals are placed in :math:`P'(g+1)`. Thereafter, a
- proportion of :math:`P'(g+1)`, determined by *mutpb*, is
- mutated and placed in :math:`P''(g+1)`, the untouched individuals are
- transferred :math:`P''(g+1)`. Finally, those new individuals are evaluated
- and the evolution loop continues until *ngen* generations are completed.
- Briefly, the operators are applied in the following order ::
+ :returns: The final population and a :class:`~deap.tools.Logbook`
+ with the statistics of the evolution.
+ The algorithm takes in a population and evolves it in place using the
+ :meth:`varAnd` method. It returns the optimized population and a
+ :class:`~deap.tools.Logbook` with the statistics of the evolution (if
+ any). The logbook will contain the generation number, the number of
+ evalutions for each generation and the statistics if a
+ :class:`~deap.tools.Statistics` if any. The *cxpb* and *mutpb* arguments
+ are passed to the :func:`varAnd` function. The pseudocode goes as follow
+ ::
+
evaluate(population)
- for i in range(ngen):
- offspring = select(population)
- offspring = mate(offspring)
- offspring = mutate(offspring)
+ for g in range(ngen):
+ population = select(population, len(population))
+ offspring = varAnd(population, toolbox, cxpb, mutpb)
evaluate(offspring)
population = offspring
+
+ As stated in the pseudocode above, the algorithm goes as follow. First, it
+ evaluates the individuals with an invalid fitness. Second, it enters the
+ generational loop where the selection procedure is applied to entirely
+ replace the parental population. The 1:1 replacement ratio of this
+ algorithm **requires** the selection procedure to be stochastic and to
+ select multiple times the same individual, for example,
+ :func:`~deap.tools.selTournament` and :func:`~deap.tools.selRoulette`.
+ Third, it applies the :func:`varAnd` function to produce the next
+ generation population. Fourth, it evaluates the new individuals and
+ compute the statistics on this population. Finally, when *ngen*
+ generations are done, the algorithm returns a tuple with the final
+ population and a :class:`~deap.tools.Logbook` of the evolution.
+
+ .. note::
+
+ Using a non-stochastic selection method will result in no selection as
+ the operator selects *n* individuals from a pool of *n*.
- This function expects :meth:`toolbox.mate`, :meth:`toolbox.mutate`,
+ This function expects the :meth:`toolbox.mate`, :meth:`toolbox.mutate`,
:meth:`toolbox.select` and :meth:`toolbox.evaluate` aliases to be
registered in the toolbox.
@@ -243,22 +257,38 @@ def eaMuPlusLambda(population, toolbox, mu, lambda_, cxpb, mutpb, ngen,
:param halloffame: A :class:`~deap.tools.HallOfFame` object that will
contain the best individuals, optional.
:param verbose: Whether or not to log the statistics.
- :returns: The final population.
-
- First, the individuals having an invalid fitness are evaluated. Then, the
- evolutionary loop begins by producing *lambda_* offspring from the
- population, the offspring are generated by a crossover, a mutation or a
- reproduction proportionally to the probabilities *cxpb*, *mutpb* and 1 -
- (cxpb + mutpb). The offspring are then evaluated and the next generation
- population is selected from both the offspring **and** the population.
- Briefly, the operators are applied as following ::
+ :returns: The final population and a :class:`~deap.tools.Logbook`
+ with the statistics of the evolution.
+ The algorithm takes in a population and evolves it in place using the
+ :meth:`varOr` method. It returns the optimized population and a
+ :class:`~deap.tools.Logbook` with the statistics of the evolution (if
+ any). The logbook will contain the generation number, the number of
+ evalutions for each generation and the statistics if a
+ :class:`~deap.tools.Statistics` if any. The *cxpb* and *mutpb* arguments
+ are passed to the :func:`varAnd` function. The pseudocode goes as follow
+ ::
+
evaluate(population)
- for i in range(ngen):
+ for g in range(ngen):
offspring = varOr(population, toolbox, lambda_, cxpb, mutpb)
evaluate(offspring)
population = select(population + offspring, mu)
-
+
+ First, the individuals having an invalid fitness are evaluated. Second,
+ the evolutionary loop begins by producing *lambda_* offspring from the
+ population, the offspring are generated by the :func:`varOr` function. The
+ offspring are then evaluated and the next generation population is
+ selected from both the offspring **and** the population. Finally, when
+ *ngen* generations are done, the algorithm returns a tuple with the final
+ population and a :class:`~deap.tools.Logbook` of the evolution.
+
+ .. note::
+
+ Care must be taken when the lambda:mu ratio is 1 to 1 as a non-stochastic
+ selection will result in no selection at all as
+ the operator selects *lambda* individuals from a pool of *mu*.
+
This function expects :meth:`toolbox.mate`, :meth:`toolbox.mutate`,
:meth:`toolbox.select` and :meth:`toolbox.evaluate` aliases to be
registered in the toolbox. This algorithm uses the :func:`varOr`
diff --git a/deap/benchmarks/__init__.py b/deap/benchmarks/__init__.py
index 6759148..dd7bdab 100644
--- a/deap/benchmarks/__init__.py
+++ b/deap/benchmarks/__init__.py
@@ -518,7 +518,8 @@ def dtlz2(individual, obj):
xm = individual[obj-1:]
g = sum((xi-0.5)**2 for xi in xm)
f = [(1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc), 1.0)]
- f.extend((1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc[:m-1]), 1) * sin(0.5*xc[m]*pi) for m in reversed(xrange(obj-1)))
+ f.extend((1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc[:m]), 1) * sin(0.5*xc[m]*pi) for m in range(obj-2, -1, -1))
+
return f
def dtlz3(individual, obj):
@@ -545,7 +546,7 @@ def dtlz3(individual, obj):
xm = individual[obj-1:]
g = 100 * (len(xm) + sum((xi-0.5)**2 - cos(20*pi*(xi-0.5)) for xi in xm))
f = [(1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc), 1.0)]
- f.extend((1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc[:m-1]), 1) * sin(0.5*xc[m]*pi) for m in reversed(xrange(obj-1)))
+ f.extend((1.0+g) * reduce(mul, (cos(0.5*xi*pi) for xi in xc[:m]), 1) * sin(0.5*xc[m]*pi) for m in range(obj-2, -1, -1))
return f
def dtlz4(individual, obj, alpha):
@@ -574,7 +575,7 @@ def dtlz4(individual, obj, alpha):
xm = individual[obj-1:]
g = sum((xi-0.5)**2 for xi in xm)
f = [(1.0+g) * reduce(mul, (cos(0.5*xi**alpha*pi) for xi in xc), 1.0)]
- f.extend((1.0+g) * reduce(mul, (cos(0.5*xi**alpha*pi) for xi in xc[:m-1]), 1) * sin(0.5*xc[m]**alpha*pi) for m in reversed(xrange(obj-1)))
+ f.extend((1.0+g) * reduce(mul, (cos(0.5*xi**alpha*pi) for xi in xc[:m]), 1) * sin(0.5*xc[m]**alpha*pi) for m in range(obj-2, -1, -1))
return f
def fonseca(individual):
diff --git a/deap/cma.py b/deap/cma.py
index e4bc83b..87f75aa 100644
--- a/deap/cma.py
+++ b/deap/cma.py
@@ -271,10 +271,10 @@ class StrategyOnePlusLambda(object):
self.parent = copy.deepcopy(population[0])
if self.psucc < self.pthresh:
self.pc = (1 - self.cc)*self.pc + sqrt(self.cc * (2 - self.cc)) * x_step
- self.C = (1-self.ccov)*self.C + self.ccov * numpy.dot(self.pc, self.pc.T)
+ self.C = (1-self.ccov)*self.C + self.ccov * numpy.outer(self.pc, self.pc)
else:
self.pc = (1 - self.cc)*self.pc
- self.C = (1-self.ccov)*self.C + self.ccov * (numpy.dot(self.pc, self.pc.T) + self.cc*(2-self.cc)*self.C)
+ self.C = (1-self.ccov)*self.C + self.ccov * (numpy.outer(self.pc, self.pc) + self.cc*(2-self.cc)*self.C)
self.sigma = self.sigma * exp(1.0/self.d * (self.psucc - self.ptarg)/(1.0-self.ptarg))
diff --git a/deap/gp.py b/deap/gp.py
index a163d34..36ddc53 100644
--- a/deap/gp.py
+++ b/deap/gp.py
@@ -120,7 +120,7 @@ class PrimitiveTree(list):
if token in pset.mapping:
primitive = pset.mapping[token]
- if len(ret_types) != 0 and primitive.ret != type_:
+ if type_ is not None and not issubclass(primitive.ret, type_):
raise TypeError("Primitive {} return type {} does not "
"match the expected one: {}."
.format(primitive, primitive.ret, type_))
@@ -137,7 +137,7 @@ class PrimitiveTree(list):
if type_ is None:
type_ = type(token)
- if type(token) != type_:
+ if not issubclass(type(token), type_):
raise TypeError("Terminal {} type {} does not "
"match the expected one: {}."
.format(token, type(token), type_))
@@ -224,12 +224,6 @@ class Ephemeral(Terminal):
def __init__(self):
Terminal.__init__(self, self.func(), symbolic=False, ret=self.ret)
- def regen(self):
- """Regenerate the ephemeral value.
- """
- self.value = self.func()
- self.name = str(self.value)
-
@staticmethod
def func():
"""Return a random value used to define the ephemeral state.
@@ -277,10 +271,13 @@ class PrimitiveSetTyped(object):
def _add(self, prim):
def addType(dict_, ret_type):
if not ret_type in dict_:
- dict_[ret_type]
+ new_list = []
for type_, list_ in dict_.items():
if issubclass(type_, ret_type):
- dict_[ret_type].extend(list_)
+ for item in list_:
+ if not item in new_list:
+ new_list.append(item)
+ dict_[ret_type] = new_list
addType(self.primitives, prim.ret)
addType(self.terminals, prim.ret)
@@ -487,7 +484,7 @@ def compileADF(expr, psets):
######################################
# GP Program generation functions #
######################################
-def genFull(pset, min_, max_, type_=__type__):
+def genFull(pset, min_, max_, type_=None):
"""Generate an expression where each leaf has a the same depth
between *min* and *max*.
@@ -503,7 +500,7 @@ def genFull(pset, min_, max_, type_=__type__):
return depth == height
return generate(pset, min_, max_, condition, type_)
-def genGrow(pset, min_, max_, type_=__type__):
+def genGrow(pset, min_, max_, type_=None):
"""Generate an expression where each leaf might have a different depth
between *min* and *max*.
@@ -522,7 +519,7 @@ def genGrow(pset, min_, max_, type_=__type__):
(depth >= min_ and random.random() < pset.terminalRatio)
return generate(pset, min_, max_, condition, type_)
-def genHalfAndHalf(pset, min_, max_, type_=__type__):
+def genHalfAndHalf(pset, min_, max_, type_=None):
"""Generate an expression with a PrimitiveSet *pset*.
Half the time, the expression is generated with :func:`~deap.gp.genGrow`,
the other half, the expression is generated with :func:`~deap.gp.genFull`.
@@ -537,7 +534,7 @@ def genHalfAndHalf(pset, min_, max_, type_=__type__):
method = random.choice((genGrow, genFull))
return method(pset, min_, max_, type_)
-def genRamped(pset, min_, max_, type_=__type__):
+def genRamped(pset, min_, max_, type_=None):
"""
.. deprecated:: 1.0
The function has been renamed. Use :func:`~deap.gp.genHalfAndHalf` instead.
@@ -546,7 +543,7 @@ def genRamped(pset, min_, max_, type_=__type__):
FutureWarning)
return genHalfAndHalf(pset, min_, max_, type_)
-def generate(pset, min_, max_, condition, type_=__type__):
+def generate(pset, min_, max_, condition, type_=None):
"""Generate a Tree as a list of list. The tree is build
from the root to the leaves, and it stop growing when the
condition is fulfilled.
@@ -562,6 +559,8 @@ def generate(pset, min_, max_, condition, type_=__type__):
:returns: A grown tree with leaves at possibly different depths
dependending on the condition function.
"""
+ if type_ is None:
+ type_ = pset.ret
expr = []
height = random.randint(min_, max_)
stack = [(0, type_)]
@@ -759,7 +758,7 @@ def mutEphemeral(individual, mode):
ephemerals_idx = (random.choice(ephemerals_idx),)
for i in ephemerals_idx:
- individual[i].regen()
+ individual[i] = type(individual[i])()
return individual,
diff --git a/doc/_templates/indexsidebar.html b/doc/_templates/indexsidebar.html
index ad1bc81..3069144 100644
--- a/doc/_templates/indexsidebar.html
+++ b/doc/_templates/indexsidebar.html
@@ -1,7 +1,7 @@
<h3>Docs for other versions</h3>
<ul>
- <li><a href="http://deap.gel.ulaval.ca/doc/dev/index.html">DEAP 1.1 (Devel)</a></li>
+ <li><a href="http://deap.readthedocs.org/en/master/">DEAP 1.1 (Devel)</a></li>
<li><a href="http://deap.gel.ulaval.ca/doc/0.9/index.html">DEAP 0.9</a></li>
</ul>
diff --git a/doc/code/tutorials/part_2/2_3_5_seeding_a_population.py b/doc/code/tutorials/part_2/2_3_5_seeding_a_population.py
index ecfc9ca..468c657 100644
--- a/doc/code/tutorials/part_2/2_3_5_seeding_a_population.py
+++ b/doc/code/tutorials/part_2/2_3_5_seeding_a_population.py
@@ -11,7 +11,8 @@ def initIndividual(icls, content):
return icls(content)
def initPopulation(pcls, ind_init, filename):
- contents = json.load(open(filename, "r"))
+ with open(filename, "r") as pop_file:
+ contents = json.load(pop_file)
return pcls(ind_init(c) for c in contents)
toolbox = base.Toolbox()
diff --git a/doc/code/tutorials/part_3/logbook.py b/doc/code/tutorials/part_3/logbook.py
index b7f4f3a..6182d47 100644
--- a/doc/code/tutorials/part_3/logbook.py
+++ b/doc/code/tutorials/part_3/logbook.py
@@ -11,7 +11,8 @@ print(logbook)
gen, avg = logbook.select("gen", "avg")
-pickle.dump(logbook, open("logbook.pkl", "w"))
+with open("logbook.pkl", "w") as lb_file:
+ pickle.dump(logbook, lb_file)
# Cleaning the pickle file ...
import os
diff --git a/doc/conf.py b/doc/conf.py
index a16130e..c65136e 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -126,13 +126,10 @@ plot_include_source = False
plot_html_show_formats = True
# -- Options for extlinks extension ----------------------------------------------
-
import subprocess
-branch = str(subprocess.check_output(["hg", "branch"])[:-1])
-extlinks = {'example': ('https://code.google.com/p/deap/source/browse/examples/%s.py?name='+branch,
- 'examples/')}
-
+tree = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip()
+extlinks = {'example': ('https://github.com/DEAP/deap/blob/{tree}/examples/%s.py'.format(tree=tree), "examples/")}
# -- Options for HTML output ---------------------------------------------------
# Add any paths that contain custom themes here, relative to this directory.
diff --git a/doc/releases.rst b/doc/releases.rst
index d340ed0..35177de 100644
--- a/doc/releases.rst
+++ b/doc/releases.rst
@@ -67,6 +67,8 @@ Documentation enhancements
Bug fixes
+++++++++
+**Release 1.0.0**
+
- creator: Issue 23: error in creator when using unicode source.
- creator: create does not handle proper slicing of created classes inheriting
from ``numpy.ndarray`` anymore. This was bug prone and extremely hard to maintain.
@@ -80,4 +82,14 @@ Bug fixes
- tools: add missing arguments to sortLogNondominated (`k`, `first_front_only`). rev: `f60a6520b666`, `4de7df29dd0f`.
- gp: issue #32: :meth:`~deap.gp.PrimitiveTree.from_string` used incorrect argument order with STGP. rev: `58c1a0711e1f`.
+**Release 1.0.2**:
+
+- benchmarks: fix computation of DTLZ2, DTLZ3 and DTLZ4.
+- cma 1+Lambda: fix the computation of the rank-one update.
+- gp: replace the generate functions default value for the argument `type_` from `object` to `None`.
+ This removes the obligation to define the type_ argument for the individual generation function when doing STGP.
+- gp: fix a bug with OOGP when calling addPrimitive and addTerminal in arbitrary order.
+- gp: fix Ephemeral regeneration with mutEphemeral. rev: `ae46705`.
+- gp: fix issue #35 - from_string had issues with OOGP.
+- Fix issue #26: in four examples, files are opened but never closed.
diff --git a/doc/tutorials/advanced/checkpoint.rst b/doc/tutorials/advanced/checkpoint.rst
index 5bba1c4..19be400 100644
--- a/doc/tutorials/advanced/checkpoint.rst
+++ b/doc/tutorials/advanced/checkpoint.rst
@@ -23,7 +23,8 @@ argument containing the path of the checkpoint file to restore. ::
def main(checkpoint=None):
if checkpoint:
# A file name has been given, then load the data from the file
- cp = pickle.load(open(checkpoint, "r"))
+ with open(checkpoint, "r") as cp_file:
+ cp = pickle.load(cp_file)
population = cp["population"]
start_gen = cp["generation"]
halloffame = cp["halloffame"]
@@ -59,7 +60,9 @@ argument containing the path of the checkpoint file to restore. ::
# Fill the dictionary using the dict(key=value[, ...]) constructor
cp = dict(population=population, generation=gen, halloffame=halloffame,
logbook=logbook, rndstate=random.getstate())
- pickle.dump(cp, open("checkpoint_name.pkl", "w"))
+
+ with open("checkpoint_name.pkl", "wb") as cp_file:
+ pickle.dump(cp, cp_file)
Now, the whole data will be written in a pickled dictionary every *FREQ*
generations. Loading the checkpoint is done if the main function is given a path
diff --git a/doc/tutorials/basic/part3.rst b/doc/tutorials/basic/part3.rst
index 4eef133..5de0254 100644
--- a/doc/tutorials/basic/part3.rst
+++ b/doc/tutorials/basic/part3.rst
@@ -93,7 +93,7 @@ The :meth:`~deap.tools.Logbook.select` method provides a way to retrieve all the
A logbook is a picklable object (as long as all inserted objects are picklable) providing a very nice way to save the statistics of an evolution on disk.
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 1,14
+ :lines: 1,15
.. note::
@@ -104,7 +104,7 @@ Printing to Screen
A logbook can be printed to screen or file. Its :meth:`~deap.tools.Logbook.__str__` method returns a header of each key inserted in the first record and the complete logbook for each of these keys. The row are in chronological order of insertion while the columns are in an undefined order. The easiest way to specify an order is to set the :attr:`~deap.tools.Logbook.header` attribute to a list of strings specifying the order of the columns.
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 20
+ :lines: 21
The result is::
@@ -129,12 +129,12 @@ Dealing with Multi-statistics
The logbook is able to cope with the dictionary of dictionaries return by the :class:`~deap.tools.MultiStatistics` object. In fact, it will log the data in :attr:`~deap.tools.Logbook.chapters` for each sub dictionary contained in the record. Thus, a *multi* record can be used exactly as a record.
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 29-30
+ :lines: 30-31
One difference is the column ordering, where we can specify an order for the chapters and their content as follows:
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 32-34
+ :lines: 33-35
The resulting output is::
@@ -147,7 +147,7 @@ The resulting output is::
Retrieving the data is also done through the chapters.
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 38-40
+ :lines: 39-41
The generations, minimum fitness and average size are obtained, chronologically ordered. If some data is not available, a :data:`None` appears in the vector.
@@ -156,7 +156,7 @@ Some Plotting Sugar
One of the most common operation when an optimization is finished is to plot the data during the evolution. The :class:`~deap.tools.Logbook` allows to do this very efficiently. Using the select method, one can retrieve the desired data and plot it using matplotlib.
.. literalinclude:: /code/tutorials/part_3/logbook.py
- :lines: 38-41,42-61
+ :lines: 39-62
When added to the symbolic regression example, it gives the following graphic:
diff --git a/examples/ga/evoknn.py b/examples/ga/evoknn.py
index 4a4fdf3..8735369 100755
--- a/examples/ga/evoknn.py
+++ b/examples/ga/evoknn.py
@@ -32,10 +32,12 @@ N_TRAIN=175
K=1
# Read data from file
-data = csv.reader(open(FILE, "r"))
-trainset = list()
-trainlabels = list()
-rows = [row for row in data]
+with open(FILE, "r") as data_csv:
+ data = csv.reader(data_csv)
+ trainset = list()
+ trainlabels = list()
+ rows = [row for row in data]
+
random.shuffle(rows)
for row in rows:
trainlabels.append(float(row[0]))
diff --git a/examples/ga/knn.py b/examples/ga/knn.py
index 1bfed3e..f97a32a 100644
--- a/examples/ga/knn.py
+++ b/examples/ga/knn.py
@@ -73,10 +73,12 @@ FILE="heart_scale.csv"
N_TRAIN=175
K=1
-data_csv = csv.reader(open(FILE, "r"))
-trainset = list()
-trainlabels = list()
-rows = [row for row in data_csv]
+with open(FILE, "r") as data_csv:
+ data = csv.reader(data_csv)
+ trainset = list()
+ trainlabels = list()
+ rows = [row for row in data]
+
random.shuffle(rows)
for row in rows:
trainlabels.append(float(row[0]))
diff --git a/examples/ga/nsga2.py b/examples/ga/nsga2.py
index c7d0432..a0551ca 100644
--- a/examples/ga/nsga2.py
+++ b/examples/ga/nsga2.py
@@ -119,7 +119,8 @@ def main(seed=None):
return pop, logbook
if __name__ == "__main__":
- optimal_front = json.load(open("pareto_front/zdt1_front.json"))
+ with open("pareto_front/zdt1_front.json") as optimal_front_data:
+ optimal_front = json.load(optimal_front_data)
# Use 500 of the 1000 points in the json file
optimal_front = sorted(optimal_front[i] for i in range(0, len(optimal_front), 2))
diff --git a/examples/ga/test.py b/examples/ga/test.py
deleted file mode 100644
index bae65b8..0000000
--- a/examples/ga/test.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from nsga2 import*
-from deap import tools
-
-ind1 = toolbox.individual()
-ind2 = toolbox.individual()
-
-ind1.fitness.values = toolbox.evaluate(ind1)
-ind2.fitness.values = toolbox.evaluate(ind2)
-
-import pdb
-pdb.set_trace()
-print(tools.sortLogNondominated([ind1, ind2], k=2))
diff --git a/examples/ga/tsp.py b/examples/ga/tsp.py
index 9e7b9ff..5950c1f 100644
--- a/examples/ga/tsp.py
+++ b/examples/ga/tsp.py
@@ -26,7 +26,9 @@ from deap import tools
# gr*.json contains the distance map in list of list style in JSON format
# Optimal solutions are : gr17 = 2085, gr24 = 1272, gr120 = 6942
-tsp = json.load(open("tsp/gr17.json", "r"))
+with open("tsp/gr17.json", "r") as tsp_data:
+ tsp = json.load(tsp_data)
+
distance_map = tsp["DistanceMatrix"]
IND_SIZE = tsp["TourSize"]
diff --git a/examples/gp/ant.py b/examples/gp/ant.py
index 0aad686..ac78b08 100644
--- a/examples/gp/ant.py
+++ b/examples/gp/ant.py
@@ -182,9 +182,9 @@ toolbox.register("mutate", gp.mutUniform, expr=toolbox.expr_mut, pset=pset)
def main():
random.seed(69)
-
- trail_file = open("ant/santafe_trail.txt")
- ant.parse_matrix(trail_file)
+
+ with open("ant/santafe_trail.txt") as trail_file:
+ ant.parse_matrix(trail_file)
pop = toolbox.population(n=300)
hof = tools.HallOfFame(1)
diff --git a/examples/gp/spambase.py b/examples/gp/spambase.py
index bc7a643..9a36ba8 100644
--- a/examples/gp/spambase.py
+++ b/examples/gp/spambase.py
@@ -30,8 +30,9 @@ from deap import gp
# The dataset is from http://archive.ics.uci.edu/ml/datasets/Spambase
# This example is a copy of the OpenBEAGLE example :
# http://beagle.gel.ulaval.ca/refmanual/beagle/html/d2/dbe/group__Spambase.html
-spamReader = csv.reader(open("spambase.csv"))
-spam = list(list(float(elem) for elem in row) for row in spamReader)
+with open("spambase.csv") as spambase:
+ spamReader = csv.reader(spambase)
+ spam = list(list(float(elem) for elem in row) for row in spamReader)
# defined a new primitive set for strongly typed GP
pset = gp.PrimitiveSetTyped("MAIN", itertools.repeat(float, 57), bool, "IN")
@@ -71,7 +72,7 @@ creator.create("FitnessMax", base.Fitness, weights=(1.0,))
creator.create("Individual", gp.PrimitiveTree, fitness=creator.FitnessMax)
toolbox = base.Toolbox()
-toolbox.register("expr", gp.genHalfAndHalf, pset=pset, type_=pset.ret, min_=1, max_=2)
+toolbox.register("expr", gp.genHalfAndHalf, pset=pset, min_=1, max_=2)
toolbox.register("individual", tools.initIterate, creator.Individual, toolbox.expr)
toolbox.register("population", tools.initRepeat, list, toolbox.individual)
toolbox.register("compile", gp.compile, pset=pset)
diff --git a/setup.py b/setup.py
index c79eb55..0b5b911 100644
--- a/setup.py
+++ b/setup.py
@@ -6,15 +6,23 @@ try:
except ImportError:
from distutils.command.build_py import build_py
+try:
+ from pypandoc import convert
+except ImportError:
+ print("warning: pypandoc module not found, could not convert Markdown to RST")
+ read_md = lambda f: open(f, 'r').read()
+else:
+ read_md = lambda f: convert(f, 'rst')
+
import deap
setup(name='deap',
version=deap.__revision__,
description='Distributed Evolutionary Algorithms in Python',
- long_description=open('README.txt').read(),
+ long_description=read_md('README.md'),
author='deap Development Team',
author_email='deap-users at googlegroups.com',
- url='http://deap.googlecode.com',
+ url='https://www.github.com/deap',
packages=['deap', 'deap.tools', 'deap.benchmarks', 'deap.tests'],
platforms=['any'],
keywords=['evolutionary algorithms','genetic algorithms','genetic programming','cma-es','ga','gp','es','pso'],
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/deap.git
More information about the Python-modules-commits
mailing list