diff --git a/eo/tutorial/html/FirstBitEA.html b/eo/tutorial/html/FirstBitEA.html index db1f28cf..9474a5fa 100644 --- a/eo/tutorial/html/FirstBitEA.html +++ b/eo/tutorial/html/FirstBitEA.html @@ -8,7 +8,7 @@
Back to Lesson 2 - Tutorial -main page - Top-Down page - Bottom-up +main page - Algorithm-Based - Component-Based page - Programming hints - EO documentation
Congratualtions - You have chosen the bottom-up approach!
+
Congratualtions - You have chosen the component-based approach!
From here you will be allowed to browse into the different components of
an Evolutionary Algorithm, and to see how to program your favorite using
the EO library.
@@ -60,8 +60,8 @@ to go directly to the corresponding section of the tutorial.
Contents
Introduction
-
The term evolution engine denotes the different parts that simulate
-the Darwinism in Evolutionary Algorithms.
+
The term evolution engine denotes +the different parts of an Evolutionary Algorithm that simulate the Darwinism:
The fittest individuals are more likely to reproduce and survive.
Both selection and replacement will be discussed in turn, before some +helper classes that are used within selection and replacement procedures +are presented. +
+
Replacement
-
+ The replacement phase takes place after the birth
of all offspring through variation operators. The idea is to close
the generation loop, i.e. to end up with a population of individuals that
will be the initial population of next generation. That population will
@@ -57,64 +86,46 @@ one generation to the next one - though nothing stops you from writing
an algorithm with varying population size.
Replacement: The
interface
- The abstract class for replacement procedures is the functor class
eoReplacement,
and the interface for its operator()
is
The replacement phase takes place after the birth
+
+
+
Replacement
+
The abstract class for replacement procedures is the functor class
+
void operator()(const eoPop<EOT>& -_parents, eoPop<EOT>& _offspring)
void operator()(eoPop<EOT>& _parents, +eoPop<EOT>& _offspring)
which you could have guessed from the inheritance tree for class eoReplacement.,
as you see there that eoReplacement derives
-from class eoBF<const eoPop<EOT>&,
-eoPop<EOT>&, void>.
+from class eoBF<eoPop<EOT>&, eoPop<EOT>&,
+void>.
This means that it takes 2 populations
(called, for obvious anthropomorphic reasons, _parents and _offspring :-)
-and puts the result into population offspring (as _parents is passed as
-constant
-population).
-
Note: After the replacement step, -all algorithms swap the parents and offspring populations - this is why -the result of the replacement is put into the _offspring population -- -the _parents being there untouched until the very last moment. +and is free to modify both, but the resulting population should be placed +in the first argument (usually called_parents) to close the loop and go +to next generation.
Replacement: Instances
-
Available instances of eoMerge objects
-are eoPlus, that simply adds
-the parents to the offspring, or eoElitism,
-that adds only some of the (best) parents to the offspring. A special case
-of eoElistism is eoNoElitism,
-an eoMerge that does nothing.
-
-
Available instances of eoReduce are eoTruncate, -that deterministically keeps only the required number of individuals, taking -the best ones, and eoEPReduce -that usees the EP stocahstic tournamenent to reduce the population.
Available instances of eoMergeReduce replacement -procedures are built on the above, and include +include
Replacement: Adding
+
You can add what is called weak elitism to any replacement by encapsulating it into an eoWeakElitismReplacement object. Weak elitism ensures that the overall best fitness in the population will never decrease: @@ -152,25 +193,228 @@ population, replacing the worse.
Within EO, this is very easy to add:
First, declare your replacement functor (here, generational, but it
can be any replacement object):
-
eoNoReplacement<Indi> genReplace;
+
eoGenerationalReplacement<Indi> genReplace;
Then wrap the weak elitism around it:
eoWeakElitismReplacement<Indi> replace(genReplace);
and use now replace as your replacement procedure within your algorithm.
Note: of course, adding weak elitism to an elitist replacement makes no sense - but will not harm either :-) -
Popular
+ Replacement: Test
+file
+ The file t-eoReplacement
+in the test directory implements all
+above replacmenet procedures withni a very simple and easy-to-monitor Dummy
+EO class.
+
+ This section will be completed soon - in the meantime just trust us
+that all of these are already implemented in EO (except maybe some of the
+last category :-) !!!!!!
+ The most popular evolution engines are listed below, together with the
+way to use them in EO. If you don't find your particuler algorithm, please
+send it to us, and we might include it here!
Tournaments are an easy and quick way to select
+individuals within a population based on simple comparisons. Though usually
+based on fitness comparisons, they can use any comparison operator.
+ In replacement procedures, one frequently needs to merge two populations
+(computed form old parents and new-born offspring). Classes derived from
+the abstract class eoMerge are written for that purpose.
+ eoMerge: interface
+
+
Popular
evolution engines
-
The most popular evolution engines are listed below, together with
-the way to use them in EO. If you don't find your particuler algorithm,
-please send it to us, and we might include it here!
+
+
+
+
Tournaments
+
In EO, there are two variants of tournaments used to select one single
+individual, namely Deterministic Tournament
+and Stochastic Tournament,
+that are used in selection and in replacement procedures, and a global
+tournament-based selection of a whole bunch of individuals, the EP
+Tournament. Though the single-selection tournaments can
+be repeated to select more than one individual, and the batch tournament
+selection can be used to select a single individual, both uses are probably
+a waste of CPU time.
+
+
-
Top-Down page - Bottom-up
-page - Programming hints -EO
+
+
Merging
+populations
+
The abstract class for merging procedures is the functor class
+eoMerge,
+and the interface for its operator()
+is
+
void operator()(const eoPop<EOT>& +_parents, eoPop<EOT>& _offspring)
which you could have guessed from the inheritance tree for class eoMerge,
+as you see there that eoMerge derives from
+
class eoBF<const eoPop<EOT>&, eoPop<EOT>&,
+void>.
+
This means that it takes 2 populations
+and modifies the seond one by adding some individuals from the first one
+(which is supposed to remain constant).
+
eoMerge: instances
+
Available instances of eoMerge objects
+are eoPlus, that simply adds
+the parents to the offspring, or eoElitism,
+that adds only some of the (best) parents to the offspring. A special case
+of eoElistism is eoNoElitism,
+an eoMerge that does nothing.
+
+
The other useful component of replacement procedures, eoReduce, +kills +some individuals from a given population. +
eoReduce: interface
+
The abstract class for reducing procedures is the functor class
+eoReduce,
+and the interface for its operator()
+is
+
void operator()(eoPop<EOT>& _parents, +unsigned int new_size)
which you could have guessed from the inheritance tree for class eoReduce,
+as you see there that eoReduce derives from
+
class eoBF<eoPop<EOT>&, unsigned
+int, void>.
+
An eoReduce shoud take a
+population and shrink it to the required size.
+
eoReduce: instances
+
Available instances of eoReduce are
+
+
Many classes in selection/replacement procedures will handle a number
+of individuals that may either be fixed or be a fraction of some argument-population
+size.
+
Of course, it is possible to write two different classes that will
+only differ by the way they compute the number of individuals they have
+to treat, as it is done for selectors with the two classes eoSelectPerc
+and eoSelectNumber (it could also have been
+possible to have some pure abstrat class and implement the computation
+of the number of individuals to treat in some derived classes).
+
However, rather than multiply the number of class, EO has defined a
+class that will handle the problem once and for all, the class eoHowMany.
+It receives a double, and
+a boolean indicating whether
+that double is to be treated as a rate
+or as an absolute (unisgned) interger.
+
eoHowMany: interface
+
The class interface for its operator()
+is
+
unsigned int operator()(unsigned int _pop_size)
which you could have guessed from the inheritance tree for class eoHowMany,
+as you see there that eoHowMany
+derives from
+
class eoUF<unsigned int, unsigned int>.
+
Its constructor takes 2 argumenrts: +
eoHowMany(double _rate, bool _interpret_as_rate += true)
It is used in eoSelectMany (which supersedes +eoSelectPerc +and eoSelectNumber, but they are left there +for tutorial reasons!) as well as in many truncation +methods. +
+
+
Note: Also,
a non-templatized fitness can be compiled
separately (not done here) into an object
file once and for all (remember
@@ -86,8 +84,6 @@ requires.
-
-
Note: In the
previous files (Bit - Real)
, the last 2 types were deduced from the first (2nd argument = fitness
@@ -111,9 +107,7 @@ You can also use different initializers and call them in turn through the
call to pop.append() function
(see Exercise 2).
-
-
-
Note: Don't
+ Variation operators involving two individuals are called crossover
-operators. They can either modify one of the parents according to the
-material of the other parent, or modify both parents. In EO, the former
-are called Binary operators and the latter Quadratic operators.
- Though most the historical evolutionary algorithms used at most one
-crossover and one mutation (see e.g. the Simple Genetic Algorithm in lesson1),
-the trend now in evolutionary computation is to combine operators, choosing
-at run-time and for each individual which operator to apply. This can be
-done in the framework of simple operators, combining for instance several
-mutations into a variation operator that chooses one of them according
-to user-defined preferences: such combinations are called in EO proportional
-combination of simple operators (see e.g. how to define and use such
-combined operators in the SGA of lesson2).
- Finally, there are many other ways to combine different variation operators
-of different kind. Within EO, you can choose to apply many different types
-of operator to the population, either in turn (this is called sequential
-combination) or by randomly choosing among a set of operators at a given
-time (this is proportional combination, generalizing the one defined for
-simple operators). You can of course mix and interleave both approaches
-at will, and this is described as general
-combination of general operators.
- EO implementation: all variation
-operators in EO derive from the base (abstract) class eoOp
-(as usual, click to see the inheritance diagram). blabla
- The characteristic of crossover operators is that they involve two parents.
However, there are crossover operators that generate two parents, and some
@@ -112,7 +159,6 @@ you are using for instance an SGA, this (de
usage).
See also the different ways that are described below, encapsulating the
operators into combined operators objects.
- Writing a crossover
operator:
The best thing to do is to go to the Lesson2
-of the tutorial, where everything is explained.
+of the tutorial, where everything is explained. You will find out how you
+can use
+
General operators in EO are variation operators that are neither simple
+mutations nor simple crossovers. They can involve any number of parents,
+and create any number of offspring. Moreover, they can make use of different
+ways to get the parents they will involve, e.g. they can use a different
+selector for each of the parents they need to select.
+ The corresponding EO class is called eoGenOp.
+and it is as usual templatized by the type of individual it can handle
+(see documentation for eoGenOp
+:-)
+ Interface:
+ 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.
+ This results in the following general interface for an eoGenOp:
+It receives as argument an eoPopulator,
+gets the individuals it needs using the operator*,
+and must handle the positinning of the using the operator++
+method.
+ void operator()(eoPopulator&
+_pop)
+ // do whatever the operator is supposed to
+do
+ What happens next? Well, it all
+depends on how many parents and how many offspring your general op needs:
+
+
+ void operator()(eoPopulator&
+_pop)
+ void operator()(eoPopulator&
+_pop)
+ 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!). Now to find out where that selector comes from, you'll
+have to wait until next section. If you can't wait, go directly there. Using general operators:
+ Writing a general
+operator:
+ There are two main ways to use and combine general operators in EO:
+ Proportional combinations behave
-like a unique operator: when it is called upon a population of candidates,
-an eoProportionalOpContainer enters
-the following loop:
- while there are individuals left in the candidate population
+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
+ while there are individuals left in the list
for all operators it contains, apply the operator to the candidate population,
-that is
+ mark the current position
+ Remark: there is actually a single list
-of individuals that is maintained through a clever mecahnism of mark, rewind
-and unmark, but that's a purely technical matter. If you are interested,
-go and check the eoOpContainer and the eoSequentialOpContainer code.
- Adding operators to a container:
- someOperatorType<Indi> myOperator;
- where XXX can be one of Proportional and Sequential.
- where YYY can be one of Proportional and Sequential.
+ It is sometimes useful to be able to use a selector from inside an operator
+(a typical example is when you want to implement sexual
+preferences, i.e. choose a mate for a first parent according
+to some characteritics of that first parent).
+ void operator()(eoPopulator&
+_pop)
+ Where does that findBlonde
+selector comes from? As usual, you have to attach it to the operator,
+in its constructor for instance, which should give something like:
+ sexualSelectorType<Indi> findBlonde;
+
+
Note: Don't
forget to evaluate the population:
the eoPop has no idea of the eval function, so it has to be done from outside!!!
@@ -134,7 +128,7 @@ or Quad (for crossovers, of class
is derived from the corresponding eoxxxOp class. When applying the eoPropCombinedxxxOp,
one of the eoxxxOp it contains is chosen by a roulette
wheel, according to their respective rates, and is applied to the arguments.
-For more details on these classes, go to the top-down
+For more details on these classes, go to the algorithm-based
corresponding pages, or to their respective documentation pages.
@@ -340,8 +334,8 @@ and stopping criteria here).
Lesson
3 -
Main page -
-Top-Down
-- Bottom-up - Hints
+Algorithm-Based
+- Component-Based - Hints
- EO
documentation
diff --git a/eo/tutorial/html/eoLesson3.html b/eo/tutorial/html/eoLesson3.html
index 17c539b4..f1a5aac5 100644
--- a/eo/tutorial/html/eoLesson3.html
+++ b/eo/tutorial/html/eoLesson3.html
@@ -10,8 +10,8 @@
Lesson
4 -
Main page -
-Top-Down
-- Bottom-up - Hints
+Algorithm-Based
+- Component-Based - Hints
- EO documentation
@@ -135,7 +135,7 @@ we will not go into details: e.g. we will not tell you that the
eoValueParam
is actually a templatized sub-class of abstract class eoParam (oops, I
said it!), nor will we deal with parameters outside their use from an eoParser.
-See the parameter section of the Bottom-up tutorial, or wait until lesson
+See the parameter section of the Component-Based tutorial, or wait until lesson
4).
diff --git a/eo/tutorial/html/eoOperators.html b/eo/tutorial/html/eoOperators.html
index 5ec0e8ef..3626af51 100644
--- a/eo/tutorial/html/eoOperators.html
+++ b/eo/tutorial/html/eoOperators.html
@@ -2,64 +2,111 @@
-
+
-
TOC : Introduction
+
Local: Introduction
- Crossover - Mutation
-- Simple combinations - General
-Operators - General combinations
+- Combinations - General
+Operators - Populators - General
+combinations- Advanced operators
Variation Operators
Variation
+Variation
Operators
Variation operators modify individuals, or, equivalently, move them
-in the search space. They 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.
-
Variation operators involving one single individual are called mutation
-operators.
-
In EO you can also define and use variation operators that generate
-any number of offspring from any number of parents (sometimes termed orgy
-operators). They are called general operators.
-
+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:
+
+
+
-
Simple
+Simple
operators: Crossover
There are only two things to modify in the template
@@ -121,7 +167,7 @@ creating!)
Simple
operators: Mutation
Mutation operators modify one single individual. The corresponding
@@ -177,7 +222,7 @@ creating!)
-
Combining
+Combining
simple operators: proportional combinations
several mutations (respectiveley crossovers) as a single operator:
+every time the operator is called, one of the available operators is chosen
+by some roulette wheel selection using realtive weights.
General
Operators
+
The interface for eoGenOp
+is based on that of another class, called eoPopulator.
+An
+eoPopulator
+is a population, but also behaves like
+an iterator over a population (hence
+the name, Population-Iterator).
+
{
+
EOT & eo1 = *_pop; // get
+(select if necessary) the guy
+
++_pop;
+
+// advance
+
EOT & eo2 = *_pop; // get
+(select if necessary) the guy
+
++_pop;
+
+// advance
+
...
+
EOT & eoN = *_pop; // get
+(select if necessary) the guy
+
++_pop;
+
+// advance
+
}
+
+
+Warning: if you use operators that
+have different number of parents than offspring, you are deviating from
+the simple generational approach. Be careful to have the proper replacement
+procedure to take care of the population size: in most instances of algorithms
+that come within EO, this is enforced (an exception is thrown if population
+size varies from one genertaion to the other) but this might not be true
+for all forthcoming EO algorithms.
+
-
{
+
EOT & eo1 = *_pop; // get
+(select if necessary) the guy
+
++_pop;
+
+// advance
+
// Now create second offspring - eo1
+is modified too!
+
EOT eo2 = create_individual(eo1);
+
// inserts eo2 in _pop after eo1
+
_pop.insert(eo2);
+
...
+
Of course the size of the resulting population will grow - and you
+should have a replacement procedure that takes care of that.
+
+
+
{
+
EOT & eo1 = *_pop; // get
+(select if necessary) the guy
+
++_pop; // advance
+
const EOT & eo2 = select(_pop.source());
+
void operator()(eoPopulator&
+_pop)
+
{
+
EOT & eo1 = *_pop; // get
+(select if necessary) the guy
+
++_pop; // advance
+
EOT & eo2 = *_pop; // get
+(select if necessary) the guy
+
++_pop; // advance
+
// do whatever needs to be done, modifying
+eo1 but not eo2
+
_pop.delete(); //
+removes (untouched) eo2 from the list
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.
+
There are many things to modify in the template
+class definitions provided.
+
+
+
+
Warning: as usual, don't forget
+to invalidate the fitness of the individual
+- if it has actually been modified. Otherwise, the lazy
+fitness evaluation procedure in EO will not know it should compute
+the fitness again and will keep the old value.
The
+populators:
+
The public interface class eoPopulator
+has been described above. However, 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:
+
+
+An immediate consequence is that if you are not sure of the numebr 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.
+
The programmer should hence be very careful that the number of available
+parents matches the requirements of the operators when using an eoSeqPopulator
+object.
+
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.
-
When called upon a population (through an eoPopulator
+object), an eoProportionalOpContainer
+enters the following loop:
+
-Sequential combinations behave like
-a unique operator: when it is called upon a population of candidates, an
+Sequential combinations
+
When it is called upon a list of pending candidates, an
eoSequentialOpContainer
enters the following loop:
-
for all operators it contains,
Remark:The eoSGATransform presented in Lesson2
can be viewed as a particular type of eoSequentialOpContainer.
@@ -268,29 +520,27 @@ It was not coded that way in order to provide a gradual introduction to
all concepts.
+
+
Exercise: write the code to perform an
eoSGA using the eoOpContainer constructs.
-
The basic function to add an operator to an eoOpContainer is the method
-add
-from class eoOpContainer.
-
It is similar to all other add
-methods in other Combined things in eo (as the simple eoProportionalCombinedXXXop
+
The way to add an operator to an eoOpContainer
+is the method
+add. It is similar
+to all other add methods in
+other Combined things in eo (as the simple eoProportionalCombinedXXXop
described above, but also the eoCombinedContinue class or the eoCheckPoint
class).
The syntax is straightforward, and it works with any of the operator
-classes defined above:
+classes eoXXXOp, where XXX stands for
+Mon,
+Bin, Quad or
+Gen:
eoXXXOpContainer<Indi> myOpContainer;
+
eoYYYOpContainer<Indi> myOpContainer;
myOpContainer.add(myOperator, rate); //
rate: double whose meaning depends on XXX
-
However, the way rate
-will be used is highly dependent on the type of OpContainer your are creating
-there:
+
Warning: the way rate
+will be used is highly dependent on the type of eoOpContainer
+your are creating there:
.
The way the eoOpContainer are applied
+on a population using an eoPopulator
+object. But, whereas the behavior of eoProportionalOpContainer
+does not depend on the type of eoPopulator,(one
+operator is chosen by roulette_wheel, and applied once before control is
+given back to the caller), the main loop in method operator()
+of
+class eoSequentialOpContainer
+iterates while (!_pop.exhausted())
+which is interpreted differently depending on the type
+of eoPopulator:
+
+
+
+
+
-
-
TOC : Introduction
+
Advanced
+general operators:
+
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()
+method shoudl look like
+
{
+
EOT & eo1 = *_pop; // get
+(select if necessary) the first guy
+
++_pop;
+
+// advance
+
EOT & eo2 = findBlonde(_pop.source());
+
+// select mate
+
// do whatever the operator is supposed to
+do
+
}
+
sexualOperatorType<Indi> yourBrainAndMyBeauty(findBlonde);
+
Local: Introduction
- Crossover - Mutation
-- Simple combinations - General
-Operators - General combinations
-
-
Top-Down page - Bottom-up
-page - Programming hints -EO
+- Combinations - General
+Operators - Populators - General
+combinations- Advanced operators
+
General: Algorithm-Based
+page - Component-Based - Programming
+hints -EO
documentation
@@ -323,5 +667,6 @@ documentation
Last
modified: Fri Dec. 8 2000
+
diff --git a/eo/tutorial/html/eoProgramming.html b/eo/tutorial/html/eoProgramming.html
index 9993f329..97627762 100644
--- a/eo/tutorial/html/eoProgramming.html
+++ b/eo/tutorial/html/eoProgramming.html
@@ -7,8 +7,8 @@
Tutorial main page -
-Top-Down
-page - Bottom-up page - Programming
+Algorithm-Based
+page - Component-Based - Programming
hints - EO
documentation
@@ -241,8 +241,8 @@ Blabla
-
Tutorial main page - Top-Down
-page - Bottom-up page - Programming
+
Tutorial main page - Algorithm-Based
+page - Component-Based - Programming
hints - EO
documentation
diff --git a/eo/tutorial/html/eoSGA.html b/eo/tutorial/html/eoSGA.html
index c7057031..7d454714 100644
--- a/eo/tutorial/html/eoSGA.html
+++ b/eo/tutorial/html/eoSGA.html
@@ -7,7 +7,7 @@
Back to Lesson 1 - Tutorial
-main page - Top-Down page - Bottom-up
+main page - Algorithm-Based - Component-Based
page - Programming hints - EO
documentation
@@ -144,7 +144,7 @@ apply<EOT>(eval, _pop);
Congratulations - You have chosen the top-down approach! This
-means that you want to start from something that already works, and gradually
-learn about the more complex constructs. We have prepared a series of "lessons"
-for you.
+
Congratulations - You have chosen the algorithm-based approach!
+This means that you want to start from something that already works, and
+gradually learn about the more complex constructs. We have prepared a series
+of "lessons" for you.
Current version (Nov. 29, 2000) stops here, but here are the plans
-(subjected to many changes, of course!)
+
+
+
Current version (Nov. 29, 2000) stops here, but here are the plans (subjected
+to many changes, of course!)
The short term idea of this tutorial is to help you build your own Evolutionary Algorithms using EO - while the long term idea is that you will be able to contribute to EO, and ultimately write our EAs :-)
Related documents
Related documents