Add function to wrap model in order to create homogeneous model easily
This commit is contained in:
parent
742b634beb
commit
fc2ea957a4
7 changed files with 39 additions and 92 deletions
|
|
@ -29,6 +29,7 @@ set (SMP_FILE
|
|||
topology/hypercubic.cpp
|
||||
topology/mesh.cpp
|
||||
notifier.cpp
|
||||
islandModelWrapper.h
|
||||
)
|
||||
|
||||
add_library(smp STATIC ${SMP_FILE})
|
||||
|
|
@ -39,7 +40,7 @@ install(TARGETS smp ARCHIVE DESTINATION ${LIB} COMPONENT libraries)
|
|||
### 3) Look for headers
|
||||
######################################################################################
|
||||
|
||||
file(GLOB HDRS smp *.h)
|
||||
file(GLOB HDRS smp *.h *.cpp)
|
||||
install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/smp COMPONENT headers)
|
||||
|
||||
######################################################################################
|
||||
|
|
@ -50,4 +51,5 @@ install(DIRECTORY MWAlgo topology
|
|||
DESTINATION include${INSTALL_SUB_DIR}/smp
|
||||
COMPONENT headers
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
PATTERN "*.cpp"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -156,4 +156,3 @@ void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::update(eoPop<bEOT> _data)
|
|||
std::lock_guard<std::mutex> lock(this->m);
|
||||
listImigrants.push(_data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ public:
|
|||
*/
|
||||
virtual void receive(void);
|
||||
|
||||
AIsland<bEOT> clone() const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
<homogeneousModel.cpp>
|
||||
<islandModelWrapper.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||
|
||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||
|
|
@ -27,13 +27,45 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
|||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
template<template <class> class EOAlgo, class EOT>
|
||||
template<class... IslandInit>
|
||||
paradiseo::smp::HomogeneousIslandModel<EOAlgo, EOT>::HomogeneousIslandModel(unsigned _islandNumber, AbstractTopology& _topo, unsigned _popSize, eoInit<EOT> &_chromInit, IslandInit... args) :
|
||||
model(_topo)
|
||||
#ifndef SMP_HOMOGENEOUS_ISLAND_MODEL_H_
|
||||
#define SMP_HOMOGENEOUS_ISLAND_MODEL_H_
|
||||
|
||||
#include <queue>
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <bimap.h>
|
||||
#include <abstractIsland.h>
|
||||
#include <island.h>
|
||||
#include <topology/topology.h>
|
||||
|
||||
namespace paradiseo
|
||||
{
|
||||
pops.resize(_islandNumber);
|
||||
islands.resize(_islandNumber);
|
||||
namespace smp
|
||||
{
|
||||
|
||||
/** IslandModelWrapper: Wrapper to create homogeneous model easily
|
||||
|
||||
IslandModelWrapper is a function that creates an homogeneous model with the number
|
||||
of specified islands, built with same parameters.
|
||||
|
||||
@see smp::IslandModel
|
||||
*/
|
||||
|
||||
template<template <class> class EOAlgo, class EOT, class... IslandInit>
|
||||
std::vector<eoPop<EOT>> IslandModelWrapper(unsigned _islandNumber, AbstractTopology& _topo, unsigned _popSize, eoInit<EOT> &_chromInit, IslandInit... args)
|
||||
{
|
||||
// Model creation
|
||||
IslandModel<EOT> model(_topo);
|
||||
|
||||
// Island and pop containers
|
||||
std::vector<Island<EOAlgo,EOT>*> islands(_islandNumber);
|
||||
std::vector<eoPop<EOT>> pops(_islandNumber);
|
||||
|
||||
// Generate islands and put them in the model
|
||||
for(unsigned i = 0; i < _islandNumber; i++)
|
||||
{
|
||||
pops[i] = eoPop<EOT>(_popSize, _chromInit);
|
||||
|
|
@ -41,18 +73,18 @@ paradiseo::smp::HomogeneousIslandModel<EOAlgo, EOT>::HomogeneousIslandModel(unsi
|
|||
model.add(*islands[i]);
|
||||
}
|
||||
|
||||
// Start the model
|
||||
model();
|
||||
}
|
||||
|
||||
template<template <class> class EOAlgo, class EOT>
|
||||
paradiseo::smp::HomogeneousIslandModel<EOAlgo, EOT>::~HomogeneousIslandModel()
|
||||
{
|
||||
// Delete islands
|
||||
for(auto& island : islands)
|
||||
delete island;
|
||||
}
|
||||
|
||||
template<template <class> class EOAlgo, class EOT>
|
||||
std::vector<eoPop<EOT>>& paradiseo::smp::HomogeneousIslandModel<EOAlgo, EOT>::getPop()
|
||||
{
|
||||
return pops;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -33,7 +33,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <MWModel.h>
|
||||
#include <scheduler.h>
|
||||
#include <islandModel.h>
|
||||
#include <homogeneousModel.h>
|
||||
#include <islandModelWrapper.h>
|
||||
#include <island.h>
|
||||
#include <abstractIsland.h>
|
||||
#include <migPolicy.h>
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ set (TEST_LIST
|
|||
t-smpTopo
|
||||
t-smpMI_Homogeneous
|
||||
t-smpMI_Heterogeneous
|
||||
t-smpMI_Wrapper
|
||||
)
|
||||
|
||||
######################################################################################
|
||||
|
|
|
|||
Loading…
Reference in a new issue