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
|
|
@ -0,0 +1,215 @@
|
|||
<!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_assembled.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> / <a class="el" href="dir_000025.html">do</a></div>
|
||||
<h1>make_checkpoint_assembled.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_assembled.h</span>
|
||||
00005 <span class="comment">// Marc Wintermantel & Oliver Koenig</span>
|
||||
00006 <span class="comment">// IMES-ST@ETHZ.CH</span>
|
||||
00007 <span class="comment">// March 2003</span>
|
||||
00008
|
||||
00009 <span class="comment">/*</span>
|
||||
00010 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
||||
00011 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
||||
00012 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
||||
00013 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
||||
00014 <span class="comment"></span>
|
||||
00015 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
||||
00016 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00017 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00018 <span class="comment"> Lesser General Public License for more details.</span>
|
||||
00019 <span class="comment"></span>
|
||||
00020 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
||||
00021 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
||||
00022 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00023 <span class="comment"></span>
|
||||
00024 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
||||
00025 <span class="comment"> Marc.Schoenauer@inria.fr</span>
|
||||
00026 <span class="comment"> mak@dhi.dk</span>
|
||||
00027 <span class="comment">*/</span>
|
||||
00028 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00029
|
||||
00030 <span class="preprocessor">#ifndef _make_checkpoint_assembled_h</span>
|
||||
00031 <span class="preprocessor"></span><span class="preprocessor">#define _make_checkpoint_assembled_h</span>
|
||||
00032 <span class="preprocessor"></span>
|
||||
00033 <span class="preprocessor">#include <vector></span>
|
||||
00034 <span class="preprocessor">#include <string></span>
|
||||
00035
|
||||
00036 <span class="preprocessor">#include <eoScalarFitnessAssembled.h></span>
|
||||
00037 <span class="preprocessor">#include <utils/selectors.h></span>
|
||||
00038 <span class="preprocessor">#include <EO.h></span>
|
||||
00039 <span class="preprocessor">#include <eoEvalFuncCounter.h></span>
|
||||
00040 <span class="preprocessor">#include <utils/checkpointing></span>
|
||||
00041
|
||||
00042 <span class="comment">// at the moment, in utils/make_help.cpp</span>
|
||||
00043 <span class="comment">// this should become some eoUtils.cpp with corresponding eoUtils.h</span>
|
||||
00044 <span class="keywordtype">bool</span> testDirRes(std::string _dirName, <span class="keywordtype">bool</span> _erase);
|
||||
00046
|
||||
00048 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
00049 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a>& do_make_checkpoint_assembled(<a class="code" href="classeo_parser.html">eoParser</a>& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<EOT></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<EOT></a>& _continue)
|
||||
00050 {
|
||||
00051
|
||||
00052 <span class="comment">// SOME PARSER PARAMETERS</span>
|
||||
00053 <span class="comment">// ----------------------</span>
|
||||
00054 std::string dirName = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(std::string(<span class="stringliteral">"Res"</span>), <span class="stringliteral">"resDir"</span>,
|
||||
00055 <span class="stringliteral">"Directory to store DISK outputs"</span>,
|
||||
00056 <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>).value();
|
||||
00057 <span class="keywordtype">bool</span> erase = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"eraseDir"</span>,
|
||||
00058 <span class="stringliteral">"Erase files in dirName if any"</span>,
|
||||
00059 <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>).value();
|
||||
00060 <span class="keywordtype">bool</span> gnuplots = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"plots"</span>,
|
||||
00061 <span class="stringliteral">"Plot stuff using GnuPlot"</span>,
|
||||
00062 <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>).value();
|
||||
00063 <span class="keywordtype">bool</span> printFile = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keyword">true</span>, <span class="stringliteral">"printFile"</span>,
|
||||
00064 <span class="stringliteral">"Print statistics file"</span>,
|
||||
00065 <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output"</span>).value();
|
||||
00066
|
||||
00067 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned></a>& saveFrequencyParam
|
||||
00068 = _parser.<a class="code" href="classeo_parser.html#a10">getORcreateParam</a>(<span class="keywordtype">unsigned</span>(0), <span class="stringliteral">"saveFrequency"</span>,
|
||||
00069 <span class="stringliteral">"Save every F generation (0 = only final state, absent = never)"</span>,
|
||||
00070 <span class="charliteral">'\0'</span>, <span class="stringliteral">"Persistence"</span> );
|
||||
00071
|
||||
00072 testDirRes(dirName, erase); <span class="comment">// TRUE</span>
|
||||
00073
|
||||
00074 <span class="comment">// CREATE CHECKPOINT FROM eoContinue</span>
|
||||
00075 <span class="comment">// ---------------------------------</span>
|
||||
00076 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a> *checkpoint = <span class="keyword">new</span> <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a>(_continue);
|
||||
00077 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(checkpoint);
|
||||
00078
|
||||
00079 <span class="comment">// GENERATIONS</span>
|
||||
00080 <span class="comment">// -----------</span>
|
||||
00081 <a class="code" href="classeo_incrementor_param.html">eoIncrementorParam<unsigned></a> *generationCounter = <span class="keyword">new</span> <a class="code" href="classeo_incrementor_param.html">eoIncrementorParam<unsigned></a>(<span class="stringliteral">"Gen."</span>);
|
||||
00082 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(generationCounter);
|
||||
00083 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*generationCounter);
|
||||
00084
|
||||
00085 <span class="comment">// TIME</span>
|
||||
00086 <span class="comment">// ----</span>
|
||||
00087 <a class="code" href="classeo_time_counter.html">eoTimeCounter</a> * tCounter = NULL;
|
||||
00088 tCounter = <span class="keyword">new</span> <a class="code" href="classeo_time_counter.html">eoTimeCounter</a>;
|
||||
00089 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(tCounter);
|
||||
00090 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*tCounter);
|
||||
00091
|
||||
00092 <span class="comment">// ACCESS DESCRIPTIONS OF TERMS OF FITNESS CLASS</span>
|
||||
00093 <span class="comment">// ---------------------------------------------</span>
|
||||
00094 <span class="comment">// define a temporary fitness instance</span>
|
||||
00095 <span class="keyword">typedef</span> <span class="keyword">typename</span> EOT::Fitness Fit;
|
||||
00096 Fit fit;
|
||||
00097 std::vector<std::string> fitness_descriptions = fit.getDescriptionVector();
|
||||
00098 <span class="keywordtype">unsigned</span> nTerms = fitness_descriptions.size();
|
||||
00099
|
||||
00100 <span class="comment">// STAT VALUES OF A POPULATION</span>
|
||||
00101 <span class="comment">// ---------------------------</span>
|
||||
00102
|
||||
00103 <span class="comment">// average vals</span>
|
||||
00104 std::vector<eoAssembledFitnessAverageStat<EOT>* > avgvals( nTerms );
|
||||
00105 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i < nTerms; ++i){
|
||||
00106 std::string descr = <span class="stringliteral">"Avg. of "</span> + fitness_descriptions[i];
|
||||
00107 avgvals[i] = <span class="keyword">new</span> <a class="code" href="classeo_assembled_fitness_average_stat.html">eoAssembledFitnessAverageStat<EOT></a>(i, descr);
|
||||
00108 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>( avgvals[i] );
|
||||
00109 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>( *avgvals[i] );
|
||||
00110 }
|
||||
00111
|
||||
00112 <span class="comment">// best vals</span>
|
||||
00113 std::vector<eoAssembledFitnessBestStat<EOT>* > bestvals( nTerms );
|
||||
00114 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j=0; j < nTerms; ++j){
|
||||
00115 std::string descr = fitness_descriptions[j] + <span class="stringliteral">" of best ind."</span>;
|
||||
00116 bestvals[j] = <span class="keyword">new</span> <a class="code" href="classeo_assembled_fitness_best_stat.html">eoAssembledFitnessBestStat<EOT></a>(j, descr);
|
||||
00117 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>( bestvals[j] );
|
||||
00118 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>( *bestvals[j] );
|
||||
00119 }
|
||||
00120
|
||||
00121 <span class="comment">// STDOUT</span>
|
||||
00122 <span class="comment">// ------</span>
|
||||
00123 <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>);
|
||||
00124 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(monitor);
|
||||
00125 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*monitor);
|
||||
00126 monitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*generationCounter);
|
||||
00127 monitor-><a class="code" href="classeo_monitor.html#a1">add</a>(_eval);
|
||||
00128 monitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*tCounter);
|
||||
00129
|
||||
00130 <span class="comment">// Add best fitness</span>
|
||||
00131 monitor-><a class="code" href="classeo_monitor.html#a1">add</a>( *bestvals[0] );
|
||||
00132
|
||||
00133 <span class="comment">// Add all average vals</span>
|
||||
00134 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> l=0; l < nTerms; ++l)
|
||||
00135 monitor-><a class="code" href="classeo_monitor.html#a1">add</a>( *avgvals[l] );
|
||||
00136
|
||||
00137 <span class="comment">// GNUPLOT</span>
|
||||
00138 <span class="comment">// -------</span>
|
||||
00139 <span class="keywordflow">if</span> (gnuplots ){
|
||||
00140 std::string stmp;
|
||||
00141
|
||||
00142 <span class="comment">// Histogramm of the different fitness vals</span>
|
||||
00143 <a class="code" href="classeo_scalar_fitness_stat.html">eoScalarFitnessStat<EOT></a> *fitStat = <span class="keyword">new</span> <a class="code" href="classeo_scalar_fitness_stat.html">eoScalarFitnessStat<EOT></a>;
|
||||
00144 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fitStat);
|
||||
00145 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*fitStat);
|
||||
00146 <span class="comment">// a gnuplot-based monitor for snapshots: needs a dir name</span>
|
||||
00147 <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>(dirName);
|
||||
00148 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fitSnapshot);
|
||||
00149 <span class="comment">// add any stat that is a vector<double> to it</span>
|
||||
00150 fitSnapshot-><a class="code" href="classeo_file_snapshot.html#a9">add</a>(*fitStat);
|
||||
00151 <span class="comment">// and of course add it to the checkpoint</span>
|
||||
00152 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*fitSnapshot);
|
||||
00153
|
||||
00154 std::vector<eoGnuplot1DMonitor*> gnumonitors(nTerms, NULL );
|
||||
00155 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> k=0; k < nTerms; ++k){
|
||||
00156 stmp = dirName + <span class="stringliteral">"/gnuplot_"</span> + fitness_descriptions[k] + <span class="stringliteral">".xg"</span>;
|
||||
00157 gnumonitors[k] = <span class="keyword">new</span> <a class="code" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a>(stmp,<span class="keyword">true</span>);
|
||||
00158 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(gnumonitors[k]);
|
||||
00159 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*gnumonitors[k]);
|
||||
00160 gnumonitors[k]-><a class="code" href="classeo_check_point.html#a2">add</a>(*generationCounter);
|
||||
00161 gnumonitors[k]-><a class="code" href="classeo_check_point.html#a2">add</a>(*bestvals[k]);
|
||||
00162 gnumonitors[k]-><a class="code" href="classeo_check_point.html#a2">add</a>(*avgvals[k]);
|
||||
00163 }
|
||||
00164
|
||||
00165 }
|
||||
00166
|
||||
00167 <span class="comment">// WRITE STUFF TO FILE</span>
|
||||
00168 <span class="comment">// -------------------</span>
|
||||
00169 <span class="keywordflow">if</span>( printFile ){
|
||||
00170 std::string stmp2 = dirName + <span class="stringliteral">"/eoStatistics.sav"</span>;
|
||||
00171 <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>(stmp2);
|
||||
00172 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(fileMonitor);
|
||||
00173 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*fileMonitor);
|
||||
00174 fileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*generationCounter);
|
||||
00175 fileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(_eval);
|
||||
00176 fileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*tCounter);
|
||||
00177
|
||||
00178 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i < nTerms; ++i){
|
||||
00179 fileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*bestvals[i]);
|
||||
00180 fileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(*avgvals[i]);
|
||||
00181 }
|
||||
00182
|
||||
00183 }
|
||||
00184
|
||||
00185 <span class="comment">// STATE SAVER</span>
|
||||
00186 <span class="comment">// -----------</span>
|
||||
00187 <span class="comment">// feed the state to state savers</span>
|
||||
00188
|
||||
00189 <span class="keywordflow">if</span> (_parser.<a class="code" href="classeo_parser.html#a8">isItThere</a>(saveFrequencyParam)) {
|
||||
00190
|
||||
00191 <span class="keywordtype">unsigned</span> freq = (saveFrequencyParam.<a class="code" href="classeo_value_param.html#a2">value</a>() > 0 ? saveFrequencyParam.<a class="code" href="classeo_value_param.html#a2">value</a>() : UINT_MAX );
|
||||
00192 std::string stmp = dirName + <span class="stringliteral">"/generations"</span>;
|
||||
00193 <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);
|
||||
00194 _state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(stateSaver1);
|
||||
00195 checkpoint-><a class="code" href="classeo_check_point.html#a2">add</a>(*stateSaver1);
|
||||
00196 }
|
||||
00197
|
||||
00198 <span class="comment">// and that's it for the (control and) output</span>
|
||||
00199 <span class="keywordflow">return</span> *checkpoint;
|
||||
00200 }
|
||||
00201
|
||||
00202 <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
|
||||
<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