Islands send pop to IslandModel. Add and clean documentation.
This commit is contained in:
parent
3a8821a923
commit
083d77ba08
20 changed files with 206 additions and 79 deletions
|
|
@ -32,7 +32,9 @@ template<class... Args>
|
||||||
paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::MWModel(unsigned workersNb, Args&... args) :
|
paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::MWModel(unsigned workersNb, Args&... args) :
|
||||||
EOAlgo<EOT>(args...),
|
EOAlgo<EOT>(args...),
|
||||||
scheduler(workersNb)
|
scheduler(workersNb)
|
||||||
{ assert(workersNb > 0); }
|
{
|
||||||
|
assert(workersNb > 0);
|
||||||
|
}
|
||||||
|
|
||||||
template<template <class> class EOAlgo, class EOT, class Policy>
|
template<template <class> class EOAlgo, class EOT, class Policy>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<PPE.h>
|
<PPExpander.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||||
|
|
@ -31,7 +31,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#define PPE_H_
|
#define PPE_H_
|
||||||
|
|
||||||
/** Parameter Pack Expansion: Utility file to expand parameter pack
|
/** Parameter Pack Expansion: Utility file to expand parameter pack
|
||||||
/* Utility file to expand parameter pack with the recursive method
|
|
||||||
|
Utility file to expand parameter pack with the recursive method
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
template<class... Arg> class Loop;
|
template<class... Arg> class Loop;
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class IslandModel;
|
||||||
|
|
||||||
/** AbstractIsland: An abstract island.
|
/** AbstractIsland: An abstract island.
|
||||||
|
|
||||||
|
The abstract island is used to manipulate island pointers wihout the knowledge of the algorithm.
|
||||||
|
|
||||||
@see smp::Island
|
@see smp::Island
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -77,6 +79,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void check(void) = 0;
|
virtual void check(void) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the algorithm is stopped.
|
||||||
|
* @return true if stopped
|
||||||
|
*/
|
||||||
virtual bool isStopped(void) = 0;
|
virtual bool isStopped(void) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ namespace paradiseo
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
/** Algo Dispatching
|
/** Algo Dispatching
|
||||||
* The Algo Dispatching enable to choose the algorithm to call at compile time by tag-dispatching method
|
|
||||||
|
The Algo Dispatching enable to choose the algorithm to call at compile time by tag-dispatching method
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// Main algorithms tags
|
// Main algorithms tags
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,22 @@ namespace paradiseo
|
||||||
{
|
{
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
|
/** Bimap
|
||||||
|
|
||||||
|
Bidirectional map in order to create a bijection between islands and vertices.
|
||||||
|
A and B objects are stocked in two std::set, then if you would avoid instances duplications,
|
||||||
|
template A and B with pointers.
|
||||||
|
|
||||||
|
**/
|
||||||
template<class A, class B>
|
template<class A, class B>
|
||||||
class Bimap
|
class Bimap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Add a relation
|
||||||
|
* @param workersNb the number of workers
|
||||||
|
* @param args... list of parameters according to the constructor of your algorithm
|
||||||
|
*/
|
||||||
void add(A a, B b)
|
void add(A a, B b)
|
||||||
{
|
{
|
||||||
ASet.insert(a);
|
ASet.insert(a);
|
||||||
|
|
@ -51,6 +61,7 @@ public:
|
||||||
leftAssociation[&b] = &a;
|
leftAssociation[&b] = &a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
B& getRight(A const a)
|
B& getRight(A const a)
|
||||||
{
|
{
|
||||||
return *rightAssociation[&a];
|
return *rightAssociation[&a];
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,22 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#define CONT_D_H_
|
#define CONT_D_H_
|
||||||
|
|
||||||
/** Continuator Dispatching
|
/** Continuator Dispatching
|
||||||
* The Continuator Dispatching enable to wrap continuator in Island constructor for a better user interface
|
|
||||||
|
The Continuator Dispatching enable to wrap continuators in Island constructor for a better user interface
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
template<class T, class U>
|
template<class T, class U>
|
||||||
U& wrap_pp_impl(T&, U& u, std::false_type)
|
U& wrap_pp_impl(T&, U& u, std::false_type)
|
||||||
{ return u; }
|
{
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class U>
|
template<class T, class U>
|
||||||
T& wrap_pp_impl(T& t, U&, std::true_type)
|
T& wrap_pp_impl(T& t, U&, std::true_type)
|
||||||
{ return t; }
|
{
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class U>
|
template<class T, class U>
|
||||||
struct result_of_wrap_pp :
|
struct result_of_wrap_pp :
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ namespace smp
|
||||||
/** ContWrapper: Utility class to wrap the algorithm continuators with island notifier.
|
/** ContWrapper: Utility class to wrap the algorithm continuators with island notifier.
|
||||||
|
|
||||||
Utility class to wrap the algorithm continuators with island notifier during the island construction.
|
Utility class to wrap the algorithm continuators with island notifier during the island construction.
|
||||||
|
By using the wrapper, we do not have to modify original continuators inside the IslandModel and then,
|
||||||
|
it avoids some side effects.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
||||||
template<template <class> class EOAlgo, class EOT>
|
template<template <class> class EOAlgo, class EOT>
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
paradiseo::smp::Island<EOAlgo,EOT>::Island(unsigned _popSize, eoInit<EOT>& _chromInit, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
|
paradiseo::smp::Island<EOAlgo,EOT>::Island(unsigned _popSize, eoInit<EOT>& _chromInit, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
|
||||||
|
|
@ -51,6 +52,9 @@ void paradiseo::smp::Island<EOAlgo,EOT>::operator()()
|
||||||
{
|
{
|
||||||
stopped = false;
|
stopped = false;
|
||||||
algo(pop);
|
algo(pop);
|
||||||
|
// Let's wait the end of communications with the island model
|
||||||
|
for(auto& message : sentMessages)
|
||||||
|
message.join();
|
||||||
stopped = true;
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,6 +104,14 @@ void paradiseo::smp::Island<EOAlgo,EOT>::send(eoSelect<EOT>& _select)
|
||||||
eoPop<EOT> migPop;
|
eoPop<EOT> migPop;
|
||||||
_select(pop, migPop);
|
_select(pop, migPop);
|
||||||
//std::cout << " La population migrante est :" << std::endl << migPop << std::endl;
|
//std::cout << " La population migrante est :" << std::endl << migPop << std::endl;
|
||||||
|
|
||||||
|
// Delete delivered messages
|
||||||
|
for(auto it = sentMessages.begin(); it != sentMessages.end(); it++)
|
||||||
|
if(!it->joinable())
|
||||||
|
sentMessages.erase(it);
|
||||||
|
|
||||||
|
sentMessages.push_back(std::thread(&IslandModel<EOT>::update, model, migPop, this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<template <class> class EOAlgo, class EOT>
|
template<template <class> class EOAlgo, class EOT>
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,12 @@ namespace paradiseo
|
||||||
{
|
{
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
|
/** Island: Concrete island that wraps an algorithm
|
||||||
|
|
||||||
|
The island wraps an algorithm and provide mecanism for emigration and integration of populations.
|
||||||
|
|
||||||
|
@see smp::AbstractIsland, smp::MigPolicy
|
||||||
|
*/
|
||||||
|
|
||||||
template<template <class> class EOAlgo, class EOT>
|
template<template <class> class EOAlgo, class EOT>
|
||||||
class Island : private ContWrapper<EOT>, public AIsland<EOT>
|
class Island : private ContWrapper<EOT>, public AIsland<EOT>
|
||||||
|
|
@ -59,7 +65,7 @@ public:
|
||||||
* @param _chromInit Population initializer.
|
* @param _chromInit Population initializer.
|
||||||
* @param _intPolicy Integration policy
|
* @param _intPolicy Integration policy
|
||||||
* @param _migPolicy Migration policy
|
* @param _migPolicy Migration policy
|
||||||
* @param args Parameters to construct the algorithm of the island.
|
* @param args Parameters to construct the algorithm.
|
||||||
*/
|
*/
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
Island(unsigned _popSize, eoInit<EOT>& _chromInit, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args);
|
Island(unsigned _popSize, eoInit<EOT>& _chromInit, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args);
|
||||||
|
|
@ -92,6 +98,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void check(void);
|
virtual void check(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the algorithm is stopped.
|
||||||
|
* @return true if stopped
|
||||||
|
*/
|
||||||
virtual bool isStopped(void);
|
virtual bool isStopped(void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -114,6 +124,7 @@ protected:
|
||||||
IntPolicy<EOT>& intPolicy;
|
IntPolicy<EOT>& intPolicy;
|
||||||
MigPolicy<EOT>& migPolicy;
|
MigPolicy<EOT>& migPolicy;
|
||||||
std::atomic<bool> stopped;
|
std::atomic<bool> stopped;
|
||||||
|
std::vector<std::thread> sentMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <island.cpp>
|
#include <island.cpp>
|
||||||
|
|
|
||||||
77
smp/src/islandModel.cpp
Normal file
77
smp/src/islandModel.cpp
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
<islandModel.cpp>
|
||||||
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
|
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||||
|
|
||||||
|
This software is governed by the CeCILL license under French law and
|
||||||
|
abiding by the rules of distribution of free software. You can ue,
|
||||||
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
|
"http://www.cecill.info".
|
||||||
|
|
||||||
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
|
software by the user in light of its specific status of free software,
|
||||||
|
that may mean that it is complicated to manipulate, and that also
|
||||||
|
therefore means that it is reserved for developers and experienced
|
||||||
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
|
encouraged to load and test the software's suitability as regards their
|
||||||
|
requirements in conditions enabling the security of their systems and/or
|
||||||
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
|
same conditions as regards security.
|
||||||
|
The fact that you are presently reading this means that you have had
|
||||||
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
*/
|
||||||
|
|
||||||
|
template<class EOT>
|
||||||
|
void paradiseo::smp::IslandModel<EOT>::add(AIsland<EOT>& _island)
|
||||||
|
{
|
||||||
|
static unsigned i = 0;
|
||||||
|
islands[i] = &_island;
|
||||||
|
islands[i]->setModel(this);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class EOT>
|
||||||
|
void paradiseo::smp::IslandModel<EOT>::operator()()
|
||||||
|
{
|
||||||
|
std::vector<Thread> threads(islands.size());
|
||||||
|
|
||||||
|
unsigned i = 0;
|
||||||
|
for(auto it : islands)
|
||||||
|
{
|
||||||
|
threads[i].start(&AIsland<EOT>::operator(), it.second);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned workingThread = islands.size();
|
||||||
|
while(workingThread > 0)
|
||||||
|
{
|
||||||
|
workingThread = islands.size();
|
||||||
|
for(auto& it : islands)
|
||||||
|
if(it.second->isStopped())
|
||||||
|
workingThread--;
|
||||||
|
std::this_thread::sleep_for(std::chrono::nanoseconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto& thread : threads)
|
||||||
|
thread.join();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class EOT>
|
||||||
|
void paradiseo::smp::IslandModel<EOT>::update(eoPop<EOT> _data, AIsland<EOT>* _island)
|
||||||
|
{
|
||||||
|
std::cout << "Pop reçue par le médiateur" << std::endl;
|
||||||
|
std::lock_guard<std::mutex> lock(this->m);
|
||||||
|
|
||||||
|
std::cout << _data << std::endl;
|
||||||
|
listEmigrants.push(std::pair<eoPop<EOT>,AIsland<EOT>*>(_data, _island));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<IslandModel.h>
|
<islandModel.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||||
|
|
@ -45,57 +45,41 @@ namespace smp
|
||||||
|
|
||||||
/** IslandModel
|
/** IslandModel
|
||||||
|
|
||||||
|
The IslandModel object is an island container that provides mecanism in order to perform a
|
||||||
|
island model pattern according to a topology.
|
||||||
|
|
||||||
|
@see smp::Island, smp::MigPolicy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class IslandModel
|
class IslandModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void add(AIsland<EOT>& _island)
|
/**
|
||||||
{
|
* Add an island to the model.
|
||||||
static unsigned i = 0;
|
* @param _island Island to add.
|
||||||
islands[i] = &_island;
|
*/
|
||||||
islands[i]->setModel(this);
|
void add(AIsland<EOT>& _island);
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()()
|
/**
|
||||||
{
|
* Launch the island model by starting islands on their population.
|
||||||
std::vector<Thread> threads(islands.size());
|
*/
|
||||||
|
void operator()();
|
||||||
|
|
||||||
unsigned i = 0;
|
/**
|
||||||
for(auto it : islands)
|
* Update the island model by adding population to send in the emigrants list.
|
||||||
{
|
*/
|
||||||
threads[i].start(&AIsland<EOT>::operator(), it.second);
|
void update(eoPop<EOT> _data, AIsland<EOT>* _island);
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned workingThread = islands.size();
|
|
||||||
while(workingThread > 0)
|
|
||||||
{
|
|
||||||
workingThread = islands.size();
|
|
||||||
for(auto& it : islands)
|
|
||||||
if(it.second->isStopped())
|
|
||||||
workingThread--;
|
|
||||||
std::this_thread::sleep_for(std::chrono::nanoseconds(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto& thread : threads)
|
|
||||||
thread.join();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void update(eoPop<EOT>* _data, AIsland<EOT>* _island)
|
|
||||||
{
|
|
||||||
listEmigrants.insert(std::pair<eoPop<EOT>*,AIsland<EOT>*>(_data, _island));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::queue<std::pair<eoPop<EOT>*,AIsland<EOT>*>> listEmigrants;
|
std::queue<std::pair<eoPop<EOT>,AIsland<EOT>*>> listEmigrants;
|
||||||
Bimap<unsigned, unsigned> table;
|
Bimap<unsigned, unsigned> table;
|
||||||
std::map<unsigned, AIsland<EOT>*> islands;
|
std::map<unsigned, AIsland<EOT>*> islands;
|
||||||
|
std::mutex m;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <islandModel.cpp>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
/** IslandNotifier: The notifier will perform the binded task each generation.
|
/** IslandNotifier: The notifier will perform the binded task each generation.
|
||||||
|
|
||||||
The island notifier makes the binded task executed by the island which observes.
|
The island notifier makes the binded task executed by the island which observes.
|
||||||
We can imagine that a continuator check is we have to execute the binded task.
|
We can imagine that a continuator checks if we have to execute the binded task.
|
||||||
At the moment the task is perfermed each generation.
|
At the moment, the task is performed each generation.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
<policy.h>
|
<migPolicy.h>
|
||||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||||
|
|
||||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||||
|
|
@ -37,7 +37,7 @@ namespace paradiseo
|
||||||
{
|
{
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
/** MigPolicy: Migration policy
|
/** MigPolicy: Migration policy is a vector of PolicyElement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ namespace paradiseo
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
/** Policies Dispatching
|
/** Policies Dispatching
|
||||||
* The Policies Dispatching enable to choose the policy to call at compile time by tag-dispatching method
|
|
||||||
|
The Policies Dispatching enable to choose the policy to call at compile time by tag-dispatching method
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
struct LinearPolicy {};
|
struct LinearPolicy {};
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
#include <eo>
|
#include <eo>
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
paradiseo::smp::PolicyElement<EOT>::PolicyElement(eoSelect<EOT>& _selection, eoContinue<EOT>& _criteria) :
|
paradiseo::smp::PolicyElement<EOT>::PolicyElement(eoSelect<EOT>& _selection, eoContinue<EOT>& _criterion) :
|
||||||
selection(_selection),
|
selection(_selection),
|
||||||
criteria(_criteria)
|
criterion(_criterion)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
|
|
@ -45,13 +45,13 @@ bool paradiseo::smp::PolicyElement<EOT>::operator()(const eoPop<EOT>& _pop)
|
||||||
//i++;
|
//i++;
|
||||||
// END DEBUG
|
// END DEBUG
|
||||||
|
|
||||||
return criteria(_pop);
|
return criterion(_pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
void paradiseo::smp::PolicyElement<EOT>::addCriteria(eoContinue<EOT>& _criteria)
|
void paradiseo::smp::PolicyElement<EOT>::addCriterion(eoContinue<EOT>& _criterion)
|
||||||
{
|
{
|
||||||
criteria.add(_criteria);
|
criterion.add(_criterion);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ namespace paradiseo
|
||||||
{
|
{
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
|
/** PolicyElement: PolicyElement is an element of a migration policy.
|
||||||
|
|
||||||
|
The policy element is a pair of a selection method and a criterion to apply the selection.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
class PolicyElement : public eoContinue<EOT>
|
class PolicyElement : public eoContinue<EOT>
|
||||||
|
|
@ -44,22 +49,22 @@ public :
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param _selection How to select elements for migration
|
* @param _selection How to select elements for migration
|
||||||
* @param _criteria When notifying the island
|
* @param _criterion When notifying the island
|
||||||
*/
|
*/
|
||||||
PolicyElement(eoSelect<EOT>& _selection, eoContinue<EOT>& _criteria);
|
PolicyElement(eoSelect<EOT>& _selection, eoContinue<EOT>& _criterion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check is the criteria is reach
|
* Check is the criterion is reach
|
||||||
* @param _pop Population which is checked by the criteria.
|
* @param _pop Population which is checked by the criteria.
|
||||||
* @return false if the criteria is reached.
|
* @return false if the criterion is reached.
|
||||||
*/
|
*/
|
||||||
bool operator()(const eoPop<EOT>& _pop);
|
bool operator()(const eoPop<EOT>& _pop);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add criteria for the same selection method.
|
* Add criteria for the same selection method.
|
||||||
* @param _criteria New criteria.
|
* @param _criterion New criterion.
|
||||||
*/
|
*/
|
||||||
void addCriteria(eoContinue<EOT>& _criteria);
|
void addCriterion(eoContinue<EOT>& _criterion);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to the selection method.
|
* Access to the selection method.
|
||||||
|
|
@ -69,7 +74,7 @@ public :
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
eoSelect<EOT>& selection;
|
eoSelect<EOT>& selection;
|
||||||
eoContinue<EOT>& criteria;
|
eoContinue<EOT>& criterion;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <policyElement.cpp>
|
#include <policyElement.cpp>
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,12 @@ namespace paradiseo
|
||||||
{
|
{
|
||||||
namespace smp
|
namespace smp
|
||||||
{
|
{
|
||||||
/**
|
/** Scheduler : Dispatch load between workers according to a policy.
|
||||||
A scheduler class
|
|
||||||
|
Dispatch load between the specified number of workers according to a policy.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template<class EOT, class Policy = LinearPolicy>
|
template<class EOT, class Policy = LinearPolicy>
|
||||||
class Scheduler
|
class Scheduler
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ paradiseo::smp::BooleanTopology<TopologyType>::BooleanTopology(unsigned nbIsland
|
||||||
TopologyType builder;
|
TopologyType builder;
|
||||||
builder(nbIsland, _matrix);
|
builder(nbIsland, _matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TopologyType>
|
template <class TopologyType>
|
||||||
std::vector<unsigned> paradiseo::smp::BooleanTopology<TopologyType>::getIdNeighbours(unsigned idIsland) const
|
std::vector<unsigned> paradiseo::smp::BooleanTopology<TopologyType>::getIdNeighbours(unsigned idIsland) const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ set (TEST_LIST
|
||||||
t-smpMW_eoEasyPSO
|
t-smpMW_eoEasyPSO
|
||||||
t-smpMW_eoSyncEasyPSO
|
t-smpMW_eoSyncEasyPSO
|
||||||
t-smpIsland
|
t-smpIsland
|
||||||
t-smpTopo)
|
#t-smpTopo
|
||||||
|
)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
### 3) Create each test
|
### 3) Create each test
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ using namespace std;
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned popSize = 10;
|
unsigned popSize = 100;
|
||||||
unsigned tSize = 2;
|
unsigned tSize = 2;
|
||||||
double pCross = 0.8;
|
double pCross = 0.8;
|
||||||
double pMut = 0.7;
|
double pMut = 0.7;
|
||||||
unsigned maxGen = 10;
|
unsigned maxGen = 10000;
|
||||||
} Param;
|
} Param;
|
||||||
|
|
||||||
Param param;
|
Param param;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue