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

288 lines
29 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: make_checkpoint.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>&nbsp;/&nbsp;<a class="el" href="dir_000025.html">do</a></div>
<h1>make_checkpoint.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">// make_checkpoint.h</span>
00005 <span class="comment">// (c) Maarten Keijzer, Marc Schoenauer and GeNeura Team, 2000</span>
00006 <span class="comment">/*</span>
00007 <span class="comment"> This library is free software; you can redistribute it and/or</span>
00008 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
00009 <span class="comment"> License as published by the Free Software Foundation; either</span>
00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
00011 <span class="comment"></span>
00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
00015 <span class="comment"> Lesser General Public License for more details.</span>
00016 <span class="comment"></span>
00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
00018 <span class="comment"> License along with this library; if not, write to the Free Software</span>
00019 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
00020 <span class="comment"></span>
00021 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
00022 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
00023 <span class="comment"> mkeijzer@dhi.dk</span>
00024 <span class="comment"> */</span>
00025 <span class="comment">//-----------------------------------------------------------------------------</span>
00026
00027 <span class="preprocessor">#ifndef _make_checkpoint_h</span>
00028 <span class="preprocessor"></span><span class="preprocessor">#define _make_checkpoint_h</span>
00029 <span class="preprocessor"></span>
00030 <span class="preprocessor">#include &lt;eoScalarFitness.h&gt;</span>
00031 <span class="preprocessor">#include &lt;utils/selectors.h&gt;</span> <span class="comment">// for minimizing_fitness()</span>
00032 <span class="preprocessor">#include &lt;EO.h&gt;</span>
00033 <span class="preprocessor">#include &lt;eoEvalFuncCounter.h&gt;</span>
00034 <span class="preprocessor">#include &lt;utils/checkpointing&gt;</span>
00035
00036 <span class="comment">// at the moment, in utils/make_help.cpp</span>
00037 <span class="comment">// this should become some eoUtils.cpp with corresponding eoUtils.h</span>
00038 <span class="keywordtype">bool</span> testDirRes(std::string _dirName, <span class="keywordtype">bool</span> _erase);
00040
00041
00042 <span class="keyword">template</span> &lt;<span class="keyword">class</span> EOT&gt;
00043 <a class="code" href="classeo_check_point.html">eoCheckPoint&lt;EOT&gt;</a>&amp; do_make_checkpoint(<a class="code" href="classeo_parser.html">eoParser</a>&amp; _parser, <a class="code" href="classeo_state.html">eoState</a>&amp; _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter&lt;EOT&gt;</a>&amp; _eval, <a class="code" href="classeo_continue.html">eoContinue&lt;EOT&gt;</a>&amp; _continue)
00044 {
00045 <span class="comment">// first, create a checkpoint from the eoContinue</span>
00046 <a class="code" href="classeo_check_point.html">eoCheckPoint&lt;EOT&gt;</a> *checkpoint = <span class="keyword">new</span> <a class="code" href="classeo_check_point.html">eoCheckPoint&lt;EOT&gt;</a>(_continue);
00047 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(checkpoint);
00048
00050 <span class="comment">// Counters</span>
00052 <span class="comment"></span> <span class="comment">// is nb Eval to be used as counter?</span>
00053 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; useEvalParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"useEval"</span>, <span class="stringliteral">"Use nb of eval. as counter (vs nb of gen.)"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>);
00054 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; useTimeParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"useTime"</span>, <span class="stringliteral">"Display time (s) every generation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>);
00055
00056 <span class="comment">// if we want the time, we need an eoTimeCounter</span>
00057 <a class="code" href="classeo_time_counter.html">eoTimeCounter</a> * tCounter = NULL;
00058
00059 <span class="comment">// Create anyway a generation-counter</span>
00060 <span class="comment">// Recent change (03/2002): it is now an eoIncrementorParam, both</span>
00061 <span class="comment">// a parameter AND updater so you can store it into the eoState</span>
00062 <a class="code" href="classeo_incrementor_param.html">eoIncrementorParam&lt;unsigned&gt;</a> *generationCounter = <span class="keyword">new</span> <a class="code" href="classeo_incrementor_param.html">eoIncrementorParam&lt;unsigned&gt;</a>(<span class="stringliteral">"Gen."</span>);
00063 <span class="comment">// store it in the state</span>
00064 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(generationCounter);
00065 <span class="comment">// And add it to the checkpoint,</span>
00066 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*generationCounter);
00067
00068 <span class="comment">// dir for DISK output</span>
00069 <a class="code" href="classeo_value_param.html">eoValueParam&lt;std::string&gt;</a>&amp; dirNameParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(std::string(<span class="stringliteral">"Res"</span>), <span class="stringliteral">"resDir"</span>, <span class="stringliteral">"Directory to store DISK outputs"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Disk"</span>);
00070 <span class="comment">// shoudl we empty it if exists</span>
00071 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; eraseParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"eraseDir"</span>, <span class="stringliteral">"erase files in dirName if any"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Disk"</span>);
00072 <span class="keywordtype">bool</span> dirOK = <span class="keyword">false</span>; <span class="comment">// not tested yet</span>
00073
00075 <span class="comment">// now some statistics on the population:</span>
00077 <span class="comment"></span>
00087 <span class="comment">// Best fitness in population</span>
00088 <span class="comment">//---------------------------</span>
00089 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; printBestParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"printBestStat"</span>, <span class="stringliteral">"Print Best/avg/stdev every gen."</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>);
00090 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; plotBestParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">false</span>, <span class="stringliteral">"plotBestStat"</span>, <span class="stringliteral">"Plot Best/avg Stat"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Graphical"</span>);
00091 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; fileBestParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">false</span>, <span class="stringliteral">"fileBestStat"</span>, <span class="stringliteral">"Output bes/avg/std to file"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Disk"</span>);
00092
00093 <a class="code" href="classeo_best_fitness_stat.html">eoBestFitnessStat&lt;EOT&gt;</a> *bestStat = NULL;
00094 <span class="keywordflow">if</span> ( printBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() || plotBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() || fileBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() )
00095 <span class="comment">// we need the bestStat for at least one of the 3 above</span>
00096 {
00097 bestStat = <span class="keyword">new</span> <a class="code" href="classeo_best_fitness_stat.html">eoBestFitnessStat&lt;EOT&gt;</a>;
00098 <span class="comment">// store it</span>
00099 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(bestStat);
00100 <span class="comment">// add it to the checkpoint</span>
00101 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*bestStat);
00102 }
00103
00104 <span class="comment">// Average fitness alone</span>
00105 <span class="comment">//----------------------</span>
00106 <a class="code" href="classeo_average_stat.html">eoAverageStat&lt;EOT&gt;</a> *averageStat = NULL; <span class="comment">// do we need averageStat?</span>
00107 <span class="keywordflow">if</span> ( plotBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() ) <span class="comment">// we need it for gnuplot output</span>
00108 {
00109 averageStat = <span class="keyword">new</span> <a class="code" href="classeo_average_stat.html">eoAverageStat&lt;EOT&gt;</a>;
00110 <span class="comment">// store it</span>
00111 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(averageStat);
00112 <span class="comment">// add it to the checkpoint</span>
00113 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*averageStat);
00114 }
00115
00116 <span class="comment">// Second moment stats: average and stdev</span>
00117 <span class="comment">//---------------------------------------</span>
00118 <a class="code" href="classeo_second_moment_stats.html">eoSecondMomentStats&lt;EOT&gt;</a> *secondStat = NULL;
00119 <span class="keywordflow">if</span> ( printBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() ) <span class="comment">// we need it for sreen output</span>
00120 {
00121 secondStat = <span class="keyword">new</span> <a class="code" href="classeo_second_moment_stats.html">eoSecondMomentStats&lt;EOT&gt;</a>;
00122 <span class="comment">// store it</span>
00123 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(secondStat);
00124 <span class="comment">// add it to the checkpoint</span>
00125 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*secondStat);
00126 }
00127
00128
00129 <span class="comment">// Dump of the whole population</span>
00130 <span class="comment">//-----------------------------</span>
00131 <a class="code" href="classeo_sorted_pop_stat.html">eoSortedPopStat&lt;EOT&gt;</a> *popStat = NULL;
00132 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a>&amp; printPopParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">false</span>, <span class="stringliteral">"printPop"</span>, <span class="stringliteral">"Print sorted pop. every gen."</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>);
00133 <span class="keywordflow">if</span> ( printPopParam.<a class="code" href="classeo_value_param.html#a2">value</a>() ) <span class="comment">// we do want pop dump</span>
00134 {
00135 popStat = <span class="keyword">new</span> <a class="code" href="classeo_sorted_pop_stat.html">eoSortedPopStat&lt;EOT&gt;</a>;
00136 <span class="comment">// store it</span>
00137 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(popStat);
00138 <span class="comment">// add it to the checkpoint</span>
00139 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*popStat);
00140 }
00141
00142
00143 <span class="comment">// do we wnat some histogram of fitnesses snpashots?</span>
00144 <a class="code" href="classeo_value_param.html">eoValueParam&lt;bool&gt;</a> plotHistogramParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keyword">false</span>, <span class="stringliteral">"plotHisto"</span>, <span class="stringliteral">"Plot histogram of fitnesses"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Graphical"</span>);
00145
00147 <span class="comment">// The monitors</span>
00149 <span class="comment"></span> <span class="comment">// do we want an eoStdoutMonitor?</span>
00150 <span class="keywordtype">bool</span> needStdoutMonitor = printBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>()
00151 || printPopParam.<a class="code" href="classeo_value_param.html#a2">value</a>() ;
00152
00153 <span class="comment">// The Stdout monitor will print parameters to the screen ...</span>
00154 <span class="keywordflow">if</span> ( needStdoutMonitor )
00155 {
00156 <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a> *monitor = <span class="keyword">new</span> <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a>(<span class="keyword">false</span>);
00157 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(monitor);
00158
00159 <span class="comment">// when called by the checkpoint (i.e. at every generation)</span>
00160 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*monitor);
00161
00162 <span class="comment">// the monitor will output a series of parameters: add them</span>
00163 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*generationCounter);
00164 <span class="keywordflow">if</span> (useEvalParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// we want nb of evaluations</span>
00165 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(_eval);
00166 <span class="keywordflow">if</span> (useTimeParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// we want time</span>
00167 {
00168 tCounter = <span class="keyword">new</span> <a class="code" href="classeo_time_counter.html">eoTimeCounter</a>;
00169 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(tCounter);
00170 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*tCounter);
00171 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*tCounter);
00172 }
00173 <span class="keywordflow">if</span> (printBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>())
00174 {
00175 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*bestStat);
00176 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*secondStat);
00177 }
00178 <span class="keywordflow">if</span> ( printPopParam.<a class="code" href="classeo_value_param.html#a2">value</a>())
00179 monitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*popStat);
00180 }
00181
00182 <span class="comment">// first handle the dir test - if we need at least one file</span>
00183 <span class="keywordflow">if</span> ( ( fileBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() || plotBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>() ||
00184 plotHistogramParam.<a class="code" href="classeo_value_param.html#a2">value</a>() )
00185 &amp;&amp; !dirOK ) <span class="comment">// just in case we add something before</span>
00186 dirOK = testDirRes(dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), eraseParam.<a class="code" href="classeo_value_param.html#a2">value</a>()); <span class="comment">// TRUE</span>
00187
00188 <span class="keywordflow">if</span> (fileBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// A file monitor for best &amp; secondMoment</span>
00189 {
00190 <span class="preprocessor">#ifdef _MSVC</span>
00191 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"\best.xg"</span>;
00192 <span class="preprocessor">#else</span>
00193 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"/best.xg"</span>;
00194 <span class="preprocessor">#endif</span>
00195 <span class="preprocessor"></span> <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a> *fileMonitor = <span class="keyword">new</span> <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a>(stmp);
00196 <span class="comment">// save and give to checkpoint</span>
00197 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fileMonitor);
00198 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*fileMonitor);
00199 <span class="comment">// and feed with some statistics</span>
00200 fileMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*generationCounter);
00201 fileMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(_eval);
00202 <span class="keywordflow">if</span> (tCounter) <span class="comment">// we want the time as well</span>
00203 {
00204 <span class="comment">// std::cout &lt;&lt; "On met timecounter\n";</span>
00205 fileMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*tCounter);
00206 }
00207 fileMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*bestStat);
00208 fileMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*secondStat);
00209 }
00210
00211 <span class="keywordflow">if</span> (plotBestParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// an eoGnuplot1DMonitor for best &amp; average</span>
00212 {
00213 std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"/gnu_best.xg"</span>;
00214 <a class="code" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a> *gnuMonitor = <span class="keyword">new</span> <a class="code" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a>(stmp,minimizing_fitness&lt;EOT&gt;());
00215 <span class="comment">// save and give to checkpoint</span>
00216 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(gnuMonitor);
00217 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*gnuMonitor);
00218 <span class="comment">// and feed with some statistics</span>
00219 <span class="keywordflow">if</span> (useEvalParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// do we want eval as X coordinate</span>
00220 gnuMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(_eval);
00221 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (tCounter) <span class="comment">// or time?</span>
00222 gnuMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*tCounter);
00223 <span class="keywordflow">else</span> <span class="comment">// default: generation</span>
00224 gnuMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*generationCounter);
00225 gnuMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*bestStat);
00226 gnuMonitor-&gt;<a class="code" href="classeo_monitor.html#a1">add</a>(*averageStat);
00227 }
00228
00229 <span class="comment">// historgram?</span>
00230 <span class="keywordflow">if</span> (plotHistogramParam.<a class="code" href="classeo_value_param.html#a2">value</a>()) <span class="comment">// want to see how the fitness is spread?</span>
00231 {
00232 <a class="code" href="classeo_scalar_fitness_stat.html">eoScalarFitnessStat&lt;EOT&gt;</a> *fitStat = <span class="keyword">new</span> <a class="code" href="classeo_scalar_fitness_stat.html">eoScalarFitnessStat&lt;EOT&gt;</a>;
00233 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fitStat);
00234 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*fitStat);
00235 <span class="comment">// a gnuplot-based monitor for snapshots: needs a dir name</span>
00236 <a class="code" href="classeo_gnuplot1_d_snapshot.html">eoGnuplot1DSnapshot</a> *fitSnapshot = <span class="keyword">new</span> <a class="code" href="classeo_gnuplot1_d_snapshot.html">eoGnuplot1DSnapshot</a>(dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>());
00237 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fitSnapshot);
00238 <span class="comment">// add any stat that is a std::vector&lt;double&gt; to it</span>
00239 fitSnapshot-&gt;<a class="code" href="classeo_file_snapshot.html#a9">add</a>(*fitStat);
00240 <span class="comment">// and of course add it to the checkpoint</span>
00241 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*fitSnapshot);
00242 }
00243
00245 <span class="comment">// State savers</span>
00247 <span class="comment"></span>
00248 <span class="comment">// feed the state to state savers</span>
00249 <span class="comment">// save state every N generation</span>
00250 <a class="code" href="classeo_value_param.html">eoValueParam&lt;unsigned&gt;</a>&amp; saveFrequencyParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keywordtype">unsigned</span>(0), <span class="stringliteral">"saveFrequency"</span>, <span class="stringliteral">"Save every F generation (0 = only final state, absent = never)"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Persistence"</span> );
00251
00252 <span class="keywordflow">if</span> (_parser.<a class="code" href="classeo_parser.html#a8">isItThere</a>(saveFrequencyParam))
00253 {
00254 <span class="comment">// first make sure dirName is OK</span>
00255 <span class="keywordflow">if</span> (! dirOK )
00256 dirOK = testDirRes(dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), eraseParam.<a class="code" href="classeo_value_param.html#a2">value</a>()); <span class="comment">// TRUE</span>
00257
00258 <span class="keywordtype">unsigned</span> freq = (saveFrequencyParam.<a class="code" href="classeo_value_param.html#a2">value</a>()&gt;0 ? saveFrequencyParam.<a class="code" href="classeo_value_param.html#a2">value</a>() : UINT_MAX );
00259 <span class="preprocessor">#ifdef _MSVC</span>
00260 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"\generations"</span>;
00261 <span class="preprocessor">#else</span>
00262 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"/generations"</span>;
00263 <span class="preprocessor">#endif</span>
00264 <span class="preprocessor"></span> <a class="code" href="classeo_counted_state_saver.html">eoCountedStateSaver</a> *stateSaver1 = <span class="keyword">new</span> <a class="code" href="classeo_counted_state_saver.html">eoCountedStateSaver</a>(freq, _state, stmp);
00265 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(stateSaver1);
00266 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*stateSaver1);
00267 }
00268
00269 <span class="comment">// save state every T seconds</span>
00270 <a class="code" href="classeo_value_param.html">eoValueParam&lt;unsigned&gt;</a>&amp; saveTimeIntervalParam = _parser.<a class="code" href="classeo_parameter_loader.html#a3">createParam</a>(<span class="keywordtype">unsigned</span>(0), <span class="stringliteral">"saveTimeInterval"</span>, <span class="stringliteral">"Save every T seconds (0 or absent = never)"</span>, <span class="charliteral">'\0'</span>,<span class="stringliteral">"Persistence"</span> );
00271 <span class="keywordflow">if</span> (_parser.<a class="code" href="classeo_parser.html#a8">isItThere</a>(saveTimeIntervalParam) &amp;&amp; saveTimeIntervalParam.<a class="code" href="classeo_value_param.html#a2">value</a>()&gt;0)
00272 {
00273 <span class="comment">// first make sure dirName is OK</span>
00274 <span class="keywordflow">if</span> (! dirOK )
00275 dirOK = testDirRes(dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), eraseParam.<a class="code" href="classeo_value_param.html#a2">value</a>()); <span class="comment">// TRUE</span>
00276
00277 <span class="preprocessor">#ifdef _MSVC</span>
00278 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"\time"</span>;
00279 <span class="preprocessor">#else</span>
00280 <span class="preprocessor"></span> std::string stmp = dirNameParam.<a class="code" href="classeo_value_param.html#a2">value</a>() + <span class="stringliteral">"/time"</span>;
00281 <span class="preprocessor">#endif</span>
00282 <span class="preprocessor"></span> <a class="code" href="classeo_timed_state_saver.html">eoTimedStateSaver</a> *stateSaver2 = <span class="keyword">new</span> <a class="code" href="classeo_timed_state_saver.html">eoTimedStateSaver</a>(saveTimeIntervalParam.<a class="code" href="classeo_value_param.html#a2">value</a>(), _state, stmp);
00283 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(stateSaver2);
00284 checkpoint-&gt;<a class="code" href="classeo_check_point.html#a2">add</a>(*stateSaver2);
00285 }
00286
00287 <span class="comment">// and that's it for the (control and) output</span>
00288 <span class="keywordflow">return</span> *checkpoint;
00289 }
00290
00291 <span class="preprocessor">#endif</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>