git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
326 lines
26 KiB
HTML
326 lines
26 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_scalar.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 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_000000.html">src</a> / <a class="el" href="dir_000025.html">do</a></div>
|
|
<h1>make_algo_scalar.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_scalar.h</span>
|
|
00005 <span class="comment">// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001</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: todos@geneura.ugr.es, http://geneura.ugr.es</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_scalar_h</span>
|
|
00028 <span class="preprocessor"></span><span class="preprocessor">#define _make_algo_scalar_h</span>
|
|
00029 <span class="preprocessor"></span>
|
|
00030 <span class="preprocessor">#include <utils/eoData.h></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 <eoRandomSelect.h></span>
|
|
00036 <span class="preprocessor">#include <eoSequentialSelect.h></span>
|
|
00037 <span class="preprocessor">#include <eoDetTournamentSelect.h></span>
|
|
00038 <span class="preprocessor">#include <eoProportionalSelect.h></span>
|
|
00039 <span class="preprocessor">#include <eoFitnessScalingSelect.h></span>
|
|
00040 <span class="preprocessor">#include <eoRankingSelect.h></span>
|
|
00041 <span class="preprocessor">#include <eoStochTournamentSelect.h></span>
|
|
00042 <span class="preprocessor">#include <eoSharingSelect.h></span>
|
|
00043 <span class="preprocessor">#include <utils/eoDistance.h></span>
|
|
00044
|
|
00045 <span class="comment">// Breeders</span>
|
|
00046 <span class="preprocessor">#include <eoGeneralBreeder.h></span>
|
|
00047
|
|
00048 <span class="comment">// Replacement</span>
|
|
00049 <span class="comment">// #include <eoReplacement.h></span>
|
|
00050 <span class="preprocessor">#include <eoMergeReduce.h></span>
|
|
00051 <span class="preprocessor">#include <eoReduceMerge.h></span>
|
|
00052 <span class="preprocessor">#include <eoSurviveAndDie.h></span>
|
|
00053
|
|
00054 <span class="comment">// distance</span>
|
|
00055 <span class="preprocessor">#include <utils/eoDistance.h></span>
|
|
00056
|
|
00057 <span class="comment">// Algorithm (only this one needed)</span>
|
|
00058 <span class="preprocessor">#include <eoEasyEA.h></span>
|
|
00059
|
|
00060 <span class="comment">// also need the parser and param includes</span>
|
|
00061 <span class="preprocessor">#include <utils/eoParser.h></span>
|
|
00062 <span class="preprocessor">#include <utils/eoState.h></span>
|
|
00063
|
|
00064
|
|
00065 <span class="comment">/*</span>
|
|
00066 <span class="comment"> * This function builds the algorithm (i.e. selection and replacement)</span>
|
|
00067 <span class="comment"> * from existing continue (or checkpoint) and operators</span>
|
|
00068 <span class="comment"> *</span>
|
|
00069 <span class="comment"> * It uses a parser (to get user parameters) and a state (to store the memory)</span>
|
|
00070 <span class="comment"> * the last argument is an individual, needed for 2 reasons</span>
|
|
00071 <span class="comment"> * it disambiguates the call after instanciations</span>
|
|
00072 <span class="comment"> * some operator might need some private information about the indis</span>
|
|
00073 <span class="comment"> *</span>
|
|
00074 <span class="comment"> * This is why the template is the complete EOT even though only the fitness</span>
|
|
00075 <span class="comment"> * is actually templatized here</span>
|
|
00076 <span class="comment">*/</span>
|
|
00077
|
|
00078
|
|
00079 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
|
00080 <a class="code" href="classeo_algo.html">eoAlgo<EOT></a> & do_make_algo_scalar(<a class="code" href="classeo_parser.html">eoParser</a>& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<EOT></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<EOT></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a>& _op, <a class="code" href="classeo_distance.html">eoDistance<EOT></a> * _dist = NULL)
|
|
00081 {
|
|
00082 <span class="comment">// the selection : help and comment depend on whether or not a distance is passed</span>
|
|
00083 std::string comment;
|
|
00084 <span class="keywordflow">if</span> (_dist == NULL)
|
|
00085 comment = <span class="stringliteral">"Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e) or Sequential(ordered/unordered)"</span>;
|
|
00086 <span class="keywordflow">else</span>
|
|
00087 comment = <span class="stringliteral">"Selection: DetTour(T), StochTour(t), Roulette, Ranking(p,e), Sharing(sigma_share) or Sequential(ordered/unordered)"</span>;
|
|
00088
|
|
00089 <a class="code" href="classeo_value_param.html">eoValueParam<eoParamParamType></a>& 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>, comment, <span class="charliteral">'S'</span>, <span class="stringliteral">"Evolution Engine"</span>);
|
|
00090
|
|
00091 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> & ppSelect = selectionParam.<a class="code" href="classeo_value_param.html#a2">value</a>(); <span class="comment">// std::pair<std::string,std::vector<std::string> ></span>
|
|
00092
|
|
00093 <a class="code" href="classeo_select_one.html">eoSelectOne<EOT></a>* select ;
|
|
00094 <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"DetTour"</span>))
|
|
00095 {
|
|
00096 <span class="keywordtype">unsigned</span> detSize;
|
|
00097
|
|
00098 <span class="keywordflow">if</span> (!ppSelect.second.size()) <span class="comment">// no parameter added</span>
|
|
00099 {
|
|
00100 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to DetTour, using 2"</span> << std::endl;
|
|
00101 detSize = 2;
|
|
00102 <span class="comment">// put back 2 in parameter for consistency (and status file)</span>
|
|
00103 ppSelect.second.push_back(std::string(<span class="stringliteral">"2"</span>));
|
|
00104 }
|
|
00105 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as DetTour(T)</span>
|
|
00106 detSize = atoi(ppSelect.second[0].c_str());
|
|
00107 select = <span class="keyword">new</span> <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<EOT></a>(detSize);
|
|
00108 }
|
|
00109 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Sharing"</span>))
|
|
00110 {
|
|
00111 <span class="keywordtype">double</span> nicheSize;
|
|
00112
|
|
00113 <span class="keywordflow">if</span> (!ppSelect.second.size()) <span class="comment">// no parameter added</span>
|
|
00114 {
|
|
00115 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to Sharing, using 0.5"</span> << std::endl;
|
|
00116 nicheSize = 0.5;
|
|
00117 <span class="comment">// put back 2 in parameter for consistency (and status file)</span>
|
|
00118 ppSelect.second.push_back(std::string(<span class="stringliteral">"0.5"</span>));
|
|
00119 }
|
|
00120 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as DetTour(T)</span>
|
|
00121 nicheSize = atof(ppSelect.second[0].c_str());
|
|
00122 <span class="keywordflow">if</span> (_dist == NULL) <span class="comment">// no distance</span>
|
|
00123 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"You didn't specify a distance when calling make_algo_scalar and using sharing"</span>);
|
|
00124 select = <span class="keyword">new</span> <a class="code" href="classeo_sharing_select.html">eoSharingSelect<EOT></a>(nicheSize, *_dist);
|
|
00125 }
|
|
00126 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"StochTour"</span>))
|
|
00127 {
|
|
00128 <span class="keywordtype">double</span> p;
|
|
00129 <span class="keywordflow">if</span> (!ppSelect.second.size()) <span class="comment">// no parameter added</span>
|
|
00130 {
|
|
00131 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to StochTour, using 1"</span> << std::endl;
|
|
00132 p = 1;
|
|
00133 <span class="comment">// put back p in parameter for consistency (and status file)</span>
|
|
00134 ppSelect.second.push_back(std::string(<span class="stringliteral">"1"</span>));
|
|
00135 }
|
|
00136 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as DetTour(T)</span>
|
|
00137 p = atof(ppSelect.second[0].c_str());
|
|
00138
|
|
00139 select = <span class="keyword">new</span> <a class="code" href="classeo_stoch_tournament_select.html">eoStochTournamentSelect<EOT></a>(p);
|
|
00140 }
|
|
00141 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.first == std::string(<span class="stringliteral">"Ranking"</span>))
|
|
00142 {
|
|
00143 <span class="keywordtype">double</span> p,e;
|
|
00144 <span class="keywordflow">if</span> (ppSelect.second.size()==2) <span class="comment">// 2 parameters: pressure and exponent</span>
|
|
00145 {
|
|
00146 p = atof(ppSelect.second[0].c_str());
|
|
00147 e = atof(ppSelect.second[1].c_str());
|
|
00148 }
|
|
00149 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppSelect.second.size()==1) <span class="comment">// 1 parameter: pressure </span>
|
|
00150 {
|
|
00151 std::cerr << <span class="stringliteral">"WARNING, no exponent to Ranking, using 1"</span> << std::endl;
|
|
00152 e = 1;
|
|
00153 ppSelect.second.push_back(std::string(<span class="stringliteral">"1"</span>));
|
|
00154 p = atof(ppSelect.second[0].c_str());
|
|
00155 }
|
|
00156 <span class="keywordflow">else</span> <span class="comment">// no parameters ... or garbage</span>
|
|
00157 {
|
|
00158 std::cerr << <span class="stringliteral">"WARNING, no parameter to Ranking, using (2,1)"</span> << std::endl;
|
|
00159 p=2;
|
|
00160 e=1;
|
|
00161 <span class="comment">// put back in parameter for consistency (and status file)</span>
|
|
00162 ppSelect.second.resize(2); <span class="comment">// just in case</span>
|
|
00163 ppSelect.second[0] = (std::string(<span class="stringliteral">"2"</span>));
|
|
00164 ppSelect.second[1] = (std::string(<span class="stringliteral">"1"</span>));
|
|
00165 }
|
|
00166 <span class="comment">// check for authorized values</span>
|
|
00167 <span class="comment">// pressure in (0,1]</span>
|
|
00168 <span class="keywordflow">if</span> ( (p<=1) || (p>2) )
|
|
00169 {
|
|
00170 std::cerr << <span class="stringliteral">"WARNING, selective pressure must be in (0,1] in Ranking, using 2\n"</span>;
|
|
00171 p=2;
|
|
00172 ppSelect.second[0] = (std::string(<span class="stringliteral">"2"</span>));
|
|
00173 }
|
|
00174 <span class="comment">// exponent >0</span>
|
|
00175 <span class="keywordflow">if</span> (e<=0)
|
|
00176 {
|
|
00177 std::cerr << <span class="stringliteral">"WARNING, exponent must be positive in Ranking, using 1\n"</span>;
|
|
00178 e=1;
|
|
00179 ppSelect.second[1] = (std::string(<span class="stringliteral">"1"</span>));
|
|
00180 }
|
|
00181 <span class="comment">// now we're OK</span>
|
|
00182 <a class="code" href="classeo_perf2_worth.html">eoPerf2Worth<EOT></a> & 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<EOT></a>(p,e) );
|
|
00183 select = <span class="keyword">new</span> <a class="code" href="classeo_roulette_worth_select.html">eoRouletteWorthSelect<EOT></a>(p2w);
|
|
00184 }
|
|
00185 <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>
|
|
00186 {
|
|
00187 <span class="keywordtype">bool</span> b;
|
|
00188 <span class="keywordflow">if</span> (ppSelect.second.size() == 0) <span class="comment">// no argument -> default = ordered</span>
|
|
00189 {
|
|
00190 b=<span class="keyword">true</span>;
|
|
00191 <span class="comment">// put back in parameter for consistency (and status file)</span>
|
|
00192 ppSelect.second.push_back(std::string(<span class="stringliteral">"ordered"</span>));
|
|
00193 }
|
|
00194 <span class="keywordflow">else</span>
|
|
00195 b = !(ppSelect.second[0] == std::string(<span class="stringliteral">"unordered"</span>));
|
|
00196 select = <span class="keyword">new</span> <a class="code" href="classeo_sequential_select.html">eoSequentialSelect<EOT></a>(b);
|
|
00197 }
|
|
00198 <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>
|
|
00199 {
|
|
00200 select = <span class="keyword">new</span> <a class="code" href="classeo_proportional_select.html">eoProportionalSelect<EOT></a>;
|
|
00201 }
|
|
00202 <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>
|
|
00203 {
|
|
00204 select = <span class="keyword">new</span> <a class="code" href="classeo_random_select.html">eoRandomSelect<EOT></a>;
|
|
00205 }
|
|
00206 <span class="keywordflow">else</span>
|
|
00207 {
|
|
00208 std::string stmp = std::string(<span class="stringliteral">"Invalid selection: "</span>) + ppSelect.first;
|
|
00209 <span class="keywordflow">throw</span> std::runtime_error(stmp.c_str());
|
|
00210 }
|
|
00211
|
|
00212 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(select);
|
|
00213
|
|
00214 <span class="comment">// the number of offspring </span>
|
|
00215 <a class="code" href="classeo_value_param.html">eoValueParam<eoHowMany></a>& 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>);
|
|
00216
|
|
00217 <span class="comment">// the replacement</span>
|
|
00218 <a class="code" href="classeo_value_param.html">eoValueParam<eoParamParamType></a>& 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">"Comma"</span>), <span class="stringliteral">"replacement"</span>, <span class="stringliteral">"Replacement: Comma, Plus or EPTour(T), SSGAWorst, SSGADet(T), SSGAStoch(t)"</span>, <span class="charliteral">'R'</span>, <span class="stringliteral">"Evolution Engine"</span>);
|
|
00219
|
|
00220 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> & ppReplace = replacementParam.<a class="code" href="classeo_value_param.html#a2">value</a>(); <span class="comment">// std::pair<std::string,std::vector<std::string> ></span>
|
|
00221
|
|
00222 <a class="code" href="classeo_replacement.html">eoReplacement<EOT></a>* replace ;
|
|
00223 <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"Comma"</span>)) <span class="comment">// Comma == generational</span>
|
|
00224 {
|
|
00225 replace = <span class="keyword">new</span> <a class="code" href="classeo_comma_replacement.html">eoCommaReplacement<EOT></a>;
|
|
00226 }
|
|
00227 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"Plus"</span>))
|
|
00228 {
|
|
00229 replace = <span class="keyword">new</span> <a class="code" href="classeo_plus_replacement.html">eoPlusReplacement<EOT></a>;
|
|
00230 }
|
|
00231 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"EPTour"</span>))
|
|
00232 {
|
|
00233 <span class="keywordtype">unsigned</span> detSize;
|
|
00234
|
|
00235 <span class="keywordflow">if</span> (!ppReplace.second.size()) <span class="comment">// no parameter added</span>
|
|
00236 {
|
|
00237 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to EPTour, using 6"</span> << std::endl;
|
|
00238 detSize = 6;
|
|
00239 <span class="comment">// put back in parameter for consistency (and status file)</span>
|
|
00240 ppReplace.second.push_back(std::string(<span class="stringliteral">"6"</span>));
|
|
00241 }
|
|
00242 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as EPTour(T)</span>
|
|
00243 detSize = atoi(ppSelect.second[0].c_str());
|
|
00244
|
|
00245 replace = <span class="keyword">new</span> <a class="code" href="classeo_e_p_replacement.html">eoEPReplacement<EOT></a>(detSize);
|
|
00246 }
|
|
00247 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"SSGAWorst"</span>))
|
|
00248 {
|
|
00249 replace = <span class="keyword">new</span> <a class="code" href="classeo_s_s_g_a_worse_replacement.html">eoSSGAWorseReplacement<EOT></a>;
|
|
00250 }
|
|
00251 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"SSGADet"</span>))
|
|
00252 {
|
|
00253 <span class="keywordtype">unsigned</span> detSize;
|
|
00254
|
|
00255 <span class="keywordflow">if</span> (!ppReplace.second.size()) <span class="comment">// no parameter added</span>
|
|
00256 {
|
|
00257 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to SSGADet, using 2"</span> << std::endl;
|
|
00258 detSize = 2;
|
|
00259 <span class="comment">// put back in parameter for consistency (and status file)</span>
|
|
00260 ppReplace.second.push_back(std::string(<span class="stringliteral">"2"</span>));
|
|
00261 }
|
|
00262 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as SSGADet(T)</span>
|
|
00263 detSize = atoi(ppSelect.second[0].c_str());
|
|
00264
|
|
00265 replace = <span class="keyword">new</span> <a class="code" href="classeo_s_s_g_a_det_tournament_replacement.html">eoSSGADetTournamentReplacement<EOT></a>(detSize);
|
|
00266 }
|
|
00267 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (ppReplace.first == std::string(<span class="stringliteral">"SSGAStoch"</span>))
|
|
00268 {
|
|
00269 <span class="keywordtype">double</span> p;
|
|
00270 <span class="keywordflow">if</span> (!ppReplace.second.size()) <span class="comment">// no parameter added</span>
|
|
00271 {
|
|
00272 std::cerr << <span class="stringliteral">"WARNING, no parameter passed to SSGAStoch, using 1"</span> << std::endl;
|
|
00273 p = 1;
|
|
00274 <span class="comment">// put back in parameter for consistency (and status file)</span>
|
|
00275 ppReplace.second.push_back(std::string(<span class="stringliteral">"1"</span>));
|
|
00276 }
|
|
00277 <span class="keywordflow">else</span> <span class="comment">// parameter passed by user as SSGADet(T)</span>
|
|
00278 p = atof(ppSelect.second[0].c_str());
|
|
00279
|
|
00280 replace = <span class="keyword">new</span> <a class="code" href="classeo_s_s_g_a_stoch_tournament_replacement.html">eoSSGAStochTournamentReplacement<EOT></a>(p);
|
|
00281 }
|
|
00282 <span class="keywordflow">else</span>
|
|
00283 {
|
|
00284 std::string stmp = std::string(<span class="stringliteral">"Invalid replacement: "</span>) + ppReplace.first;
|
|
00285 <span class="keywordflow">throw</span> std::runtime_error(stmp.c_str());
|
|
00286 }
|
|
00287
|
|
00288 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(replace);
|
|
00289
|
|
00290 <span class="comment">// adding weak elitism</span>
|
|
00291 <a class="code" href="classeo_value_param.html">eoValueParam<bool></a>& weakElitismParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">false</span>, <span class="stringliteral">"weakElitism"</span>, <span class="stringliteral">"Old best parent replaces new worst offspring *if necessary*"</span>, <span class="charliteral">'w'</span>, <span class="stringliteral">"Evolution Engine"</span>);
|
|
00292 <span class="keywordflow">if</span> (weakElitismParam.<a class="code" href="classeo_value_param.html#a2">value</a>())
|
|
00293 {
|
|
00294 <a class="code" href="classeo_replacement.html">eoReplacement<EOT></a> *replaceTmp = replace;
|
|
00295 replace = <span class="keyword">new</span> <a class="code" href="classeo_weak_elitist_replacement.html">eoWeakElitistReplacement<EOT></a>(*replaceTmp);
|
|
00296 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(replace);
|
|
00297 }
|
|
00298
|
|
00299 <span class="comment">// the general breeder</span>
|
|
00300 <a class="code" href="classeo_general_breeder.html">eoGeneralBreeder<EOT></a> *breed =
|
|
00301 <span class="keyword">new</span> <a class="code" href="classeo_general_breeder.html">eoGeneralBreeder<EOT></a>(*select, _op, offspringRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
|
|
00302 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(breed);
|
|
00303
|
|
00304 <span class="comment">// now the eoEasyEA</span>
|
|
00305 <a class="code" href="classeo_algo.html">eoAlgo<EOT></a> *algo = <span class="keyword">new</span> <a class="code" href="classeo_easy_e_a.html">eoEasyEA<EOT></a>(_continue, _eval, *breed, *replace);
|
|
00306 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(algo);
|
|
00307 <span class="comment">// that's it!</span>
|
|
00308 <span class="keywordflow">return</span> *algo;
|
|
00309 }
|
|
00310
|
|
00311 <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
|
|
<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>
|