An evaluation is performed before the replacement by the island
This commit is contained in:
parent
3ae7dcc60c
commit
60a119e4c9
5 changed files with 13 additions and 57 deletions
|
|
@ -1,35 +0,0 @@
|
|||
/*
|
||||
<intPolicy.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>
|
||||
paradiseo::smp::IntPolicy<EOT>::IntPolicy(eoEvalFunc<EOT>& _eval, eoReplacement<EOT>& _replace) :
|
||||
eval(_eval),
|
||||
replace(_replace)
|
||||
{}
|
||||
|
||||
|
|
@ -45,21 +45,7 @@ The island model will check its policy to know how to integrate population sent
|
|||
*/
|
||||
|
||||
template <class EOT>
|
||||
class IntPolicy
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
* @param _eval Method to evaluate the population to integrate.
|
||||
* @param _replace Method to replace elements in the island.
|
||||
*/
|
||||
IntPolicy(eoEvalFunc<EOT>& _eval, eoReplacement<EOT>& _replace);
|
||||
|
||||
eoEvalFunc<EOT>& eval;
|
||||
eoReplacement<EOT>& replace;
|
||||
};
|
||||
|
||||
#include<intPolicy.cpp>
|
||||
using IntPolicy = eoReplacement<EOT>;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ paradiseo::smp::Island<EOAlgo,EOT>::Island(unsigned _popSize, eoInit<EOT>& _chro
|
|||
ContWrapper<EOT>(Loop<Args...>().template findValue<eoContinue<EOT>>(args...), this),
|
||||
// We inject the wrapped continuator by tag dispatching method during the algorithm construction.
|
||||
algo(EOAlgo<EOT>(wrap_pp<eoContinue<EOT>>(this->ck,args)...)),
|
||||
// With the PPE we look for the eval function in order to evaluate EOT to integrate
|
||||
eval(Loop<Args...>().template findValue<eoEvalFunc<EOT>>(args...)),
|
||||
pop(_popSize, _chromInit),
|
||||
intPolicy(_intPolicy),
|
||||
migPolicy(_migPolicy),
|
||||
|
|
@ -120,9 +122,12 @@ void paradiseo::smp::Island<EOAlgo,EOT>::receive(void)
|
|||
while (!listImigrants.empty())
|
||||
{
|
||||
eoPop<EOT> offspring = *(listImigrants.front());
|
||||
for(auto indi : offspring)
|
||||
|
||||
intPolicy.replace(pop, offspring);
|
||||
// Evaluate objects to integrate
|
||||
for(auto& indi : offspring)
|
||||
eval(indi);
|
||||
|
||||
intPolicy(pop, offspring);
|
||||
listImigrants.pop();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ protected:
|
|||
*/
|
||||
virtual void receive(void);
|
||||
|
||||
IslandModel<EOT>* model;
|
||||
IslandModel<EOT>* model;
|
||||
eoEvalFunc<EOT>& eval;
|
||||
eoPop<EOT> pop;
|
||||
EOAlgo<EOT> algo;
|
||||
std::queue<eoPop<EOT>*> listImigrants;
|
||||
|
|
@ -125,6 +126,7 @@ protected:
|
|||
MigPolicy<EOT>& migPolicy;
|
||||
std::atomic<bool> stopped;
|
||||
std::vector<std::thread> sentMessages;
|
||||
|
||||
};
|
||||
|
||||
#include <island.cpp>
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ int main(void)
|
|||
migPolicy.push_back(PolicyElement<Indi>(who, criteria));
|
||||
|
||||
// // Integration policy
|
||||
eoPlusReplacement<Indi> replace_1;
|
||||
IntPolicy<Indi> intPolicy(plainEval,replace_1);
|
||||
eoPlusReplacement<Indi> intPolicy;
|
||||
|
||||
Island<eoEasyEA,Indi> test(param.popSize, chromInit, intPolicy, migPolicy, genCont, plainEval, select, transform, replace);
|
||||
|
||||
|
|
@ -77,8 +76,7 @@ int main(void)
|
|||
migPolicy_2.push_back(PolicyElement<Indi>(who_2, criteria_2));
|
||||
|
||||
// // Integration policy
|
||||
eoPlusReplacement<Indi> replace_2;
|
||||
IntPolicy<Indi> intPolicy_2(plainEval,replace_2);
|
||||
eoPlusReplacement<Indi> intPolicy_2;
|
||||
|
||||
Island<eoEasyEA,Indi> test2(param.popSize, chromInit, intPolicy_2, migPolicy_2, genCont_2, plainEval, select, transform, replace);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue