Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
37
smp/src/MWAlgo/MWAlgo.h
Normal file
37
smp/src/MWAlgo/MWAlgo.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
<MWAlgo.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||
|
||||
Alexandre Quemy
|
||||
|
||||
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 MWAlGO_H
|
||||
#define MWAlGO_H
|
||||
|
||||
#include <MWAlgo/eoEasyEA.cpp>
|
||||
#include <MWAlgo/eoEasyPSO.cpp>
|
||||
#include <MWAlgo/eoSyncEasyPSO.cpp>
|
||||
|
||||
#endif
|
||||
43
smp/src/MWAlgo/eoEasyEA.cpp
Normal file
43
smp/src/MWAlgo/eoEasyEA.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
template<template <class> class EOAlgo, class EOT, class Policy>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoEasyEA_tag&)
|
||||
{
|
||||
|
||||
if (this->isFirstCall)
|
||||
{
|
||||
size_t total_capacity = _pop.capacity() + this->offspring.capacity();
|
||||
_pop.reserve(total_capacity);
|
||||
this->offspring.reserve(total_capacity);
|
||||
this->isFirstCall = false;
|
||||
}
|
||||
|
||||
eoPop<EOT> empty_pop;
|
||||
|
||||
this->popEval(empty_pop, _pop); // A first eval of pop.
|
||||
|
||||
do
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned pSize = _pop.size();
|
||||
this->offspring.clear(); // new offspring
|
||||
this->breed(_pop, this->offspring);
|
||||
|
||||
scheduler(EOAlgo<EOT>::eval, this->offspring); // eval of parents + offspring if necessary
|
||||
|
||||
this->replace(_pop, this->offspring); // after replace, the new pop. is in _pop
|
||||
|
||||
if (pSize > _pop.size())
|
||||
throw std::runtime_error("Population shrinking!");
|
||||
else if (pSize < _pop.size())
|
||||
throw std::runtime_error("Population growing!");
|
||||
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string s = e.what();
|
||||
s.append( " in eoEasyEA");
|
||||
throw std::runtime_error( s );
|
||||
}
|
||||
}
|
||||
while (this->continuator( _pop ) );
|
||||
}
|
||||
35
smp/src/MWAlgo/eoEasyPSO.cpp
Normal file
35
smp/src/MWAlgo/eoEasyPSO.cpp
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
template<template <class> class EOAlgo, class EOT, class Policy>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoEasyPSO_tag&)
|
||||
{
|
||||
try
|
||||
{
|
||||
// initializes the topology, velocity, best particle(s)
|
||||
this->init();
|
||||
do
|
||||
{
|
||||
// loop over all the particles for the current iteration
|
||||
for (unsigned idx = 0; idx < _pop.size (); idx++)
|
||||
{
|
||||
// perform velocity evaluation
|
||||
this->velocity (_pop[idx],idx);
|
||||
|
||||
// apply the flight
|
||||
this->flight (_pop[idx]);
|
||||
}
|
||||
|
||||
// evaluate the position
|
||||
scheduler(EOAlgo<EOT>::eval, _pop);
|
||||
|
||||
for (unsigned idx = 0; idx < _pop.size (); idx++)
|
||||
// update the topology (particle and local/global best(s))
|
||||
this->velocity.updateNeighborhood(_pop[idx],idx);
|
||||
|
||||
} while (this->continuator (_pop));
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::string s = e.what ();
|
||||
s.append (" in eoEasyPSO");
|
||||
throw std::runtime_error (s);
|
||||
}
|
||||
}
|
||||
36
smp/src/MWAlgo/eoSyncEasyPSO.cpp
Normal file
36
smp/src/MWAlgo/eoSyncEasyPSO.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
template<template <class> class EOAlgo, class EOT, class Policy>
|
||||
void paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::operator()(eoPop<EOT>& _pop, const eoSyncEasyPSO_tag&)
|
||||
{
|
||||
try
|
||||
{
|
||||
// initializes the topology, velocity, best particle(s)
|
||||
this->init();
|
||||
|
||||
// just to use a loop eval
|
||||
eoPop<EOT> empty_pop;
|
||||
|
||||
do
|
||||
{
|
||||
// perform velocity evaluation
|
||||
//scheduler(this->velocity, _pop);
|
||||
this->velocity.apply(_pop);
|
||||
|
||||
// apply the flight
|
||||
this->flight.apply(_pop);
|
||||
|
||||
// evaluate the position (with a loop eval, empty_swarm IS USELESS)
|
||||
scheduler(EOAlgo<EOT>::eval, _pop);
|
||||
|
||||
// update the topology (particle and local/global best(s))
|
||||
this->velocity.updateNeighborhood(_pop);
|
||||
|
||||
} while (this->continuator(_pop));
|
||||
|
||||
}
|
||||
catch (std::exception & e)
|
||||
{
|
||||
std::string s = e.what ();
|
||||
s.append (" in eoSyncEasyPSO");
|
||||
throw std::runtime_error (s);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue