From 4cb797544acca7c91057ca2a9fe46cef2a15af3a Mon Sep 17 00:00:00 2001 From: evomarc Date: Tue, 3 Apr 2001 17:14:53 +0000 Subject: [PATCH] eoOperators now is in sync with the last modif of eoPopulator by Maarten! --- eo/tutorial/html/eoOperators.html | 170 +++++++++++++++++------------- 1 file changed, 94 insertions(+), 76 deletions(-) diff --git a/eo/tutorial/html/eoOperators.html b/eo/tutorial/html/eoOperators.html index b7c61d1b5..b95b61797 100644 --- a/eo/tutorial/html/eoOperators.html +++ b/eo/tutorial/html/eoOperators.html @@ -147,29 +147,28 @@ an eoQuad object.

Using crossover operators:
Directly applying crossover operators is straightforward from the interface above: -
eoBinOpDerivedClass<Indi> myBinOp(parameters);   +
eoBinOpDerivedClass<Indi> myBinOp(parameters); //  use constructor to pass
eoQuadOpDerivedClass<Indi> myQuadOp(parameters); - -//  any useful argument -
Indi eo1= ..., eo2= ...;    - -// the candidates to crossover +
//  +any useful argument
+
Indi eo1= ..., eo2= ...;   // +the candidates to crossover
if (myBinOp(eo1, eo2)) -
   { ...                    +
   { ...                  // eo1 has been modified, not eo2
   } -
else ...                    +
else ...                  // none has been modified
if (myQuadOp(eo1, eo2)) -
   { ...                    +
   { ...                  // both eo1 and eo2 have been modified
   } -
else ...                    +
else ...                  // none has been modified

However, you will hardly have to actually apply operators to individuals, @@ -182,9 +181,10 @@ are described below, encapsulating the operators into combined operators objects.

Writing a crossover operator: -
There are three things to modify in the template -class definitions provided (apart from the name of the class you are -creating!) +
There are three things to modify in the template class definitions +provided in the Templates directory for both binary +crossover and quadratic crossovers +(apart from the name of the class you are creating!)

Warning: if you use operators that @@ -441,18 +450,25 @@ But anyway general operators were thought to be used putely in below.

Writing a general operator: -
There are many things to modify in the template -class definitions provided. +
There are many things to do to write a general operator - but the Templates +directory contains some sample tempaltes files to help you. It all depends +on whether you want more or less offspring than parents, and whetehr you +want the same selector for every parent or more specialized selectors.

  • -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.
  • +It you want more (or as many) offspring than +parents, you should use the moreOffspringGenOp.tmpl +template - if you want to use the same selector for all parents, the one +embedded in the argument eoPopulator. +Otherwise, you'll have to write your own operator based on an external +selector, as described in lessOffspringExternalSelectorGenOp.tmpl.
  • -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.
  • +If you decide to have more parents than offspring, you can decide either +to get the extra parents using the eoPopulator  +own selector (see lessOffspringSameSelectorGenOp.tmpl, +or to use an external selector (passed at construct-time) as described +in lessOffspringExternalSelectorGenOp.tmpl.
  • Now you can modify the constructor, where @@ -463,12 +479,12 @@ object.
  • Finally, write the core of the operator in method apply(). -Remember you must use the argument eoPopulatorto +Remember you must use the argument eoPopulator +to 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.
  • +as well as the insert methods.
    Warning: in general operators, @@ -484,9 +500,8 @@ the fitness again and will keep the old obsolete value.
populators:

As has been said above, an eoPopulator -is a population, but also behaves like -an iterator over a population (hence -the name, Population-Iterator). +mainly behaves like an iterator over +a population (hence the name, Population-Iterator).

The basic interface of an eoPopulator (see also the documentation, @@ -503,9 +518,8 @@ position management through seekp (go to a given position);

  • -Individuals can also be inserted and -erased -at current position using the corresponding methods;
  • +Individuals can also be inserted at +current position using the corresponding methods;
  • last but not least, as the individuals are returned by reference, it is @@ -514,8 +528,8 @@ 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, +Moreover, a public method termed select,  +is used inside the object to get new parents for the following operator*, and its implementation distinguishes two types of eoPopulator:
    • @@ -541,8 +555,7 @@ of parents, then you must use an Example: An eoSelectivePopulator -is the main ingredient of the eoGeneralBreeder -operator() +is the main ingredient of the eoGeneralBreederoperator() method - a class that creates a population of offspring from the parents applying an eoGenOp (usually an eoOpContainer) to all selected parents in turn. @@ -660,12 +673,12 @@ Gen: 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. +corresponding eoGenOp (see e.g. how an eoMonOpis +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 @@ -745,14 +758,19 @@ _pop)

      {
        EOT & eo1 = *_pop; // get (select if necessary) the first guy -
        ++_pop;       - -// advance -
        EOT & eo2 = findBlonde(_pop.source()); +
        EOT & maBlonde = findBlonde(_pop.source()); // select mate -
      // do whatever the operator is supposed to -do +
        // do whatever the operator is supposed +to do +
        ... +
        // if you want to put maBlonde into +the offspring, you must +
        ++_pop;     + +// advance +
        _pop.insert(maBlonde);    +// and insert it
      }

      Where does that findBlonde selector comes from? As usual, you have to attach it to the operator,