paradiseo/trunk/paradiseo-eo/doc/html/make__algo__easea_8h-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

349 lines
28 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: make_algo_easea.h 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_000000.html">src</a>&nbsp;/&nbsp;<a class="el" href="dir_000025.html">do</a></div>
<h1>make_algo_easea.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
00002
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
00004 <span class="comment">// make_algo_easea.h</span>
00005 <span class="comment">// (c) Marc Schoenauer and Pierre Collet, 2002</span>
00006 <span class="comment">/* </span>
00007 <span class="comment"> This library is free software; you can redistribute it and/or</span>
00008 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
00009 <span class="comment"> License as published by the Free Software Foundation; either</span>
00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
00011 <span class="comment"></span>
00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
00015 <span class="comment"> Lesser General Public License for more details.</span>
00016 <span class="comment"></span>
00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
00018 <span class="comment"> License along with this library; if not, write to the Free Software</span>
00019 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
00020 <span class="comment"></span>
00021 <span class="comment"> Contact: Pierre.Collet@polytechnique.fr</span>
00022 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
00023 <span class="comment"> mkeijzer@dhi.dk</span>
00024 <span class="comment"> */</span>
00025 <span class="comment">//-----------------------------------------------------------------------------</span>
00026
00027 <span class="preprocessor">#ifndef _make_algo_easea_h</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#define _make_algo_easea_h</span>
00029 <span class="preprocessor"></span>
00030 <span class="preprocessor">#include &lt;utils/eoData.h&gt;</span> <span class="comment">// for eo_is_a_rate</span>
00031 <span class="comment">// everything tha's needed for the algorithms - SCALAR fitness</span>
00032
00033 <span class="comment">// Selection</span>
00034 <span class="comment">// the eoSelectOne's</span>
00035 <span class="preprocessor">#include &lt;eoRandomSelect.h&gt;</span>
00036 <span class="preprocessor">#include &lt;eoSequentialSelect.h&gt;</span>
00037 <span class="preprocessor">#include &lt;eoDetTournamentSelect.h&gt;</span>
00038 <span class="preprocessor">#include &lt;eoProportionalSelect.h&gt;</span>
00039 <span class="preprocessor">#include &lt;eoFitnessScalingSelect.h&gt;</span>
00040 <span class="preprocessor">#include &lt;eoRankingSelect.h&gt;</span>
00041 <span class="preprocessor">#include &lt;eoStochTournamentSelect.h&gt;</span>
00042 <span class="comment">// #include &lt;eoSelect.h&gt; included in all others</span>
00043
00044 <span class="comment">// Breeders</span>
00045 <span class="preprocessor">#include &lt;eoGeneralBreeder.h&gt;</span>
00046
00047 <span class="comment">// Replacement</span>
00048 <span class="preprocessor">#include "make_general_replacement.h"</span>
00049 <span class="preprocessor">#include "eoMGGReplacement.h"</span>
00050 <span class="preprocessor">#include "eoG3Replacement.h"</span>
00051
00052
00053 <span class="comment">// Algorithm (only this one needed)</span>
00054 <span class="preprocessor">#include &lt;eoEasyEA.h&gt;</span>
00055
00056 <span class="comment">// also need the parser and param includes</span>
00057 <span class="preprocessor">#include &lt;utils/eoParser.h&gt;</span>
00058 <span class="preprocessor">#include &lt;utils/eoState.h&gt;</span>
00059
00060
00061 <span class="comment">/*</span>
00062 <span class="comment"> * This function builds the algorithm (i.e. selection and replacement)</span>
00063 <span class="comment"> * from existing continue (or checkpoint) and operators</span>
00064 <span class="comment"> *</span>
00065 <span class="comment"> * It uses a parser (to get user parameters) and a state (to store the memory)</span>
00066 <span class="comment"> * the last argument is an individual, needed for 2 reasons</span>
00067 <span class="comment"> * it disambiguates the call after instanciations</span>
00068 <span class="comment"> * some operator might need some private information about the indis</span>
00069 <span class="comment"> *</span>
00070 <span class="comment"> * This is why the template is the complete EOT even though only the fitness</span>
00071 <span class="comment"> * is actually templatized here</span>
00072 <span class="comment">*/</span>
00073
00074 <span class="keyword">template</span> &lt;<span class="keyword">class</span> EOT&gt;
00075 <a class="code" href="classeo_algo.html">eoAlgo&lt;EOT&gt;</a> &amp; do_make_algo_scalar(<a class="code" href="classeo_parser.html">eoParser</a>&amp; _parser, <a class="code" href="classeo_state.html">eoState</a>&amp; _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc&lt;EOT&gt;</a>&amp; _eval, <a class="code" href="classeo_continue.html">eoContinue&lt;EOT&gt;</a>&amp; _continue, <a class="code" href="classeo_gen_op.html">eoGenOp&lt;EOT&gt;</a>&amp; _op)
00076 {
00077 <span class="comment">// the selection</span>
00078 <a class="code" href="classeo_value_param.html">eoValueParam&lt;eoParamParamType&gt;</a>&amp; selectionParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(<span class="stringliteral">"DetTour(2)"</span>), <span class="stringliteral">"selection"</span>, <span class="stringliteral">"Selection: Roulette, Ranking(p,e), DetTour(T), StochTour(t), Sequential(ordered/unordered) or EliteSequentialSelect"</span>, <span class="charliteral">'S'</span>, <span class="stringliteral">"Evolution Engine"</span>);
00079
00080 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> &amp; ppSelect = selectionParam.<a class="code" href="classeo_value_param.html#a2">value</a>(); <span class="comment">// std::pair&lt;std::string,std::vector&lt;std::string&gt; &gt;</span>
00081
00082 <a class="code" href="classeo_select_one.html">eoSelectOne&lt;EOT&gt;</a>* select ;
00083 <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"DetTour"</span>))
00084 {
00085 <span class="keywordtype">unsigned</span> detSize;
00086
00087 <span class="keywordflow">if</span> (!ppSelect.second.size()) <span class="comment">// no parameter added</span>
00088 {
00089 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter passed to DetTour, using 2"</span> &lt;&lt; std::endl;
00090 detSize = 2;
00091 <span class="comment">// put back 2 in parameter for consistency (and status file)</span>
00092 ppSelect.second.push_back(std::string(<span class="stringliteral">"2"</span>));
00093 }
00094 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as DetTour(T)</span>
00095 detSize = atoi(ppSelect.second[0].c_str());
00096 select = <span class="keyword">new</span> <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect&lt;EOT&gt;</a>(detSize);
00097 }
00098 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"StochTour"</span>))
00099 {
00100 <span class="keywordtype">double</span> p;
00101 <span class="keywordflow">if</span> (!ppSelect.second.size()) <span class="comment">// no parameter added</span>
00102 {
00103 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter passed to StochTour, using 1"</span> &lt;&lt; std::endl;
00104 p = 1;
00105 <span class="comment">// put back p in parameter for consistency (and status file)</span>
00106 ppSelect.second.push_back(std::string(<span class="stringliteral">"1"</span>));
00107 }
00108 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as DetTour(T)</span>
00109 p = atof(ppSelect.second[0].c_str());
00110
00111 select = <span class="keyword">new</span> <a class="code" href="classeo_stoch_tournament_select.html">eoStochTournamentSelect&lt;EOT&gt;</a>(p);
00112 }
00113 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Ranking"</span>))
00114 {
00115 <span class="keywordtype">double</span> p,e;
00116 <span class="keywordflow">if</span> (ppSelect.second.size()==2) <span class="comment">// 2 parameters: pressure and exponent</span>
00117 {
00118 p = atof(ppSelect.second[0].c_str());
00119 e = atof(ppSelect.second[1].c_str());
00120 }
00121 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.second.size()==1) <span class="comment">// 1 parameter: pressure </span>
00122 {
00123 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no exponent to Ranking, using 1"</span> &lt;&lt; std::endl;
00124 e = 1;
00125 ppSelect.second.push_back(std::string(<span class="stringliteral">"1"</span>));
00126 p = atof(ppSelect.second[0].c_str());
00127 }
00128 <span class="keywordflow">else</span> <span class="comment">// no parameters ... or garbage</span>
00129 {
00130 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter to Ranking, using (2,1)"</span> &lt;&lt; std::endl;
00131 p=2;
00132 e=1;
00133 <span class="comment">// put back in parameter for consistency (and status file)</span>
00134 ppSelect.second.resize(2); <span class="comment">// just in case</span>
00135 ppSelect.second[0] = (std::string(<span class="stringliteral">"2"</span>));
00136 ppSelect.second[1] = (std::string(<span class="stringliteral">"1"</span>));
00137 }
00138 <span class="comment">// check for authorized values</span>
00139 <span class="comment">// pressure in (0,1]</span>
00140 <span class="keywordflow">if</span> ( (p&lt;=1) || (p&gt;2) )
00141 {
00142 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, selective pressure must be in (1,2] in Ranking, using 2\n"</span>;
00143 p=2;
00144 ppSelect.second[0] = (std::string(<span class="stringliteral">"2"</span>));
00145 }
00146 <span class="comment">// exponent &gt;0</span>
00147 <span class="keywordflow">if</span> (e&lt;=0)
00148 {
00149 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, exponent must be positive in Ranking, using 1\n"</span>;
00150 e=1;
00151 ppSelect.second[1] = (std::string(<span class="stringliteral">"1"</span>));
00152 }
00153 <span class="comment">// now we're OK</span>
00154 <a class="code" href="classeo_perf2_worth.html">eoPerf2Worth&lt;EOT&gt;</a> &amp; p2w = _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>( <span class="keyword">new</span> <a class="code" href="classeo_ranking.html">eoRanking&lt;EOT&gt;</a>(p,e) );
00155 select = <span class="keyword">new</span> <a class="code" href="classeo_roulette_worth_select.html">eoRouletteWorthSelect&lt;EOT&gt;</a>(p2w);
00156 }
00157 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Sequential"</span>)) <span class="comment">// one after the other</span>
00158 {
00159 <span class="keywordtype">bool</span> b;
00160 <span class="keywordflow">if</span> (ppSelect.second.size() == 0) <span class="comment">// no argument -&gt; default = ordered</span>
00161 {
00162 b=<span class="keyword">true</span>;
00163 <span class="comment">// put back in parameter for consistency (and status file)</span>
00164 ppSelect.second.push_back(std::string(<span class="stringliteral">"ordered"</span>));
00165 }
00166 <span class="keywordflow">else</span>
00167 b = !(ppSelect.second[0] == std::string(<span class="stringliteral">"unordered"</span>));
00168 select = <span class="keyword">new</span> <a class="code" href="classeo_sequential_select.html">eoSequentialSelect&lt;EOT&gt;</a>(b);
00169 }
00170 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"EliteSequential"</span>)) <span class="comment">// Best first, one after the other in random order afterwards</span>
00171 {
00172 select = <span class="keyword">new</span> <a class="code" href="classeo_elite_sequential_select.html">eoEliteSequentialSelect&lt;EOT&gt;</a>;
00173 }
00174 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Roulette"</span>)) <span class="comment">// no argument (yet)</span>
00175 {
00176 select = <span class="keyword">new</span> <a class="code" href="classeo_proportional_select.html">eoProportionalSelect&lt;EOT&gt;</a>;
00177 }
00178 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Random"</span>)) <span class="comment">// no argument</span>
00179 {
00180 select = <span class="keyword">new</span> <a class="code" href="classeo_random_select.html">eoRandomSelect&lt;EOT&gt;</a>;
00181 }
00182 <span class="keywordflow">else</span>
00183 {
00184 std::string stmp = std::string(<span class="stringliteral">"Invalid selection: "</span>) + ppSelect.first;
00185 <span class="keywordflow">throw</span> std::runtime_error(stmp.c_str());
00186 }
00187
00188 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(select);
00189
00190 <span class="comment">// the number of offspring </span>
00191 <a class="code" href="classeo_value_param.html">eoValueParam&lt;eoHowMany&gt;</a>&amp; offspringRateParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a>(1.0), <span class="stringliteral">"nbOffspring"</span>, <span class="stringliteral">"Nb of offspring (percentage or absolute)"</span>, <span class="charliteral">'O'</span>, <span class="stringliteral">"Evolution Engine"</span>);
00192
00194 <span class="comment">// the replacement</span>
00196 <span class="comment"></span>
00225 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> &amp; replacementParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(<span class="stringliteral">"General"</span>), <span class="stringliteral">"replacement"</span>, <span class="stringliteral">"Type of replacement: General, or Generational, ESComma, ESPlus, SSGA(T), EP(T), G3, MGG(T)"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Evolution Engine"</span>).value();
00226 <span class="comment">// the pointer</span>
00227 <a class="code" href="classeo_replacement.html">eoReplacement&lt;EOT&gt;</a> * ptReplace;
00228
00229 <span class="comment">// first, separate G3 and MGG</span>
00230 <span class="comment">// maybe one day we have a common class - but is it really necessary???</span>
00231 <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"G3"</span>))
00232 {
00233 <span class="comment">// reduce the parents: by default, survive parents = -2 === 2 parents die</span>
00234 <a class="code" href="classeo_how_many.html">eoHowMany</a> surviveParents = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a>(-2,<span class="keyword">false</span>), <span class="stringliteral">"surviveParents"</span>, <span class="stringliteral">"Nb of surviving parents (percentage or absolute)"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Evolution Engine / Replacement"</span>).value();
00235 <span class="comment">// at the moment, this is the only argument</span>
00236 ptReplace = <span class="keyword">new</span> <a class="code" href="classeo_g3_replacement.html">eoG3Replacement&lt;EOT&gt;</a>(-surviveParents); <span class="comment">// must receive nb of eliminated parets!</span>
00237 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptReplace);
00238 }
00239 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"MGG"</span>))
00240 {
00241 <span class="keywordtype">float</span> t;
00242 <span class="keywordtype">unsigned</span> tSize;
00243 <span class="comment">// reduce the parents: by default, survive parents = -2 === 2 parents die</span>
00244 <a class="code" href="classeo_how_many.html">eoHowMany</a> surviveParents = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a>(-2,<span class="keyword">false</span>), <span class="stringliteral">"surviveParents"</span>, <span class="stringliteral">"Nb of surviving parents (percentage or absolute)"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Evolution Engine / Replacement"</span>).value();
00245 <span class="comment">// the tournament size</span>
00246 <span class="keywordflow">if</span> (!replacementParam.second.size()) <span class="comment">// no parameter added</span>
00247 {
00248 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter passed to MGG replacement, using 2"</span> &lt;&lt; std::endl;
00249 tSize = 2;
00250 <span class="comment">// put back 2 in parameter for consistency (and status file)</span>
00251 replacementParam.second.push_back(std::string(<span class="stringliteral">"2"</span>));
00252 }
00253 <span class="keywordflow">else</span>
00254 {
00255 t = atof(replacementParam.second[0].c_str());
00256 <span class="keywordflow">if</span> (t&gt;=2)
00257 { <span class="comment">// build the appropriate deafult value</span>
00258 tSize = unsigned(t);
00259 }
00260 <span class="keywordflow">else</span>
00261 {
00262 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Sorry, only deterministic tournament available at the moment"</span>);
00263 }
00264 }
00265 ptReplace = <span class="keyword">new</span> <a class="code" href="classeo_m_g_g_replacement.html">eoMGGReplacement&lt;EOT&gt;</a>(-surviveParents, tSize);
00266 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptReplace);
00267 }
00268 <span class="keywordflow">else</span> { <span class="comment">// until the end of what was the only loop/switch</span>
00269
00270 <span class="comment">// the default deafult values</span>
00271 <a class="code" href="classeo_how_many.html">eoHowMany</a> elite (0.0);
00272 <span class="keywordtype">bool</span> strongElitism (<span class="keyword">false</span>);
00273 <a class="code" href="classeo_how_many.html">eoHowMany</a> surviveParents (0.0);
00274 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> reduceParentType (<span class="stringliteral">"Deterministic"</span>);
00275 <a class="code" href="classeo_how_many.html">eoHowMany</a> surviveOffspring (1.0);
00276 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> reduceOffspringType (<span class="stringliteral">"Deterministic"</span>);
00277 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> reduceFinalType (<span class="stringliteral">"Deterministic"</span>);
00278
00279 <span class="comment">// depending on the value entered by the user, change some of the above</span>
00280 <span class="keywordtype">double</span> t;
00281
00282 <span class="comment">// ---------- General</span>
00283 <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"General"</span>))
00284 {
00285 ; <span class="comment">// defaults OK</span>
00286 }
00287 <span class="comment">// ---------- ESComma</span>
00288 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"ESComma"</span>))
00289 {
00290 ; <span class="comment">// OK too</span>
00291 }
00292 <span class="comment">// ---------- ESPlus</span>
00293 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"ESPlus"</span>))
00294 {
00295 surviveParents = <a class="code" href="classeo_how_many.html">eoHowMany</a>(1.0);
00296 }
00297 <span class="comment">// ---------- Generational</span>
00298 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"Generational"</span>))
00299 {
00300 ; <span class="comment">// OK too (we should check nb of offspring)</span>
00301 }
00302 <span class="comment">// ---------- EP</span>
00303 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"EP"</span>))
00304 {
00305 <span class="keywordflow">if</span> (!replacementParam.second.size()) <span class="comment">// no parameter added</span>
00306 {
00307 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter passed to EP replacement, using 6"</span> &lt;&lt; std::endl;
00308 <span class="comment">// put back 6 in parameter for consistency (and status file)</span>
00309 replacementParam.second.push_back(std::string(<span class="stringliteral">"6"</span>));
00310 }
00311 <span class="comment">// by coincidence, the syntax for the EP reducer is the same than here:</span>
00312 reduceFinalType = replacementParam;
00313 surviveParents = <a class="code" href="classeo_how_many.html">eoHowMany</a>(1.0);
00314 }
00315 <span class="comment">// ---------- SSGA</span>
00316 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (replacementParam.first == std::string(<span class="stringliteral">"SSGA"</span>))
00317 {
00318 <span class="keywordflow">if</span> (!replacementParam.second.size()) <span class="comment">// no parameter added</span>
00319 {
00320 std::cerr &lt;&lt; <span class="stringliteral">"WARNING, no parameter passed to SSGA replacement, using 2"</span> &lt;&lt; std::endl;
00321 <span class="comment">// put back 2 in parameter for consistency (and status file)</span>
00322 replacementParam.second.push_back(std::string(<span class="stringliteral">"2"</span>));
00323 reduceParentType = <a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(std::string(<span class="stringliteral">"DetTour(2)"</span>));
00324 }
00325 <span class="keywordflow">else</span>
00326 {
00327 t = atof(replacementParam.second[0].c_str());
00328 <span class="keywordflow">if</span> (t&gt;=2)
00329 { <span class="comment">// build the appropriate deafult value</span>
00330 reduceParentType = <a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(std::string(<span class="stringliteral">"DetTour("</span>) + replacementParam.second[0].c_str() + <span class="stringliteral">")"</span>);
00331 }
00332 <span class="keywordflow">else</span> <span class="comment">// check for [0.5,1] will be made in make_general_replacement</span>
00333 { <span class="comment">// build the appropriate deafult value</span>
00334 reduceParentType = <a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(std::string(<span class="stringliteral">"StochTour("</span>) + replacementParam.second[0].c_str() + <span class="stringliteral">")"</span>);
00335 }
00336 }
00337 <span class="comment">// </span>
00338 surviveParents = <a class="code" href="classeo_how_many.html">eoHowMany</a>(-1);
00339 surviveOffspring = <a class="code" href="classeo_how_many.html">eoHowMany</a>(1);
00340 }
00341 <span class="keywordflow">else</span> <span class="comment">// no replacement recognized</span>
00342 {
00343 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid replacement type "</span> + replacementParam.first);
00344 }
00345
00346 ptReplace = &amp; make_general_replacement&lt;EOT&gt;(
00347 _parser, _state, elite, strongElitism, surviveParents, reduceParentType, surviveOffspring, reduceOffspringType, reduceFinalType);
00348
00349 } <span class="comment">// end of the ugly construct due to G3 and MGG - totaly heterogeneous at the moment</span>
00350
00351
00353 <span class="comment">// the general breeder</span>
00355 <span class="comment"></span> <a class="code" href="classeo_general_breeder.html">eoGeneralBreeder&lt;EOT&gt;</a> *breed =
00356 <span class="keyword">new</span> <a class="code" href="classeo_general_breeder.html">eoGeneralBreeder&lt;EOT&gt;</a>(*select, _op, offspringRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00357 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(breed);
00358
00360 <span class="comment">// now the eoEasyEA</span>
00362 <span class="comment"></span> <a class="code" href="classeo_algo.html">eoAlgo&lt;EOT&gt;</a> *algo = <span class="keyword">new</span> <a class="code" href="classeo_easy_e_a.html">eoEasyEA&lt;EOT&gt;</a>(_continue, _eval, *breed, *ptReplace);
00363 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(algo);
00364 <span class="comment">// that's it!</span>
00365 <span class="keywordflow">return</span> *algo;
00366 }
00367
00368 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>