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

69 lines
5.7 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: eoG3Replacement.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></div>
<h1>eoG3Replacement.h</h1><div class="fragment"><pre class="fragment">00001
00024 <span class="comment">//-----------------------------------------------------------------------------</span>
00025
00026 <span class="preprocessor">#ifndef _eoG3Replacement_h</span>
00027 <span class="preprocessor"></span><span class="preprocessor">#define _eoG3Replacement_h</span>
00028 <span class="preprocessor"></span>
00029
00030 <span class="comment">//-----------------------------------------------------------------------------</span>
00031 <span class="preprocessor">#include &lt;eoPop.h&gt;</span>
00032 <span class="preprocessor">#include &lt;eoFunctor.h&gt;</span>
00033 <span class="preprocessor">#include &lt;eoMerge.h&gt;</span>
00034 <span class="preprocessor">#include &lt;eoReduce.h&gt;</span>
00035 <span class="preprocessor">#include &lt;utils/eoHowMany.h&gt;</span>
00036 <span class="preprocessor">#include &lt;eoReduceSplit.h&gt;</span>
00037 <span class="comment">//-----------------------------------------------------------------------------</span>
00038
00049 <span class="keyword">template</span> &lt;<span class="keyword">class</span> EOT&gt;
<a name="l00050"></a><a class="code" href="classeo_g3_replacement.html">00050</a> <span class="keyword">class </span><a class="code" href="classeo_g3_replacement.html">eoG3Replacement</a> : <span class="keyword">public</span> <a class="code" href="classeo_replacement.html">eoReplacement</a>&lt;EOT&gt;
00051 {
00052 <span class="keyword">public</span>:
00053 <a class="code" href="classeo_g3_replacement.html">eoG3Replacement</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a> _howManyEliminatedParents = <a class="code" href="classeo_how_many.html">eoHowMany</a>(2, <span class="keyword">false</span>)) :
00054 <span class="comment">// split truncates the parents and returns eliminated parents</span>
00055 split(_howManyEliminatedParents, <span class="keyword">true</span>),
00056 <span class="comment">// reduce truncates the offpsring and does not return eliminated guys</span>
00057 reduce(-_howManyEliminatedParents, <span class="keyword">false</span>)
00058 {}
00059
<a name="l00060"></a><a class="code" href="classeo_g3_replacement.html#a1">00060</a> <span class="keywordtype">void</span> <a class="code" href="classeo_g3_replacement.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop&lt;EOT&gt;</a> &amp; _parents, <a class="code" href="classeo_pop.html">eoPop&lt;EOT&gt;</a> &amp; _offspring)
00061 {
00062 <a class="code" href="classeo_pop.html">eoPop&lt;EOT&gt;</a> temp;
00063 split(_parents, temp);
00064 <span class="keywordtype">unsigned</span> toKeep = temp.size(); <span class="comment">// how many to keep from merged populations</span>
00065 <span class="comment">// merge temp into offspring</span>
00066 plus(temp, _offspring); <span class="comment">// add temp to _offspring (a little inconsistent!)</span>
00067
00068 <span class="comment">// reduce merged</span>
00069 reduce(_offspring, temp); <span class="comment">// temp dummy arg. will not be modified</span>
00070 <span class="comment">// minimla check:</span>
00071 <span class="keywordflow">if</span> (_offspring.size() != toKeep)
00072 {
00073 std::cerr &lt;&lt; <span class="stringliteral">"Les tailles "</span> &lt;&lt; _offspring.size() &lt;&lt; <span class="stringliteral">" "</span> &lt;&lt; toKeep &lt;&lt; std::endl;
00074 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"eoG3Replacement: wrong number of remaining offspring"</span>);
00075 }
00076 <span class="comment">// and put back into _parents</span>
00077 plus(_offspring, _parents);
00078 }
00079
00080 <span class="keyword">private</span>:
00081 <a class="code" href="classeo_linear_truncate_split.html">eoLinearTruncateSplit&lt;EOT&gt;</a> split; <span class="comment">// few parents to truncate -&gt; linear </span>
00082 <a class="code" href="classeo_truncate_split.html">eoTruncateSplit&lt;EOT&gt;</a> reduce; <span class="comment">// supposedly many offspring to truncate</span>
00083 <a class="code" href="classeo_plus.html">eoPlus&lt;EOT&gt;</a> plus;
00084 };
00085
00086 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:35 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>