Island modified
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@923 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
77506fb591
commit
e7f6d3ca83
8 changed files with 62 additions and 62 deletions
|
|
@ -61,7 +61,7 @@
|
|||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
template< class EOT, class TYPE > class peoAsyncIslandMig : public Cooperative, public eoUpdater
|
||||
template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
|
@ -73,8 +73,8 @@ template< class EOT, class TYPE > class peoAsyncIslandMig : public Cooperative,
|
|||
//! @param Topology& __topology
|
||||
peoAsyncIslandMig(
|
||||
continuator & __cont,
|
||||
selector <TYPE> & __select,
|
||||
replacement <TYPE> & __replace,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
);
|
||||
|
||||
|
|
@ -95,27 +95,27 @@ template< class EOT, class TYPE > class peoAsyncIslandMig : public Cooperative,
|
|||
|
||||
private:
|
||||
//! @param continuator & cont
|
||||
//! @param selector <TYPE> & select
|
||||
//! @param replacement <TYPE> & replace
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPE > imm
|
||||
//! @param std :: queue< TYPE > em
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
continuator & cont;
|
||||
selector <TYPE> & select;
|
||||
replacement <TYPE> & replace;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPE > imm;
|
||||
std :: queue< TYPE > em;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
};
|
||||
|
||||
|
||||
template< class EOT , class TYPE> peoAsyncIslandMig< EOT, TYPE > :: peoAsyncIslandMig(
|
||||
template< class TYPESELECT , class TYPEREPLACE> peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: peoAsyncIslandMig(
|
||||
|
||||
continuator & __cont,
|
||||
selector <TYPE> & __select,
|
||||
replacement <TYPE> & __replace,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
|
||||
) : select( __select ), replace( __replace ), topology( __topology ), cont(__cont)
|
||||
|
|
@ -125,7 +125,7 @@ template< class EOT , class TYPE> peoAsyncIslandMig< EOT, TYPE > :: peoAsyncIsla
|
|||
}
|
||||
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: pack()
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: pack()
|
||||
{
|
||||
lock ();
|
||||
::pack( coop_em.front()->getKey() );
|
||||
|
|
@ -136,19 +136,19 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: pack()
|
|||
}
|
||||
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: unpack()
|
||||
template< class TYPESELECT, class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: unpack()
|
||||
{
|
||||
lock ();
|
||||
TYPE mig;
|
||||
TYPEREPLACE mig;
|
||||
mig.unpack();
|
||||
imm.push( mig );
|
||||
unlock();
|
||||
}
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: packSynchronizeReq()
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: packSynchronizeReq()
|
||||
{}
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: emigrate()
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: emigrate()
|
||||
{
|
||||
std :: vector< Cooperative* >in, out;
|
||||
topology.setNeighbors( this, in, out );
|
||||
|
|
@ -156,7 +156,7 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: emigrat
|
|||
for ( unsigned i = 0; i < out.size(); i++ )
|
||||
{
|
||||
|
||||
TYPE mig;
|
||||
TYPESELECT mig;
|
||||
select(mig);
|
||||
em.push( mig );
|
||||
coop_em.push( out[i] );
|
||||
|
|
@ -166,7 +166,7 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: emigrat
|
|||
}
|
||||
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: immigrate()
|
||||
template< class TYPESELECT, class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: immigrate()
|
||||
{
|
||||
|
||||
lock ();
|
||||
|
|
@ -183,7 +183,7 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: immigra
|
|||
}
|
||||
|
||||
|
||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: operator()()
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE > :: operator()()
|
||||
{
|
||||
|
||||
if (cont.check())
|
||||
|
|
|
|||
|
|
@ -68,20 +68,20 @@
|
|||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, public eoUpdater
|
||||
template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param unsigned __frequency
|
||||
//! @param selector <TYPE> & __select
|
||||
//! @param replacement <TYPE> & __replace
|
||||
//! @param selector <TYPESELECT> & __select
|
||||
//! @param replacement <TYPEREPLACE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoSyncIslandMig(
|
||||
unsigned __frequency,
|
||||
selector <TYPE> & __select,
|
||||
replacement <TYPE> & __replace,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
);
|
||||
|
||||
|
|
@ -110,11 +110,11 @@ template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative,
|
|||
|
||||
private:
|
||||
//! @param eoSyncContinue cont
|
||||
//! @param selector <TYPE> & select
|
||||
//! @param replacement <TYPE> & replace
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPE > imm
|
||||
//! @param std :: queue< TYPE > em
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
//! @param sem_t sync
|
||||
//! @param bool explicitPassive
|
||||
|
|
@ -122,11 +122,11 @@ template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative,
|
|||
//! @param std :: vector< Cooperative* > in, out, all
|
||||
//! @param unsigned nbMigrations
|
||||
eoSyncContinue cont;
|
||||
selector <TYPE> & select;
|
||||
replacement <TYPE> & replace;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPE > imm;
|
||||
std :: queue< TYPE > em;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
sem_t sync;
|
||||
bool explicitPassive;
|
||||
|
|
@ -136,11 +136,11 @@ template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative,
|
|||
};
|
||||
|
||||
|
||||
template< class EOT, class TYPE > peoSyncIslandMig< EOT,TYPE > :: peoSyncIslandMig(
|
||||
template< class TYPESELECT, class TYPEREPLACE > peoSyncIslandMig< TYPESELECT,TYPEREPLACE > :: peoSyncIslandMig(
|
||||
|
||||
unsigned __frequency,
|
||||
selector <TYPE> & __select,
|
||||
replacement <TYPE> & __replace,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
) : cont( __frequency ), select( __select ), replace( __replace ), topology( __topology )
|
||||
{
|
||||
|
|
@ -150,7 +150,7 @@ template< class EOT, class TYPE > peoSyncIslandMig< EOT,TYPE > :: peoSyncIslandM
|
|||
}
|
||||
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: pack()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT, TYPEREPLACE > :: pack()
|
||||
{
|
||||
::pack( coop_em.front()->getKey() );
|
||||
em.front().pack();
|
||||
|
|
@ -158,27 +158,27 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: pack()
|
|||
em.pop();
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: unpack()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT, TYPEREPLACE > :: unpack()
|
||||
{
|
||||
TYPE mig;
|
||||
TYPEREPLACE mig;
|
||||
mig.unpack();
|
||||
imm.push( mig );
|
||||
explicitPassive = true;
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT,TYPE > :: packSynchronizeReq()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT,TYPEREPLACE > :: packSynchronizeReq()
|
||||
{
|
||||
|
||||
packSynchronRequest( all );
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: emigrate()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: emigrate()
|
||||
{
|
||||
|
||||
for ( unsigned i = 0; i < out.size(); i ++ )
|
||||
{
|
||||
|
||||
TYPE mig;
|
||||
TYPESELECT mig;
|
||||
select( mig );
|
||||
em.push( mig );
|
||||
coop_em.push( out[ i ] );
|
||||
|
|
@ -187,7 +187,7 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: emigrat
|
|||
}
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: immigrate()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: immigrate()
|
||||
{
|
||||
assert( imm.size() );
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: immigra
|
|||
printDebugMessage( "peoSyncIslandMig: receiving some immigrants." );
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: operator()()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: operator()()
|
||||
{
|
||||
|
||||
if ( cont.check() )
|
||||
|
|
@ -222,12 +222,12 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: operato
|
|||
}
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: notifySending()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: notifySending()
|
||||
{
|
||||
if ( !explicitPassive ) getOwner()->setPassive();
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: notifyReceiving()
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: notifyReceiving()
|
||||
{
|
||||
nbMigrations++;
|
||||
|
||||
|
|
@ -239,13 +239,13 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: notifyR
|
|||
}
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySendingSyncReq ()
|
||||
template< class TYPESELECT, class TYPE > void peoSyncIslandMig< TYPESELECT, TYPE > :: notifySendingSyncReq ()
|
||||
{
|
||||
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySynchronized ()
|
||||
template< class TYPESELECT, class TYPE > void peoSyncIslandMig< TYPESELECT, TYPE > :: notifySynchronized ()
|
||||
{
|
||||
|
||||
standbyMigration = true;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ int main (int __argc, char *__argv[])
|
|||
eoReplace <Indi, peoPop<Indi> > mig_replace (replace,pop);
|
||||
eoPeriodicContinue< Indi > mig_cont( 2 );
|
||||
eoContinuator<Indi> cont(mig_cont, pop);
|
||||
peoAsyncIslandMig<Indi, peoPop<Indi> > mig(cont,mig_select,mig_replace,topology);
|
||||
peoAsyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig(cont,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
|
|
@ -62,7 +62,7 @@ int main (int __argc, char *__argv[])
|
|||
eoReplace <Indi, peoPop<Indi> > mig_replace2 (replace2,pop2);
|
||||
eoPeriodicContinue< Indi > mig_cont2( 2 );
|
||||
eoContinuator<Indi> cont2(mig_cont2, pop2);
|
||||
peoAsyncIslandMig<Indi, peoPop<Indi> > mig2(cont2,mig_select2,mig_replace2,topology);
|
||||
peoAsyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig2(cont2,mig_select2,mig_replace2,topology);
|
||||
checkpoint2.add(mig2);
|
||||
eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 );
|
||||
peoWrapper parallelEA2( eaAlg2, pop2);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ int main (int __argc, char *__argv[])
|
|||
eoRandomSelect<Indi> mig_select_one;
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select (mig_select_one,2,pop);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace (replace,pop);
|
||||
peoSyncIslandMig<Indi, peoPop<Indi> > mig(2,mig_select,mig_replace,topology);
|
||||
peoSyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig(2,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
|
|
@ -58,7 +58,7 @@ int main (int __argc, char *__argv[])
|
|||
eoRandomSelect<Indi> mig_select_one2;
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select2 (mig_select_one2,2,pop2);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace2 (replace2,pop2);
|
||||
peoSyncIslandMig<Indi, peoPop<Indi> > mig2(2,mig_select2,mig_replace2,topology);
|
||||
peoSyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig2(2,mig_select2,mig_replace2,topology);
|
||||
checkpoint2.add(mig2);
|
||||
eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 );
|
||||
peoWrapper parallelEA2( eaAlg2, pop2);
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ int main (int __argc, char *__argv[])
|
|||
eoContinuator<Indi> cont2(mig_cont2,pop2);
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select2 (mig_selec2,1,pop2);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace2 (mig_replac2,pop2);
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
checkpoint.add( mig );
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
checkpoint2.add( mig2 );
|
||||
eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight);
|
||||
peoWrapper parallelPSO( psa, pop);
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ int main (int __argc, char *__argv[])
|
|||
eoContinuator<Indi> cont2(mig_cont2,pop2);
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select2 (mig_selec2,1,pop2);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace2 (mig_replac2,pop2);
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
checkpoint.add( mig );
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
checkpoint2.add( mig2 );
|
||||
eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight);
|
||||
peoWrapper parallelPSO( psa, pop);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int main (int __argc, char *__argv[])
|
|||
eoRandomSelect<Indi> mig_select_one;
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select (mig_select_one,MIG_SIZE,pop);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace (replace,pop);
|
||||
peoSyncIslandMig<Indi, peoPop<Indi> > mig(MIG_FREQ,mig_select,mig_replace,topology);
|
||||
peoSyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig(MIG_FREQ,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
|
|
@ -121,7 +121,7 @@ int main (int __argc, char *__argv[])
|
|||
eoRandomSelect<Indi> mig_select_one2;
|
||||
eoSelector <Indi, peoPop<Indi> > mig_select2 (mig_select_one2,MIG_SIZE,pop2);
|
||||
eoReplace <Indi, peoPop<Indi> > mig_replace2 (replace2,pop2);
|
||||
peoSyncIslandMig<Indi, peoPop<Indi> > mig2(MIG_FREQ,mig_select2,mig_replace2,topology);
|
||||
peoSyncIslandMig<peoPop<Indi>, peoPop<Indi> > mig2(MIG_FREQ,mig_select2,mig_replace2,topology);
|
||||
checkpoint2.add(mig2);
|
||||
eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 );
|
||||
peoWrapper parallelEA2( eaAlg2, pop2);
|
||||
|
|
|
|||
|
|
@ -137,9 +137,9 @@ int main (int __argc, char *__argv[])
|
|||
|
||||
// Island model
|
||||
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
checkpoint.add( mig );
|
||||
peoAsyncIslandMig< Indi, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
peoAsyncIslandMig< peoPop<Indi>, peoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
checkpoint2.add( mig2 );
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue