paradiseo/trunk/paradiseo-peo/doc/html/LessonParallelAlgorithm_2main_8cpp-source.html
legrand abc68c9e88 completed doc
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@665 331e1502-861f-0410-8da2-ba01fb791d7f
2007-10-08 09:41:23 +00:00

366 lines
45 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-PEOMovingObjects: main.cpp 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.4.7 -->
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</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>main.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// "main.cpp"</span>
<a name="l00002"></a>00002
<a name="l00003"></a>00003 <span class="comment">// (c) OPAC Team, LIFL, January 2006</span>
<a name="l00004"></a>00004
<a name="l00005"></a>00005 <span class="comment">/* </span>
<a name="l00006"></a>00006 <span class="comment"> Contact: paradiseo-help@lists.gforge.inria.fr</span>
<a name="l00007"></a>00007 <span class="comment">*/</span>
<a name="l00008"></a>00008
<a name="l00009"></a>00009 <span class="preprocessor">#include &lt;eo&gt;</span>
<a name="l00010"></a>00010 <span class="preprocessor">#include &lt;paradiseo&gt;</span>
<a name="l00011"></a>00011
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;peoParallelAlgorithmWrapper.h&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;peoSynchronousMultiStart.h&gt;</span>
<a name="l00014"></a>00014
<a name="l00015"></a>00015
<a name="l00016"></a>00016
<a name="l00017"></a>00017 <span class="preprocessor">#include "route.h"</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include "route_init.h"</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include "route_eval.h"</span>
<a name="l00020"></a>00020
<a name="l00021"></a>00021 <span class="preprocessor">#include "order_xover.h"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "city_swap.h"</span>
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include "param.h"</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026
<a name="l00027"></a>00027
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;mo.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;graph.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;route.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;route_eval.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;route_init.h&gt;</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;two_opt.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;two_opt_init.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;two_opt_next.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;two_opt_incr_eval.h&gt;</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#define RANDOM_POP_SIZE 30</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="preprocessor">#define RANDOM_ITERATIONS 10</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#define POP_SIZE 10</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="preprocessor">#define NUM_GEN 100</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="preprocessor">#define CROSS_RATE 1.0</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span><span class="preprocessor">#define MUT_RATE 0.01</span>
<a name="l00051"></a>00051 <span class="preprocessor"></span>
<a name="l00052"></a>00052 <span class="preprocessor">#define NUMBER_OF_POPULATIONS 3</span>
<a name="l00053"></a>00053 <span class="preprocessor"></span>
<a name="l00054"></a>00054
<a name="l00055"></a>00055
<a name="l00056"></a><a class="code" href="structRandomExplorationAlgorithm.html">00056</a> <span class="keyword">struct </span><a class="code" href="structRandomExplorationAlgorithm.html">RandomExplorationAlgorithm</a> {
<a name="l00057"></a>00057
<a name="l00058"></a><a class="code" href="structRandomExplorationAlgorithm.html#ed4847c164759fbb1168948d3620037c">00058</a> <a class="code" href="structRandomExplorationAlgorithm.html#ed4847c164759fbb1168948d3620037c">RandomExplorationAlgorithm</a>( <a class="code" href="classpeoPopEval.html">peoPopEval&lt; Route &gt;</a>&amp; __popEval, <a class="code" href="classpeoSynchronousMultiStart.html">peoSynchronousMultiStart&lt; Route &gt;</a>&amp; extParallelExecution )
<a name="l00059"></a>00059 : <a class="code" href="structRandomExplorationAlgorithm.html#e9fbab7402f290c62224cedebd9de0a4">popEval</a>( __popEval ), <a class="code" href="structRandomExplorationAlgorithm.html#e36e837e956772738773364cd71201de">parallelExecution</a>( extParallelExecution ) {
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="comment">// the sequential algorithm to be executed in parallel by the wrapper</span>
<a name="l00064"></a><a class="code" href="structRandomExplorationAlgorithm.html#3a7b3cc174726fff45985854c3d1b812">00064</a> <span class="keywordtype">void</span> <a class="code" href="structRandomExplorationAlgorithm.html#3a7b3cc174726fff45985854c3d1b812">operator()</a>() {
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_init.html">RouteInit</a> route_init; <span class="comment">// random init object - creates random Route objects</span>
<a name="l00067"></a>00067 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> route_eval;
<a name="l00068"></a>00068 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_pop.html">eoPop&lt; Route &gt;</a> population( RANDOM_POP_SIZE, route_init );
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <a class="code" href="structRandomExplorationAlgorithm.html#e9fbab7402f290c62224cedebd9de0a4">popEval</a>( population );
<a name="l00071"></a>00071
<a name="l00072"></a>00072
<a name="l00073"></a>00073 <span class="comment">// executing HCs on the population in parallel</span>
<a name="l00074"></a>00074 <a class="code" href="structRandomExplorationAlgorithm.html#e36e837e956772738773364cd71201de">parallelExecution</a>( population );
<a name="l00075"></a>00075
<a name="l00076"></a>00076
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="comment">// just to show off :: HCs on a vector of Route objects</span>
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_vector.html">Route</a>* rVect = <span class="keyword">new</span> <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_vector.html">Route</a>[ 5 ];
<a name="l00081"></a>00081 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; 5; index++ ) {
<a name="l00082"></a>00082
<a name="l00083"></a>00083 route_init( rVect[ index ] ); route_eval( rVect[ index ] );
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="comment">// applying the HCs on the vector of Route objects</span>
<a name="l00087"></a>00087 <a class="code" href="structRandomExplorationAlgorithm.html#e36e837e956772738773364cd71201de">parallelExecution</a>( rVect, rVect + 5 );
<a name="l00088"></a>00088 <span class="keyword">delete</span>[] rVect;
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090
<a name="l00091"></a>00091
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_vector.html">Route</a> bestRoute = population.<a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_pop.html#bd89eb233cb6af943eab45f2533d06cf">best_element</a>();
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; RANDOM_ITERATIONS; index++ ) {
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> routeIndex = 0; routeIndex &lt; RANDOM_POP_SIZE; routeIndex++ ) {
<a name="l00098"></a>00098
<a name="l00099"></a>00099 route_init( population[ routeIndex ] );
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <a class="code" href="structRandomExplorationAlgorithm.html#e9fbab7402f290c62224cedebd9de0a4">popEval</a>( population );
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <span class="keywordflow">if</span> ( fabs( population.best_element().fitness() ) &lt; fabs( bestRoute.<a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/class_e_o.html#57d5610c9296eb927816a2f06bd00a08">fitness</a>() ) ) bestRoute = population.best_element();
<a name="l00105"></a>00105
<a name="l00106"></a>00106 std::cout &lt;&lt; <span class="stringliteral">"Random Iteration #"</span> &lt;&lt; index &lt;&lt; <span class="stringliteral">"... [ "</span> &lt;&lt; bestRoute.<a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/class_e_o.html#57d5610c9296eb927816a2f06bd00a08">fitness</a>() &lt;&lt; <span class="stringliteral">" ]"</span> &lt;&lt; std::flush &lt;&lt; std::endl;
<a name="l00107"></a>00107 }
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109
<a name="l00110"></a>00110
<a name="l00111"></a><a class="code" href="structRandomExplorationAlgorithm.html#e9fbab7402f290c62224cedebd9de0a4">00111</a> <a class="code" href="classpeoPopEval.html">peoPopEval&lt; Route &gt;</a>&amp; <a class="code" href="structRandomExplorationAlgorithm.html#e9fbab7402f290c62224cedebd9de0a4">popEval</a>;
<a name="l00112"></a><a class="code" href="structRandomExplorationAlgorithm.html#e36e837e956772738773364cd71201de">00112</a> <a class="code" href="classpeoSynchronousMultiStart.html">peoSynchronousMultiStart&lt; Route &gt;</a>&amp; <a class="code" href="structRandomExplorationAlgorithm.html#e36e837e956772738773364cd71201de">parallelExecution</a>;
<a name="l00113"></a>00113 };
<a name="l00114"></a>00114
<a name="l00115"></a>00115
<a name="l00116"></a>00116
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <span class="keywordtype">int</span> main( <span class="keywordtype">int</span> __argc, <span class="keywordtype">char</span>** __argv ) {
<a name="l00119"></a>00119
<a name="l00120"></a>00120 srand( time(NULL) );
<a name="l00121"></a>00121
<a name="l00122"></a>00122
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="comment">// initializing the ParadisEO-PEO environment</span>
<a name="l00125"></a>00125 <a class="code" href="namespacepeo.html#8184c3b1f7eecc68f69bb8e8b872a7d3">peo :: init</a>( __argc, __argv );
<a name="l00126"></a>00126
<a name="l00127"></a>00127
<a name="l00128"></a>00128 <span class="comment">// processing the command line specified parameters</span>
<a name="l00129"></a>00129 loadParameters( __argc, __argv );
<a name="l00130"></a>00130
<a name="l00131"></a>00131
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00134"></a>00134 <span class="comment">// #1 An EO evolutionary algorithm to be executed in parallel with other algorithms (no parallel evaluation, no etc.).</span>
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="comment">// init, eval operators, EA operators -------------------------------------------------------------------------------------------------------------</span>
<a name="l00137"></a>00137 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_init.html">RouteInit</a> route_init; <span class="comment">// random init object - creates random Route objects</span>
<a name="l00138"></a>00138 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> full_eval; <span class="comment">// evaluator object - offers a fitness value for a specified Route object</span>
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_order_xover.html">OrderXover</a> crossover; <span class="comment">// crossover operator - creates two offsprings out of two specified parents</span>
<a name="l00141"></a>00141 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_city_swap.html">CitySwap</a> mutation; <span class="comment">// mutation operator - randomly mutates one gene for a specified individual</span>
<a name="l00142"></a>00142 <span class="comment">// ------------------------------------------------------------------------------------------------------------------------------------------------</span>
<a name="l00143"></a>00143
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="comment">// evolutionary algorithm components --------------------------------------------------------------------------------------------------------------</span>
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_pop.html">eoPop&lt; Route &gt;</a> population( POP_SIZE, route_init ); <span class="comment">// initial population for the algorithm having POP_SIZE individuals</span>
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_gen_continue.html">eoGenContinue&lt; Route &gt;</a> eaCont( NUM_GEN ); <span class="comment">// continuation criterion - the algorithm will iterate for NUM_GEN generations</span>
<a name="l00150"></a>00150 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_check_point.html">eoCheckPoint&lt; Route &gt;</a> eaCheckpointContinue( eaCont ); <span class="comment">// checkpoint object - verify at each iteration if the continuation criterion is met</span>
<a name="l00151"></a>00151
<a name="l00152"></a>00152 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_ranking_select.html">eoRankingSelect&lt; Route &gt;</a> selectionStrategy; <span class="comment">// selection strategy - applied at each iteration for selecting parent individuals</span>
<a name="l00153"></a>00153 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_select_number.html">eoSelectNumber&lt; Route &gt;</a> eaSelect( selectionStrategy, POP_SIZE ); <span class="comment">// selection object - POP_SIZE individuals are selected at each iteration</span>
<a name="l00154"></a>00154
<a name="l00155"></a>00155 <span class="comment">// transform operator - includes the crossover and the mutation operators with a specified associated rate</span>
<a name="l00156"></a>00156 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_s_g_a_transform.html">eoSGATransform&lt; Route &gt;</a> transform( crossover, CROSS_RATE, mutation, MUT_RATE );
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_plus_replacement.html">eoPlusReplacement&lt; Route &gt;</a> eaReplace; <span class="comment">// replacement strategy - for replacing the initial population with offspring individuals</span>
<a name="l00159"></a>00159 <span class="comment">// ------------------------------------------------------------------------------------------------------------------------------------------------</span>
<a name="l00160"></a>00160
<a name="l00161"></a>00161
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00164"></a>00164 <span class="comment">// SEQENTIAL ALGORITHM DEFINITION -----------------------------------------------------------------------------------------------------------------</span>
<a name="l00165"></a>00165 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_easy_e_a.html">eoEasyEA&lt; Route &gt;</a> eaAlg( eaCheckpointContinue, full_eval, eaSelect, transform, eaReplace );
<a name="l00166"></a>00166 <span class="comment">// SEQENTIAL ALGORITHM DEFINITION -----------------------------------------------------------------------------------------------------------------</span>
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00169"></a>00169 <a class="code" href="classpeoParallelAlgorithmWrapper.html">peoParallelAlgorithmWrapper</a> parallelEAAlg( eaAlg, population ); <span class="comment">// specifying the embedded algorithm and the algorithm input data</span>
<a name="l00170"></a>00170 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00171"></a>00171 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00172"></a>00172 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00173"></a>00173
<a name="l00174"></a>00174
<a name="l00175"></a>00175
<a name="l00176"></a>00176
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00179"></a>00179 <span class="comment">// #2 A MO hill climbing to be executed in parallel with other algorithms (no parallel evaluation, no etc.).</span>
<a name="l00180"></a>00180
<a name="l00181"></a>00181 <span class="keywordflow">if</span> ( getNodeRank() == 1 ) {
<a name="l00182"></a>00182
<a name="l00183"></a>00183 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/namespace_graph.html#95f0bc08fa93f8f4abf1801674488b30">Graph::load</a>( __argv [ 1 ] );
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_vector.html">Route</a> route;
<a name="l00187"></a>00187 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_init.html">RouteInit</a> <a class="code" href="namespacepeo.html#8184c3b1f7eecc68f69bb8e8b872a7d3">init</a>; init( route );
<a name="l00188"></a>00188 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> full_evalHC; full_evalHC( route );
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordflow">if</span> ( getNodeRank() == 1 ) {
<a name="l00191"></a>00191
<a name="l00192"></a>00192 std :: cout &lt;&lt; <span class="stringliteral">"[From] "</span> &lt;&lt; route &lt;&lt; std :: endl;
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194
<a name="l00195"></a>00195
<a name="l00196"></a>00196 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_two_opt_init.html">TwoOptInit</a> two_opt_init;
<a name="l00197"></a>00197 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_two_opt_next.html">TwoOptNext</a> two_opt_next;
<a name="l00198"></a>00198 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_two_opt_incr_eval.html">TwoOptIncrEval</a> two_opt_incr_eval;
<a name="l00199"></a>00199
<a name="l00200"></a>00200 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/classmo_best_impr_select.html">moBestImprSelect&lt; TwoOpt &gt;</a> two_opt_select;
<a name="l00201"></a>00201
<a name="l00202"></a>00202
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00205"></a>00205 <span class="comment">// SEQENTIAL ALGORITHM DEFINITION -----------------------------------------------------------------------------------------------------------------</span>
<a name="l00206"></a>00206 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/classmo_h_c.html">moHC&lt; TwoOpt &gt;</a> hill_climbing( two_opt_init, two_opt_next, two_opt_incr_eval, two_opt_select, full_evalHC );
<a name="l00207"></a>00207 <span class="comment">// SEQENTIAL ALGORITHM DEFINITION -----------------------------------------------------------------------------------------------------------------</span>
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00210"></a>00210 <a class="code" href="classpeoParallelAlgorithmWrapper.html">peoParallelAlgorithmWrapper</a> parallelHillClimbing( hill_climbing, route ); <span class="comment">// specifying the embedded algorithm and the algorithm input data</span>
<a name="l00211"></a>00211 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00212"></a>00212 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00213"></a>00213 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00214"></a>00214
<a name="l00215"></a>00215
<a name="l00216"></a>00216
<a name="l00217"></a>00217
<a name="l00218"></a>00218
<a name="l00219"></a>00219
<a name="l00220"></a>00220 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00221"></a>00221 <span class="comment">// #3 A user defined algorithm to be executed in parallel with other algorithms - parallel evaluation and synchronous </span>
<a name="l00222"></a>00222 <span class="comment">// multi-start of several hill-climbing algorithms (inside the user defined algorithm)!!.</span>
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> full_evalRandom;
<a name="l00225"></a>00225 <a class="code" href="classpeoParaPopEval.html">peoParaPopEval&lt; Route &gt;</a> randomParaEval( full_evalRandom );
<a name="l00226"></a>00226
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <a class="code" href="classpeoSynchronousMultiStart.html">peoSynchronousMultiStart&lt; Route &gt;</a> parallelExecution( hill_climbing );
<a name="l00229"></a>00229
<a name="l00230"></a>00230 <a class="code" href="structRandomExplorationAlgorithm.html">RandomExplorationAlgorithm</a> randomExplorationAlgorithm( randomParaEval, parallelExecution );
<a name="l00231"></a>00231
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00234"></a>00234 <a class="code" href="classpeoParallelAlgorithmWrapper.html">peoParallelAlgorithmWrapper</a> parallelRandExp( randomExplorationAlgorithm ); <span class="comment">// specifying the embedded algorithm - no input data in this case</span>
<a name="l00235"></a>00235
<a name="l00236"></a>00236 randomParaEval.setOwner( parallelRandExp );
<a name="l00237"></a>00237 parallelExecution.setOwner( parallelRandExp );
<a name="l00238"></a>00238 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00239"></a>00239 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00240"></a>00240
<a name="l00241"></a>00241
<a name="l00242"></a>00242
<a name="l00243"></a>00243
<a name="l00244"></a>00244 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00245"></a>00245 <span class="comment">// #4 Synchronous Multi-Start: several hill-climbing algorithms launched in parallel on different initial solutions</span>
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_init.html">RouteInit</a> ex_hc_route_init; <span class="comment">// random init object - creates random Route objects</span>
<a name="l00248"></a>00248 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> ex_hc_full_eval; <span class="comment">// evaluator object - offers a fitness value for a specified Route object</span>
<a name="l00249"></a>00249
<a name="l00250"></a>00250 <a class="codeRef" doxygen="eo.doxytag:http://eodev.sourceforge.net/eo/doc/html/" href="http://eodev.sourceforge.net/eo/doc/html/classeo_pop.html">eoPop&lt; Route &gt;</a> ex_hc_population( POP_SIZE, ex_hc_route_init );
<a name="l00251"></a>00251
<a name="l00252"></a>00252 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; POP_SIZE; index++ ) {
<a name="l00253"></a>00253
<a name="l00254"></a>00254 ex_hc_full_eval( ex_hc_population[ index ] );
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257
<a name="l00258"></a>00258 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00259"></a>00259 <a class="code" href="classpeoSynchronousMultiStart.html">peoSynchronousMultiStart&lt; Route &gt;</a> ex_hc_parallelExecution( hill_climbing );
<a name="l00260"></a>00260 <a class="code" href="classpeoParallelAlgorithmWrapper.html">peoParallelAlgorithmWrapper</a> ex_hc_parallel( ex_hc_parallelExecution, ex_hc_population ); <span class="comment">// specifying the embedded algorithm - no input data in this case</span>
<a name="l00261"></a>00261
<a name="l00262"></a>00262 ex_hc_parallelExecution.setOwner( ex_hc_parallel );
<a name="l00263"></a>00263 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00264"></a>00264 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00265"></a>00265
<a name="l00266"></a>00266
<a name="l00267"></a>00267
<a name="l00268"></a>00268
<a name="l00269"></a>00269
<a name="l00270"></a>00270 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00271"></a>00271 <span class="comment">// #5 Synchronous Multi-Start: Multiple EO evolutionary algorithms to be executed in parallel</span>
<a name="l00272"></a>00272 <span class="comment">// (inside different processes, on different populations; no parallel evaluation, no etc.).</span>
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_init.html">RouteInit</a> ex_route_init; <span class="comment">// random init object - creates random Route objects</span>
<a name="l00275"></a>00275 <a class="codeRef" doxygen="mo.doxytag:/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/" href="/data/OPAC/software/paradisEO/repository/paradiseo/trunk/paradiseo-peo/build/../../paradiseo-mo/build/doc/html/class_route_eval.html">RouteEval</a> ex_full_eval; <span class="comment">// evaluator object - offers a fitness value for a specified Route object</span>
<a name="l00276"></a>00276
<a name="l00277"></a>00277 std::vector&lt; eoPop&lt; Route &gt; &gt; ex_population;
<a name="l00278"></a>00278 ex_population.resize( NUMBER_OF_POPULATIONS );
<a name="l00279"></a>00279
<a name="l00280"></a>00280 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> indexPop = 0; indexPop &lt; NUMBER_OF_POPULATIONS; indexPop++ ) {
<a name="l00281"></a>00281
<a name="l00282"></a>00282 ex_population[ indexPop ].resize( POP_SIZE );
<a name="l00283"></a>00283
<a name="l00284"></a>00284 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; POP_SIZE; index++ ) {
<a name="l00285"></a>00285
<a name="l00286"></a>00286 ex_route_init( ex_population[ indexPop ][ index ] );
<a name="l00287"></a>00287 ex_full_eval( ex_population[ indexPop ][ index ] );
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290
<a name="l00291"></a>00291
<a name="l00292"></a>00292 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00293"></a>00293 <a class="code" href="classpeoSynchronousMultiStart.html">peoSynchronousMultiStart&lt; eoPop&lt; Route &gt;</a> &gt; ex_parallelExecution( eaAlg );
<a name="l00294"></a>00294 <a class="code" href="classpeoParallelAlgorithmWrapper.html">peoParallelAlgorithmWrapper</a> ex_parallel( ex_parallelExecution, ex_population ); <span class="comment">// specifying the embedded algorithm - no input data in this case</span>
<a name="l00295"></a>00295
<a name="l00296"></a>00296 ex_parallelExecution.setOwner( ex_parallel );
<a name="l00297"></a>00297 <span class="comment">// SETTING UP THE PARALLEL WRAPPER ----------------------------------------------------------------------------------------------------------------</span>
<a name="l00298"></a>00298 <span class="comment">// &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300
<a name="l00301"></a>00301
<a name="l00302"></a>00302
<a name="l00303"></a>00303
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <a class="code" href="namespacepeo.html#10819b2d60b37477c6a89b60c595c67c">peo :: run</a>( );
<a name="l00306"></a>00306 <a class="code" href="namespacepeo.html#f90478489cc92d1e6abb222179163a30">peo :: finalize</a>( );
<a name="l00307"></a>00307 <span class="comment">// shutting down the ParadisEO-PEO environment</span>
<a name="l00308"></a>00308
<a name="l00309"></a>00309
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <span class="comment">// the algorithm is executed in the #1 rank process</span>
<a name="l00312"></a>00312 <span class="keywordflow">if</span> ( getNodeRank() == 1 ) {
<a name="l00313"></a>00313
<a name="l00314"></a>00314 std :: cout &lt;&lt; <span class="stringliteral">"[To] "</span> &lt;&lt; route &lt;&lt; std :: endl &lt;&lt; std::endl;
<a name="l00315"></a>00315
<a name="l00316"></a>00316
<a name="l00317"></a>00317 std :: cout &lt;&lt; <span class="stringliteral">"Synchronous Multi-Start HCs:"</span> &lt;&lt; std :: endl ;
<a name="l00318"></a>00318 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; POP_SIZE; index++ ) {
<a name="l00319"></a>00319
<a name="l00320"></a>00320 std::cout &lt;&lt; ex_hc_population[ index ] &lt;&lt; std::endl;
<a name="l00321"></a>00321 }
<a name="l00322"></a>00322 std::cout &lt;&lt; std::endl &lt;&lt; std::endl;
<a name="l00323"></a>00323
<a name="l00324"></a>00324
<a name="l00325"></a>00325 std :: cout &lt;&lt; <span class="stringliteral">"Synchronous Multi-Start EAs:"</span> &lt;&lt; std :: endl ;
<a name="l00326"></a>00326 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index = 0; index &lt; NUMBER_OF_POPULATIONS; index++ ) {
<a name="l00327"></a>00327
<a name="l00328"></a>00328 std::cout &lt;&lt; ex_population[ index ] &lt;&lt; std::endl;
<a name="l00329"></a>00329 }
<a name="l00330"></a>00330 std::cout &lt;&lt; std::endl &lt;&lt; std::flush;
<a name="l00331"></a>00331
<a name="l00332"></a>00332 }
<a name="l00333"></a>00333
<a name="l00334"></a>00334
<a name="l00335"></a>00335
<a name="l00336"></a>00336 <span class="keywordflow">return</span> 0;
<a name="l00337"></a>00337 }
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Oct 8 11:16:45 2007 for ParadisEO-PEOMovingObjects by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>