git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
79 lines
5.2 KiB
HTML
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 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 Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <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 <iostream></span>
|
|
00002
|
|
00003 <span class="preprocessor">#include <ga/make_ga.h></span>
|
|
00004 <span class="preprocessor">#include <eoEvalFuncPtr.h></span>
|
|
00005 <span class="preprocessor">#include "binary_value.h"</span>
|
|
00006 <span class="preprocessor">#include <apply.h></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<double></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<EOT, double></a> mainEval( binary_value<EOT> );
|
|
00026 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<EOT></a> eval(mainEval);
|
|
00027
|
|
00028 <span class="comment">// the genotype - through a genotype initializer</span>
|
|
00029 <a class="code" href="classeo_init.html">eoInit<EOT></a>& 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<EOT></a>& 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<EOT></a>& pop = make_pop(parser, state, init);
|
|
00040
|
|
00041 <span class="comment">// stopping criteria</span>
|
|
00042 <a class="code" href="classeo_continue.html">eoContinue<EOT></a> & term = make_continue(parser, state, eval);
|
|
00043 <span class="comment">// output</span>
|
|
00044 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a> & 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<EOT></a>& 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<EOT>(eval, pop);
|
|
00057 <span class="comment">// print it out</span>
|
|
00058 std::cout << <span class="stringliteral">"Initial Population\n"</span>;
|
|
00059 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(std::cout);
|
|
00060 std::cout << std::endl;
|
|
00061
|
|
00062 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
|
00063
|
|
00064 std::cout << <span class="stringliteral">"Final Population\n"</span>;
|
|
00065 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(std::cout);
|
|
00066 std::cout << std::endl;
|
|
00067 }
|
|
00068 <span class="keywordflow">catch</span>(std::exception& e)
|
|
00069 {
|
|
00070 std::cout << e.what() << 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
|
|
<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>
|