From 7c8c4aec1bb4d6895b62fb5bd6d001d84c3bd3f8 Mon Sep 17 00:00:00 2001 From: liefooga Date: Tue, 26 Jun 2007 12:07:30 +0000 Subject: [PATCH] add archive git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@370 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/archive/moeoArchive.h | 180 ++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100644 branches/paradiseo-moeo-1.0/src/archive/moeoArchive.h diff --git a/branches/paradiseo-moeo-1.0/src/archive/moeoArchive.h b/branches/paradiseo-moeo-1.0/src/archive/moeoArchive.h new file mode 100644 index 000000000..9338799d8 --- /dev/null +++ b/branches/paradiseo-moeo-1.0/src/archive/moeoArchive.h @@ -0,0 +1,180 @@ +// -*- 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 +#include + +/** + * An archive is a secondary population that stores non-dominated solutions. + */ +template < class MOEOT > +class moeoArchive : public eoPop < MOEOT > +{ +public: + + using eoPop < MOEOT > :: size; + using eoPop < MOEOT > :: operator[]; + using eoPop < MOEOT > :: back; + using eoPop < 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 int i = 0; i & _pop) + { + for (unsigned int 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 int i=0; i & comparator; + /** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */ + moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + +}; + +#endif /*MOEOARCHIVE_H_ */