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:
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:
- However, you will hardly have to actually apply operators to individuals,
@@ -243,8 +243,8 @@ objects.
Writing a mutation
operator:
- void apply()(eoPopulator&
_pop)
// invalidate the parents that
@@ -384,46 +383,56 @@ and you can access it from inside the GenOp method. For instance
- void apply()(eoPopulator&
_pop)
where select is any selector you like. Note the
+ // then kill the ones that are now
-useless
- Writing a general
operator:
- The basic
interface of an eoPopulator
(see also the documentation,
@@ -503,9 +518,8 @@ position management through seekp
(go to a given position);
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
Where does that findBlonde
selector comes from? As usual, you have to attach it to the operator,
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
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!)
Indi eo = ...;
// eo is candidate to mutation
if (myMutation(eo))
-
{ ...
+
{ ...
// eo has been modified
}
-
else
+
else
// eo has not been modified
There are only two things to modify in the template
-class definitions provided (apart from the name of the class you are
-creating!)
+class definitions provided in the Templates directory (apart from the
+name of the class you are creating!)
EOT& parent1 = *_pop;
//
select the first parent
-
++_plop;
+
++_plop;
// advance once for each selected parents
...
EOT& parentN = *_pop;
//
select the last parent
-
+
// don't advance after the last one: _plop always
@@ -342,8 +342,6 @@ in the following:
-
{
@@ -354,8 +352,9 @@ of parents (see above)
EOT ofs1 = create_individual(...);
...
EOT ofsK = create_individual(...);
-
// inserts offspring in _pop after
-parentN
+
// advance and inserts offspring in
+_pop after parentN
+
++_pop;
_pop.insert(ofs1);
...
-
{
-
// get the necessary number
-of parents (see above)
+
// get as many parents as you
+will have offspring (see above)
...
// get extra parents - use
private selector
const EOT& parentN+1 = select(_pop.source());
...
const EOT& parentM = select(_pop.source());
-
// do whatever needs to be done
+
...
+
// and of course invalidate fitnesses
+of remaining modified parents
+
parent1.invalidate();
+
...
+
parentN.invalidate();
+
}
+
where select is any selector you like. Note the
const: you are not allowed to modify an element of the original
population (but you could of course have copied it!). As usual, the select
-selector was pased to the operator at construct time.
+selector was passed to the operator at construct time. This typically allows
+one to use a different selector for one parent and the others, as demonstrated
+here.
+
void apply()(eoPopulator&
_pop)
{
-
// get the necessary number
-of parents (see above)
+
// get as many parents as you
+will have offspring (see above)
...
-
// do whatever needs to be done to
-any parent
-
_plop.erase();
-// as many times as necessary
-
...
-
// invalidate fitnesses of remaining
-modified parents
+
// get extra parents - use
+populator selector
+
const EOT& parentN+1 = _pop.select();
+
...
+
const EOT& parentM = _pop.select();
+
// do whatever needs to be done
+
...
+
// and of course invalidate fitnesses
+of remaining modified parents
parent1.invalidate();
...
-
parentK.invalidate();
+
parentN.invalidate();
}
Warning: if you use operators that
@@ -441,18 +450,25 @@ But anyway general operators were thought to be used putely in below.
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.
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 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
}