edo/CMakeLists.txt updated
This commit is contained in:
parent
09d08bf043
commit
9bd53e3057
18 changed files with 154 additions and 251 deletions
|
|
@ -125,7 +125,7 @@ SET(SAMPLE_SRCS)
|
|||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
ADD_SUBDIRECTORY(application)
|
||||
ADD_SUBDIRECTORY(test)
|
||||
#ADD_SUBDIRECTORY(test)
|
||||
ADD_SUBDIRECTORY(doc)
|
||||
|
||||
######################################################################################
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ int main(int ac, char** av)
|
|||
eoPopLoopEval<EOT> popEval( eval );
|
||||
|
||||
// EDA algorithm configuration
|
||||
edoAlgo< Distrib >* algo = new edoEDA< Distrib >
|
||||
edoAlgo< Distrib >* algo = new edoAlgoStateless< Distrib >
|
||||
(popEval, *selector, *estimator, *sampler, *replacor,
|
||||
pop_continue, *distribution_continue );
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
mkdir -p release
|
||||
cd release
|
||||
cmake ..
|
||||
cmake -DWITH_EIGEN=1 ..
|
||||
#cmake -DWITH_BOOST=1 ..
|
||||
make
|
||||
cd ..
|
||||
|
|
|
|||
|
|
@ -30,17 +30,21 @@ Authors:
|
|||
|
||||
#include "edoAlgo.h"
|
||||
//#include "edoEDASA.h"
|
||||
#include "edoEDA.h"
|
||||
#include "edoAlgoAdaptive.h"
|
||||
#include "edoAlgoStateless.h"
|
||||
|
||||
#include "edoDistrib.h"
|
||||
#include "edoUniform.h"
|
||||
#include "edoNormalMono.h"
|
||||
#include "edoNormalMulti.h"
|
||||
#include "edoNormalAdaptive.h"
|
||||
|
||||
#include "edoEstimator.h"
|
||||
#include "edoEstimatorUniform.h"
|
||||
#include "edoEstimatorNormalMono.h"
|
||||
#include "edoEstimatorNormalMulti.h"
|
||||
#include "edoEstimatorAdaptive.h"
|
||||
#include "edoEstimatorNormalAdaptive.h"
|
||||
|
||||
#include "edoModifier.h"
|
||||
#include "edoModifierDispersion.h"
|
||||
|
|
@ -53,6 +57,7 @@ Authors:
|
|||
#include "edoSamplerUniform.h"
|
||||
#include "edoSamplerNormalMono.h"
|
||||
#include "edoSamplerNormalMulti.h"
|
||||
#include "edoSamplerNormalAdaptive.h"
|
||||
|
||||
#include "edoVectorBounds.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ template < typename D >
|
|||
class edoAlgo : public eoAlgo< typename D::EOType >
|
||||
{
|
||||
//! Alias for the type
|
||||
typedef typename D::EOType EOT;
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
// virtual R operator()(A1) = 0; (defined in eoUF)
|
||||
|
||||
|
|
|
|||
195
edo/src/edoEDA.h
195
edo/src/edoEDA.h
|
|
@ -1,195 +0,0 @@
|
|||
/*
|
||||
The Evolving Distribution Objects framework (EDO) is a template-based,
|
||||
ANSI-C++ evolutionary computation library which helps you to write your
|
||||
own estimation of distribution algorithms.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Copyright (C) 2010 Thales group
|
||||
*/
|
||||
/*
|
||||
Authors:
|
||||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
Caner Candan <caner.candan@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef _edoEDA_h
|
||||
#define _edoEDA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
#include "edoAlgo.h"
|
||||
#include "edoEstimator.h"
|
||||
#include "edoModifierMass.h"
|
||||
#include "edoSampler.h"
|
||||
#include "edoContinue.h"
|
||||
|
||||
//! edoEDA< D >
|
||||
|
||||
template < typename D >
|
||||
class edoEDA : public edoAlgo< D >
|
||||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! edoEDA constructor
|
||||
/*!
|
||||
Takes algo operators, all are mandatory
|
||||
|
||||
\param evaluation Evaluate a population
|
||||
\param selector Selection of the best candidate solutions in the population
|
||||
\param estimator Estimation of the distribution parameters
|
||||
\param sampler Generate feasible solutions using the distribution
|
||||
\param replacor Replace old solutions by new ones
|
||||
\param pop_continuator Stopping criterion based on the population features
|
||||
\param distribution_continuator Stopping criterion based on the distribution features
|
||||
*/
|
||||
edoEDA (
|
||||
eoPopEvalFunc < EOT > & evaluator,
|
||||
eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
edoSampler< D > & sampler,
|
||||
eoReplacement< EOT > & replacor,
|
||||
eoContinue< EOT > & pop_continuator,
|
||||
edoContinue< D > & distribution_continuator
|
||||
) :
|
||||
_evaluator(evaluator),
|
||||
_selector(selector),
|
||||
_estimator(estimator),
|
||||
_sampler(sampler),
|
||||
_replacor(replacor),
|
||||
_pop_continuator(pop_continuator),
|
||||
_dummy_continue(),
|
||||
_distribution_continuator(distribution_continuator)
|
||||
{}
|
||||
|
||||
//! edoEDA constructor without an edoContinue
|
||||
/*!
|
||||
Takes algo operators, all are mandatory
|
||||
|
||||
\param evaluation Evaluate a population
|
||||
\param selector Selection of the best candidate solutions in the population
|
||||
\param estimator Estimation of the distribution parameters
|
||||
\param sampler Generate feasible solutions using the distribution
|
||||
\param replacor Replace old solutions by new ones
|
||||
\param pop_continuator Stopping criterion based on the population features
|
||||
*/
|
||||
edoEDA (
|
||||
eoPopEvalFunc < EOT > & evaluator,
|
||||
eoSelect< EOT > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
edoSampler< D > & sampler,
|
||||
eoReplacement< EOT > & replacor,
|
||||
eoContinue< EOT > & pop_continuator
|
||||
) :
|
||||
_evaluator(evaluator),
|
||||
_selector(selector),
|
||||
_estimator(estimator),
|
||||
_sampler(sampler),
|
||||
_replacor(replacor),
|
||||
_pop_continuator(pop_continuator),
|
||||
_dummy_continue(),
|
||||
_distribution_continuator( _dummy_continue )
|
||||
{}
|
||||
|
||||
|
||||
/** A basic EDA algorithm that iterates over:
|
||||
* selection, estimation, sampling, bounding, evaluation, replacement
|
||||
*
|
||||
* \param pop the population of candidate solutions
|
||||
* \return void
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
eoPop< EOT > selected_pop;
|
||||
|
||||
// FIXME one must instanciate a first distrib here because there is no empty constructor, see if it is possible to instanciate Distributions without parameters
|
||||
D distrib = _estimator(pop);
|
||||
|
||||
// Evaluating a first time the candidate solutions
|
||||
// The first pop is not supposed to be evaluated (@see eoPopLoopEval).
|
||||
_evaluator( current_pop, pop );
|
||||
|
||||
do {
|
||||
// (1) Selection of the best points in the population
|
||||
//selected_pop.clear(); // FIXME is it necessary to clear?
|
||||
_selector(pop, selected_pop);
|
||||
assert( selected_pop.size() > 0 );
|
||||
// TODO: utiliser selected_pop ou pop ???
|
||||
|
||||
// (2) Estimation of the distribution parameters
|
||||
distrib = _estimator(selected_pop);
|
||||
|
||||
// (3) sampling
|
||||
// The sampler produces feasible solutions (@see edoSampler that
|
||||
// encapsulate an edoBounder)
|
||||
current_pop.clear();
|
||||
for( unsigned int i = 0; i < pop.size(); ++i ) {
|
||||
current_pop.push_back( _sampler(distrib) );
|
||||
}
|
||||
|
||||
// (4) Evaluate new solutions
|
||||
_evaluator( pop, current_pop );
|
||||
|
||||
// (5) Replace old solutions by new ones
|
||||
_replacor(pop, current_pop); // e.g. copy current_pop in pop
|
||||
|
||||
} while( _distribution_continuator( distrib ) && _pop_continuator( pop ) );
|
||||
} // operator()
|
||||
|
||||
private:
|
||||
|
||||
//! A full evaluation function.
|
||||
eoPopEvalFunc < EOT > & _evaluator;
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continuator;
|
||||
|
||||
//! A D continuator that always return true
|
||||
edoDummyContinue<D> _dummy_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continuator;
|
||||
|
||||
};
|
||||
|
||||
#endif // !_edoEDA_h
|
||||
|
|
@ -29,7 +29,7 @@ Authors:
|
|||
#define _edoEDASA_h
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
|
|
@ -46,13 +46,13 @@ class edoEDASA : public edoAlgo< D >
|
|||
{
|
||||
public:
|
||||
//! Alias for the type EOT
|
||||
typedef typename D::EOType EOT;
|
||||
typedef typename D::EOType EOType;
|
||||
|
||||
//! Alias for the atom type
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
typedef typename EOType::AtomType AtomType;
|
||||
|
||||
//! Alias for the fitness
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
typedef typename EOType::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
|
|
@ -73,18 +73,18 @@ public:
|
|||
\param initial_temperature The initial temperature.
|
||||
\param replacor Population replacor
|
||||
*/
|
||||
edoEDASA (eoSelect< EOT > & selector,
|
||||
edoEDASA (eoSelect< EOType > & selector,
|
||||
edoEstimator< D > & estimator,
|
||||
eoSelectOne< EOT > & selectone,
|
||||
eoSelectOne< EOType > & selectone,
|
||||
edoModifierMass< D > & modifier,
|
||||
edoSampler< D > & sampler,
|
||||
eoContinue< EOT > & pop_continue,
|
||||
eoContinue< EOType > & pop_continue,
|
||||
edoContinue< D > & distribution_continue,
|
||||
eoEvalFunc < EOT > & evaluation,
|
||||
moContinuator< moDummyNeighbor<EOT> > & sa_continue,
|
||||
moCoolingSchedule<EOT> & cooling_schedule,
|
||||
eoEvalFunc < EOType > & evaluation,
|
||||
moContinuator< moDummyNeighbor<EOType> > & sa_continue,
|
||||
moCoolingSchedule<EOType> & cooling_schedule,
|
||||
double initial_temperature,
|
||||
eoReplacement< EOT > & replacor
|
||||
eoReplacement< EOType > & replacor
|
||||
)
|
||||
: _selector(selector),
|
||||
_estimator(estimator),
|
||||
|
|
@ -108,15 +108,15 @@ public:
|
|||
\param pop A population to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
void operator ()(eoPop< EOT > & pop)
|
||||
void operator ()(eoPop< EOType > & pop)
|
||||
{
|
||||
assert(pop.size() > 0);
|
||||
|
||||
double temperature = _initial_temperature;
|
||||
|
||||
eoPop< EOT > current_pop;
|
||||
eoPop< EOType > current_pop;
|
||||
|
||||
eoPop< EOT > selected_pop;
|
||||
eoPop< EOType > selected_pop;
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
|
@ -165,7 +165,7 @@ public:
|
|||
// Init of a variable contening a point with the bestest fitnesses
|
||||
//-------------------------------------------------------------
|
||||
|
||||
EOT current_solution = _selectone(selected_pop);
|
||||
EOType current_solution = _selectone(selected_pop);
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ public:
|
|||
|
||||
do
|
||||
{
|
||||
EOT candidate_solution = _sampler(distrib);
|
||||
EOType candidate_solution = _sampler(distrib);
|
||||
_evaluation( candidate_solution );
|
||||
|
||||
// TODO: verifier le critere d'acceptation
|
||||
|
|
@ -232,14 +232,14 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
//! A EOT selector
|
||||
eoSelect < EOT > & _selector;
|
||||
//! A EOType selector
|
||||
eoSelect < EOType > & _selector;
|
||||
|
||||
//! A EOT estimator. It is going to estimate distribution parameters.
|
||||
//! A EOType estimator. It is going to estimate distribution parameters.
|
||||
edoEstimator< D > & _estimator;
|
||||
|
||||
//! SelectOne
|
||||
eoSelectOne< EOT > & _selectone;
|
||||
eoSelectOne< EOType > & _selectone;
|
||||
|
||||
//! A D modifier
|
||||
edoModifierMass< D > & _modifier;
|
||||
|
|
@ -247,26 +247,26 @@ private:
|
|||
//! A D sampler
|
||||
edoSampler< D > & _sampler;
|
||||
|
||||
//! A EOT population continuator
|
||||
eoContinue < EOT > & _pop_continue;
|
||||
//! A EOType population continuator
|
||||
eoContinue < EOType > & _pop_continue;
|
||||
|
||||
//! A D continuator
|
||||
edoContinue < D > & _distribution_continue;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & _evaluation;
|
||||
eoEvalFunc < EOType > & _evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moContinuator< moDummyNeighbor<EOT> > & _sa_continue;
|
||||
moContinuator< moDummyNeighbor<EOType> > & _sa_continue;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule<EOT> & _cooling_schedule;
|
||||
moCoolingSchedule<EOType> & _cooling_schedule;
|
||||
|
||||
//! Initial temperature
|
||||
double _initial_temperature;
|
||||
|
||||
//! A EOT replacor
|
||||
eoReplacement < EOT > & _replacor;
|
||||
//! A EOType replacor
|
||||
eoReplacement < EOType > & _replacor;
|
||||
};
|
||||
|
||||
#endif // !_edoEDASA_h
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ Authors:
|
|||
template < typename EOT >
|
||||
class edoNormalMono : public edoDistrib< EOT >
|
||||
{
|
||||
public:
|
||||
public:
|
||||
edoNormalMono()
|
||||
: _mean(EOT(1,0)), _variance(EOT(1,1))
|
||||
{}
|
||||
|
||||
edoNormalMono( const EOT& mean, const EOT& variance )
|
||||
: _mean(mean), _variance(variance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,6 +45,15 @@ class edoNormalMulti : public edoDistrib< EOT >
|
|||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
|
||||
edoNormalMulti( unsigned int dim = 1 ) :
|
||||
_mean( const ublas::vector<AtomType>(0,dim) ),
|
||||
_varcovar( const ublas::identity_matrix<AtomType>(dim) )
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.size() == _varcovar.size1());
|
||||
assert(_mean.size() == _varcovar.size2());
|
||||
}
|
||||
|
||||
edoNormalMulti
|
||||
(
|
||||
const ublas::vector< AtomType >& mean,
|
||||
|
|
@ -86,6 +95,15 @@ public:
|
|||
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, 1> Vector;
|
||||
typedef Eigen::Matrix< AtomType, Eigen::Dynamic, Eigen::Dynamic> Matrix;
|
||||
|
||||
edoNormalMulti( unsigned int dim = 1 ) :
|
||||
_mean( Vector::Zero(dim) ),
|
||||
_varcovar( Matrix::Identity(dim,dim) )
|
||||
{
|
||||
assert(_mean.size() > 0);
|
||||
assert(_mean.innerSize() == _varcovar.innerSize());
|
||||
assert(_mean.innerSize() == _varcovar.outerSize());
|
||||
}
|
||||
|
||||
edoNormalMulti(
|
||||
const Vector & mean,
|
||||
const Matrix & varcovar
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ Authors:
|
|||
#include <boost/numeric/ublas/lu.hpp>
|
||||
#include <boost/numeric/ublas/symmetric.hpp>
|
||||
|
||||
template< class EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
template< typename EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
class edoSamplerNormalMulti : public edoSampler< EOD >
|
||||
{
|
||||
public:
|
||||
|
|
@ -91,7 +91,7 @@ protected:
|
|||
#else
|
||||
#ifdef WITH_EIGEN
|
||||
|
||||
template< class EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
template< typename EOT, typename EOD = edoNormalMulti< EOT > >
|
||||
class edoSamplerNormalMulti : public edoSampler< EOD >
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ Authors:
|
|||
#include<sstream>
|
||||
|
||||
#include "edoStat.h"
|
||||
#include "edoNormalMulti.h"
|
||||
#include "../edoNormalMulti.h"
|
||||
|
||||
#ifdef WITH_BOOST
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ template < typename EOT >
|
|||
class edoStatNormalMulti : public edoDistribStat< edoNormalMulti< EOT > >
|
||||
{
|
||||
public:
|
||||
typedef typename EOT::AtomType AtomType;
|
||||
// typedef typename EOT::AtomType AtomType;
|
||||
|
||||
using edoDistribStat< edoNormalMulti< EOT > >::value;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Authors:
|
|||
#include <iomanip>
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <edo>
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Authors:
|
|||
#include <fstream>
|
||||
|
||||
#include <eo>
|
||||
#include <mo>
|
||||
//#include <mo>
|
||||
|
||||
#include <edo>
|
||||
|
||||
|
|
|
|||
28
eo/NEWS
28
eo/NEWS
|
|
@ -1,4 +1,22 @@
|
|||
* current version
|
||||
- features:
|
||||
- delete the deprecated code parts (was marked as deprecated in the release 1.1)
|
||||
- eoSignal: a class to handle signal with eoCheckpoint instances
|
||||
- eoDetSingleBitFlip: bit flip mutation that changes exactly k bits while checking for duplicate
|
||||
- eoFunctorStat: a wrapper to turn any stand-alone function and into an eoStat
|
||||
- generilazed the output of an eoState: now you can change the format, comes with defaults formatting (latex and json)
|
||||
- eoWrongParamTypeException: a new exception to handle cases where a wrong template is given to eoParser::valueOf
|
||||
- added a getParam method to the eoParser, that raise an exception if the parameter has not been declared
|
||||
- eoParserLogger features are now included in the default eoParser
|
||||
- build system:
|
||||
- improvements of the build architecture
|
||||
- create PKGBUILD file for archlinux package manager
|
||||
- a FindEO module for CMake
|
||||
- bugfixes:
|
||||
- fixed regression with gcc 4.7
|
||||
- fixed compilation issues in Microsoft Visual C++, related to time measurement
|
||||
- added several asserts accross the framework (note: asserts are included only in debug mode)
|
||||
- lot of small bugfixes :-)
|
||||
|
||||
* release 1.2 (16. May. 2011)
|
||||
- fixed the incremental allocation issue in variation operators which were
|
||||
|
|
@ -20,11 +38,11 @@
|
|||
- GCC 4.3 compatibility
|
||||
- new versatile log system with several nested verbose levels
|
||||
- classes using intern verbose parameters marked as deprecated, please update your code accordingly if you use one of the following files:
|
||||
eo/src/eoCombinedInit.h
|
||||
eo/src/eoGenContinue.h
|
||||
eo/src/eoProportionalCombinedOp.h
|
||||
eo/src/utils/eoData.h
|
||||
eo/src/utils/eoStdoutMonitor.h
|
||||
eo/src/eoCombinedInit.h
|
||||
eo/src/eoGenContinue.h
|
||||
eo/src/eoProportionalCombinedOp.h
|
||||
eo/src/utils/eoData.h
|
||||
eo/src/utils/eoStdoutMonitor.h
|
||||
- an evaluator that throw an exception if a maximum eval numbers has been reached, independently of the number of generations
|
||||
- new monitor that can write on any ostream
|
||||
- new continuator that can catch POSIX system user signals
|
||||
|
|
|
|||
|
|
@ -58,14 +58,26 @@ void apply(eoUF<EOT&, void>& _proc, std::vector<EOT>& _pop)
|
|||
if (!eo::parallel.isDynamic())
|
||||
{
|
||||
#pragma omp parallel for if(eo::parallel.isEnabled()) //default(none) shared(_proc, _pop, size)
|
||||
#ifdef _MSC_VER
|
||||
//Visual Studio supports only OpenMP version 2.0 in which
|
||||
//an index variable must be of a signed integral type
|
||||
for (long long i = 0; i < size; ++i) { _proc(_pop[i]); }
|
||||
#else // _MSC_VER
|
||||
for (size_t i = 0; i < size; ++i) { _proc(_pop[i]); }
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#pragma omp parallel for schedule(dynamic) if(eo::parallel.isEnabled())
|
||||
#ifdef _MSC_VER
|
||||
//Visual Studio supports only OpenMP version 2.0 in which
|
||||
//an index variable must be of a signed integral type
|
||||
for (long long i = 0; i < size; ++i) { _proc(_pop[i]); }
|
||||
#else // _MSC_VER
|
||||
//doesnot work with gcc 4.1.2
|
||||
//default(none) shared(_proc, _pop, size)
|
||||
for (size_t i = 0; i < size; ++i) { _proc(_pop[i]); }
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( eo::parallel.enableResults() )
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@
|
|||
#include <eoSharingSelect.h>
|
||||
// Embedding truncation selection
|
||||
#include <eoTruncatedSelectOne.h>
|
||||
#include <eoRankMuSelect.h>
|
||||
|
||||
// the batch selection - from an eoSelectOne
|
||||
#include <eoSelectPerc.h>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include <math.h>
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** eoDetSelect selects many individuals determinisctically
|
||||
/** eoDetSelect selects many individuals deterministically
|
||||
*
|
||||
* @ingroup Selectors
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,27 +21,30 @@ Authors:
|
|||
Johann Dréo <johann.dreo@thalesgroup.com>
|
||||
*/
|
||||
|
||||
#ifndef __unix__
|
||||
#warning "Warning: class 'eoEvalUserTimeThrowException' is only available under UNIX systems (defining 'rusage' in 'sys/resource.h'), contributions for other systems are welcomed."
|
||||
#else
|
||||
#if !defined(__unix__) && !defined(_WINDOWS)
|
||||
#warning "Warning: class 'eoEvalUserTimeThrowException' is only available under UNIX (defining 'rusage' in 'sys/resource.h') or Win32 (defining 'GetProcessTimes' in 'WinBase.h') systems, contributions for other systems are welcomed."
|
||||
#else //!defined(__unix__) && !defined(_WINDOWS)
|
||||
|
||||
#ifndef __EOEVALUSERTIMETHROWEXCEPTION_H__
|
||||
#define __EOEVALUSERTIMETHROWEXCEPTION_H__
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <eoExceptions.h>
|
||||
|
||||
/** Check at each evaluation if a given CPU user time contract has been reached.
|
||||
*
|
||||
* Throw an eoMaxTimeException if the given max time has been reached.
|
||||
* Usefull if you want to end the search independently of generations.
|
||||
* This class uses (almost-)POSIX headers.
|
||||
* This class uses (almost-)POSIX or Win32 headers, depending on the platform.
|
||||
* It uses a computation of the user time used on the CPU. For a wallclock time measure, see eoEvalTimeThrowException
|
||||
*
|
||||
* @ingroup Evaluation
|
||||
*/
|
||||
|
||||
#include <eoExceptions.h>
|
||||
|
||||
#ifdef __unix__
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
template< class EOT >
|
||||
class eoEvalUserTimeThrowException : public eoEvalFuncCounter< EOT >
|
||||
{
|
||||
|
|
@ -58,7 +61,7 @@ public:
|
|||
if( current >= _max ) {
|
||||
throw eoMaxTimeException( current );
|
||||
} else {
|
||||
func(eo);
|
||||
this->func(eo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -68,5 +71,41 @@ protected:
|
|||
struct rusage _usage;
|
||||
};
|
||||
|
||||
#else
|
||||
#ifdef _WINDOWS
|
||||
//here _WINDOWS is defined
|
||||
|
||||
#include <WinBase.h>
|
||||
|
||||
template< class EOT >
|
||||
class eoEvalUserTimeThrowException : public eoEvalFuncCounter< EOT >
|
||||
{
|
||||
public:
|
||||
eoEvalUserTimeThrowException( eoEvalFunc<EOT> & func, const long max ) : eoEvalFuncCounter<EOT>( func, "CPU-user"), _max(max) {}
|
||||
|
||||
virtual void operator() ( EOT & eo )
|
||||
{
|
||||
if( eo.invalid() ) {
|
||||
FILETIME dummy;
|
||||
GetProcessTimes(GetCurrentProcess(), &dummy, &dummy, &dummy, &_usage);
|
||||
|
||||
ULARGE_INTEGER current;
|
||||
current.LowPart = _usage.dwLowDateTime;
|
||||
current.HighPart = _usage.dwHighDateTime;
|
||||
if( current.QuadPart >= _max ) {
|
||||
throw eoMaxTimeException( current.QuadPart );
|
||||
} else {
|
||||
func(eo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
const long _max;
|
||||
FILETIME _usage;
|
||||
};
|
||||
|
||||
#endif // _WINDOWS
|
||||
#endif //__unix__
|
||||
#endif // __EOEVALUSERTIMETHROWEXCEPTION_H__
|
||||
#endif // __UNIX__
|
||||
#endif //!defined(__unix__) && !defined(_WINDOWS)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue