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

297 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_op_real.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>make_op_real.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/eoEsChromInit.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
00067 <span class="keyword">template</span> &lt;<span class="keyword">class</span> EOT&gt;
00068 <a class="code" href="classeo_gen_op.html">eoGenOp&lt;EOT&gt;</a> &amp; do_make_op(<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_real_init_bounded.html">eoRealInitBounded&lt;EOT&gt;</a>&amp; _init)
00069 {
00070 <span class="comment">// get std::vector size</span>
00071 <span class="keywordtype">unsigned</span> vecSize = _init.<a class="code" href="classeo_real_init_bounded.html#a3">size</a>();
00072
00073 <span class="comment">// First, decide whether the objective variables are bounded</span>
00074 <a class="code" href="classeo_value_param.html">eoValueParam&lt;eoRealVectorBounds&gt;</a>&amp; boundsParam
00075 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<a class="code" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a>(vecSize,eoDummyRealNoBounds), <span class="stringliteral">"objectBounds"</span>,
00076 <span class="stringliteral">"Bounds for variables"</span>, <span class="charliteral">'B'</span>, <span class="stringliteral">"Variation Operators"</span>);
00077
00078 <span class="comment">// this is a temporary version(!),</span>
00079 <span class="comment">// while Maarten codes the full tree-structured general operator input</span>
00080 <span class="comment">// BTW we must leave that simple version available somehow, as it is the one</span>
00081 <span class="comment">// that 90% people use!</span>
00082 <a class="code" href="classeo_value_param.html">eoValueParam&lt;std::string&gt;</a>&amp; operatorParam
00083 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"SGA"</span>), <span class="stringliteral">"operator"</span>,
00084 <span class="stringliteral">"Description of the operator (SGA only now)"</span>,
00085 <span class="charliteral">'o'</span>, <span class="stringliteral">"Variation Operators"</span>);
00086
00087 <span class="keywordflow">if</span> (operatorParam.value() != std::string(<span class="stringliteral">"SGA"</span>))
00088 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Sorry, only SGA-like operator available right now\n"</span>);
00089
00090 <span class="comment">// now we read Pcross and Pmut,</span>
00091 <span class="comment">// the relative weights for all crossovers -&gt; proportional choice</span>
00092 <span class="comment">// the relative weights for all mutations -&gt; proportional choice</span>
00093 <span class="comment">// and create the eoGenOp that is exactly</span>
00094 <span class="comment">// crossover with pcross + mutation with pmut</span>
00095
00096 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; pCrossParam
00097 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(0.6, <span class="stringliteral">"pCross"</span>,
00098 <span class="stringliteral">"Probability of Crossover"</span>,
00099 <span class="charliteral">'C'</span>, <span class="stringliteral">"Variation Operators"</span> );
00100 <span class="comment">// minimum check</span>
00101 <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) )
00102 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pCross"</span>);
00103
00104 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; pMutParam
00105 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(0.1, <span class="stringliteral">"pMut"</span>,
00106 <span class="stringliteral">"Probability of Mutation"</span>,
00107 <span class="charliteral">'M'</span>, <span class="stringliteral">"Variation Operators"</span> );
00108 <span class="comment">// minimum check</span>
00109 <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) )
00110 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pMut"</span>);
00111
00112 <span class="comment">// the crossovers</span>
00114 <span class="comment"></span> <span class="comment">// the parameters</span>
00115 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; alphaParam
00116 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keywordtype">double</span>(0.0), <span class="stringliteral">"alpha"</span>,
00117 <span class="stringliteral">"Bound for factor of linear recombinations"</span>,
00118 <span class="charliteral">'a'</span>, <span class="stringliteral">"Variation Operators"</span> );
00119 <span class="comment">// minimum check</span>
00120 <span class="keywordflow">if</span> ( (alphaParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00121 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid BLX coefficient alpha"</span>);
00122
00123
00124 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; segmentRateParam
00125 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keywordtype">double</span>(1.0), <span class="stringliteral">"segmentRate"</span>,
00126 <span class="stringliteral">"Relative rate for segment crossover"</span>,
00127 <span class="charliteral">'s'</span>, <span class="stringliteral">"Variation Operators"</span> );
00128 <span class="comment">// minimum check</span>
00129 <span class="keywordflow">if</span> ( (segmentRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00130 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid segmentRate"</span>);
00131
00132 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; hypercubeRateParam
00133 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keywordtype">double</span>(1.0), <span class="stringliteral">"hypercubeRate"</span>,
00134 <span class="stringliteral">"Relative rate for hypercube crossover"</span>,
00135 <span class="charliteral">'A'</span>, <span class="stringliteral">"Variation Operators"</span> );
00136 <span class="comment">// minimum check</span>
00137 <span class="keywordflow">if</span> ( (hypercubeRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00138 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid hypercubeRate"</span>);
00139
00140 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a>&amp; uxoverRateParam
00141 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keywordtype">double</span>(1.0), <span class="stringliteral">"uxoverRate"</span>,
00142 <span class="stringliteral">"Relative rate for uniform crossover"</span>,
00143 <span class="charliteral">'A'</span>, <span class="stringliteral">"Variation Operators"</span> );
00144 <span class="comment">// minimum check</span>
00145 <span class="keywordflow">if</span> ( (uxoverRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00146 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid uxoverRate"</span>);
00147
00148 <span class="comment">// minimum check</span>
00149 <span class="keywordtype">bool</span> bCross = <span class="keyword">true</span>;
00150 <span class="keywordflow">if</span> (segmentRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()+hypercubeRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()+uxoverRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>()==0)
00151 {
00152 std::cerr &lt;&lt; <span class="stringliteral">"Warning: no crossover"</span> &lt;&lt; std::endl;
00153 bCross = <span class="keyword">false</span>;
00154 }
00155
00156 <span class="comment">// Create the CombinedQuadOp</span>
00157 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp&lt;EOT&gt;</a> *ptCombinedQuadOp = NULL;
00158 <a class="code" href="classeo_quad_op.html">eoQuadOp&lt;EOT&gt;</a> *ptQuad = NULL;
00159
00160 <span class="keywordflow">if</span> (bCross)
00161 {
00162 <span class="comment">// segment crossover for bitstring - pass it the bounds</span>
00163 ptQuad = <span class="keyword">new</span> <a class="code" href="classeo_segment_crossover.html">eoSegmentCrossover&lt;EOT&gt;</a>(boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), alphaParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00164 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00165 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>());
00166
00167 <span class="comment">// hypercube crossover</span>
00168 ptQuad = <span class="keyword">new</span> eoHypercubeCrossover&lt;EOT&gt;(boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), alphaParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00169 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00170 ptCombinedQuadOp-&gt;<a class="code" href="classeo_prop_combined_quad_op.html#a2">add</a>(*ptQuad, hypercubeRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00171
00172 <span class="comment">// uniform crossover</span>
00173 ptQuad = <span class="keyword">new</span> eoRealUXover&lt;EOT&gt;();
00174 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00175 ptCombinedQuadOp-&gt;<a class="code" href="classeo_prop_combined_quad_op.html#a2">add</a>(*ptQuad, uxoverRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00176
00177 <span class="comment">// don't forget to store the CombinedQuadOp</span>
00178 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptCombinedQuadOp);
00179 }
00180
00181 <span class="comment">// the mutations</span>
00183 <span class="comment"></span> <span class="comment">// the parameters</span>
00184 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; epsilonParam
00185 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(0.01, <span class="stringliteral">"epsilon"</span>,
00186 <span class="stringliteral">"Half-size of interval for Uniform Mutation"</span>,
00187 <span class="charliteral">'e'</span>, <span class="stringliteral">"Variation Operators"</span> );
00188 <span class="comment">// minimum check</span>
00189 <span class="keywordflow">if</span> ( (epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00190 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid epsilon"</span>);
00191
00192 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; uniformMutRateParam
00193 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"uniformMutRate"</span>,
00194 <span class="stringliteral">"Relative rate for uniform mutation"</span>,
00195 <span class="charliteral">'u'</span>, <span class="stringliteral">"Variation Operators"</span> );
00196 <span class="comment">// minimum check</span>
00197 <span class="keywordflow">if</span> ( (uniformMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00198 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid uniformMutRate"</span>);
00199
00200 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; detMutRateParam
00201 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"detMutRate"</span>,
00202 <span class="stringliteral">"Relative rate for deterministic uniform mutation"</span>,
00203 <span class="charliteral">'d'</span>, <span class="stringliteral">"Variation Operators"</span> );
00204 <span class="comment">// minimum check</span>
00205 <span class="keywordflow">if</span> ( (detMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00206 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid detMutRate"</span>);
00207
00208 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; normalMutRateParam
00209 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"normalMutRate"</span>,
00210 <span class="stringliteral">"Relative rate for Gaussian mutation"</span>, <span class="charliteral">'d'</span>, <span class="stringliteral">"Variation Operators"</span> );
00211 <span class="comment">// minimum check</span>
00212 <span class="keywordflow">if</span> ( (normalMutRateParam.<a class="code" href="classeo_value_param.html#a2">value</a>() &lt; 0) )
00213 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid normalMutRate"</span>);
00214
00215 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; sigmaParam
00216 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(0.3, <span class="stringliteral">"sigma"</span>,
00217 <span class="stringliteral">"Sigma (fixed) for Gaussian mutation"</span>,
00218 <span class="charliteral">'s'</span>, <span class="stringliteral">"Variation Operators"</span> );
00219
00220 <a class="code" href="classeo_value_param.html">eoValueParam&lt;double&gt;</a> &amp; pNormalParam
00221 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"pNormal"</span>,
00222 <span class="stringliteral">"Proba. to change each variable for Gaussian mutation"</span>,
00223 <span class="charliteral">'s'</span>, <span class="stringliteral">"Variation Operators"</span> );
00224
00225 <span class="comment">// minimum check</span>
00226 <span class="keywordtype">bool</span> bMut = <span class="keyword">true</span>;
00227 <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)
00228 {
00229 std::cerr &lt;&lt; <span class="stringliteral">"Warning: no mutation"</span> &lt;&lt; std::endl;
00230 bMut = <span class="keyword">false</span>;
00231 }
00232 <span class="keywordflow">if</span> (!bCross &amp;&amp; !bMut)
00233 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"No operator called in SGA operator definition!!!"</span>);
00234
00235 <span class="comment">// Create the CombinedMonOp</span>
00236 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp&lt;EOT&gt;</a> *ptCombinedMonOp = NULL;
00237 <a class="code" href="classeo_mon_op.html">eoMonOp&lt;EOT&gt;</a> *ptMon = NULL;
00238
00239 <span class="keywordflow">if</span> (bMut)
00240 {
00241 <span class="comment">// uniform mutation on all components:</span>
00242 <span class="comment">// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]</span>
00243 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_uniform_mutation.html">eoUniformMutation&lt;EOT&gt;</a>(boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00244 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00245 <span class="comment">// create the CombinedMonOp</span>
00246 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>());
00247
00248 <span class="comment">// mutate exactly 1 component (uniformly) per individual</span>
00249 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_det_uniform_mutation.html">eoDetUniformMutation&lt;EOT&gt;</a>(boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), epsilonParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00250 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00251 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>());
00252
00253 <span class="comment">// mutate all component using Gaussian mutation</span>
00254 ptMon = <span class="keyword">new</span> <a class="code" href="classeo_normal_vec_mutation.html">eoNormalVecMutation&lt;EOT&gt;</a>(boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), sigmaParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), pNormalParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00255 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptMon);
00256 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>());
00257 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptCombinedMonOp);
00258 }
00259
00260 <span class="comment">// now build the eoGenOp:</span>
00261 <span class="comment">// to simulate SGA (crossover with proba pCross + mutation with proba pMut</span>
00262 <span class="comment">// we must construct</span>
00263 <span class="comment">// a sequential combination of</span>
00264 <span class="comment">// with proba 1, a proportional combination of</span>
00265 <span class="comment">// a QuadCopy and our crossover</span>
00266 <span class="comment">// with proba pMut, our mutation</span>
00267
00268 <span class="comment">// the crossover - with probability pCross</span>
00269 <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> ;
00270 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(cross);
00271 ptQuad = <span class="keyword">new</span> <a class="code" href="classeo_quad_clone_op.html">eoQuadCloneOp&lt;EOT&gt;</a>;
00272 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptQuad);
00273 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>
00274 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>
00275
00276 <span class="comment">// now the sequential</span>
00277 <a class="code" href="classeo_sequential_op.html">eoSequentialOp&lt;EOT&gt;</a> &amp; op = _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(<span class="keyword">new</span> <a class="code" href="classeo_sequential_op.html">eoSequentialOp&lt;EOT&gt;</a>);
00278 op.<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>
00279 op.<a class="code" href="classeo_op_container.html#a3">add</a>(*ptCombinedMonOp, pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00280
00281 <span class="comment">// that's it!</span>
00282 <span class="keywordflow">return</span> op;
00283 }
00284 <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>