From b7fc213b6d7d784aa92be8fbec83a8c827ac38e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Hees?= Date: Sat, 1 Nov 2014 00:50:21 +0100 Subject: [PATCH] minor changes --- doc/tutorials/basic/part2.rst | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/tutorials/basic/part2.rst b/doc/tutorials/basic/part2.rst index e3df12ae0..0336ec977 100644 --- a/doc/tutorials/basic/part2.rst +++ b/doc/tutorials/basic/part2.rst @@ -3,7 +3,7 @@ Operators and Algorithms ======================== -Before starting with complex algorithms, we will see some basis of DEAP. +Before starting with complex algorithms, we will see some basics of DEAP. First, we will start by creating simple individuals (as seen in the :ref:`creating-types` tutorial) and make them interact with each other using different operators. Afterwards, we will learn how to use the algorithms and @@ -12,7 +12,7 @@ other tools. A First Individual ------------------ -First import the required modules and register the different functions required to create individuals that are a list of floats with a minimizing two objectives fitness. +First import the required modules and register the different functions required to create individuals that are lists of floats with a minimizing two objectives fitness. .. literalinclude:: /code/tutorials/part_3/3_next_step.py :lines: 2-16 @@ -34,11 +34,11 @@ Evaluation The evaluation is the most personal part of an evolutionary algorithm, it is the only part of the library that you must write yourself. A typical -evaluation function takes one individual as argument and return its fitness as +evaluation function takes one individual as argument and returns its fitness as a :class:`tuple`. As shown in the in the :ref:`core` section, a fitness is a list of floating point values and has a property :attr:`~deap.base.Fitness.valid` to know if this individual shall be re-evaluated. The fitness is set by setting the :attr:`~deap.base.Fitness.values` to the -associated :class:`tuple`. For example, the following evaluates the previously created individual ``ind1`` and assign its fitness to the corresponding values. +associated :class:`tuple`. For example, the following evaluates the previously created individual ``ind1`` and assigns its fitness to the corresponding values. .. literalinclude:: /code/tutorials/part_3/3_next_step.py :lines: 24-32 @@ -49,13 +49,13 @@ Mutation -------- The next kind of operator that we will present is the mutation operator. There is a variety of mutation operators in the :mod:`deap.tools` module. -Each mutation has its own characteristics and may be applied to different type -of individual. Be careful to read the documentation of the selected operator +Each mutation has its own characteristics and may be applied to different types +of individuals. Be careful to read the documentation of the selected operator in order to avoid undesirable behaviour. The general rule for mutation operators is that they **only** mutate, this means that an independent copy must be made prior to mutating the individual -if the original individual has to be kept or is a *reference* to an other individual (see the selection operator). +if the original individual has to be kept or is a *reference* to another individual (see the selection operator). In order to apply a mutation (here a gaussian mutation) on the individual ``ind1``, simply apply the desired function. @@ -63,7 +63,7 @@ simply apply the desired function. .. literalinclude:: /code/tutorials/part_3/3_next_step.py :lines: 35-37 -The fitness' values are deleted because they not related to the individual anymore. As stated above, the mutation does mutate and only mutate an individual it is not responsible of invalidating the fitness nor anything else. The following shows that ``ind2`` and ``mutant`` are in fact the same individual. +The fitness' values are deleted because they're not related to the individual anymore. As stated above, the mutation does mutate and only mutate an individual it is neither responsible of invalidating the fitness nor anything else. The following shows that ``ind2`` and ``mutant`` are in fact the same individual. .. literalinclude:: /code/tutorials/part_3/3_next_step.py :lines: 39-40 @@ -73,13 +73,13 @@ Crossover The second kind of operator that we will present is the crossover operator. There is a variety of crossover operators in the :mod:`deap.tools` module. -Each crossover has its own characteristics and may be applied to different type +Each crossover has its own characteristics and may be applied to different types of individuals. Be careful to read the documentation of the selected operator in order to avoid undesirable behaviour. The general rule for crossover operators is that they **only** mate individuals, this means that an independent copies must be made prior to mating the individuals -if the original individuals have to be kept or is are *references* to other +if the original individuals have to be kept or are *references* to other individuals (see the selection operator). Lets apply a crossover operation to produce the two children that are cloned beforehand. @@ -104,7 +104,7 @@ Selection --------- Selection is made among a population by the selection operators that are -available in the :mod:`deap.operators` module. The selection operator usually +available in the :mod:`deap.tools` module. The selection operator usually takes as first argument an iterable container of individuals and the number of individuals to select. It returns a list containing the references to the selected individuals. The selection is made as follow. @@ -130,7 +130,7 @@ Using the Toolbox The toolbox is intended to contain all the evolutionary tools, from the object initializers to the evaluation operator. It allows easy configuration of each -algorithms. The toolbox has basically two methods, +algorithm. The toolbox has basically two methods, :meth:`~deap.toolbox.Toolbox.register` and :meth:`~deap.toolbox.Toolbox.unregister`, that are used to add or remove tools from the toolbox. @@ -163,22 +163,22 @@ very simple generational evolutionary algorithm. This is a complete algorithm. It is generic enough to accept any kind of individual and any operator, as long as the operators are suitable for the chosen individual type. As shown in the last example, the usage of the toolbox -allows to write algorithms that are as close as possible to the pseudo code. -Now it is up to you to write and experiment your own. +allows to write algorithms that are as close as possible to pseudo code. +Now it is up to you to write and experiment on your own. Tool Decoration +++++++++++++++ Tool decoration is a very powerful feature that helps to control very precise -thing during an evolution without changing anything in the algorithm or +things during an evolution without changing anything in the algorithm or operators. A decorator is a wrapper that is called instead of a function. It is asked to make some initialization and termination work before and after the actual function is called. For example, in the case of a constrained domain, one can apply a decorator to the mutation and crossover in order to keep any individual from being out-of-bound. The following defines a decorator that -checks if any attribute in the list is out-of-bound and clips it if it is the +checks if any attribute in the list is out-of-bound and clips it if this is the case. The decorator is defined using three functions in order to receive the *min* and *max* arguments. Whenever the mutation or crossover is called, -bounds will be check on the resulting individuals. +bounds will be checked on the resulting individuals. .. literalinclude:: /code/tutorials/part_3/3_6_2_tool_decoration.py :lines: 8- @@ -194,28 +194,28 @@ and `Python Decorator Libary