Fix guard in bimap
This commit is contained in:
parent
aa9c01568b
commit
e1c3e55c6f
3 changed files with 27 additions and 15 deletions
|
|
@ -45,7 +45,7 @@ install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/smp COMPONENT header
|
||||||
### 4) Install directories
|
### 4) Install directories
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
install(DIRECTORY MWAlgo
|
install(DIRECTORY MWAlgo topology
|
||||||
DESTINATION include${INSTALL_SUB_DIR}/smp
|
DESTINATION include${INSTALL_SUB_DIR}/smp
|
||||||
COMPONENT headers
|
COMPONENT headers
|
||||||
FILES_MATCHING PATTERN "*.h"
|
FILES_MATCHING PATTERN "*.h"
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BIMAP_MODEL_H_
|
#ifndef BIMAP_MODEL_H_
|
||||||
#define BIMAP_H_
|
#define BIMAP_MODEL_H_
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,19 @@
|
||||||
using namespace paradiseo::smp;
|
using namespace paradiseo::smp;
|
||||||
using namespace std;
|
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)
|
int main(void)
|
||||||
{
|
{
|
||||||
// Defining parameters
|
// Defining parameters
|
||||||
|
|
@ -35,6 +48,11 @@ int main(void)
|
||||||
eoSGATransform<Indi> transform(Xover, param.pCross, mutationSwap, param.pMut);
|
eoSGATransform<Indi> transform(Xover, param.pCross, mutationSwap, param.pMut);
|
||||||
eoPlusReplacement<Indi> replace;
|
eoPlusReplacement<Indi> replace;
|
||||||
|
|
||||||
|
// MODEL
|
||||||
|
// Topologies
|
||||||
|
Topology<Complete> topo;
|
||||||
|
IslandModel<Indi> model(topo);
|
||||||
|
|
||||||
// ISLAND 1
|
// ISLAND 1
|
||||||
// // Algorithm part
|
// // Algorithm part
|
||||||
eoGenContinue<Indi> genCont(param.maxGen+100);
|
eoGenContinue<Indi> genCont(param.maxGen+100);
|
||||||
|
|
@ -45,6 +63,10 @@ int main(void)
|
||||||
eoDetTournamentSelect<Indi> selectOne1(20);
|
eoDetTournamentSelect<Indi> selectOne1(20);
|
||||||
eoSelectNumber<Indi> who(selectOne1, 3);
|
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<Indi> migPolicy;
|
||||||
migPolicy.push_back(PolicyElement<Indi>(who, criteria));
|
migPolicy.push_back(PolicyElement<Indi>(who, criteria));
|
||||||
|
|
||||||
|
|
@ -92,24 +114,14 @@ int main(void)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Topologies
|
|
||||||
Topology<Complete> topo;
|
|
||||||
Topology<Ring> topo2;
|
|
||||||
|
|
||||||
IslandModel<Indi> model(topo);
|
|
||||||
|
|
||||||
model.add(test);
|
model.add(test);
|
||||||
model.add(test2);
|
model.add(test2);
|
||||||
model.add(test3);
|
model.add(test3);
|
||||||
|
|
||||||
std::thread t = std::thread(&IslandModel<Indi>::operator(), &model);
|
model();
|
||||||
|
|
||||||
// Change topology after 1s of computation
|
|
||||||
std::chrono::milliseconds dura(1000);
|
|
||||||
std::this_thread::sleep_for( dura );
|
|
||||||
|
|
||||||
model.setTopology(topo2);
|
|
||||||
|
|
||||||
t.join();
|
|
||||||
|
|
||||||
cout << test.getPop() << endl;
|
cout << test.getPop() << endl;
|
||||||
cout << test2.getPop() << endl;
|
cout << test2.getPop() << endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue