// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- //----------------------------------------------------------------------------- // moeoArchive.h // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 /* This library... Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr */ //----------------------------------------------------------------------------- #ifndef MOEOARCHIVE_H_ #define MOEOARCHIVE_H_ #include #include /** * An archive is a secondary population that stores non-dominated solutions. */ template < class MOEOT > class moeoArchive : public eoPop < MOEOT > { public: using std::vector < MOEOT > :: size; using std::vector < MOEOT > :: operator[]; using std::vector < MOEOT > :: back; using std::vector < MOEOT > :: pop_back; /** * The type of an objective vector for a solution */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; /** * Default ctor. * The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance */ moeoArchive() : eoPop < MOEOT >(), comparator(paretoComparator) {} /** * Ctor * @param _comparator the moeoObjectiveVectorComparator used to compare solutions */ moeoArchive(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : eoPop < MOEOT >(), comparator(_comparator) {} /** * Returns true if the current archive dominates _objectiveVector according to the moeoObjectiveVectorComparator given in the constructor * @param _objectiveVector the objective vector to compare with the current archive */ bool dominates (const ObjectiveVector & _objectiveVector) const { for (unsigned i = 0; i & _pop) { for (unsigned i=0; i<_pop.size(); i++) { update(_pop[i]); } } /** * Returns true if the current archive contains the same objective vectors * than the given archive _arch * @param _arch the given archive */ bool equals (const moeoArchive < MOEOT > & _arch) { for (unsigned i=0; i & comparator; /** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; }; #endif /*MOEOARCHIVE_H_ */