/* 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) 2020 Thales group */ /* Authors: Johann Dréo */ #ifndef _edoEstimatorAdaptiveCombined_h #define _edoEstimatorAdaptiveCombined_h #include #include #include "edoEstimatorAdaptive.h" /** An estimator that calls several ordered estimators, stateful version. * * @ingroup Estimators */ template class edoEstimatorCombinedAdaptive : public edoEstimatorAdaptive, public std::vector*> { public: typedef typename D::EOType EOType; edoEstimatorCombinedAdaptive( D& distrib, edoEstimator& estim) : edoEstimatorAdaptive(distrib), std::vector*>(1,&estim) {} edoEstimatorCombinedAdaptive( D& distrib, std::vector*> estims) : edoEstimatorAdaptive(distrib), std::vector*>(estims) {} void add( edoEstimator& estim ) { this->push_back(&estim); } virtual D operator()( eoPop& pop ) { for(edoEstimator* pestim : *this) { this->_distrib = (*pestim)( pop ); } return this->_distrib; } }; /** An estimator that calls several ordered estimators, stateless version. * * @ingroup Estimators */ template class edoEstimatorCombinedStateless : public edoEstimatorCombinedAdaptive { public: typedef typename D::EOType EOType; edoEstimatorCombinedStateless( edoEstimator& estim ) : edoEstimatorCombinedAdaptive(*(new D), estim) {} edoEstimatorCombinedStateless( std::vector*> estims) : edoEstimatorCombinedAdaptive(*(new D), estims) {} virtual D operator()( eoPop& pop ) { delete &(this->_distrib); this->_distrib = *(new D); return edoEstimatorCombinedAdaptive::operator()(pop); } ~edoEstimatorCombinedStateless() { delete &(this->_distrib); } }; #endif // !_edoEstimatorAdaptiveCombined_h