git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@810 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
atantar 2007-11-23 16:41:23 +00:00
commit 7526792805
49 changed files with 449 additions and 420 deletions

View file

@ -144,68 +144,68 @@
//! the associated distinctly parametrized migration objects. The interconnecting element is the underlying topology, defined at step 1
//! (the same C++ migTopology object has to be passed as parameter for all the migration objects, in order to interconnect them).
template< class EOT > class peoSyncIslandMig : public Cooperative, public eoUpdater
{
{
public:
public:
//! Constructor for the peoSyncIslandMig class; the characteristics of the migration model are defined
//! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters.
//!
//! @param unsigned __frequency - frequency of the migrations - the migrations occur periodically;
//! @param eoSelect< EOT >& __select - selection strategy to be applied for constructing a list of emigrant individuals out of the source population;
//! @param eoReplacement< EOT >& __replace - replacement strategy used for integrating the immigrant individuals in the destination population;
//! @param Topology& __topology - topological model to be followed when performing migrations;
//! @param eoPop< EOT >& __source - source population from which the emigrant individuals are selected;
//! @param eoPop< EOT >& __destination - destination population in which the immigrant population are integrated.
peoSyncIslandMig(
unsigned __frequency,
eoSelect< EOT >& __select,
eoReplacement< EOT >& __replace,
Topology& __topology,
eoPop< EOT >& __source,
eoPop< EOT >& __destination
);
//! Constructor for the peoSyncIslandMig class; the characteristics of the migration model are defined
//! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters.
//!
//! @param unsigned __frequency - frequency of the migrations - the migrations occur periodically;
//! @param eoSelect< EOT >& __select - selection strategy to be applied for constructing a list of emigrant individuals out of the source population;
//! @param eoReplacement< EOT >& __replace - replacement strategy used for integrating the immigrant individuals in the destination population;
//! @param Topology& __topology - topological model to be followed when performing migrations;
//! @param eoPop< EOT >& __source - source population from which the emigrant individuals are selected;
//! @param eoPop< EOT >& __destination - destination population in which the immigrant population are integrated.
peoSyncIslandMig(
unsigned __frequency,
eoSelect< EOT >& __select,
eoReplacement< EOT >& __replace,
Topology& __topology,
eoPop< EOT >& __source,
eoPop< EOT >& __destination
);
//! Function operator to be called as checkpoint for performing the migration step. The emigrant individuals are selected
//! from the source population and sent to the next island (defined by the topology object) while the immigrant
//! individuals are integrated in the destination population. There is no need to explicitly call the function - the
//! wrapper checkpoint object (please refer to the above example) will perform the call when required.
void operator()();
//! Function operator to be called as checkpoint for performing the migration step. The emigrant individuals are selected
//! from the source population and sent to the next island (defined by the topology object) while the immigrant
//! individuals are integrated in the destination population. There is no need to explicitly call the function - the
//! wrapper checkpoint object (please refer to the above example) will perform the call when required.
void operator()();
//! Auxiliary function dealing with sending the emigrant individuals. There is no need to explicitly call the function.
void pack();
//! Auxiliary function dealing with receiving immigrant individuals. There is no need to explicitly call the function.
void unpack();
//! Auxiliary function dealing with sending the emigrant individuals. There is no need to explicitly call the function.
void pack();
//! Auxiliary function dealing with receiving immigrant individuals. There is no need to explicitly call the function.
void unpack();
//! Auxiliary function dealing with migration notifications. There is no need to explicitly call the function.
void notifySending();
//! Auxiliary function dealing with migration notifications. There is no need to explicitly call the function.
void notifySending();
private:
private:
void emigrate();
void immigrate();
void emigrate();
void immigrate();
private:
private:
eoPeriodicContinue< EOT > cont;
eoSelect< EOT >& select; // selection strategy
eoReplacement< EOT >& replace; // replacement strategy
Topology& topology; // neighboring topology
eoPeriodicContinue< EOT > cont;
eoSelect< EOT >& select; // selection strategy
eoReplacement< EOT >& replace; // replacement strategy
Topology& topology; // neighboring topology
// source and target populations
eoPop< EOT >& source;
eoPop< EOT >& destination;
// source and target populations
eoPop< EOT >& source;
eoPop< EOT >& destination;
// immigrants & emigrants in the queue
std :: queue< eoPop< EOT > > imm;
std :: queue< eoPop< EOT > > em;
// immigrants & emigrants in the queue
std :: queue< eoPop< EOT > > imm;
std :: queue< eoPop< EOT > > em;
std :: queue< Cooperative* > coop_em;
std :: queue< Cooperative* > coop_em;
sem_t sync;
};
sem_t sync;
};
template< class EOT > peoSyncIslandMig< EOT > :: peoSyncIslandMig(
@ -261,15 +261,15 @@ template< class EOT > void peoSyncIslandMig< EOT > :: emigrate()
topology.setNeighbors( this, in, out );
for ( unsigned i = 0; i < out.size(); i ++ )
{
{
eoPop< EOT > mig;
select( source, mig );
em.push( mig );
coop_em.push( out[ i ] );
send( out[ i ] );
printDebugMessage( "sending some emigrants." );
}
eoPop< EOT > mig;
select( source, mig );
em.push( mig );
coop_em.push( out[ i ] );
send( out[ i ] );
printDebugMessage( "peoSyncIslandMig: sending some emigrants." );
}
}
@ -282,7 +282,7 @@ template< class EOT > void peoSyncIslandMig< EOT > :: immigrate()
assert( imm.size() );
replace( destination, imm.front() ) ;
imm.pop();
printDebugMessage( "receiving some immigrants." );
printDebugMessage( "peoSyncIslandMig: receiving some immigrants." );
}
unlock();
}
@ -292,19 +292,19 @@ template< class EOT > void peoSyncIslandMig< EOT > :: operator()()
{
if ( !cont( source ) )
{
{
// sending emigrants
emigrate();
stop();
// sending emigrants
emigrate();
stop();
// synchronizing
sem_wait( &sync );
getOwner()->setActive();
// synchronizing
sem_wait( &sync );
getOwner()->setActive();
// receiving immigrants
immigrate();
}
// receiving immigrants
immigrate();
}
}
@ -315,13 +315,13 @@ template< class EOT > void peoSyncIslandMig< EOT > :: notifySending()
{
if ( imm.empty() )
{
{
printDebugMessage( "entering pasive mode\n" );
getOwner()->setPassive();
}
}
unlock();
printDebugMessage( "peoSyncIslandMig: entering pasive mode\n" );
getOwner()->setPassive();
}
}
unlock();
resume();
}