📄 eolesson4.html
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]"> <title>Tutorial: Lesson 4</title></head><body text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000" background="beige009.jpg"><a href="eoLesson3.html">Lesson 3</a> -<a href="eoLesson5.html">Lesson5</a> -<a href="eoTutorial.html">Main page</a> -<a href="eoTopDown.html">Algorithm-Based</a>- <a href="eoBottomUp.html">Component-Based</a> - <a href="eoProgramming.html">Hints</a>- <b><font face="Arial,Helvetica"><font size=+1><a href="../../doc/html/index.html">EOdocumentation</a></font></font></b><br><hr WIDTH="100%"><br><b><font color="#FF0000">User's guide:</font></b> <a href="#userguide">General</a>- <a href="#binary">Bitstring</a> - <a href="#real">Real</a> - <a href="#ES">ES</a>- <b><font color="#FF0000">Programmer's guide:</font></b> <a href="#programmerguide">General</a>- <a href="#memory">Memory management </a>- <a href="#parameter">Parameters</a><br><hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- --><center><h1><font color="#FF0000">Tutorial Lesson 4: ready-to-use fully operational EA</font></h1></center>In this lesson, you will still use the same Evolutionary Algorithm. Butthis time you will have <b><font color="#FF6600">full control of all components</font></b>from the <b><font color="#FF6600">command-line or a parameter file</font></b>.<br>You can even use the algorithm decribed here <b><font color="#FF6600">without any other knowledgeof EO</font></b>, just by writing your fitness function as a plain C++ function. <br><br><b><font color="#000099"><font size=+2>Contents</font></font></b><br><ul><li><b><font color="#FF0000">User's guide</font></b> <ul> <li> <a href="#userguide">Representation independent</a>,useful for <b><font color="#FF6600">all</font></b> applications</li> <li> <a href="#binary">BitEA, the binary version</a>, similarto previous lessons</li> <li> <a href="#real">RealEA, the basic real-valued version</a>,not efficient - see by yourself!</li> <li> <a href="#ES">RealEA, the self-adaptive Evolution Strategy</a>, best choice for continuous optimization in EO today (December 2004)</li> </ul></li><li><b><font color="#FF0000">Programmer's guide</font></b>: the ultimate purpose of this tutorial is to make you able to doyour own experiments - and these these will likely fall outside the scopeof the two ready-to-use programs above. You wil hence need to learn more about <ul> <li> <a href="#programmerguide">Building libraries</a> (in spite of the <a href="eoProgramming.html#templates">template problem</a>)</li> <li> <a href="#memory">Memory management</a>: it is radicallydifferent that in the 3 previous lessons - though relying of course on the same objects. Note that eoPersistent objects and eoParamobjects are handled by different mechanisms. </li> </ul></li></ul><p><hr WIDTH="100%"><br><a NAME="userguide"></a><b><font color="#000099"><font size=+2>User'sguide</font></font></b><p><font color="#000000">As already said, the behavior of the algorithmswill be exactly the same as the previous one as far as optimization isconcerned. Only now you will be able to tune every component of the algorithms(except the type of genotype) using run-time parameters.</font><br><font color="#000000">Also, as in previous lessons, most of the codeis representation-independent, i.e. is the same for both the binary genotypesand the real-valued genotypes. This small user's guide reflects that, butyou can go directly to the <a href="#binary">binary</a> or the <a href="#real">real</a>parts if you wish.</font><p><b><font color="#FF0000">Warning</font></b><font color="#000000">: thisis a user guide, not a programming guide. In particular, the </font><font color="#FF6600">keywords</font><font color="#000000">of the parameters are </font><b><font color="#FF6600">not</font></b><font color="#000000">the </font><font color="#FF6600">names</font><font color="#000000"> ofthe underlying classes (though they should be similar in most cases).</font><p><b><font size=+1><font color="#000099">User's guide:</font><font color="#FF0000">Parameterinput</font></font></b><font color="#000000"> The way to input parametershas already be described in <a href="eoLesson3.html#paraminput">Lesson3</a>. To get a list of parameters, type the command with option --help(or -h): with both testBit and testReal this will result in</font><ul><li><font color="#000000">Printing the list of keywords on the standard output</font></li><li><font color="#000000">Creating (or overwriting) a file name testBit.statusor testReal.status that contains the list of all recognized parametersand has the format of an input parameter file.</font></li></ul><b><font size=+1><font color="#000099">User's guide:</font><font color="#FF0000">Thestatus file</font></font></b><br><font color="#000000">This file will always contain the list of theparameters that have been actually used by the last run of the program,however thay have been entered (try </font><b><tt><font color="#FF6666"><font size=+1>testBit-G1</font></font></tt></b><font color="#000000"> and take a look a thestatus file). The parameters that are commented out (a # character commentsout the rest of the line) in the file are those that were not specifiedby the user.</font><br><font color="#000000">On the status file, the parameters are organizedin sections. Note, however, that this format is not mandatory in the paramfile, as </font><font color="#FF6600">only the keywords</font><font color="#000000">are processed.</font><p><b><font size=+1><font color="#000099">User's guide:</font><font color="#FF0000">Representation-independentparameters</font></font></b><br><font color="#000000">In what follows, the fixed font colored textis directly taken from the status file and is commented between the lines.The presentation follows the status file format - only two sections arerepresentation-dependent (see the corresponding <a href="#binary">binary</a>or <a href="#real">real</a> sections). All other sections are presentednow:</font><p><hr SIZE=5 WIDTH="30%"><br><b><font size=+1><font color="#FF0000">Section </font><tt><font color="#993300">######General ######</font></tt></font></b><br><b><tt><font color="#993300"><font size=+1># --help=0 # -h : Printsthis message</font></font></tt></b><br><font color="#FF0000">Boolean parameter </font><font color="#000000">ofabsolutely no interest: tells whether or not help was requested.</font><p><b><tt><font color="#993300"><font size=+1># --seed=988700289 # -S :Random number seed</font></font></tt></b><br><font color="#FF0000">Unsigned long parameter:</font><font color="#000000">the seed for the <a href="eoProgramming.html#random">Random Number Generator</a>If the parameter is absent, then time(0) is used, which indicates the numberof seconds since Jan. 1 1980, is used ... and stored in the status file,of course, so you can repeat the same run by simply assigning that valueagain. There is </font><font color="#FF0000">no default value ("true" randomseed)</font><font color="#000000">.</font><p><hr SIZE=5 WIDTH="30%"><p><b><font size=+1><font color="#FF0000">Section </font><tt><font color="#009900">######engine ######</font></tt></font></b><br><font color="#000000">In this section, one chooses all components ofthe <a href="eoEngine.html">Evolution Engine</a> (selection, replacemenetand the like).</font><p><b><tt><font color="#009900"><font size=+1># --popSize=20 # -P : PopulationSize</font></font></tt></b><br><font color="#FF0000">Integer parameter:</font><font color="#000000">the size of the population (constant along evolution). And yes, this isa representation independent parameter, as the population is created eitherfrom a file or using an eoInit object - and only that object is representation-dependent.</font><br><b><tt><font color="#009900"><font size=+1># --selection=DetTour(2)# -S : Selection: Roulette, DetTour(T), StochTour(t) or Sequential(ordered/unordered)</font></font></tt></b><br><font color="#FF0000">String parameter:</font><font color="#000000">Name of <a href="eoEngine.html#selection">selection procedure.</a> Availabableare the </font><b><font color="#FF6600">roulette wheel</font></b><font color="#000000">(name </font><b><tt><font color="#009900"><font size=+1>Roulette</font></font></tt></b><font color="#000000">,fitness scaling coming soon); </font><b><font color="#FF6600">deterministictournament</font></b><font color="#000000"> (name </font><b><tt><font color="#009900"><font size=+1>DetTour</font></font></tt></b><font color="#000000">with size - integer > 2 - in parentheses right after the name, use doublequotes on the command line); </font><b><font color="#FF6600">stochastictournament</font></b><font color="#000000"> (name </font><b><tt><font color="#009900"><font size=+1>StochTour</font></font></tt></b><font color="#000000">with probability - float in [0.5, 1] - in parentheses); </font><b><font color="#FF6600">sequential</font></b><font color="#000000">(name</font><b><tt><font color="#009900"><font size=+1>Sequential</font></font></tt></b><font color="#000000">,all individuals in turn), either from best to worst (option </font><b><tt><font color="#009900"><font size=+1>ordered</font></font></tt></b><font color="#000000">in parentheses), or in random ordered (option </font><b><tt><font color="#009900"><font size=+1>unordered</font></font></tt></b><font color="#000000">);and finally repeated </font><b><font color="#FF6600">independent uniformchoices</font></b><font color="#000000"> (name </font><b><tt><font color="#009900"><font size=+1>Random</font></font></tt></b><font color="#000000">).Default is </font><font color="#FF0000">DetTour(2)</font><font color="#000000">.</font><p><b><tt><font color="#009900"><font size=+1># --nbOffspring=100% # -O: Nb of offspring (percentage or absolute)</font></font></tt></b><br><font color="#FF0000">Integer or real-valued parameter:</font><font color="#000000">this parameter indicates the </font><b><font color="#FF6600">amount ofoffspring</font></b><font color="#000000"> that will be generated fromthe genitors every generation. However, this amount can be specified either</font><font color="#FF6600">relative</font><font color="#000000">to the population size, and it should then end with percent character (%),or as an </font><font color="#FF6600">absolute</font><font color="#000000">integer number (without the percent char).</font><br><font color="#000000">Indeed, you can either want, say 7 times moreoffspring than parents (a rather common situation in Evolution Strategies),in which case you give value 700% to </font><b><tt><font color="#009900"><font size=+1>nbOffspring</font></font></tt></b><font color="#000000">parameter; or you might want a single offspring whatever the populationsize, like in Steady-State evolution engines, in which case you simplyenter value 1. </font><font color="#FF0000">Default is 100%</font><font color="#000000">.</font><p><b><tt><font color="#009900"><font size=+1># --replacement=Comma # -R: Replacement: Comma, Plus, EPTour(T), SSGAWorst, SSGADet(T), SSGAStoch(t)</font></font></tt></b><br><font color="#FF0000">String parameter:</font><font color="#000000">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -