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

📄 firstbitga.html

📁 这是linux下的进化计算的源代码。 === === === === === === === === === === === ===== check latest news at http:
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</font></tt></b><tt><font color="#993399">// and put it in the population</font></tt><br><b><tt><font color="#993399">&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt></b></td></tr></table><a NAME="output"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCFFFF" NOSAVE ><tr><td><tt><font color="#3366FF"><b>&nbsp;</b>// sort pop before printingit!</font></tt><br><b><tt><font color="#3366FF">&nbsp;pop.sort();</font></tt></b><br><tt><font color="#3366FF"><b>&nbsp;</b>// Print (sorted) intial population(raw printout)</font></tt><br><b><tt><font color="#3366FF">&nbsp;cout &lt;&lt; "Initial Population"&lt;&lt; endl;</font></tt></b><br><b><tt><font color="#3366FF">&nbsp;cout &lt;&lt; pop;</font></tt></b></td></tr></table><a NAME="engine"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#99FFCC" NOSAVE ><tr><td><tt><font color="#009900"><b>&nbsp;</b>/////////////////////////////////////</font></tt><br><tt><font color="#009900"><b>&nbsp;</b>// selection and replacement</font></tt><br><tt><font color="#009900"><b>&nbsp;</b>////////////////////////////////////</font></tt></td></tr></table><a NAME="select"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#99FFCC" NOSAVE ><tr><td><tt><font color="#009900"><b>&nbsp;</b>// The robust tournament selection</font></tt><br><tt><font color="#009900"><b>&nbsp;eoDetTournamentSelect&lt;Indi> select(T_SIZE);&nbsp;</b>// T_SIZE in [2,POP_SIZE]</font></tt></td></tr></table><a NAME="replace"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#99FFCC" NOSAVE ><tr><td><tt><font color="#009900"><b>&nbsp;</b>// The simple GA evolution engineuses generational replacement</font></tt><br><tt><font color="#009900"><b>&nbsp;</b>// so no replacement procedureis needed</font></tt></td></tr></table><a NAME="stop"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCFFFF" NOSAVE ><tr><td></td></tr></table><a NAME="operators"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCFF" NOSAVE ><tr><td><tt><font color="#993399"><b>&nbsp;</b>//////////////////////////////////////</font></tt><br><tt><font color="#993399"><b>&nbsp;</b>// The variation operators</font></tt><br><tt><font color="#993399"><b>&nbsp;</b>//////////////////////////////////////</font></tt></td></tr></table><a NAME="crossover"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCFF" NOSAVE ><tr><td><tt><font color="#993399"><b>&nbsp;</b>// 1-point crossover for bitstring</font></tt><br><b><tt><font color="#993399">&nbsp;eo1PtBitXover&lt;Indi> xover;</font></tt></b></td></tr></table><a NAME="mutation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCFF" NOSAVE ><tr><td><br><tt><font color="#993399"><b>&nbsp;</b>// standard bit-flip mutationfor bitstring</font></tt><br><b><tt><font color="#993399">&nbsp;eoBitMutation&lt;Indi>&nbsp; mutation(P_MUT_PER_BIT);</font></tt></b></td></tr></table><a NAME="stop"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCFFFF" NOSAVE ><tr><td><tt><font color="#3366FF"><b>&nbsp;</b>//////////////////////////////////////</font></tt><br><tt><font color="#3366FF"><b>&nbsp;</b>// termination condition</font></tt><br><tt><font color="#3366FF"><b>&nbsp;</b>/////////////////////////////////////</font></tt><br><tt><font color="#3366FF"><b>&nbsp;</b>// stop after MAX_GEN generations</font></tt><br><b><tt><font color="#3366FF">&nbsp;eoGenContinue&lt;Indi> continuator(MAX_GEN);</font></tt></b><br>&nbsp;</td></tr></table><a NAME="generation"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCC99" NOSAVE ><tr><td><tt><font color="#FF6666"><b>&nbsp;</b>/////////////////////////////////////////</font></tt><br><tt><font color="#FF6666"><b>&nbsp;</b>// the algorithm</font></tt><br><tt><font color="#FF6666"><b>&nbsp;</b>////////////////////////////////////////</font></tt><br><tt><font color="#FF6666"><b>&nbsp;</b>// standard Generational GArequires as parameters</font></tt><br><tt><font color="#FF6666"><b>&nbsp;</b>// selection, evaluation, crossoverand mutation, stopping criterion</font></tt><p><b><tt><font color="#FF6666">&nbsp;eoSGA&lt;Indi> gga(select, xover,CROSS_RATE, mutation, MUT_RATE,&nbsp;</font></tt></b><br><b><tt><font color="#FF6666">&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;eval, continuator);</font></tt></b><br><tt><font color="#FF6666"><b>&nbsp;</b>// Apply algo to pop - that'sit!</font></tt><br><b><tt><font color="#FF6666">&nbsp;gga(pop);</font></tt></b><br>&nbsp;</td></tr></table><a NAME="final_output"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCFFFF" NOSAVE ><tr><td><tt><font color="#3366FF"><b>&nbsp;</b>// Print (sorted) intial population</font></tt><br><b><tt><font color="#3366FF">&nbsp;pop.sort();</font></tt></b><br><b><tt><font color="#3366FF">&nbsp;cout &lt;&lt; "FINAL Population\n"&lt;&lt; pop &lt;&lt; endl;</font></tt></b></td></tr></table><a NAME="main"></a><table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCC99" NOSAVE ><tr><td><b><tt><font color="#993300">}</font></tt></b><br><tt><font color="#993300">// A main that catches the exceptions</font></tt><br><b><tt><font color="#993300">int main(int argc, char **argv)</font></tt></b><br><b><tt><font color="#993300">{</font></tt></b><br><b><tt><font color="#993300">#ifdef _MSC_VER</font></tt></b><br><tt><font color="#993300"><b>&nbsp;</b>//&nbsp; rng.reseed(42);</font></tt><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; int flag = _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF);</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag|= _CRTDBG_LEAK_CHECK_DF;</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; _CrtSetDbgFlag(flag);</font></tt></b><br><tt><font color="#993300">//&nbsp;&nbsp;&nbsp; _CrtSetBreakAlloc(100);</font></tt><br><b><tt><font color="#993300">#endif</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; try</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; {</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;main_function(argc, argv);</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; catch(exception&amp;e)</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; {</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cout &lt;&lt; "Exception: " &lt;&lt; e.what() &lt;&lt; '\n';</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; }</font></tt></b><br><b><tt><font color="#993300">&nbsp;&nbsp;&nbsp;&nbsp; return 1;</font></tt></b><br><b><tt><font color="#993300">}</font></tt></b></td></tr></table><hr WIDTH="100%"><a href="eoLesson1.html">Back to Lesson 1</a> - <a href="eoTutorial.html">Tutorialmain page </a>- <a href="eoTopDown.html">Algorithm-Based</a> - <a href="eoBottomUp.html">Component-Basedpage</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="../../doc/html/index.html">EOdocumentation</a></font><hr><address><a href="mailto:Marc.Schoenauer@inria.fr">Marc Schoenauer</a></address><br><!-- Created: Nov 2000 --><!-- hhmts start -->Last modified: Sun Nov19 08:31:26 2000<!-- hhmts end --></body></html>

⌨️ 快捷键说明

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