Fix guard in bimap

This commit is contained in:
quemy 2012-12-05 17:57:30 +01:00
commit e1c3e55c6f
3 changed files with 27 additions and 15 deletions

View file

@ -45,7 +45,7 @@ install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/smp COMPONENT header
### 4) Install directories
######################################################################################
install(DIRECTORY MWAlgo
install(DIRECTORY MWAlgo topology
DESTINATION include${INSTALL_SUB_DIR}/smp
COMPONENT headers
FILES_MATCHING PATTERN "*.h"

View file

@ -28,7 +28,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef BIMAP_MODEL_H_
#define BIMAP_H_
#define BIMAP_MODEL_H_
#include <set>
#include <map>

View file

@ -6,6 +6,19 @@
using namespace paradiseo::smp;
using namespace std;
void changeTopo(IslandModel<Indi>& _model, AbstractTopology& _topo)
{
static bool first = false;
// Change topology after 1s of computation
std::chrono::milliseconds dura(1000);
std::this_thread::sleep_for( dura );
if(!first)
{
_model.setTopology(_topo);
first = !first;
}
}
int main(void)
{
// Defining parameters
@ -35,6 +48,11 @@ int main(void)
eoSGATransform<Indi> transform(Xover, param.pCross, mutationSwap, param.pMut);
eoPlusReplacement<Indi> replace;
// MODEL
// Topologies
Topology<Complete> topo;
IslandModel<Indi> model(topo);
// ISLAND 1
// // Algorithm part
eoGenContinue<Indi> genCont(param.maxGen+100);
@ -45,6 +63,10 @@ int main(void)
eoDetTournamentSelect<Indi> selectOne1(20);
eoSelectNumber<Indi> who(selectOne1, 3);
Topology<Ring> topo2;
//std::function<void(void)> task = std::bind(changeTopo, model, topo2);
//Notifier topoChanger(task);
MigPolicy<Indi> migPolicy;
migPolicy.push_back(PolicyElement<Indi>(who, criteria));
@ -92,24 +114,14 @@ int main(void)
try
{
// Topologies
Topology<Complete> topo;
Topology<Ring> topo2;
IslandModel<Indi> model(topo);
model.add(test);
model.add(test2);
model.add(test3);
std::thread t = std::thread(&IslandModel<Indi>::operator(), &model);
// Change topology after 1s of computation
std::chrono::milliseconds dura(1000);
std::this_thread::sleep_for( dura );
model.setTopology(topo2);
t.join();
model();
cout << test.getPop() << endl;
cout << test2.getPop() << endl;