From cf561b537a0e8ec7edd178700b9f9e8de021b5c8 Mon Sep 17 00:00:00 2001 From: quemy Date: Sun, 11 Nov 2012 22:36:21 +0100 Subject: [PATCH] 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. --- smp/src/abstractIsland.h | 71 +++++++++++++++++++ smp/src/contWrapper.cpp | 36 ++++++++++ smp/src/contWrapper.h | 20 ++++-- smp/src/intPolicy.cpp | 35 +++++++++ smp/src/intPolicy.h | 68 ++++++++++++++++++ smp/src/island.cpp | 36 ++++++++-- smp/src/island.h | 43 +++++++++-- smp/src/islandNotifier.cpp | 41 +++++++++++ smp/src/islandNotifier.h | 68 ++++++++++++++++++ smp/src/migPolicy.h | 53 ++------------ smp/src/policyElement.cpp | 61 ++++++++++++++++ .../{migPolicyElement.h => policyElement.h} | 48 ++++++------- smp/src/smp.h | 4 +- smp/test/t-smpIsland.cpp | 7 +- 14 files changed, 498 insertions(+), 93 deletions(-) create mode 100644 smp/src/abstractIsland.h create mode 100644 smp/src/contWrapper.cpp create mode 100644 smp/src/intPolicy.cpp create mode 100644 smp/src/intPolicy.h create mode 100644 smp/src/islandNotifier.cpp create mode 100644 smp/src/islandNotifier.h create mode 100644 smp/src/policyElement.cpp rename smp/src/{migPolicyElement.h => policyElement.h} (71%) diff --git a/smp/src/abstractIsland.h b/smp/src/abstractIsland.h new file mode 100644 index 000000000..2c04465ea --- /dev/null +++ b/smp/src/abstractIsland.h @@ -0,0 +1,71 @@ +/* + +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 +*/ + +#ifndef ABS_ISLAND_H_ +#define ABS_ISLAND_H_ + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +/** AbstractIsland: An abstract island. + +@see smp::Island +*/ + +template +class AIsland +{ +public: + /** + * Send population to mediator + * @param _select Method to select EOT to send + */ + virtual void send(eoSelect& _select) = 0; + + /** + * Check if there is population to receive + */ + virtual void receive(void) = 0; + + /** + * Check if there is population to receive or to emigrate + */ + virtual void check(void) = 0; +}; + +} + +} + +#endif diff --git a/smp/src/contWrapper.cpp b/smp/src/contWrapper.cpp new file mode 100644 index 000000000..38737bcdc --- /dev/null +++ b/smp/src/contWrapper.cpp @@ -0,0 +1,36 @@ +/* + +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 +paradiseo::smp::ContWrapper::ContWrapper(eoContinue& _cont, AIsland* island) : + ck(_cont), + islandNotifier(island, &AIsland::check) +{ + ck.add(islandNotifier); +} diff --git a/smp/src/contWrapper.h b/smp/src/contWrapper.h index 3df93af9d..75cadbce6 100644 --- a/smp/src/contWrapper.h +++ b/smp/src/contWrapper.h @@ -36,26 +36,36 @@ Contact: paradiseo-help@lists.gforge.inria.fr #include #include +#include namespace paradiseo { namespace smp { +/** 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. + +*/ template class ContWrapper { public: - ContWrapper(eoContinue& _cont, Policy& _policy) : - ck(_cont) - { - ck.add(_policy); - } + /** + * Constructor + * @param _cont Original continuators + * @param _policy Policy to wrap with continuators + */ + ContWrapper(eoContinue& _cont, AIsland* island); protected: eoCheckPoint ck; + IslandNotifier islandNotifier; }; +#include + } } diff --git a/smp/src/intPolicy.cpp b/smp/src/intPolicy.cpp new file mode 100644 index 000000000..ca4664403 --- /dev/null +++ b/smp/src/intPolicy.cpp @@ -0,0 +1,35 @@ +/* + +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 +paradiseo::smp::IntPolicy::IntPolicy(eoEvalFunc& _eval, eoReplacement& _replace) : + eval(_eval), + replace(_replace) +{} + diff --git a/smp/src/intPolicy.h b/smp/src/intPolicy.h new file mode 100644 index 000000000..038b5f6e3 --- /dev/null +++ b/smp/src/intPolicy.h @@ -0,0 +1,68 @@ +/* + +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 +*/ + +#ifndef INT_POLICY_H_ +#define INT_POLICY_H_ + +#include + +namespace paradiseo +{ +namespace smp +{ + +/** IntPolicy: Integration policy for island. + +The island model will check its policy to know how to integrate population sent by other islands. + +@see smp::Island, smp::MigPolicy +*/ + +template +class IntPolicy +{ +public: + /** + * Constructor + * @param _eval Method to evaluate the population to integrate. + * @param _replace Method to replace elements in the island. + */ + IntPolicy(eoEvalFunc& _eval, eoReplacement& _replace); + + eoEvalFunc& eval; + eoReplacement& replace; +}; + +#include + +} + +} + +#endif diff --git a/smp/src/island.cpp b/smp/src/island.cpp index da6066117..a7920d108 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -31,14 +31,18 @@ Contact: paradiseo-help@lists.gforge.inria.fr template