From e0ace0794fa94b08662a5d3452ede74f6be170e3 Mon Sep 17 00:00:00 2001 From: evomarc Date: Sat, 17 Feb 2001 08:22:53 +0000 Subject: [PATCH] Now takes into account the last (and last!) modification of the operator interace: no more invalidate, but a bool returned for simple operators, and a better description of the eoPopulator/eoOpContainer links. --- eo/tutorial/html/eoOperators.html | 464 ++++++++++++++++++------------ 1 file changed, 284 insertions(+), 180 deletions(-) diff --git a/eo/tutorial/html/eoOperators.html b/eo/tutorial/html/eoOperators.html index bcd070cb..b7c61d1b 100644 --- a/eo/tutorial/html/eoOperators.html +++ b/eo/tutorial/html/eoOperators.html @@ -2,7 +2,7 @@ - + Variation Operators @@ -24,10 +24,10 @@ combinations- Advanced operators Variation Operators Variation Operators -
Variation operators modify individuals, or, equivalently, move them -in the search space. In Evolutionary Algorithms, varitaion operators are -almost always stochastic, i.e. they -are based on random numbers, or equivalently, perform random modifications +
Variation operators modify the gnotype of individuals, or, equivalently, +move them in the search space. In Evolutionary Algorithms, varitaion operators +are almost always stochastic, i.e. +they are based on random numbers, or equivalently, perform random modifications of their arguments. Variation operators are classified depending on the number of arguments they use and/or modify. -EO classes for variation operators: +Implementation +

The basic idea of EO variation operators is that they operate on genotypes +only. Hence there should be generally no reference to anything related +to the fitness within a variation operator. However, whenever the genotype +of an individual has been modified, it will be necessary to recompute its +fitness before any selection process. This is why all +variation operator return a bool that indicates whether or not +the genotype argument has been modified or not. +

EO classes for variation operators:

Warning: if you use operators that have different number of parents than offspring, you are deviating from @@ -398,36 +437,84 @@ for all forthcoming EO algorithms.
Directly applying general operators to given individuals is impossible in EO, due to its interface. You need the help of an individual dispenser of class eoPopulator. -But anyway general operators were thought to be used mainly in combination -of one another, as described below. +But anyway general operators were thought to be used putely in eoOpContainer, +as described below.

