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

📄 onemaxea.html

📁 这是linux下的进化计算的源代码。 === === === === === === === === === === === ===== check latest news at http:
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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>Templates/OneMaxEA.cpp</title></head><body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorialmain page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-uppage</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="doc/html/index.html">EOdocumentation</a></font><br><hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- --><center><h1><font color="#FF0000">Templates/OneMaxEA.cpp</font></h1></center>The places where you have to put some code are on <b><font color="#FF6666">pinkbackground</font></b>.. Only the the <a href="eoTutorial.html#colors">charactercolors have the usual meaning</a>.<br><a NAME="start"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr NOSAVE><td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt><br><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt><br><tt><font color="#993300">*/</font></tt><br><tt><font color="#993300">/*</font></tt><br><tt><font color="#993300">Template for creating a new representationin EO</font></tt><br><tt><font color="#993300">================================================</font></tt><br><tt><font color="#993300">This is the template main file.</font></tt><br><tt><font color="#993300">It includes all other files that have beengenerated by the script create.sh</font></tt><br><tt><font color="#993300">so it is the only file to compile.</font></tt><br><tt><font color="#993300">In case you want to build up a separate libraryfor your new Evolving Object,</font></tt><br><tt><font color="#993300">you'll need some work - follow what's donein the src/ga dir, used in the</font></tt><br><tt><font color="#993300">main file BitEA in tutorial/Lesson4 dir.</font></tt><br><tt><font color="#993300">Or you can wait until we do it :-)</font></tt><br><tt><font color="#993300">*/</font></tt><br><tt><font color="#993300">// Miscilaneous include and declaration&nbsp;</font></tt><br><b><tt><font color="#993300">#include &lt;iostream></font></tt></b><br><b><tt><font color="#993300">using namespace std;</font></tt></b><br><tt><font color="#993300">// eo general include</font></tt><br><b><tt><font color="#993300">#include "eo"</font></tt></b><br><tt><font color="#993300">// the real bounds (not yet in general eoinclude)</font></tt><br><b><tt><font color="#993300">#include "utils/eoRealVectorBounds.h"</font></tt></b><br><tt><font color="#993300">// include here whatever specific files foryour representation</font></tt><br><tt><font color="#993300">// Basically, this should include at leastthe following</font></tt><br><tt><font color="#993300">/** definition of representation:&nbsp;</font></tt><br><tt><font color="#993300">* class eoOneMax MUST derive from EO&lt;FitT>for some fitness</font></tt><br><tt><font color="#993300">*/</font></tt></td></tr></table><a NAME="representation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#999900">#include "eoOneMax.h"</font></tt></b><br><tt><font color="#999900">/** definition of initilizqtion:&nbsp;</font></tt><br><tt><font color="#999900">* class eoOneMaxInit MUST derive from eoInit&lt;eoOneMax></font></tt><br><tt><font color="#999900">*/</font></tt></td></tr></table><a NAME="init"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#993399">#include "eoOneMaxInit.h"</font></tt></b><br><tt><font color="#993399">/** definition of evaluation:&nbsp;</font></tt><br><tt><font color="#993399">* class eoOneMaxEvalFunc MUST derive fromeoEvalFunc&lt;eoOneMax></font></tt><br><tt><font color="#993399">* and should test for validity before doingany computation</font></tt><br><tt><font color="#993399">* see tutorial/Templates/evalFunc.tmpl</font></tt><br><tt><font color="#993399">*/</font></tt></td></tr></table><a NAME="fitness"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><b><tt><font color="#CC0000">#include "eoOneMaxEvalFunc.h"</font></tt></b><br><tt><font color="#CC0000">// GENOTYPE&nbsp;&nbsp;&nbsp; eoOneMax ***MUST***be templatized over the fitness</font></tt></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE ><tr><td><tt><font color="#CC0000">// START fitness type: double or eoMaximizingFitnessif you are maximizing</font></tt><br><tt><font color="#CC0000">//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eoMinimizingFitness if you are minimizing</font></tt><br><tt><font color="#CC0000"><b>typedef eoMinimizingFitness MyFitT ; </b>//type of fitness&nbsp;</font></tt><br><tt><font color="#CC0000">// END fitness type</font></tt></td></tr></table><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td></td></tr></table><a NAME="representation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#999900">// Then define your EO objects using thatfitness type</font></tt><br><tt><font color="#999900"><b>typedef eoOneMax&lt;MyFitT> Indi;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>// ***MUST*** derive from EO&nbsp;</font></tt></td></tr></table><a NAME="init"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#993399">// create an initializer</font></tt><br><b><tt><font color="#993399">#include "make_genotype_OneMax.h"</font></tt></b><br><b><tt><font color="#993399">eoInit&lt;Indi> &amp; make_genotype(eoParser&amp;_parser, eoState&amp;_state, Indi _eo)</font></tt></b><br><b><tt><font color="#993399">{</font></tt></b><br><b><tt><font color="#993399">&nbsp;return do_make_genotype(_parser,_state, _eo);</font></tt></b><br><b><tt><font color="#993399">}&nbsp;</font></tt></b></td></tr></table><a NAME="operators"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#993399">// and the variation operaotrs</font></tt><br><b><tt><font color="#993399">#include "make_op_OneMax.h"</font></tt></b><br><b><tt><font color="#993399">eoGenOp&lt;Indi>&amp;&nbsp; make_op(eoParser&amp;_parser, eoState&amp; _state, eoInit&lt;Indi>&amp; _init)</font></tt></b><br><b><tt><font color="#993399">{</font></tt></b><br><b><tt><font color="#993399">&nbsp;return do_make_op(_parser, _state,_init);</font></tt></b><br><b><tt><font color="#993399">}</font></tt></b></td></tr></table><a NAME="init"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#993399">// Use existing modules to define representationindependent routines</font></tt><br><tt><font color="#993399">// These are parser-based definitions ofobjects</font></tt><br><tt><font color="#993399">// how to initialize the population&nbsp;</font></tt><br><tt><font color="#993399">// it IS representation independent if aneoInit is given</font></tt><br><b><tt><font color="#993399">#include &lt;do/make_pop.h></font></tt></b><br><b><tt><font color="#993399">eoPop&lt;Indi >&amp;&nbsp; make_pop(eoParser&amp;_parser, eoState&amp; _state, eoInit&lt;Indi> &amp; _init)</font></tt></b><br><b><tt><font color="#993399">{</font></tt></b><br><b><tt><font color="#993399">&nbsp;return do_make_pop(_parser, _state,_init);</font></tt></b><br><b><tt><font color="#993399">}</font></tt></b></td></tr></table><a NAME="stop"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#3366FF">// the stopping criterion</font></tt><br><b><tt><font color="#3366FF">#include &lt;do/make_continue.h></font></tt></b><br><b><tt><font color="#3366FF">eoContinue&lt;Indi>&amp; make_continue(eoParser&amp;_parser, eoState&amp; _state, eoEvalFuncCounter&lt;Indi> &amp; _eval)</font></tt></b><br><b><tt><font color="#3366FF">{</font></tt></b><br><b><tt><font color="#3366FF">&nbsp;return do_make_continue(_parser,_state, _eval);</font></tt></b><br><b><tt><font color="#3366FF">}</font></tt></b></td></tr></table><a NAME="stat"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE ><tr><td><tt><font color="#3366FF">// outputs (stats, population dumps, ...)</font></tt><br><b><tt><font color="#3366FF">#include &lt;do/make_checkpoint.h></font></tt></b><br><b><tt><font color="#3366FF">eoCheckPoint&lt;Indi>&amp; make_checkpoint(eoParser&amp;

⌨️ 快捷键说明

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