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

📄 eolesson3.html

📁 这是linux下的进化计算的源代码。 === === === === === === === === === === === ===== check latest news at http:
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<p><b><font color="#FF0000">Note</font></b>: actually, there are 2 distinctclasses that compute and give access to statistics: <b><tt><font color="#3366FF">eoStat</font></tt></b>and<b><tt><font color="#3366FF">eoSortedStat</font></tt></b>.As its name indicate, the latter is used whenever computing the statisticsrequire a sorted population: not only this avoids to sort the populationmany times, but also it avoids changing the order of the population atall as <b><tt><font color="#3366FF">eoSortedStat</font></tt></b> objectswork on a temporary vector of fitnesses . But <font color="#FF6600">asfar as their usage is concerned, its makes no difference</font>.<br><hr WIDTH="50%"><br><a NAME="monitor"></a><b><font color="#000099">eoCheckpoint: </font><font color="#FF0000">MonitoringeoParameters</font></b><br><font color="#000000">The </font><b><tt><font color="#3366FF">eoMonitor</font></tt></b><font color="#000000">objects are used to display or store to a file a set of </font><b><tt><font color="#3366FF">eoValueParam</font></tt></b><font color="#000000">objects.</font><p><b><font color="#000099">Monitors</font></b>: <b><font color="#FF0000">Availableinstances</font></b><br>A few monitors are available in the EO distribution:<ul><li><b><tt><font color="#3366FF">eoStdoutMonitor</font></tt></b> displays itsparameters in <font color="#FF6600">text format on the screen</font>. The(optional) boolean value in the constructor modifies the output: when true(the default), verbose output is used, with one line per parameter. Whenfalse, parsimonious output displays one line for all parameters.</li><li><b><tt><font color="#3366FF">eoFileMonitor</font></tt></b> writes its parametersin <font color="#FF6600">text format in a file</font>. A file name is requiredin the constructor, and an optional separator character can be added (defaultis ' '). Note that the file is by default overwritten by next call to thesame program, unless you pass "true" as third (optional) boolean parameter,which will result in appending to the file if it ever exists.</li><li><b><tt><font color="#3366FF">eoGnuplot1DMonitor</font></tt></b> displaysits parameters in <font color="#FF6600">graphical format on the screen</font>by calling the <b><tt><font color="#660000">gnuplot</font></tt></b> program,and as of today, only works in the Unix version of EO (as always, volunteersare welcome to port that to MS Windows). It takes an optional filenameas input, as communication of data with <b><tt><font color="#660000">gnuplot</font></tt></b>is done through a file. If no filename is provided, the file will be erasedat the end of the run, while it is otherwise kept (though it will be overwrittenby next call to the same program).</li></ul><p><br><b><font color="#000099">Monitors</font></b>: <b><font color="#FF0000">Addingto the checkpoint</font></b><br>To display something while the algorithm is running, you need to <a href="SecondBitEA.html#monitor_declare">declare</a>an <b><tt><font color="#3366FF">eoMonitor</font></tt></b> object, <a href="SecondBitEA.html#monitor_add">add</a>some objects (that must be <b><tt><font color="#3366FF">eoValueParam</font></tt></b>objects) to that monitor, and of course <a href="SecondBitEA.html#monitor_pass">add</a>the monitor to the <b><tt><font color="#3366FF">eoCheckpoint</font></tt></b>you use in the algorithm.<br><hr WIDTH="50%"><br><a NAME="update"></a><b><font color="#000099">eoCheckpoint: Updatingthings</font></b><br><font color="#000000">The last type of objects that&nbsp; </font><b><tt><font color="#3366FF">eoCheckpoint</font></tt></b><font color="#000000">can handle are </font><b><tt><font color="#3366FF">eoUpdater</font></tt></b><font color="#000000">objects. You should simply encapsulate in an </font><b><tt><font color="#3366FF">eoUpdater</font></tt></b><font color="#000000">anything you wish to do which does not fit into one of the above category.Note that their </font><b><tt><font color="#660000">operator() method</font></tt></b><font color="#000000">does not receive any argument.</font><p><b><font color="#000099">Updater: </font><font color="#FF0000">Availableinstances</font></b>: A few updaters are available in the EO distribution:<ul><li><b><tt><font color="#3366FF">eoIncrementor</font></tt></b> A simple updaterwhich maintains a <font color="#FF6600">counter</font> (an <b><tt><font color="#3366FF">eoValueParam</font></tt></b>that needs to be created beforehand, and passed in the constructor). Itis incremented every time the <b><tt><font color="#660000">operator()</font></tt></b>method is called (every generation at the moment). You can of course alsogive an increment in the constructor (1 by default).</li><li><a NAME="statesaver"></a><b><tt><font color="#3366FF">eoCountedStateSaver</font></tt></b>and <b><tt><font color="#3366FF">eoTimedStateSaver</font></tt></b> canbe used to <font color="#FF6600">save</font> some existing <b><tt><font color="#3366FF">eoState</font></tt></b>(see <a href="#state">above</a>) to a file regularly, either based on thegeneration count (e.g. every 4 generations) or based on the clock (e.g.every 5 seconds).</li></ul><b><font color="#000099">Updater: </font><font color="#FF0000">Adding tothe checkpoint</font></b><br>A very simple example of using an <b><tt><font color="#3366FF">eoUpdater</font></tt></b>is given in the code for SecondBitEA: First <a href="SecondBitEA.html#param_declare">declare</a>an <b><tt><font color="#3366FF">eoValueParam</font></tt></b> object, then<a href="SecondBitEA.html#param_pass">useit to construct</a> an <b><tt><font color="#3366FF">eoIncrementor</font></tt></b>that you must <a href="SecondBitEA.html#updater_pass">add</a> to the <b><tt><font color="#3366FF">eoCheckpoint</font></tt></b>in order to activate its update. You can then use the parameter for yourpurpose, for instance as a first coordinate for a monitor.<br>Note also how to use the statesavers: first <a href="SecondBitEA.html#outstate_declare">declare</a>a state, then <a href="SecondBitEA.html#outstate_register">register</a>whatever you think necessary to that state, then <a href="SecondBitEA.html#statesaver_declare">pass</a>the state to some state-saver - and don't forget to <a href="SecondBitEA.html#statesaver_pass">add</a>the statesavers to the current <b><tt><font color="#3366FF">eoCheckpoint</font></tt></b>.<br><hr WIDTH="100%"><br><b><font color="#000099"><font size=+2>Exercise 1:</font></font></b><ul><li><font color="#000000">The code of </font><b><tt><font color="#660000"><font size=+1>SecondBitEA</font></font></tt></b><font color="#000000">display things in the current window in text format. Replace the </font><b><tt><font color="#3366FF">eoFileMonitor</font></tt></b><font color="#000000">by an </font><b><tt><font color="#3366FF">eoGnuplot1DMonitor</font></tt></b><font color="#000000">and watch the </font><b><font color="#FF6600">graphical output </font></b><font color="#000000">(</font><font color="#FF6600">Unix</font><font color="#000000">systems with </font><font color="#FF6600">gnuplot</font><font color="#000000">installed only, sorry).</font></li><li><font color="#000000">Note that you must also replace the </font><b><tt><font color="#3366FF">eoSecondMomentStat</font></tt></b><font color="#000000">by an </font><b><tt><font color="#3366FF">eoAverageStat</font></tt></b><font color="#000000">,otherwise the standard deviations won't make any sense here.</font></li><li><font color="#000000">Please try to understand why the average is always0 before taking a look at the solution (file <a href="NoWay.html">exercise1.cpp</a>).</font></li><li><font color="#000000">Then run</font></li><br><b><tt><font color="#660000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exercise1 --vecSize=1000 --maxGen=1000</font></tt></b><br><font color="#000000">to get a chance to see something happening beforethe program ends!</font></ul><hr WIDTH="100%"><b><font color="#000099"><font size=+2>Exercise 2:</font></font></b><br><font color="#000000">Write the </font><b><tt><font color="#3366FF">eoDiversityStat</font></tt></b><font color="#000000">stat computation and test it. Thanks to send us the code!</font><br><hr WIDTH="100%"><br><b><font color="#000099"><font size=+2>Exercise 3:</font></font></b><br><font color="#000000">Write the code for an </font><b><tt><font color="#3366FF">eoGnuplotSecondStatMonitor</font></tt></b><font color="#000000">that would display the </font><b><tt><font color="#3366FF">eoSecondMomentStat</font></tt></b><font color="#000000">(i.e. take into account the standard deviations and display them as error-bars.</font><br><font color="#000000">Again, send us the code afterwards, thanks :-)</font><br><hr WIDTH="100%"><br><b><font color="#000099"><font size=+2>Lessons learned:</font></font></b><ul><li>Value of program parameters can be set <b><font color="#FF6600">at run-time</font></b>using the <b><tt><font color="#3366FF">eoParser</font></tt></b> class.</li><li><b><font color="#FF6600">Snapshots</font></b> of the algorithms can easilybe <font color="#FF6600">saved</font> (and <font color="#FF6600">restored</font>)thanks to the <b><tt><font color="#3366FF">eoState</font></tt></b> class.</li><li>The <b><tt><font color="#3366FF">eoCheckpoint</font></tt></b> mechanismlet you <b><font color="#FF6600">do things every generation</font></b>without modifying existing algorithms, by simply writing the necessarycode and encapsulating it into an object that <b><tt><font color="#3366FF">eoCheckpoint</font></tt></b>is aware of, that are at the moment the following:</li><li>computing <b><font color="#FF6600">statistics</font></b>, <b><font color="#FF6600">displaying</font></b>parameters(e.g. statistics),&nbsp; <b><font color="#FF6600">saving</font></b> the<b><tt><font color="#3366FF">(eo)State</font></tt></b>of the program.</li></ul>In next lesson you will find out that many <a href="intro.html#adaptive">adaptivetechniques</a> (the state-of-the-art in Evolutionary Computation) can easilybe programmed through the <b><tt><font color="#3366FF">eoUpdater</font></tt></b>construct.<br><hr WIDTH="100%"><a href="eoLesson2.html">Lesson 2</a> -<a href="eoLesson4.html">Lesson4</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: None of your business!<!-- hhmts end --></body></html>

⌨️ 快捷键说明

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