- Main Page
- Namespaces
- Classes
- Files

- Search for |

# peoSyncMultiStart.h

    00001 /*
    00002 * <peoSyncMultiStart.h>
    00003 * Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
    00004 * (C) OPAC Team, LIFL, 2002-2007
    00005 *
    00006 * Sebastien Cahon, Alexandru-Adrian Tantar
    00007 *
    00008 * This software is governed by the CeCILL license under French law and
    00009 * abiding by the rules of distribution of free software.  You can  use,
    00010 * modify and/ or redistribute the software under the terms of the CeCILL
    00011 * license as circulated by CEA, CNRS and INRIA at the following URL
    00012 * "http://www.cecill.info".
    00013 *
    00014 * As a counterpart to the access to the source code and  rights to copy,
    00015 * modify and redistribute granted by the license, users are provided only
    00016 * with a limited warranty  and the software's author,  the holder of the
    00017 * economic rights,  and the successive licensors  have only  limited liability.
    00018 *
    00019 * In this respect, the user's attention is drawn to the risks associated
    00020 * with loading,  using,  modifying and/or developing or reproducing the
    00021 * software by the user in light of its specific status of free software,
    00022 * that may mean  that it is complicated to manipulate,  and  that  also
    00023 * therefore means  that it is reserved for developers  and  experienced
    00024 * professionals having in-depth computer knowledge. Users are therefore
    00025 * encouraged to load and test the software's suitability as regards their
    00026 * requirements in conditions enabling the security of their systems and/or
    00027 * data to be ensured and,  more generally, to use and operate it in the
    00028 * same conditions as regards security.
    00029 * The fact that you are presently reading this means that you have had
    00030 * knowledge of the CeCILL license and that you accept its terms.
    00031 *
    00032 * ParadisEO WebSite : http://paradiseo.gforge.inria.fr
    00033 * Contact: paradiseo-help@lists.gforge.inria.fr
    00034 *
    00035 */
    00036
    00037 #ifndef __peoSyncMultiStart_h
    00038 #define __peoSyncMultiStart_h
    00039
    00040 #include <utils/eoUpdater.h>
    00041 #include <moAlgo.h>
    00042
    00043 #include <eoSelect.h>
    00044 #include <eoReplacement.h>
    00045 #include <eoContinue.h>
    00046
    00047 #include "core/service.h"
    00048 #include "core/messaging.h"
    00049 #include "core/peo_debug.h"
    00050
    00051
    00052 extern int getNodeRank();
    00053
    00054
    00056
    00064 template< class EOT > class peoSyncMultiStart : public Service, public eoUpdater {
    00065
    00066 public:
    00067
    00075         peoSyncMultiStart(
    00076
    00077                                 eoContinue< EOT >& __cont,
    00078                                 eoSelect< EOT >& __select,
    00079                                 eoReplacement< EOT >& __replace,
    00080                                 moAlgo< EOT >& __ls,
    00081                                 eoPop< EOT >& __pop
    00082                 );
    00083
    00086         void operator()();
    00087
    00090         void packData();
    00091
    00094         void unpackData();
    00095
    00098         void execute();
    00099
    00102         void packResult();
    00103
    00106         void unpackResult();
    00107
    00110         void notifySendingData();
    00111
    00114         void notifySendingAllResourceRequests();
    00115
    00116 private:
    00117
    00118         eoContinue< EOT >& cont;
    00119         eoSelect< EOT >& select;
    00120         eoReplacement< EOT >& replace;
    00121
    00122         moAlgo< EOT >& ls;
    00123
    00124         eoPop< EOT >& pop;
    00125         eoPop< EOT > sel;
    00126         eoPop< EOT > impr_sel;
    00127
    00128         EOT sol;
    00129         unsigned idx;
    00130         unsigned num_term;
    00131 };
    00132
    00133
    00134 template< class EOT > peoSyncMultiStart< EOT > :: peoSyncMultiStart(
    00135
    00136                                 eoContinue < EOT >& __cont,
    00137                                 eoSelect< EOT >& __select,
    00138                                 eoReplacement< EOT >& __replace,
    00139                                 moAlgo < EOT >& __ls,
    00140                                 eoPop< EOT >& __pop
    00141
    00142                 ) : cont( __cont ), select( __select ), replace( __replace ), ls( __ls ), pop( __pop )
    00143 {
    00144
    00145 }
    00146
    00147
    00148 template< class EOT > void peoSyncMultiStart< EOT > :: packData() {
    00149
    00150          :: pack( sel[ idx++ ] );
    00151 }
    00152
    00153
    00154 template< class EOT > void peoSyncMultiStart< EOT > :: unpackData() {
    00155
    00156         unpack( sol );
    00157 }
    00158
    00159
    00160 template< class EOT > void peoSyncMultiStart< EOT > :: execute() {
    00161
    00162         ls( sol );
    00163 }
    00164
    00165
    00166 template< class EOT > void peoSyncMultiStart< EOT > :: packResult() {
    00167
    00168         pack( sol );
    00169 }
    00170
    00171
    00172 template< class EOT > void peoSyncMultiStart< EOT > :: unpackResult() {
    00173
    00174         unpack( sol );
    00175         impr_sel.push_back( sol );
    00176         num_term++;
    00177
    00178         if ( num_term == sel.size() ) {
    00179
    00180                 getOwner()->setActive();
    00181                 replace( pop, impr_sel );
    00182
    00183                 printDebugMessage( "replacing the improved individuals in the population." );
    00184                 resume();
    00185         }
    00186 }
    00187
    00188
    00189 template< class EOT > void peoSyncMultiStart< EOT > :: operator()() {
    00190
    00191         printDebugMessage( "performing the parallel multi-start hybridization." );
    00192         select( pop, sel );
    00193         impr_sel.clear();
    00194         idx = num_term = 0;
    00195         requestResourceRequest( sel.size() );
    00196         stop();
    00197 }
    00198
    00199
    00200 template< class EOT > void peoSyncMultiStart< EOT > :: notifySendingData() {
    00201
    00202 }
    00203
    00204
    00205 template< class EOT > void peoSyncMultiStart< EOT > :: notifySendingAllResourceRequests() {
    00206
    00207         getOwner()->setPassive();
    00208 }
    00209
    00210
    00211 #endif