/* (c) 2013 Thales group 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; version 2 of the License. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: http://eodev.sourceforge.net Authors: Johann Dréo */ #ifndef MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ #define MOEOEXPBINARYINDICATORBASEDDUALFITNESSASSIGNMENT_H_ #include template class moeoExpBinaryIndicatorBasedDualFitnessAssignment : public moeoExpBinaryIndicatorBasedFitnessAssignment { protected: eoDualPopSplit _pop_split; public: typedef typename MOEOT::ObjectiveVector ObjectiveVector; typedef typename ObjectiveVector::Type Type; using moeoExpBinaryIndicatorBasedFitnessAssignment::values; moeoExpBinaryIndicatorBasedDualFitnessAssignment( moeoNormalizedSolutionVsSolutionBinaryMetric & metric, const double kappa = 0.05 ) : moeoExpBinaryIndicatorBasedFitnessAssignment( metric, kappa ) {} /*! If the population is homogeneous (only composed of feasible individuals or unfeasible ones), * then apply the operators on the whole population. * But, if there is at least one feasible individual, then apply them only on the feasible individuals. */ virtual void operator()( eoPop& pop ) { // separate the pop in feasible/unfeasible _pop_split( pop ); eoPop* ppop; // if there is at least one feasible individual, // it will supersede all the unfeasible ones if( _pop_split.feasible().size() == 0 ) { ppop = & _pop_split.unfeasible(); } else { ppop = & _pop_split.feasible(); } this->setup(*ppop); this->computeValues(*ppop); this->setFitnesses(*ppop); // NOTE: this alter individuals // bring back altered individuals in the pop pop = _pop_split.merge(); } protected: using moeoExpBinaryIndicatorBasedFitnessAssignment::kappa; /** * Compute every indicator value in values (values[i] = I(_v[i], _o)) * @param _pop the population */ virtual void computeValues(const eoPop < MOEOT > & pop) { values.clear(); values.resize(pop.size()); for (unsigned int i=0; i & pop) { for (unsigned int i=0; icomputeFitness(i), pop[i].fitness().is_feasible() ); } } virtual Type computeFitness(const unsigned int _idx) { Type result( 0.0, values[_idx][_idx].is_feasible() ); for (unsigned int i=0; i