Add islandNotifier to allow the mig and int policy to be checked in the island. The islandNotifier is added to the algorithm continuator and will make the island perform a binded task. In the case of island, the task is to check policies.
This commit is contained in:
parent
477dbe49a9
commit
cf561b537a
14 changed files with 498 additions and 93 deletions
|
|
@ -30,61 +30,18 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#ifndef MIG_POLICY_H_
|
||||
#define MIG_POLICY_H_
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <eo>
|
||||
#include <migPolicyElement.h>
|
||||
#include <island.h>
|
||||
#include <abstractIsland.h>
|
||||
#include <policyElement.h>
|
||||
|
||||
namespace paradiseo
|
||||
{
|
||||
namespace smp
|
||||
{
|
||||
// Forward declaration
|
||||
template <class EOT>
|
||||
class AIsland;
|
||||
/** MigPolicy: Migration policy
|
||||
*/
|
||||
|
||||
template <class EOT>
|
||||
class Policy : public eoContinue<EOT>, public std::vector<PolicyElement<EOT>>
|
||||
{
|
||||
public:
|
||||
bool operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
std::cout << "On regarde la politique de migration" << std::endl;
|
||||
for(PolicyElement<EOT>& elem : *this)
|
||||
{
|
||||
std::cout << ".";
|
||||
if(!elem(_pop))
|
||||
{
|
||||
std::cout << "On lance l'emmigration" << std::endl;
|
||||
notifyIsland(elem.getSelect());
|
||||
}
|
||||
}
|
||||
return true; // Always return true because it never stops the algorithm
|
||||
}
|
||||
|
||||
void addObserver(AIsland<EOT>* _observer)
|
||||
{
|
||||
observers.insert(_observer);
|
||||
}
|
||||
|
||||
void removeObserver(AIsland<EOT>* _observer)
|
||||
{
|
||||
observers.erase(_observer);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void notifyIsland(eoSelect<EOT>& _select) const
|
||||
{
|
||||
std::cout << "On notifie les iles" << std::endl;
|
||||
for (AIsland<EOT>* it : observers)
|
||||
it->send(_select);
|
||||
}
|
||||
|
||||
std::set<AIsland<EOT>*> observers;
|
||||
};
|
||||
template <class EOT>
|
||||
using MigPolicy = std::vector<PolicyElement<EOT>>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue