paradiseo/trunk/docs/html/mo_rand_impr_select_8h-source.html

103 lines
8.4 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>PARADISEO-MO: moRandImprSelect.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.1 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="classes.html"><span>Classes</span></a></li>
<li id="current"><a href="files.html"><span>Files</span></a></li>
<li>
<form action="search.php" method="get">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
<td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
</tr>
</table>
</form>
</li>
</ul></div>
<h1>moRandImprSelect.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
<a name="l00002"></a>00002
<a name="l00003"></a>00003 <span class="comment">// "moRandImprSelect.h"</span>
<a name="l00004"></a>00004
<a name="l00005"></a>00005 <span class="comment">// (c) OPAC Team, LIFL, 2003-2006</span>
<a name="l00006"></a>00006
<a name="l00007"></a>00007 <span class="comment">/* LICENCE TEXT</span>
<a name="l00008"></a>00008 <span class="comment"> </span>
<a name="l00009"></a>00009 <span class="comment"> Contact: paradiseo-help@lists.gforge.inria.fr</span>
<a name="l00010"></a>00010 <span class="comment">*/</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#ifndef __moRandImprSelect_h</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define __moRandImprSelect_h</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span>
<a name="l00015"></a>00015 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;utils/eoRNG.h&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include "moMoveSelect.h"</span>
<a name="l00019"></a>00019
<a name="l00021"></a>00021
<a name="l00025"></a><a class="code" href="classmo_rand_impr_select.html">00025</a> <span class="keyword">template</span> &lt; <span class="keyword">class</span> M &gt; <span class="keyword">class </span><a class="code" href="classmo_rand_impr_select.html">moRandImprSelect</a>:<span class="keyword">public</span> <a class="code" href="classmo_move_select.html">moMoveSelect</a> &lt; M &gt;
<a name="l00026"></a>00026 {
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="keyword">public</span>:
<a name="l00029"></a>00029
<a name="l00031"></a><a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">00031</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> M::EOType::Fitness <a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">Fitness</a>;
<a name="l00032"></a>00032
<a name="l00034"></a>00034
<a name="l00040"></a><a class="code" href="classmo_rand_impr_select.html#a19726a1509cff874801615d63a3b5d9">00040</a> <span class="keywordtype">void</span> <a class="code" href="classmo_rand_impr_select.html#a19726a1509cff874801615d63a3b5d9">init</a> (<span class="keyword">const</span> <a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">Fitness</a> &amp; __fit)
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042 <a class="code" href="classmo_rand_impr_select.html#d153c277a0a2ea95ac484210d445b40e">init_fit</a> = __fit;
<a name="l00043"></a>00043 <a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>.clear ();
<a name="l00044"></a>00044 <a class="code" href="classmo_rand_impr_select.html#2ace12bd179144fa71d56324694201f5">vect_better_moves</a>.clear ();
<a name="l00045"></a>00045 }
<a name="l00046"></a>00046
<a name="l00048"></a>00048
<a name="l00056"></a><a class="code" href="classmo_rand_impr_select.html#60ae5548560caee7e28d5ed2446186c9">00056</a> <span class="keywordtype">bool</span> <a class="code" href="classmo_rand_impr_select.html#60ae5548560caee7e28d5ed2446186c9">update</a> (<span class="keyword">const</span> M &amp; __move, <span class="keyword">const</span> <a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">Fitness</a> &amp; __fit)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="keywordflow">if</span> (__fit &gt; <a class="code" href="classmo_rand_impr_select.html#d153c277a0a2ea95ac484210d445b40e">init_fit</a>)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>.push_back (__fit);
<a name="l00063"></a>00063 <a class="code" href="classmo_rand_impr_select.html#2ace12bd179144fa71d56324694201f5">vect_better_moves</a>.push_back (__move);
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068
<a name="l00070"></a>00070
<a name="l00077"></a><a class="code" href="classmo_rand_impr_select.html#5ee57f77a450c0a9ce50bfccf3ad2a55">00077</a> <span class="keywordtype">void</span> <a class="code" href="classmo_rand_impr_select.html#5ee57f77a450c0a9ce50bfccf3ad2a55">operator () </a>(M &amp; __move, <a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">Fitness</a> &amp; __fit) <span class="keywordflow">throw</span> (<a class="code" href="class_empty_selection.html">EmptySelection</a>)
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keywordflow">if</span> (!<a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>.empty ())
<a name="l00081"></a>00081 {
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keywordtype">unsigned</span> n = rng.random (<a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>.size ());
<a name="l00084"></a>00084
<a name="l00085"></a>00085 __move = <a class="code" href="classmo_rand_impr_select.html#2ace12bd179144fa71d56324694201f5">vect_better_moves</a>[n];
<a name="l00086"></a>00086 __fit = <a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>[n];
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088 <span class="keywordflow">else</span>
<a name="l00089"></a>00089 <span class="keywordflow">throw</span> <a class="code" href="class_empty_selection.html">EmptySelection</a> ();
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keyword">private</span>:
<a name="l00093"></a>00093
<a name="l00095"></a><a class="code" href="classmo_rand_impr_select.html#d153c277a0a2ea95ac484210d445b40e">00095</a> <a class="code" href="classmo_rand_impr_select.html#3bff2fdb963297430543c82ffb567a5c">Fitness</a> <a class="code" href="classmo_rand_impr_select.html#d153c277a0a2ea95ac484210d445b40e">init_fit</a>;
<a name="l00096"></a>00096
<a name="l00098"></a><a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">00098</a> std::vector &lt; Fitness &gt; <a class="code" href="classmo_rand_impr_select.html#05c7c3b858e8a25632f2f5c86b0c97a3">vect_better_fit</a>;
<a name="l00099"></a>00099
<a name="l00101"></a><a class="code" href="classmo_rand_impr_select.html#2ace12bd179144fa71d56324694201f5">00101</a> std::vector &lt; M &gt; <a class="code" href="classmo_rand_impr_select.html#2ace12bd179144fa71d56324694201f5">vect_better_moves</a>;
<a name="l00102"></a>00102 };
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue Dec 12 14:28:36 2006 for PARADISEO-MO by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.1 </small></address>
</body>
</html>