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
298
trunk/paradiseo-eo/doc/html/eo_reduce_split_8h-source.html
Normal file
298
trunk/paradiseo-eo/doc/html/eo_reduce_split_8h-source.html
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
<!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: eoReduceSplit.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></div>
|
||||
<h1>eoReduceSplit.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">// eoReduceSplit.h</span>
|
||||
00005 <span class="comment">// Base class for population-reducing classes - retaining the poor losers</span>
|
||||
00006 <span class="comment">// (c) GeNeura Team, 1998, Marc Schoenauer, 2002</span>
|
||||
00007 <span class="comment">/* </span>
|
||||
00008 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
||||
00009 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
||||
00010 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
||||
00011 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
||||
00012 <span class="comment"></span>
|
||||
00013 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
||||
00014 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00015 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00016 <span class="comment"> Lesser General Public License for more details.</span>
|
||||
00017 <span class="comment"></span>
|
||||
00018 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
||||
00019 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
||||
00020 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00021 <span class="comment"></span>
|
||||
00022 <span class="comment"> Contact: Marc.Schoenauer@inria.fr</span>
|
||||
00023 <span class="comment"> */</span>
|
||||
00024 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00025
|
||||
00026 <span class="preprocessor">#ifndef eoReduceSplit_h</span>
|
||||
00027 <span class="preprocessor"></span><span class="preprocessor">#define eoReduceSplit_h</span>
|
||||
00028 <span class="preprocessor"></span>
|
||||
00029 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00030
|
||||
00031 <span class="preprocessor">#include <iostream></span>
|
||||
00032
|
||||
00033 <span class="comment">// EO includes</span>
|
||||
00034 <span class="preprocessor">#include <eoPop.h></span> <span class="comment">// eoPop</span>
|
||||
00035 <span class="preprocessor">#include <eoFunctor.h></span> <span class="comment">// eoReduce</span>
|
||||
00036 <span class="preprocessor">#include <utils/selectors.h></span>
|
||||
00037
|
||||
<a name="l00042"></a><a class="code" href="classeo_reduce_split.html">00042</a> <span class="keyword">template</span><<span class="keyword">class</span> EOT> <span class="keyword">class </span><a class="code" href="classeo_reduce_split.html">eoReduceSplit</a>: <span class="keyword">public</span> <a class="code" href="classeo_b_f.html">eoBF</a><eoPop<EOT>&, eoPop<EOT> &, void >
|
||||
00043 {};
|
||||
00044
|
||||
00046 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00047"></a><a class="code" href="classeo_truncate_split.html">00047</a> <span class="keyword">class </span><a class="code" href="classeo_truncate_split.html">eoTruncateSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce_split.html">eoReduceSplit</a><EOT>
|
||||
00048 {
|
||||
00049 <span class="keyword">public</span>:
|
||||
<a name="l00053"></a><a class="code" href="classeo_truncate_split.html#a0">00053</a> <a class="code" href="classeo_truncate_split.html#a0">eoTruncateSplit</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany, <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00054 howMany(_howMany), returnEliminated(_returnEliminated) {}
|
||||
00055
|
||||
<a name="l00057"></a><a class="code" href="classeo_truncate_split.html#a1">00057</a> <span class="keywordtype">void</span> <a class="code" href="classeo_truncate_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00058 {
|
||||
00059 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00060 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00061 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00062 return ;
|
||||
00063 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00064 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00065 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoTruncateSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00066
|
||||
00067 _newgen.<a class="code" href="classeo_pop.html#a13">nth_element</a>(newsize);
|
||||
00068
|
||||
00069 <span class="comment">// save poor losers if necessary</span>
|
||||
00070 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00071 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<eliminated; i++)
|
||||
00072 _eliminated.push_back(_newgen[newsize+i]);
|
||||
00073 <span class="comment">// truncate</span>
|
||||
00074 _newgen.resize(newsize);
|
||||
00075 return ;
|
||||
00076 }
|
||||
00077
|
||||
00078 <span class="keyword">private</span>:
|
||||
00079 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00080 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00081 };
|
||||
00082
|
||||
00086 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00087"></a><a class="code" href="classeo_linear_truncate_split.html">00087</a> <span class="keyword">class </span><a class="code" href="classeo_linear_truncate_split.html">eoLinearTruncateSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce_split.html">eoReduceSplit</a><EOT>
|
||||
00088 {
|
||||
00089 <span class="keyword">public</span>:
|
||||
<a name="l00093"></a><a class="code" href="classeo_linear_truncate_split.html#a0">00093</a> <a class="code" href="classeo_linear_truncate_split.html#a0">eoLinearTruncateSplit</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany, <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00094 howMany(_howMany), returnEliminated(_returnEliminated) {}
|
||||
00095
|
||||
<a name="l00097"></a><a class="code" href="classeo_linear_truncate_split.html#a1">00097</a> <span class="keywordtype">void</span> <a class="code" href="classeo_linear_truncate_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00098 {
|
||||
00099 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00100 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00101 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00102 return ;
|
||||
00103 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00104 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00105 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoLinearTruncateSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00106
|
||||
00107 _eliminated.reserve(_eliminated.size()+eliminated); <span class="comment">//in case not empty?</span>
|
||||
00108 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<eliminated; i++)
|
||||
00109 {
|
||||
00110 <span class="keyword">typename</span> <a class="code" href="classeo_pop.html">eoPop<EOT></a>::iterator it = _newgen.<a class="code" href="classeo_pop.html#a12">it_worse_element</a>();
|
||||
00111 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00112 _eliminated.push_back(*it);
|
||||
00113 _newgen.erase(it);
|
||||
00114 }
|
||||
00115 }
|
||||
00116
|
||||
00117 <span class="keyword">private</span>:
|
||||
00118 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00119 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00120 };
|
||||
00121
|
||||
00123 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00124"></a><a class="code" href="classeo_random_split.html">00124</a> <span class="keyword">class </span><a class="code" href="classeo_random_split.html">eoRandomSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce_split.html">eoReduceSplit</a><EOT>
|
||||
00125 {
|
||||
00126 <span class="keyword">public</span>:
|
||||
<a name="l00130"></a><a class="code" href="classeo_random_split.html#a0">00130</a> <a class="code" href="classeo_random_split.html#a0">eoRandomSplit</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany, <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00131 howMany(_howMany), returnEliminated(_returnEliminated) {}
|
||||
00132
|
||||
<a name="l00134"></a><a class="code" href="classeo_random_split.html#a1">00134</a> <span class="keywordtype">void</span> <a class="code" href="classeo_random_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00135 {
|
||||
00136 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00137 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00138 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00139 return ;
|
||||
00140 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00141 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00142 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoRandomSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00143
|
||||
00144 _newgen.<a class="code" href="classeo_pop.html#a7">shuffle</a>();
|
||||
00145
|
||||
00146 <span class="comment">// save poor losers if necessary</span>
|
||||
00147 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00148 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<eliminated; i++)
|
||||
00149 _eliminated.push_back(_newgen[newsize+i]);
|
||||
00150 <span class="comment">// truncate</span>
|
||||
00151 _newgen.resize(newsize);
|
||||
00152 return ;
|
||||
00153 }
|
||||
00154
|
||||
00155 <span class="keyword">private</span>:
|
||||
00156 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00157 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00158 };
|
||||
00159
|
||||
00160
|
||||
00162 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00163"></a><a class="code" href="classeo_linear_random_split.html">00163</a> <span class="keyword">class </span><a class="code" href="classeo_linear_random_split.html">eoLinearRandomSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce_split.html">eoReduceSplit</a><EOT>
|
||||
00164 {
|
||||
00165 <span class="keyword">public</span>:
|
||||
<a name="l00169"></a><a class="code" href="classeo_linear_random_split.html#a0">00169</a> <a class="code" href="classeo_linear_random_split.html#a0">eoLinearRandomSplit</a>(<a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany, <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00170 howMany(_howMany), returnEliminated(_returnEliminated) {}
|
||||
00171
|
||||
<a name="l00173"></a><a class="code" href="classeo_linear_random_split.html#a1">00173</a> <span class="keywordtype">void</span> <a class="code" href="classeo_linear_random_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00174 {
|
||||
00175 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00176 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00177 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00178 return ;
|
||||
00179 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00180 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00181 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoLinearRandomSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00182
|
||||
00183 _eliminated.reserve(_eliminated.size()+eliminated); <span class="comment">//in case not empty?</span>
|
||||
00184 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<eliminated; i++)
|
||||
00185 {
|
||||
00186 <span class="keywordtype">unsigned</span> loser=random(_newgen.size());
|
||||
00187 <span class="keyword">typename</span> <a class="code" href="classeo_pop.html">eoPop<EOT></a>::iterator it = _newgen.begin()+loser;
|
||||
00188 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00189 _eliminated.push_back(*it);
|
||||
00190 _newgen.erase(it);
|
||||
00191 }
|
||||
00192 return ;
|
||||
00193 }
|
||||
00194
|
||||
00195 <span class="keyword">private</span>:
|
||||
00196 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00197 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00198 };
|
||||
00199
|
||||
00200
|
||||
00204 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00205"></a><a class="code" href="classeo_det_tournament_truncate_split.html">00205</a> <span class="keyword">class </span><a class="code" href="classeo_det_tournament_truncate_split.html">eoDetTournamentTruncateSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce_split.html">eoReduceSplit</a><EOT>
|
||||
00206 {
|
||||
00207 <span class="keyword">public</span>:
|
||||
<a name="l00211"></a><a class="code" href="classeo_det_tournament_truncate_split.html#a0">00211</a> <a class="code" href="classeo_det_tournament_truncate_split.html#a0">eoDetTournamentTruncateSplit</a>(<span class="keywordtype">unsigned</span> _t_size, <a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany,
|
||||
00212 <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00213 t_size(_t_size), howMany(_howMany),
|
||||
00214 returnEliminated(_returnEliminated)
|
||||
00215 {
|
||||
00216 <span class="keywordflow">if</span> (t_size < 2)
|
||||
00217 {
|
||||
00218 std::cout << <span class="stringliteral">"Warning, Size for eoDetTournamentTruncateSplit adjusted to 2\n"</span>;
|
||||
00219 t_size = 2;
|
||||
00220 }
|
||||
00221 }
|
||||
00222
|
||||
<a name="l00224"></a><a class="code" href="classeo_det_tournament_truncate_split.html#a1">00224</a> <span class="keywordtype">void</span> <a class="code" href="classeo_det_tournament_truncate_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00225 <span class="comment">// BUG??? void operator()(eoPop<EOT>& _newgen, unsigned _newsize)</span>
|
||||
00226 {
|
||||
00227 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00228 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00229 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00230 return ;
|
||||
00231 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00232 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00233 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00234
|
||||
00235
|
||||
00236 _eliminated.reserve(_eliminated.size()+eliminated); <span class="comment">//in case not empty?</span>
|
||||
00237 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<eliminated; i++)
|
||||
00238 {
|
||||
00239 <span class="keyword">typename</span> <a class="code" href="classeo_pop.html">eoPop<EOT></a>::iterator it = inverse_deterministic_tournament(_newgen.begin(), _newgen.end(), t_size);
|
||||
00240 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00241 _eliminated.push_back(*it);
|
||||
00242 _newgen.erase(it);
|
||||
00243 }
|
||||
00244 }
|
||||
00245
|
||||
00246 <span class="keyword">private</span>:
|
||||
00247 <span class="keywordtype">unsigned</span> t_size;
|
||||
00248 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00249 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00250 };
|
||||
00251
|
||||
00255 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00256"></a><a class="code" href="classeo_stoch_tournament_truncate_split.html">00256</a> <span class="keyword">class </span><a class="code" href="classeo_stoch_tournament_truncate_split.html">eoStochTournamentTruncateSplit</a> : <span class="keyword">public</span> <a class="code" href="classeo_reduce.html">eoReduce</a><EOT>
|
||||
00257 {
|
||||
00258 <span class="keyword">public</span>:
|
||||
<a name="l00262"></a><a class="code" href="classeo_stoch_tournament_truncate_split.html#a0">00262</a> <a class="code" href="classeo_stoch_tournament_truncate_split.html#a0">eoStochTournamentTruncateSplit</a>(<span class="keywordtype">double</span> _t_rate, <a class="code" href="classeo_how_many.html">eoHowMany</a> _howMany,
|
||||
00263 <span class="keywordtype">bool</span> _returnEliminated = <span class="keyword">false</span>):
|
||||
00264 t_rate(_t_rate), howMany(_howMany),
|
||||
00265 returnEliminated(_returnEliminated)
|
||||
00266 {
|
||||
00267 <span class="keywordflow">if</span> (t_rate <= 0.5)
|
||||
00268 {
|
||||
00269 std::cout << <span class="stringliteral">"Warning, Rate for eoStochTournamentTruncateSplit adjusted to 0.51\n"</span>;
|
||||
00270 t_rate = 0.51;
|
||||
00271 }
|
||||
00272 <span class="keywordflow">if</span> (t_rate > 1)
|
||||
00273 {
|
||||
00274 std::cout << <span class="stringliteral">"Warning, Rate for eoStochTournamentTruncateSplit adjusted to 1\n"</span>;
|
||||
00275 t_rate = 1;
|
||||
00276 }
|
||||
00277 }
|
||||
00278
|
||||
<a name="l00280"></a><a class="code" href="classeo_stoch_tournament_truncate_split.html#a1">00280</a> <span class="keywordtype">void</span> <a class="code" href="classeo_stoch_tournament_truncate_split.html#a1">operator()</a>(<a class="code" href="classeo_pop.html">eoPop<EOT></a>& _newgen, <a class="code" href="classeo_pop.html">eoPop<EOT></a> & _eliminated)
|
||||
00281 <span class="comment">//BUG??? void operator()(eoPop<EOT>& _newgen, unsigned _newsize)</span>
|
||||
00282 {
|
||||
00283 <span class="comment">/* old version</span>
|
||||
00284 <span class="comment"> if (!_eliminated.size()) // nothing to do</span>
|
||||
00285 <span class="comment"> return;</span>
|
||||
00286 <span class="comment"> unsigned oldSize = _newgen.size();</span>
|
||||
00287 <span class="comment"> unsigned newSize = oldSize - _eliminated.size();</span>
|
||||
00288 <span class="comment"> unsigned eliminated = howMany(popSize);</span>
|
||||
00289 <span class="comment"> if (newSize < 0)</span>
|
||||
00290 <span class="comment"> throw std::logic_error("eoStochTournamentTruncateSplit: Cannot truncate to a larger size!\n");</span>
|
||||
00291 <span class="comment"></span>
|
||||
00292 <span class="comment">end of old version */</span>
|
||||
00293
|
||||
00294 <span class="keywordtype">unsigned</span> popSize = _newgen.size();
|
||||
00295 <span class="keywordtype">unsigned</span> eliminated = howMany(popSize);
|
||||
00296 <span class="keywordflow">if</span> (!eliminated) <span class="comment">// nothing to do</span>
|
||||
00297 return ;
|
||||
00298 <span class="keywordtype">unsigned</span> newsize = popSize - eliminated;
|
||||
00299 <span class="keywordflow">if</span> (newsize < 0)
|
||||
00300 <span class="keywordflow">throw</span> std::logic_error(<span class="stringliteral">"eoDetTournamentTruncateSplit: Cannot truncate to a larger size!\n"</span>);
|
||||
00301
|
||||
00302
|
||||
00303
|
||||
00304 _eliminated.reserve(_eliminated.size()+eliminated); <span class="comment">//in case not empty?</span>
|
||||
00305 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<_eliminated.size(); i++)
|
||||
00306 {
|
||||
00307 <span class="keyword">typename</span> <a class="code" href="classeo_pop.html">eoPop<EOT></a>::iterator it = inverse_stochastic_tournament(_newgen.begin(), _newgen.end(), t_rate);
|
||||
00308 <span class="keywordflow">if</span> (returnEliminated)
|
||||
00309 _eliminated.push_back(*it);
|
||||
00310 _newgen.erase(it);
|
||||
00311 }
|
||||
00312 }
|
||||
00313
|
||||
00314
|
||||
00315 <span class="keyword">private</span>:
|
||||
00316 <span class="keywordtype">double</span> t_rate;
|
||||
00317 <a class="code" href="classeo_how_many.html">eoHowMany</a> howMany;
|
||||
00318 <span class="keywordtype">bool</span> returnEliminated;
|
||||
00319 };
|
||||
00320
|
||||
00321 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00322
|
||||
00323 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:38 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