paradiseo/trunk/paradiseo-eo/doc/html/t-eo_g_a_8cpp-source.html
legrand c3aec878e5 Paradiseo-eo sources added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
2006-12-12 14:49:08 +00:00

79 lines
5.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>EO: t-eoGA.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.9.1 -->
<div class="qindex"> <form class="search" action="search.php" method="get">
<a class="qindex" href="main.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a> | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<div class="nav">
<a class="el" href="dir_000002.html">test</a></div>
<h1>t-eoGA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#include &lt;iostream&gt;</span>
00002
00003 <span class="preprocessor">#include &lt;ga/make_ga.h&gt;</span>
00004 <span class="preprocessor">#include &lt;eoEvalFuncPtr.h&gt;</span>
00005 <span class="preprocessor">#include "binary_value.h"</span>
00006 <span class="preprocessor">#include &lt;apply.h&gt;</span>
00007
00008 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
00009
00010 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
00011 {
00012
00013 <span class="keywordflow">try</span>
00014 {
00015 <span class="keyword">typedef</span> <a class="code" href="classeo_bit.html">eoBit&lt;double&gt;</a> <a class="code" href="struct_dummy.html">EOT</a>;
00016
00017 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
00018
00019 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
00020
00023
00024 <span class="comment">// The evaluation fn - encapsulated into an eval counter for output </span>
00025 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr&lt;EOT, double&gt;</a> mainEval( binary_value&lt;EOT&gt; );
00026 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter&lt;EOT&gt;</a> eval(mainEval);
00027
00028 <span class="comment">// the genotype - through a genotype initializer</span>
00029 <a class="code" href="classeo_init.html">eoInit&lt;EOT&gt;</a>&amp; init = make_genotype(parser, state, EOT());
00030
00031 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
00032 <a class="code" href="classeo_gen_op.html">eoGenOp&lt;EOT&gt;</a>&amp; op = make_op(parser, state, init);
00033
00036
00037 <span class="comment">// initialize the population - and evaluate</span>
00038 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
00039 <a class="code" href="classeo_pop.html">eoPop&lt;EOT&gt;</a>&amp; pop = make_pop(parser, state, init);
00040
00041 <span class="comment">// stopping criteria</span>
00042 <a class="code" href="classeo_continue.html">eoContinue&lt;EOT&gt;</a> &amp; term = make_continue(parser, state, eval);
00043 <span class="comment">// output</span>
00044 <a class="code" href="classeo_check_point.html">eoCheckPoint&lt;EOT&gt;</a> &amp; checkpoint = make_checkpoint(parser, state, eval, term);
00045 <span class="comment">// algorithm (need the operator!)</span>
00046 <a class="code" href="classeo_algo.html">eoAlgo&lt;EOT&gt;</a>&amp; ga = make_algo_scalar(parser, state, eval, checkpoint, op);
00047
00050 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
00051 make_help(parser);
00052
00055 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
00056 apply&lt;EOT&gt;(eval, pop);
00057 <span class="comment">// print it out</span>
00058 std::cout &lt;&lt; <span class="stringliteral">"Initial Population\n"</span>;
00059 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(std::cout);
00060 std::cout &lt;&lt; std::endl;
00061
00062 run_ea(ga, pop); <span class="comment">// run the ga</span>
00063
00064 std::cout &lt;&lt; <span class="stringliteral">"Final Population\n"</span>;
00065 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(std::cout);
00066 std::cout &lt;&lt; std::endl;
00067 }
00068 <span class="keywordflow">catch</span>(std::exception&amp; e)
00069 {
00070 std::cout &lt;&lt; e.what() &lt;&lt; std::endl;
00071 }
00072 }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:43 2006 for EO by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
</body>
</html>