diff --git a/cmake/Config.cmake b/cmake/Config.cmake index ac6553b54..1a39102d1 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -44,6 +44,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Wunknown-pragmas -O2" CACHE STRING "" FORCE) if(SMP) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -pthread" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -pthread" CACHE STRING "" FORCE) + add_definitions(-D_GLIBCXX_USE_NANOSLEEP) endif(SMP) ###################################################################################### diff --git a/smp/src/abstractIsland.h b/smp/src/abstractIsland.h index 2c04465ea..4fa2178f0 100644 --- a/smp/src/abstractIsland.h +++ b/smp/src/abstractIsland.h @@ -30,6 +30,8 @@ Contact: paradiseo-help@lists.gforge.inria.fr #ifndef ABS_ISLAND_H_ #define ABS_ISLAND_H_ +#include + #include #include @@ -38,6 +40,10 @@ namespace paradiseo namespace smp { +// Forward declaration +template +class IslandModel; + /** AbstractIsland: An abstract island. @see smp::Island @@ -47,6 +53,14 @@ template class AIsland { public: + + virtual void operator()() = 0; + + /** + * Check if there is population to receive + */ + virtual void setModel(IslandModel* _model) = 0; + /** * Send population to mediator * @param _select Method to select EOT to send @@ -62,6 +76,9 @@ public: * Check if there is population to receive or to emigrate */ virtual void check(void) = 0; + + virtual bool isStopped(void) = 0; + }; } diff --git a/smp/src/bimap.h b/smp/src/bimap.h new file mode 100644 index 000000000..2c8e42f82 --- /dev/null +++ b/smp/src/bimap.h @@ -0,0 +1,85 @@ +/* + +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 BIMAP_MODEL_H_ +#define BIMAP_H_ + +#include +#include + +namespace paradiseo +{ +namespace smp +{ + +template +class Bimap +{ +public: + + void add(A a, B b) + { + ASet.insert(a); + BSet.insert(b); + rightAssociation[&a] = &b; + leftAssociation[&b] = &a; + } + + B& getRight(A const a) + { + return *rightAssociation[&a]; + } + + A& getLeft(B const b) + { + return *leftAssociation[&b]; + } + + unsigned size() + { + return ASet.size(); + } + + bool empty() + { + return ASet.empty(); + } + +protected: + std::set ASet; + std::set BSet; + std::map rightAssociation; + std::map leftAssociation; +}; + +} + +} + +#endif diff --git a/smp/src/island.cpp b/smp/src/island.cpp index a7920d108..51b399d5c 100644 --- a/smp/src/island.cpp +++ b/smp/src/island.cpp @@ -39,7 +39,8 @@ paradiseo::smp::Island::Island(unsigned _popSize, eoInit& _chro algo(EOAlgo(wrap_pp>(this->ck,args)...)), pop(_popSize, _chromInit), intPolicy(_intPolicy), - migPolicy(_migPolicy) + migPolicy(_migPolicy), + stopped(false) { // Check in compile time the inheritance thanks to type_trait. static_assert(std::is_base_of,EOAlgo>::value, "Algorithm must inherit from eoAlgo"); @@ -48,7 +49,15 @@ paradiseo::smp::Island::Island(unsigned _popSize, eoInit& _chro template