Writing a general operator: -
There are many things to modify in the template +
There are many things to modify in the
template class definitions provided.

  • -The constructor, where you pass to the object -any useful parameter (see private data at end of class definition).
  • +First you have to choose which kind of general +operator you want, i.e. with more (or as many) offspring than parents, +or less offspring than parents.
  • -The operator() method, which performs the -actual crossover. Remember you must use the argument eoPopulatorto -access the members of the [p[ulation in turn (method +In the latter case (more parents than offspring), you can decide either +to get the extra parents from the populator (to delete them later), or +to select extra parents using a private selector.
  • + +
  • +Now you can modify the constructor, where +you pass to the object any useful parameter (see private data at end of +class definition). In case you need an external selector, you have to choose +it (or write it!) - it should be an eoSelectOne +object.
  • + +
  • +Finally, write the core of the operator in method apply(). +Remember you must use the argument eoPopulatorto +access the members of the population in turn (method operator*), you may use the initial population (method source()), as well as the insert or delete methods.
  • +
-
Warning: as usual, don't forget -to invalidate the fitness of the individual -- if it has actually been modified. Otherwise, the lazy + +the fitness again and will keep the old obsolete value.
The populators: -
The public interface class eoPopulator -has been described above. However, a protected method, termed select,  +
As has been said above, an +eoPopulator +is a population, but also behaves like +an iterator over a population (hence +the name, Population-Iterator). +

The basic +interface of an eoPopulator +(see also the documentation, +of course) is the following: +

    +
  • +Individuals are accessed through the operator*;
  • + +
  • +Basic iterator operations are available, like (pre)incrementation through +operator++, +position management through seekp +(returns the current position) and tellp +(go to a given position);
  • + +
  • +Individuals can also be inserted and +erased +at current position using the corresponding methods;
  • + +
  • +last but not least, as the individuals are returned by reference, it is +mandatory to ensure that they will not be moved around later: the memory +management  routine reserve +is called whenever there is a chance to add some individuals in the population +- i.e. in the eoGenOp base class operator() method.
  • +
+Moreover, a protected method, termed select,  is used inside the object to get new parents for the following operator, and its implementation distinguishes two types of eoPopulator:
    @@ -447,19 +534,29 @@ object (passed at construct time). Hence it can handle any number of parents at will. The idea of such populator is to handle the whole breeding process, i.e. selection and variation operators.
-An immediate consequence is that if you are not sure of the numebr of  +An immediate consequence is that if you are not sure of the number of  parents you will need in some operators (e.g. because of some stochastic proportional selection ebtween operators that don't need the same number of parents, then you must use an eoSelectivePopulator -to apply the variation operators to the population. +to apply the variation operators to the population, and thus get exactly +the number of offspring you want. +

Example: An eoSelectivePopulator +is the main ingredient of the eoGeneralBreeder +operator() +method - a class that creates a population of offspring from the parents +applying an eoGenOp (usually an eoOpContainer) to all selected parents +in turn.


General -Combinations: -
There are two main ways to use and combine general operators in EO: -the proportional combination, similar to what has been described for simple -operators above, and the sequential -combination, which amounts to apply all operators in turn to a bunch of -individuals, each operator being applied with a specific probability. +Operator Containers:
+
General operators in EO are meant to be used withing eoOpContainer +objects, that allow to combine them in a hierarchical and flexible way. +There are two ways to do that: the proportional +combination, similar to what has been described for simple operators +above, +and the sequential combination, which +amounts to apply all operators in turn to a bunch of individuals, each +operator being applied with a specific probability.

Proportional combinations
When called upon a population (through an eoPopulator object), an eoProportionalOpContainer @@ -519,6 +616,25 @@ Next pending parent

  • Next operator
  • +Warning: the way rate +will be used is highly dependent on the type of eoOpContainer +your are creating there: +
      +
    • +The rates for eoProportionalOpContainer +will be used in a roulette wheel choice among all operators. They can take +any value, the only important thing is their relative +values.
    • + +
    • +The "rates" for eoSequentialOpContainer actually +are probabilities, i.e. they will be +used in a coin-flipping to determine whether that particuler operator will +be applied to the next candidates at hand. They should be in +[0,1] (no error will happen if they are not, but the operator +will be applied systematically - this is equivalent of a rate equal to +1).
    • +
    Remark:The eoSGATransform presented in Lesson2 can be viewed as a particular type of eoSequentialOpContainer. It was not coded that way in order to provide a gradual introduction to @@ -541,28 +657,16 @@ Gen
    :

    someOperatorType<Indi> myOperator;
    eoYYYOpContainer<Indi> myOpContainer;
    myOpContainer.add(myOperator, rate); // -rate: double whose meaning depends on XXX -

    where YYY can be one of Proportional and Sequential. -
    Warning: the way rate -will be used is highly dependent on the type of eoOpContainer -your are creating there: -

      -
    • -The rates for eoProportionalOpContainer -will be used in a roulette wheel choice among all operators. They can take -any value, the only important thing is their relative -values.
    • - -
    • -The "rates" for eoSequentialOpContainer actually -are probabilities, i.e. they will be -used in a coin-flipping to determine whether that particuler operator will -be applied to the next candidates at hand. They should be in -[0,1] (no error will happen if they are not, but the operator -will be applied systematically - this is equivalent of a rate equal to -1).
    • -
    -Containers, +rate: double whose meaning depends on YYY
    +

    where YYY can be one of Proportional and Sequential. Note that before +being added to the container, all simple operators are wrapped into the +corresponding eoGenOp (see e.g. how an eoMonOp +is wrapped into +an eoMonGenOp- or how any +operator is handled by calling the appropriate wrapper). In particular, +the wrapper ensures that individuals who have +been modified are invalidated. +

    Containers, Selectors and Populators
    The way the eoOpContainer are applied on a population using an eoPopulator @@ -633,20 +737,20 @@ general operators:
    preferences, i.e. choose a mate for a first parent according to some characteritics of that first parent).
    This is made possible in EO because the general operators have a handle -on the initial population through the method source() of the argument eoPopulator -they work on. Their operator() +on the initial population through the method source() +of the argument eoPopulator they work on. Their apply() method shoudl look like -

    void operator()(eoPopulator& +

    void apply()(eoPopulator& _pop)
    {
      EOT & eo1 = *_pop; // get (select if necessary) the first guy -
      ++_pop;          +
      ++_pop;       -// advance +
    // advance
      EOT & eo2 = findBlonde(_pop.source()); - -// select mate +
    // +select mate
    // do whatever the operator is supposed to do
    } @@ -671,7 +775,7 @@ documentation Marc Schoenauer
    Last -modified: Fri Dec. 8 2000  +modified: Sat. Feb. 17 2001