⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eolesson2.html

📁 这是linux下的进化计算的源代码。 === === === === === === === === === === === ===== check latest news at http:
💻 HTML
📖 第 1 页 / 共 2 页
字号:
with a Gaussian noise, with standard deviation passed in the constructor.</font></ul><b><font color="#FF0000">Note:</font></b> A third optional argument inmethod <b><tt><font color="#660000">add</font></tt></b> is a boolean (defaultedto false). When true, the actual rates for all operators are displayedon the screen as percentages: you don't have to input rates that sum upto 1, all rates are scaled anyway.<p><a NAME="transform"></a><b><font color="#FF0000">Note:</font></b> Theoperators have to be encapsulated into an <b><tt><font color="#CC33CC">eoTransform</font></tt></b>object (<a href="FirstBitEA.html#transform">Bit</a> - <a href="FirstRealEA.html#transform">Real</a>)to be passed to the <b><tt><font color="#FF6666">eoEasyEA </font></tt></b>algorithm.The <b><tt><font color="#CC33CC">eoSGATransform</font></tt></b> is a simple<b><tt><font color="#CC33CC">eoTransform</font></tt></b>that does exactly the same thing than <b><tt><font color="#FF6666">eoSGA</font></tt></b>:each pair from the selected parents undergoes the <font color="#CC33CC">crossoveroperator with given probability</font>, and all individuals (after crossovereventually) undergo <font color="#CC33CC">mutation with given probability</font>.The arguments to the <b><tt><font color="#CC33CC">eoSGATransform</font></tt></b>are an <b><tt><font color="#CC33CC">eoQuadOp</font></tt></b> with its probabilityand an <b><tt><font color="#CC33CC">eoMonOp</font></tt></b> with the associatedprobability.<br>&nbsp;<li><a NAME="combinedContinue"></a><font color="#000000">You can use </font><b><font color="#3366FF">combinations</font></b><font color="#000000">ofseveral stopping criteria by using an object of the class </font><b><tt><font color="#3366FF">eoCombinedContinue</font></tt></b><font color="#000000">(<a href="FirstBitEA.html#stop">Bit</a>- <a href="FirstRealEA.html#stop">Real</a>). Initialize it with an objectof class </font><font color="#3366FF"><b><tt>eoContinue</tt></b>, </font><font color="#000000">and</font><b><tt><font color="#3366FF">add</font></tt></b><font color="#000000">as many of other such objects as you wish. And as an </font><b><tt><font color="#3366FF">eoCombinedContinue</font></tt><font color="#FF6600">isan</font><tt><font color="#3366FF"> eoContinue</font></tt></b><font color="#000000">,simply pass it to the algorithm (<a href="FirstBitEA.html#generation">Bit</a>- <a href="FirstRealEA.html#generation">Real</a>). To find out more, andto get the list and syntax of existing eoContinue subclasses, check outthe corresponding <a href="eoCheckPoint.html#existingContinue">component-basedpage</a>.</font></li><br>&nbsp;<li><a NAME="evolution"></a><font color="#000000">The</font><b><font color="#009900">full selection/replacement mechanism </font></b><font color="#000000">isnow in place through the </font><font color="#FF6666"><b><tt>eoEasyEA</tt></b>algorithm.</font></li><br>This means that you can use different <font color="#009900">selectors</font>.which was already true in Lesson 1, but also different <font color="#009900">replacementstrategies</font> (see <a href="#Exercise3">Exercise 3</a>) whereas <font color="#009900">generationalreplacement</font> was hard-coded in the algorithm <b><tt><font color="#FF6666">eoSGA</font></tt></b>used in Lesson1.<p>Beware that we have to encapsulate&nbsp; <font color="#000000">(<a href="FirstBitEA.html#select_encapsulate">Bit</a>- <a href="FirstRealEA.html#select_encapsulate">Real</a>) </font>the <font color="#FF6600">eoDetTournament</font>,which is of class <font color="#FF6600">eoSelectOne</font> (i.e. allowsto select one individual from a population, its <b><tt><font color="#660000">operator()</font></tt></b>returning a single individual) into an object of the <font color="#FF6600">eoSelectPerc</font>(perc stands for percentage) which allows to select a ... percentage ofa population (his <b><tt><font color="#660000">operator()</font></tt></b>&nbsp;returns a population). This was done internally in the&nbsp; <a href="../../doc/html/classeo_s_g_a.html#a0">constructorof eoSGA</a>&nbsp; - see lesson1.</ul><hr WIDTH="100%"><a NAME="Exercise1"></a><b><font size=+2><font color="#000099">Exercise1: </font><font color="#FF0000">minimizing</font></font></b><br><font color="#000000">Modify the algorithm so that it minimizes thefitness.</font><ul><li><font color="#000000">For the bitstring case, you only have to modify the<a href="FirstBitEA.html#representation">declarationof the representation</a>, using </font><b><tt><font color="#999900">eoMinimizingFitness</font></tt></b><font color="#000000">instead of </font><b><tt><font color="#999900">double</font></tt></b><font color="#000000">.But is that really all? Give it a try, look at the output, and do it rightthe second time!!!</font></li><li><font color="#000000">For the real-valued problem, you also need to modifythe file <b><tt><a href="real_value.html">real_value.h</a></tt></b> sothat it returns the sum of squares instead of its inverse. And again thereis something else to modify...</font></li></ul><a NAME="exercise2"></a><b><font size=+2><font color="#000099">Exercise2: </font><font color="#FF0000">initialization</font></font></b><br><font color="#000000">Use different initializers: for instance, onthe real-valued sphere function minimization, try to initialize half ofthe population in [-2,-1] and the other half in [1,2], with and withoutthe segment and hypercube crossovers (and for large values of VEC_SIZE,the size of the vectors). Amazing, isn't it! Explain that result.</font><p><a NAME="Exercise3"></a><b><font size=+2><font color="#000099">Exercise3:&nbsp; </font><font color="#FF0000">full selection/replacement</font></font></b><br><font color="#000000">You can now twiddle the number of offspring thatwill be generated from the parents. But of course you need to adjust thereplacement to keep a constant population size.</font><ul><li><font color="#000000">To </font><font color="#FF6600">modify the numberof offspring</font><font color="#000000">, use the second argument of the</font>encapsulator<font color="#000000">(<a href="FirstBitEA.html#select_encapsulate">Bit</a> - <a href="FirstRealEA.html#select_encapsulate">Real</a>)of the </font><font color="#009900">selector</font><font color="#000000">of class </font><b><tt><font color="#009900">eoSelectOne</font></tt></b><font color="#000000">into an eoSelectPerc object. For instance, try</font></li><br><b><tt><font color="#009900">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eoSelectPerc&lt;Indi> select(selectOne,2.0)</font></tt></b><br><font color="#000000">to generate twice as many offspring as thereare parents.</font><br><font color="#000000">You can also use the other encapsulator thattakes as second argument an absolute number (e.g. if you want to generate2 offspring whatever the population size):</font><br><b><tt><font color="#009900">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eoSelectNumber&lt;Indi> select(selectOne,2)</font></tt></b><br><font color="#000000">Or you can use the <a href="eoEngine.html#howmany">HowMany</a>paradigm and the </font><b><tt><font color="#009900">eoSelectMany </font></tt></b><font color="#000000">todo either one depending on some command-line input (advanced).</font><li><font color="#000000">To </font><font color="#FF6600">keep a constant populationsize</font><font color="#000000">, you can use either the </font><b><tt><font color="#009900">eoCommaReplacement</font></tt></b><font color="#000000">class, or the </font><b><tt><font color="#009900">eoPlusReplacement</font></tt></b><font color="#000000">.The former selects the best offspring to replace the parents, the latterselects the best among parents+offspring. Of course you cannot use </font><b><tt><font color="#009900">eoCommaReplacement</font></tt></b><font color="#000000">if you have less offspring than parents!</font></li><br>Now if you use <b><tt><font color="#009900">eoSelectRandom</font></tt></b>as selector with a rate of<i>lambda</i>, you end up with exactly the <i>(mu+lambda)</i>or<i>(mu,lambda)</i> strategies from <a href="intro.html#ES">EvolutionStrategies</a>.<li><font color="#FF0000">Question</font><font color="#000000">: what do youget if you select 1 offspring only, and an </font><b><tt><font color="#009900">eoPlusReplacement</font></tt></b><font color="#000000">strategy? Yes, you get almost the replace_worst Steady-State GA, thoughrather inefficient, as you sort the population at every generation.</font></li><li><font color="#FF0000">Hint</font><font color="#000000">: there are a fewSteady-State replacement strategies already there in EO. See the <a href="eoEngine.html#SSGA">Replacementpage</a>.</font></li></ul><font color="#FF0000">Remember</font><font color="#000000">: all solutionsare in the same sub-directory of the Tutorial dir than the examples (i.e.here Lesson2), and are described <a href="NoWay.html">here</a>.</font><p><hr WIDTH="100%"><br><b><font color="#000099"><font size=+2>Lessons learned:</font></font></b><ul><li>How to write a <font color="#CC0000">fitness function</font> that onlyneeds a genotype, not a full individual. Moreover you can compile it separately.</li><br>How to <font color="#CC33CC">initialize</font> the population usingrandom generators<li>How to use other <font color="#009900">evolution engine</font> than thesimple generational GA.</li><li>How to combine different objects of the same kind into a single objectthat you can use like a simple basic object (<font color="#CC33CC">operators</font>and <font color="#3366FF">stopping criteria</font> here).</li></ul><hr WIDTH="100%"><a href="eoLesson1.html">Lesson 1</a> -<a href="eoLesson3.html">Lesson3</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><address><a href="mailto:Marc.Schoenauer@inria.fr">Marc Schoenauer</a></address><br><!-- Created: Fri Nov  3 18:49:12 CET 2000 --><!-- hhmts start -->Lastmodified: Fri Nov 3 18:49:12 CET 2000<!-- hhmts end --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -