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:
parent
bc1f453978
commit
c3aec878e5
3609 changed files with 342772 additions and 0 deletions
210
trunk/paradiseo-eo/doc/html/make__op__es_8h-source.html
Normal file
210
trunk/paradiseo-eo/doc/html/make__op__es_8h-source.html
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
<!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_es.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_000010.html">es</a></div>
|
||||
<h1>make_op_es.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2001</span>
|
||||
00002 <span class="comment"></span>
|
||||
00003 <span class="comment">This library is free software; you can redistribute it and/or modify it under</span>
|
||||
00004 <span class="comment">the terms of the GNU Lesser General Public License as published by the Free</span>
|
||||
00005 <span class="comment">Software Foundation; either version 2 of the License, or (at your option) any</span>
|
||||
00006 <span class="comment">later version.</span>
|
||||
00007 <span class="comment"></span>
|
||||
00008 <span class="comment">This library is distributed in the hope that it will be useful, but WITHOUT ANY</span>
|
||||
00009 <span class="comment">WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A</span>
|
||||
00010 <span class="comment">PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.</span>
|
||||
00011 <span class="comment"></span>
|
||||
00012 <span class="comment">You should have received a copy of the GNU Lesser General Public License along</span>
|
||||
00013 <span class="comment">with this library; if not, write to the Free Software Foundation, Inc., 59</span>
|
||||
00014 <span class="comment">Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment">Contact: http://eodev.sourceforge.net</span>
|
||||
00017 <span class="comment"> todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
||||
00018 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
|
||||
00019 <span class="comment"> mkeijzer@dhi.dk</span>
|
||||
00020 <span class="comment"> */</span>
|
||||
00021
|
||||
00022
|
||||
00023 <span class="preprocessor">#ifndef EO_make_op_h</span>
|
||||
00024 <span class="preprocessor"></span><span class="preprocessor">#define EO_make_op_h</span>
|
||||
00025 <span class="preprocessor"></span>
|
||||
00026 <span class="comment">// the operators</span>
|
||||
00027 <span class="preprocessor">#include <eoOp.h></span>
|
||||
00028 <span class="preprocessor">#include <eoGenOp.h></span>
|
||||
00029 <span class="preprocessor">#include <eoCloneOps.h></span>
|
||||
00030 <span class="preprocessor">#include <eoOpContainer.h></span>
|
||||
00031 <span class="comment">// combinations of simple eoOps (eoMonOp and eoQuadOp)</span>
|
||||
00032 <span class="preprocessor">#include <eoProportionalCombinedOp.h></span>
|
||||
00033
|
||||
00034 <span class="comment">// the specialized Real stuff</span>
|
||||
00035 <span class="preprocessor">#include <es/eoReal.h></span>
|
||||
00036 <span class="preprocessor">#include <es/eoRealAtomXover.h></span>
|
||||
00037 <span class="preprocessor">#include <es/eoEsChromInit.h></span>
|
||||
00038 <span class="preprocessor">#include <es/eoEsMutationInit.h></span>
|
||||
00039 <span class="preprocessor">#include <es/eoEsMutate.h></span>
|
||||
00040 <span class="preprocessor">#include <es/eoEsGlobalXover.h></span>
|
||||
00041 <span class="preprocessor">#include <es/eoEsStandardXover.h></span>
|
||||
00042 <span class="comment">// also need the parser and param includes</span>
|
||||
00043 <span class="preprocessor">#include <utils/eoParser.h></span>
|
||||
00044 <span class="preprocessor">#include <utils/eoState.h></span>
|
||||
00045
|
||||
00046
|
||||
00047 <span class="comment">/*</span>
|
||||
00048 <span class="comment"> * This function builds the operators that will be applied to the eoReal</span>
|
||||
00049 <span class="comment"> *</span>
|
||||
00050 <span class="comment"> * It uses a parser (to get user parameters) and a state (to store the memory)</span>
|
||||
00051 <span class="comment"> * the last argument is an individual, needed for 2 reasons</span>
|
||||
00052 <span class="comment"> * it disambiguates the call after instanciations</span>
|
||||
00053 <span class="comment"> * some operator might need some private information about the indis</span>
|
||||
00054 <span class="comment"> *</span>
|
||||
00055 <span class="comment"> * This is why the template is the complete EOT even though only the fitness</span>
|
||||
00056 <span class="comment"> * is actually templatized here: the following only applies to bitstrings</span>
|
||||
00057 <span class="comment"> *</span>
|
||||
00058 <span class="comment"> * Note : the last parameter is an eoInit: if some operator needs some info</span>
|
||||
00059 <span class="comment"> * about the gneotypes, the init has it all (e.g. bounds, ...)</span>
|
||||
00060 <span class="comment"> * Simply do</span>
|
||||
00061 <span class="comment"> * EOT myEO;</span>
|
||||
00062 <span class="comment"> * _init(myEO);</span>
|
||||
00063 <span class="comment"> * and myEO is then an ACTUAL object</span>
|
||||
00064 <span class="comment">*/</span>
|
||||
00065
|
||||
00066 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
00067 <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a> & do_make_op(<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_real_init_bounded.html">eoRealInitBounded<EOT></a>& _init)
|
||||
00068 {
|
||||
00069 <span class="comment">// get std::vector size</span>
|
||||
00070 <span class="keywordtype">unsigned</span> vecSize = _init.<a class="code" href="classeo_real_init_bounded.html#a3">size</a>();
|
||||
00071
|
||||
00072 <span class="comment">// First, decide whether the objective variables are bounded</span>
|
||||
00073 <a class="code" href="classeo_value_param.html">eoValueParam<eoRealVectorBounds></a>& boundsParam
|
||||
00074 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<a class="code" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a>(vecSize,eoDummyRealNoBounds),
|
||||
00075 <span class="stringliteral">"objectBounds"</span>, <span class="stringliteral">"Bounds for variables"</span>,
|
||||
00076 <span class="charliteral">'B'</span>, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00077
|
||||
00078 std::cerr << boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>() << std::endl;
|
||||
00079
|
||||
00080 <span class="comment">// now we read Pcross and Pmut,</span>
|
||||
00081 <a class="code" href="classeo_value_param.html">eoValueParam<std::string></a>& operatorParam
|
||||
00082 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"SGA"</span>), <span class="stringliteral">"operator"</span>,
|
||||
00083 <span class="stringliteral">"Description of the operator (SGA only now)"</span>,
|
||||
00084 <span class="charliteral">'o'</span>, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00085
|
||||
00086 <span class="keywordflow">if</span> (operatorParam.value() != std::string(<span class="stringliteral">"SGA"</span>))
|
||||
00087 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Sorry, only SGA-like operator available right now\n"</span>);
|
||||
00088
|
||||
00089 <span class="comment">// now we read Pcross and Pmut,</span>
|
||||
00090 <span class="comment">// and create the eoGenOp that is exactly</span>
|
||||
00091 <span class="comment">// crossover with pcross + mutation with pmut</span>
|
||||
00092
|
||||
00093 <a class="code" href="classeo_value_param.html">eoValueParam<double></a>& pCrossParam
|
||||
00094 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"pCross"</span>, <span class="stringliteral">"Probability of Crossover"</span>,
|
||||
00095 <span class="charliteral">'C'</span>, <span class="stringliteral">"Variation Operators"</span> );
|
||||
00096 <span class="comment">// minimum check</span>
|
||||
00097 <span class="keywordflow">if</span> ( (pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>() < 0) || (pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>() > 1) )
|
||||
00098 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pCross"</span>);
|
||||
00099
|
||||
00100 <a class="code" href="classeo_value_param.html">eoValueParam<double></a>& pMutParam
|
||||
00101 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(1.0, <span class="stringliteral">"pMut"</span>, <span class="stringliteral">"Probability of Mutation"</span>,
|
||||
00102 <span class="charliteral">'M'</span>, <span class="stringliteral">"Variation Operators"</span> );
|
||||
00103 <span class="comment">// minimum check</span>
|
||||
00104 <span class="keywordflow">if</span> ( (pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>() < 0) || (pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>() > 1) )
|
||||
00105 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid pMut"</span>);
|
||||
00106
|
||||
00107
|
||||
00108 <span class="comment">// crossover</span>
|
||||
00110 <span class="comment"></span> <span class="comment">// ES crossover</span>
|
||||
00111 <a class="code" href="classeo_value_param.html">eoValueParam<std::string></a>& crossTypeParam
|
||||
00112 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"global"</span>), <span class="stringliteral">"crossType"</span>,
|
||||
00113 <span class="stringliteral">"Type of ES recombination (global or standard)"</span>,
|
||||
00114 <span class="charliteral">'C'</span>, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00115
|
||||
00116 <a class="code" href="classeo_value_param.html">eoValueParam<std::string></a>& crossObjParam
|
||||
00117 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"discrete"</span>), <span class="stringliteral">"crossObj"</span>,
|
||||
00118 <span class="stringliteral">"Recombination of object variables (discrete, intermediate or none)"</span>,
|
||||
00119 <span class="charliteral">'O'</span>, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00120 <a class="code" href="classeo_value_param.html">eoValueParam<std::string></a>& crossStdevParam
|
||||
00121 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"intermediate"</span>), <span class="stringliteral">"crossStdev"</span>,
|
||||
00122 <span class="stringliteral">"Recombination of mutation strategy parameters "</span>
|
||||
00123 <span class="stringliteral">"(intermediate, discrete or none)"</span>,
|
||||
00124 <span class="charliteral">'S'</span>, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00125
|
||||
00126 <span class="comment">// The pointers: first the atom Xover</span>
|
||||
00127 <a class="code" href="classeo_bin_op.html">eoBinOp<double></a> *ptObjAtomCross = NULL;
|
||||
00128 <a class="code" href="classeo_bin_op.html">eoBinOp<double></a> *ptStdevAtomCross = NULL;
|
||||
00129 <span class="comment">// then the EOT-level one (need to be an eoGenOp as global Xover is</span>
|
||||
00130 <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a> *ptCross;
|
||||
00131
|
||||
00132 <span class="comment">// check for the atom Xovers</span>
|
||||
00133 <span class="keywordflow">if</span> (crossObjParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"discrete"</span>))
|
||||
00134 ptObjAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_double_exchange.html">eoDoubleExchange</a>;
|
||||
00135 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (crossObjParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"intermediate"</span>))
|
||||
00136 ptObjAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_double_intermediate.html">eoDoubleIntermediate</a>;
|
||||
00137 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (crossObjParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"none"</span>))
|
||||
00138 ptObjAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_bin_clone_op.html">eoBinCloneOp<double></a>;
|
||||
00139 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid Object variable crossover type"</span>);
|
||||
00140
|
||||
00141 <span class="keywordflow">if</span> (crossStdevParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"discrete"</span>))
|
||||
00142 ptStdevAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_double_exchange.html">eoDoubleExchange</a>;
|
||||
00143 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (crossStdevParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"intermediate"</span>))
|
||||
00144 ptStdevAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_double_intermediate.html">eoDoubleIntermediate</a>;
|
||||
00145 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (crossStdevParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"none"</span>))
|
||||
00146 ptStdevAtomCross = <span class="keyword">new</span> <a class="code" href="classeo_bin_clone_op.html">eoBinCloneOp<double></a>;
|
||||
00147 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid mutation strategy parameter crossover type"</span>);
|
||||
00148
|
||||
00149 <span class="comment">// and build the indi Xover</span>
|
||||
00150 <span class="keywordflow">if</span> (crossTypeParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"global"</span>))
|
||||
00151 ptCross = <span class="keyword">new</span> <a class="code" href="classeo_es_global_xover.html">eoEsGlobalXover<EOT></a>(*ptObjAtomCross, *ptStdevAtomCross);
|
||||
00152 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (crossTypeParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == std::string(<span class="stringliteral">"standard"</span>))
|
||||
00153 { <span class="comment">// using a standard eoBinOp, but wrap it into an eoGenOp</span>
|
||||
00154 <a class="code" href="classeo_bin_op.html">eoBinOp<EOT></a> & crossTmp = _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(
|
||||
00155 <span class="keyword">new</span> <a class="code" href="classeo_es_standard_xover.html">eoEsStandardXover<EOT></a>(*ptObjAtomCross, *ptStdevAtomCross)
|
||||
00156 );
|
||||
00157 ptCross = <span class="keyword">new</span> <a class="code" href="classeo_bin_gen_op.html">eoBinGenOp<EOT></a>(crossTmp);
|
||||
00158 }
|
||||
00159 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalide Object variable crossover type"</span>);
|
||||
00160
|
||||
00161 <span class="comment">// now that everything is OK, DON'T FORGET TO STORE MEMORY</span>
|
||||
00162 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptObjAtomCross);
|
||||
00163 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptStdevAtomCross);
|
||||
00164 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(ptCross);
|
||||
00165
|
||||
00166 <span class="comment">// mutation</span>
|
||||
00168 <span class="comment"></span>
|
||||
00169 <span class="comment">// Ok, time to set up the self-adaptive mutation</span>
|
||||
00170 <span class="comment">// Proxy for the mutation parameters</span>
|
||||
00171 <a class="code" href="classeo_es_mutation_init.html">eoEsMutationInit</a> mutateInit(_parser, <span class="stringliteral">"Variation Operators"</span>);
|
||||
00172
|
||||
00173 <a class="code" href="classeo_es_mutate.html">eoEsMutate<EOT></a> & mut = _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(
|
||||
00174 <span class="keyword">new</span> <a class="code" href="classeo_es_mutate.html">eoEsMutate<EOT></a>(mutateInit, boundsParam.<a class="code" href="classeo_value_param.html#a2">value</a>()));
|
||||
00175
|
||||
00176 <span class="comment">// now the general op - a sequential application of crossover and mutatation</span>
|
||||
00177 <span class="comment">// no need to first have crossover combined with a clone as it is an</span>
|
||||
00178 <span class="comment">// eoBinOp and not an eoQuadOp as in SGA paradigm</span>
|
||||
00179
|
||||
00180 <a class="code" href="classeo_sequential_op.html">eoSequentialOp<EOT></a> & 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<EOT></a>);
|
||||
00181 op.<a class="code" href="classeo_op_container.html#a3">add</a>(*ptCross, pCrossParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
|
||||
00182 op.<a class="code" href="classeo_op_container.html#a3">add</a>(mut, pMutParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
|
||||
00183
|
||||
00184 <span class="comment">// that's it!</span>
|
||||
00185 <span class="keywordflow">return</span> op;
|
||||
00186 }
|
||||
00187 <span class="preprocessor">#endif // EO_make_op_h</span>
|
||||
00188 <span class="preprocessor"></span>
|
||||
00189
|
||||
00190
|
||||
00191 <span class="comment">// Local Variables:</span>
|
||||
00192 <span class="comment">// coding: iso-8859-1</span>
|
||||
00193 <span class="comment">// mode:C++</span>
|
||||
00194 <span class="comment">// c-file-style: "Stroustrup"</span>
|
||||
00195 <span class="comment">// comment-column: 35</span>
|
||||
00196 <span class="comment">// fill-column: 80</span>
|
||||
00197 <span class="comment">// End:</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue