paradiseo/trunk/doc/html/moeoBinaryMetricSavingUpdater_8h-source.html
legrand 42ae34557a MOEO (Multi Objective Evolving Objects) main directory
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@12 331e1502-861f-0410-8da2-ba01fb791d7f
2006-12-06 10:04:47 +00:00

101 lines
10 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-MOEO: moeoBinaryMetricSavingUpdater.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><a href="pages.html"><span>Related&nbsp;Pages</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>moeoBinaryMetricSavingUpdater.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">//-----------------------------------------------------------------------------</span>
<a name="l00004"></a>00004 <span class="comment">// moeoBinaryMetricSavingUpdater.h</span>
<a name="l00005"></a>00005 <span class="comment">// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006</span>
<a name="l00006"></a>00006 <span class="comment">/*</span>
<a name="l00007"></a>00007 <span class="comment"> This library...</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, http://paradiseo.gforge.inria.fr</span>
<a name="l00010"></a>00010 <span class="comment"> */</span>
<a name="l00011"></a>00011 <span class="comment">//-----------------------------------------------------------------------------</span>
<a name="l00012"></a>00012
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef MOEOBINARYMETRICSAVINGUPDATER_H_</span>
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define MOEOBINARYMETRICSAVINGUPDATER_H_</span>
<a name="l00015"></a>00015 <span class="preprocessor"></span>
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;fstream&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;eoPop.h&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;utils/eoUpdater.h&gt;</span>
<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;metric/moeoMetric.h&gt;</span>
<a name="l00021"></a>00021
<a name="l00026"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html">00026</a> <span class="keyword">template</span> &lt; <span class="keyword">class</span> EOT &gt; <span class="keyword">class </span><a class="code" href="classmoeoBinaryMetricSavingUpdater.html">moeoBinaryMetricSavingUpdater</a>:<span class="keyword">public</span> eoUpdater
<a name="l00027"></a>00027 {
<a name="l00028"></a>00028 <span class="keyword">public</span>:
<a name="l00029"></a>00029
<a name="l00033"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c22e390633d94bbf69309e8d0cae1f0a">00033</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> EOT::Fitness <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c22e390633d94bbf69309e8d0cae1f0a">EOFitness</a>;
<a name="l00034"></a>00034
<a name="l00041"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#978c6e8a99459722220387f911c1f461">00041</a> <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#978c6e8a99459722220387f911c1f461">moeoBinaryMetricSavingUpdater</a> (moeoVectorVsVectorBM &lt; EOT, double &gt;&amp;_metric,
<a name="l00042"></a>00042 <span class="keyword">const</span> eoPop &lt; EOT &gt; &amp;_pop,
<a name="l00043"></a>00043 std::string _filename):<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#52e12414a266bce1dbce0b913025fd37">metric</a> (_metric),
<a name="l00044"></a>00044 <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a> (_pop), <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#32c78860e3aee52346df3aa30c5ac42f">filename</a> (_filename), <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#280b52506c280b07356726ad5d497ef8">counter</a> (1)
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047
<a name="l00051"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#2d051d28def4cadf69957c8a21bf88dc">00051</a> <span class="keywordtype">void</span> <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#2d051d28def4cadf69957c8a21bf88dc">operator () </a>()
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053 <span class="keywordflow">if</span> (<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a>.size ())
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055 <span class="keywordflow">if</span> (<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#1e40103a5cfa592a9d2408102e507a19">firstGen</a>)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 firstGen = <span class="keyword">false</span>;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059 <span class="keywordflow">else</span>
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061 <span class="comment">// creation of the two Pareto sets </span>
<a name="l00062"></a>00062 std::vector &lt; EOFitness &gt; from;
<a name="l00063"></a>00063 std::vector &lt; EOFitness &gt; to;
<a name="l00064"></a>00064 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a>.size (); i++)
<a name="l00065"></a>00065 from.push_back (<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a>[i].fitness ());
<a name="l00066"></a>00066 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i &lt; <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c1751bf23ef440d895a39cdff25c384c">oldPop</a>.size (); i++)
<a name="l00067"></a>00067 to.push_back (<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c1751bf23ef440d895a39cdff25c384c">oldPop</a>[i].fitness ());
<a name="l00068"></a>00068 <span class="comment">// writing the result into the file</span>
<a name="l00069"></a>00069 std::ofstream f (<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#32c78860e3aee52346df3aa30c5ac42f">filename</a>.c_str (), std::ios::app);
<a name="l00070"></a>00070 f &lt;&lt; <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#280b52506c280b07356726ad5d497ef8">counter</a>++ &lt;&lt; <span class="charliteral">' '</span> &lt;&lt; <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#52e12414a266bce1dbce0b913025fd37">metric</a> (from, to) &lt;&lt; std::endl;
<a name="l00071"></a>00071 f.close ();
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c1751bf23ef440d895a39cdff25c384c">oldPop</a> = <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a>;
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="keyword">private</span>:
<a name="l00078"></a>00078
<a name="l00080"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#52e12414a266bce1dbce0b913025fd37">00080</a> moeoVectorVsVectorBM &lt; EOT, double &gt;&amp;<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#52e12414a266bce1dbce0b913025fd37">metric</a>;
<a name="l00082"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">00082</a> <span class="keyword">const</span> eoPop &lt; EOT &gt; &amp;<a class="code" href="classmoeoBinaryMetricSavingUpdater.html#9c30673aca66a1531856cb92068edaf7">pop</a>;
<a name="l00084"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c1751bf23ef440d895a39cdff25c384c">00084</a> eoPop &lt; EOT &gt; <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#c1751bf23ef440d895a39cdff25c384c">oldPop</a>;
<a name="l00086"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#32c78860e3aee52346df3aa30c5ac42f">00086</a> std::string <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#32c78860e3aee52346df3aa30c5ac42f">filename</a>;
<a name="l00088"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#1e40103a5cfa592a9d2408102e507a19">00088</a> <span class="keywordtype">bool</span> <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#1e40103a5cfa592a9d2408102e507a19">firstGen</a>;
<a name="l00090"></a><a class="code" href="classmoeoBinaryMetricSavingUpdater.html#280b52506c280b07356726ad5d497ef8">00090</a> <span class="keywordtype">unsigned</span> <a class="code" href="classmoeoBinaryMetricSavingUpdater.html#280b52506c280b07356726ad5d497ef8">counter</a>;
<a name="l00091"></a>00091
<a name="l00092"></a>00092 };
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="preprocessor">#endif </span><span class="comment">/*MOEOBINARYMETRICSAVINGUPDATER_H_ */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Wed Dec 6 10:16:12 2006 for ParadisEO-MOEO 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>