Paradiseo-eo sources added

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
legrand 2006-12-12 14:49:08 +00:00
commit c3aec878e5
3609 changed files with 342772 additions and 0 deletions

View file

@ -0,0 +1,303 @@
<!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_op.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_000010.html">es</a></div>
<h1>es/make_op.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_op.h - the real-valued version</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_op_h</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#define _make_op_h</span>
00029 <span class="preprocessor"></span>
00030 <span class="comment">// the operators</span>
00031 <span class="preprocessor">#include &lt;eoOp.h&gt;</span>
00032 <span class="preprocessor">#include &lt;eoGenOp.h&gt;</span>
00033 <span class="preprocessor">#include &lt;eoCloneOps.h&gt;</span>
00034 <span class="preprocessor">#include &lt;eoOpContainer.h&gt;</span>
00035 <span class="comment">// combinations of simple eoOps (eoMonOp and eoQuadOp)</span>
00036 <span class="preprocessor">#include &lt;eoProportionalCombinedOp.h&gt;</span>
00037
00038 <span class="comment">// the specialized Real stuff</span>
00039 <span class="preprocessor">#include &lt;es/eoReal.h&gt;</span>
00040 <span class="preprocessor">#include &lt;es/eoRealInitBounded.h&gt;</span>
00041 <span class="preprocessor">#include &lt;es/eoRealOp.h&gt;</span>
00042 <span class="preprocessor">#include &lt;es/eoNormalMutation.h&gt;</span>
00043 <span class="comment">// also need the parser and param includes</span>
00044 <span class="preprocessor">#include &lt;utils/eoParser.h&gt;</span>
00045 <span class="preprocessor">#include &lt;utils/eoState.h&gt;</span>
00046
00047
00048 <span class="comment">/*</span>
00049 <span class="comment"> * This function builds the operators that will be applied to the eoReal</span>
00050 <span class="comment"> *</span>
00051 <span class="comment"> * It uses a parser (to get user parameters) and a state (to store the memory)</span>
00052 <span class="comment"> * the last argument is an individual, needed for 2 reasons</span>
00053 <span class="comment"> * it disambiguates the call after instanciations</span>
00054 <span class="comment"> * some operator might need some private information about the indis</span>
00055 <span class="comment"> *</span>
00056 <span class="comment"> * This is why the template is the complete EOT even though only the fitness</span>
00057 <span class="comment"> * is actually templatized here: the following only applies to bitstrings</span>
00058 <span class="comment"> *</span>
00059 <span class="comment"> * Note : the last parameter is an eoInit: if some operator needs some info</span>
00060 <span class="comment"> * about the gneotypes, the init has it all (e.g. bounds, ...)</span>
00061 <span class="comment"> * Simply do</span>
00062 <span class="comment"> * EOT myEO;</span>
00063 <span class="comment"> * _init(myEO);</span>
00064 <span class="comment"> * and myEO is then an ACTUAL object</span>
00065 <span class="comment">*/</span>
00066 <span class="keyword">template</span> &lt;<span class="keyword">class</span> EOT&gt;
00067 <a class="code" href="classeo_gen_op.html">eoGenOp&lt;EOT&gt;</a> &amp; do_make_op(<a class="code" href="classeo_parameter_loader.html">eoParameterLoader</a>&amp; _parser, <a class="code" href="classeo_state.html">eoState</a>&amp; _state, <a class="code" href="classeo_init.html">eoInit&lt;EOT&gt;</a>&amp; _init)
00068 {
00069 <span class="comment">// First, decide whether the objective variables are bounded</span>
00070 <a class="code" href="classeo_value_param.html">eoValueParam&lt;eoParamParamType&gt;</a>&amp; boundsParam
00071 = _parser.getORcreateParam(<a class="code" href="classeo_param_param_type.html">eoParamParamType</a>(<span class="stringliteral">"(0,1)"</span>), <span class="stringliteral">"objectBounds"</span>,
00072 <span class="stringliteral">"Bounds for variables (unbounded if absent)"</span>,
00073 <span class="charliteral">'B'</span>, <span class="stringliteral">"Genetic Operators"</span>);
00074
00075 <span class="comment">// get initisalizer size == std::vector size</span>
00076 <span class="comment">// eoRealInitBounded&lt;EOT&gt; * realInit = (eoRealInitBounded&lt;EOT&gt;*)(&amp;_init);</span>
00077 <span class="comment">// unsigned vecSize = realInit-&gt;theBounds().size();</span>
00078
00079 <span class="comment">// get std::vector size: safer???</span>
00080 <a class="code" href="struct_dummy.html">EOT</a> eoTmp;
00081 _init(eoTmp);
00082 <span class="keywordtype">unsigned</span> vecSize = eoTmp.size();
00083
00084 <span class="comment">// the bounds pointer</span>
00085 <a class="code" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a> * ptBounds;
00086 <span class="keywordflow">if</span> (_parser.<a class="code" href="classeo_parameter_loader.html#a2">isItThere</a>(boundsParam)) <span class="comment">// otherwise, no bounds</span>
00087 {
00091 <a class="code" href="classeo_param_param_type.html">eoParamParamType</a> &amp; ppBounds = boundsParam.<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>
00092 <span class="comment">// transform into a std::vector&lt;double&gt;</span>
00093 std::vector&lt;double&gt; v;
00094 std::vector&lt;std::string&gt;::iterator it;
00095 <span class="keywordflow">for</span> (it=ppBounds.second.begin(); it&lt;ppBounds.second.end(); it++)
00096 {
00097 istrstream is(it-&gt;c_str());
00098 <span class="keywordtype">double</span> r;
00099 is &gt;&gt; r;
00100 v.push_back(r);
00101 }
00102 <span class="comment">// now create the eoRealVectorBounds object</span>
00103 <span class="keywordflow">if</span> (v.size() == 2) <span class="comment">// a min and a max for all variables</span>
00104 ptBounds = <span class="keyword">new</span> <a class="code" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a>(vecSize, v[0], v[1]);
00105 <span class="keywordflow">else</span> <span class="comment">// no time now</span>
00106 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Sorry, only unique bounds for all variables implemented at the moment. Come back later"</span>);
00107 <span class="comment">// we need to give ownership of this pointer to somebody</span>
00109 <span class="comment"></span> }
00110 <span class="keywordflow">else</span> <span class="comment">// no param for bounds was given</span>
00111 ptBounds = <span class="keyword">new</span> <a class="code" href="classeo_real_vector_no_bounds.html">eoRealVectorNoBounds</a>(vecSize); <span class="comment">// DON'T USE eoDummyVectorNoBounds</span>
00112 <span class="comment">// as it does not have any dimension</span>
00113
00114 <span class="comment">// this is a temporary version(!),</span>
00115 <span class="comment">// while Maarten codes the full tree-structured general operator input</span>
00116 <span class="comment">// BTW we must leave that simple version available somehow, as it is the one</span>
00117 <span class="comment">// that 90% people use!</span>
00118 <a class="code" href="classeo_value_param.html">eoValueParam&lt;std::string&gt;</a>&amp; operatorParam
00119 = _parser.getORcreateParam(std::string(<span class="stringliteral">"SGA"</span>), <span class="stringliteral">"operator"</span>,
00120 <span class="stringliteral">"Description of the operator (SGA only now)"</span>,
00121 <span class="charliteral">'o'</span>, <span class="stringliteral">"Genetic Operators"</span>);
00122
00123 <span class="keywordflow">if</span> (operatorParam.value() != std::string(<span class="stringliteral">"SGA"</span>))
00124 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Sorry, only SGA-like operator available right now\n"</span>);
00125
00126 <span class="comment">// now we read Pcross and Pmut,</span>
00127 <span class="comment">// the relative weights for all crossovers -&gt; proportional choice</span>
00128 <span class="comment">// the relative weights for all mutations -&gt; proportional choice</span>
00129 <span class="comment">// and create the eoGenOp that is exactly</span>
00130 <span class="comment">// crossover with pcross + mutation with pmut</span>
00131
00132 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; pCrossParam
00133 = _parser.getORcreateParam(0.6, <span class="stringliteral">"pCross"</span>, <span class="stringliteral">"Probability of Crossover"</span>,
00134 <span class="charliteral">'C'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00135 <span class="comment">// minimum check</span>
00136 <span class="keywordflow">if</span> ( (pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) || (pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &gt; 1) )
00137 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pCross"</span>);
00138
00139 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; pMutParam
00140 = _parser.getORcreateParam(0.1, <span class="stringliteral">"pMut"</span>, <span class="stringliteral">"Probability of Mutation"</span>,
00141 <span class="charliteral">'M'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00142 <span class="comment">// minimum check</span>
00143 <span class="keywordflow">if</span> ( (pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) || (pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &gt; 1) )
00144 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pMut"</span>);
00145
00146 <span class="comment">// the crossovers</span>
00148 <span class="comment"></span> <span class="comment">// the parameters</span>
00149 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; segmentRateParam
00150 = _parser.getORcreateParam(<span class="keywordtype">double</span>(1.0), <span class="stringliteral">"segmentRate"</span>,
00151 <span class="stringliteral">"Relative rate for segment crossover"</span>,
00152 <span class="charliteral">'s'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00153 <span class="comment">// minimum check</span>
00154 <span class="keywordflow">if</span> ( (segmentRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00155 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid segmentRate"</span>);
00156
00157 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; arithmeticRateParam
00158 = _parser.getORcreateParam(<span class="keywordtype">double</span>(2.0), <span class="stringliteral">"arithmeticRate"</span>,
00159 <span class="stringliteral">"Relative rate for arithmetic crossover"</span>,
00160 <span class="charliteral">'A'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00161 <span class="comment">// minimum check</span>
00162 <span class="keywordflow">if</span> ( (arithmeticRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00163 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid arithmeticRate"</span>);
00164
00165 <span class="comment">// minimum check</span>
00166 <span class="keywordtype">bool</span> bCross = <span class="keyword">true</span>;
00167 <span class="keywordflow">if</span> (segmentRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()+arithmeticRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()==0)
00168 {
00169 std::cerr &lt;&lt; <span class="stringliteral">"Warning: no crossover"</span> &lt;&lt; std::endl;
00170 bCross = <span class="keyword">false</span>;
00171 }
00172
00173 <span class="comment">// Create the CombinedQuadOp</span>
00174 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp&lt;EOT&gt;</a> *ptCombinedQuadOp = NULL;
00175 <a class="code" href="classeo_quad_op.html">eoQuadOp&lt;EOT&gt;</a> *ptQuad = NULL;
00176
00177 <span class="keywordflow">if</span> (bCross)
00178 {
00179 <span class="comment">// segment crossover for bitstring - pass it the bounds</span>
00180 ptQuad = <span class="keyword">new</span> <a class="code" href="classeo_segment_crossover.html">eoSegmentCrossover&lt;EOT&gt;</a>(*ptBounds);
00181 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00182 ptCombinedQuadOp = <span class="keyword">new</span> <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp&lt;EOT&gt;</a>(*ptQuad, segmentRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00183
00184 <span class="comment">// arithmetic crossover</span>
00185 ptQuad = <span class="keyword">new</span> <a class="code" href="classeo_arithmetic_crossover.html">eoArithmeticCrossover&lt;EOT&gt;</a>(*ptBounds);
00186 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00187 ptCombinedQuadOp-&gt;<a class="code" href="classeo_prop_combined_quad_op.html#a2">add</a>(*ptQuad, arithmeticRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00188
00189 <span class="comment">// don't forget to store the CombinedQuadOp</span>
00190 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptCombinedQuadOp);
00191 }
00192
00193 <span class="comment">// the mutations</span>
00195 <span class="comment"></span> <span class="comment">// the parameters</span>
00196 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; epsilonParam
00197 = _parser.getORcreateParam(0.01, <span class="stringliteral">"epsilon"</span>, <span class="stringliteral">"Half-size of interval for Uniform Mutation"</span>,
00198 <span class="charliteral">'e'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00199 <span class="comment">// minimum check</span>
00200 <span class="keywordflow">if</span> ( (epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00201 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid epsilon"</span>);
00202
00203 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; uniformMutRateParam
00204 = _parser.getORcreateParam(1.0, <span class="stringliteral">"uniformMutRate"</span>,
00205 <span class="stringliteral">"Relative rate for uniform mutation"</span>, <span class="charliteral">'u'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00206 <span class="comment">// minimum check</span>
00207 <span class="keywordflow">if</span> ( (uniformMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00208 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid uniformMutRate"</span>);
00209
00210 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; detMutRateParam
00211 = _parser.getORcreateParam(1.0, <span class="stringliteral">"detMutRate"</span>,
00212 <span class="stringliteral">"Relative rate for deterministic uniform mutation"</span>,
00213 <span class="charliteral">'d'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00214 <span class="comment">// minimum check</span>
00215 <span class="keywordflow">if</span> ( (detMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00216 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid detMutRate"</span>);
00217
00218 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; normalMutRateParam
00219 = _parser.getORcreateParam(1.0, <span class="stringliteral">"normalMutRate"</span>,
00220 <span class="stringliteral">"Relative rate for Gaussian mutation"</span>,
00221 <span class="charliteral">'d'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00222 <span class="comment">// minimum check</span>
00223 <span class="keywordflow">if</span> ( (normalMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00224 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid normalMutRate"</span>);
00225 <span class="comment">// and the sigma</span>
00226 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; sigmaParam
00227 = _parser.getORcreateParam(1.0, <span class="stringliteral">"sigma"</span>,
00228 <span class="stringliteral">"Sigma (fixed) for Gaussian mutation"</span>,
00229 <span class="charliteral">'S'</span>, <span class="stringliteral">"Genetic Operators"</span> );
00230 <span class="comment">// minimum check</span>
00231 <span class="keywordflow">if</span> ( (sigmaParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00232 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid sigma"</span>);
00233
00234 <span class="comment">// minimum check</span>
00235 <span class="keywordtype">bool</span> bMut = <span class="keyword">true</span>;
00236 <span class="keywordflow">if</span> (uniformMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()+detMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()+normalMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()==0)
00237 {
00238 std::cerr &lt;&lt; <span class="stringliteral">"Warning: no mutation"</span> &lt;&lt; std::endl;
00239 bMut = <span class="keyword">false</span>;
00240 }
00241 <span class="keywordflow">if</span> (!bCross &amp;&amp; !bMut)
00242 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"No operator called in SGA operator definition!!!"</span>);
00243
00244 <span class="comment">// Create the CombinedMonOp</span>
00245 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp&lt;EOT&gt;</a> *ptCombinedMonOp = NULL;
00246 <a class="code" href="classeo_mon_op.html">eoMonOp&lt;EOT&gt;</a> *ptMon = NULL;
00247
00248 <span class="keywordflow">if</span> (bMut)
00249 {
00250 <span class="comment">// uniform mutation on all components:</span>
00251 <span class="comment">// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]</span>
00252 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_uniform_mutation.html">eoUniformMutation&lt;EOT&gt;</a>(*ptBounds, epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00253 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00254 <span class="comment">// create the CombinedMonOp</span>
00255 ptCombinedMonOp = <span class="keyword">new</span> <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp&lt;EOT&gt;</a>(*ptMon, uniformMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00256
00257 <span class="comment">// mutate exactly 1 component (uniformly) per individual</span>
00258 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_det_uniform_mutation.html">eoDetUniformMutation&lt;EOT&gt;</a>(*ptBounds, epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00259 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00260 ptCombinedMonOp-&gt;<a class="code" href="classeo_prop_combined_mon_op.html#a2">add</a>(*ptMon, detMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00261
00262 <span class="comment">// mutate all component using Gaussian mutation</span>
00263 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_normal_mutation.html">eoNormalMutation&lt;EOT&gt;</a>(*ptBounds, sigmaParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00264 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00265 ptCombinedMonOp-&gt;<a class="code" href="classeo_prop_combined_mon_op.html#a2">add</a>(*ptMon, normalMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00266 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptCombinedMonOp);
00267 }
00268
00269 <span class="comment">// now build the eoGenOp:</span>
00270 <span class="comment">// to simulate SGA (crossover with proba pCross + mutation with proba pMut</span>
00271 <span class="comment">// we must construct</span>
00272 <span class="comment">// a sequential combination of</span>
00273 <span class="comment">// with proba 1, a proportional combination of</span>
00274 <span class="comment">// a QuadCopy and our crossover</span>
00275 <span class="comment">// with proba pMut, our mutation</span>
00276
00277 <span class="comment">// the crossover - with probability pCross</span>
00278 <a class="code" href="classeo_proportional_op.html">eoProportionalOp&lt;EOT&gt;</a> * cross = <span class="keyword">new</span> <a class="code" href="classeo_proportional_op.html">eoProportionalOp&lt;EOT&gt;</a> ;
00279 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(cross);
00280 ptQuad = <span class="keyword">new</span> <a class="code" href="classeo_quad_clone_op.html">eoQuadCloneOp&lt;EOT&gt;</a>;
00281 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00282 cross-&gt;<a class="code" href="classeo_op_container.html#a3">add</a>(*ptCombinedQuadOp, pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>()); <span class="comment">// user crossover</span>
00283 cross-&gt;<a class="code" href="classeo_op_container.html#a3">add</a>(*ptQuad, 1-pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>()); <span class="comment">// clone operator</span>
00284
00285 <span class="comment">// now the sequential</span>
00286 <a class="code" href="classeo_sequential_op.html">eoSequentialOp&lt;EOT&gt;</a> *op = <span class="keyword">new</span> <a class="code" href="classeo_sequential_op.html">eoSequentialOp&lt;EOT&gt;</a>;
00287 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(op);
00288 op-&gt;<a class="code" href="classeo_op_container.html#a3">add</a>(*cross, 1.0); <span class="comment">// always crossover (but clone with prob 1-pCross</span>
00289 op-&gt;<a class="code" href="classeo_op_container.html#a3">add</a>(*ptCombinedMonOp, pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00290
00291 <span class="comment">// that's it!</span>
00292 <span class="keywordflow">return</span> *op;
00293 }
00294 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>