diff --git a/tags/paradiseo-moeo-0.3/AUTHORS b/tags/paradiseo-moeo-0.3/AUTHORS
new file mode 100644
index 000000000..ffa751632
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/AUTHORS
@@ -0,0 +1,4 @@
+Arnaud Liefooghe
+Thomas Legrand
+Sébastien Cahon
+Abdelhakim Deneche
diff --git a/tags/paradiseo-moeo-0.3/ChangeLog b/tags/paradiseo-moeo-0.3/ChangeLog
new file mode 100644
index 000000000..e69de29bb
diff --git a/tags/paradiseo-moeo-0.3/Makefile.am b/tags/paradiseo-moeo-0.3/Makefile.am
new file mode 100644
index 000000000..953971025
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/Makefile.am
@@ -0,0 +1,16 @@
+SUBDIRS = docs src tutorials
+
+clean_all: clean_aux clean_doc
+ -@make clean
+ -@(rm -rf aclocal.m4 autom4te.cache configure config.* CO* dep* INST* install-sh miss* mkins* Makefile Makefile.in;\
+ cd docs; rm -rf Makefile Makefile.in *.doxytag; cd ../src ; rm -rf Makefile Makefile.in; cd ../tutorials; rm -rf Makefile Makefile.in;\
+ cd lesson1; rm -rf .deps/ Makefile Makefile.in; cd ../lesson2; rm -rf .deps/ Makefile Makefile.in)
+
+clean_aux:
+ -@find . \( -name "*~" -o -name "*.old" -o -name "#*" -o -name "*.bak" \) -print -exec rm -rf \{\} \;
+
+doc:
+ -@(cd docs; make doc)
+
+clean_doc:
+ -@(cd docs; make clean-local)
diff --git a/tags/paradiseo-moeo-0.3/NEWS b/tags/paradiseo-moeo-0.3/NEWS
new file mode 100644
index 000000000..31fe551dc
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/NEWS
@@ -0,0 +1,7 @@
+* release 0.1
+
+# Local Variables:
+# coding: iso-8859-1
+# mode: text
+# fill-column: 80
+# End:
diff --git a/tags/paradiseo-moeo-0.3/README b/tags/paradiseo-moeo-0.3/README
new file mode 100644
index 000000000..74a966fdf
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/README
@@ -0,0 +1,63 @@
+ PARADISEO-MOEO README FILE
+=======================================================================
+ check latest news at http://paradiseo.gforge.inria.fr/
+=======================================================================
+
+Welcome to ParadisEO-MOEO, the Multi-Objective Evolving Objects library.
+The latest news about ParadisEO-MOEO can be found on the gforge repository at
+http://paradiseo.gforge.inria.fr/
+In case of any problem, please e-mail us at
+paradiseo-help@lists.gforge.inria.fr
+
+
+==================================================================
+ BUILDING PARADISEO-MOEO
+==================================================================
+The basic installation procedure goes the following:
+
+Go to your build-directory and run
+ > ./autogen.sh --with-EOdir=$(EO_SRC)
+ > make
+ > make doc
+
+where $(EO_SRC) is the top-level source directory of PARADISEO-EO.
+
+In case of problems, you can read the INSTALL file - but remember this
+is a standard installation file from GNU and that it contains nothing
+specific about PARADISEO-MOEO.
+
+To clean everything, the simply run
+ > make clean_all
+
+===================================================================
+ DIRECTORY STRUCTURE
+===================================================================
+After unpacking the archive file, you should end up with the following
+structure:
+
+.../ The main PARADISEO-MOEO directory, created when unpacking.
+ |
+ +-- src SOURCE directory Contains most PARADISEO-MOEO .h files.
+ |
+ +-- docs DOCUMENTATION directory (generated by Doxygen).
+ | |
+ | +- html HTML files - start at index.html.
+ | |
+ | +- latex latex files - use to generate Postcript doc.
+ | |
+ | +- man Unix man format documentation.
+ |
+ |
+ +-- tutorials APPLICATIONS - one directory per separate application.
+ |
+ +-- lesson1 A bi-objective flow-shop problem example with main algorithms.
+ | |
+ | +-benchmarks Instance files for testing.
+ |
+ |-- lesson2 Implement NSGA-II for the SCH1 problem.
+
+===================================================================
+ NOTES
+===================================================================
+
+Mailing list : paradiseo-help@lists.gforge.inria.fr
diff --git a/tags/paradiseo-moeo-0.3/autogen.sh b/tags/paradiseo-moeo-0.3/autogen.sh
new file mode 100644
index 000000000..293b7972e
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/autogen.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+PKG_NAME="the package."
+
+DIE=0
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`autoconf' installed to."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
+ (libtool --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`libtool' installed."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
+ grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
+ (gettext --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`gettext' installed."
+ echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+grep "^AM_GNOME_GETTEXT" $srcdir/configure.in >/dev/null && {
+ grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
+ (gettext --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`gettext' installed."
+ echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`automake' installed."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ NO_AUTOMAKE=yes
+}
+
+
+# if no automake, don't bother testing for aclocal
+test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: Missing \`aclocal'. The version of \`automake'"
+ echo "installed doesn't appear recent enough."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "**Warning**: I am going to run \`configure' with no arguments."
+ echo "If you wish to pass any to it, please specify them on the"
+ echo \`$0\'" command line."
+ echo
+fi
+
+case $CC in
+xlc )
+ am_opt=--include-deps;;
+esac
+
+for coin in `find $srcdir -name configure.in -print`
+do
+ dr=`dirname $coin`
+ if test -f $dr/NO-AUTO-GEN; then
+ echo skipping $dr -- flagged as no auto-gen
+ else
+ echo processing $dr
+ macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
+ ( cd $dr
+ aclocalinclude="$ACLOCAL_FLAGS"
+ for k in $macrodirs; do
+ if test -d $k; then
+ aclocalinclude="$aclocalinclude -I $k"
+ ##else
+ ## echo "**Warning**: No such directory \`$k'. Ignored."
+ fi
+ done
+ if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
+ if grep "sed.*POTFILES" configure.in >/dev/null; then
+ : do nothing -- we still have an old unmodified configure.in
+ else
+ echo "Creating $dr/aclocal.m4 ..."
+ test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
+ echo "Running gettextize... Ignore non-fatal messages."
+ echo "no" | gettextize --force --copy
+ echo "Making $dr/aclocal.m4 writable ..."
+ test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
+ fi
+ fi
+ if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then
+ echo "Creating $dr/aclocal.m4 ..."
+ test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
+ echo "Running gettextize... Ignore non-fatal messages."
+ echo "no" | gettextize --force --copy
+ echo "Making $dr/aclocal.m4 writable ..."
+ test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
+ fi
+ if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
+ echo "Running libtoolize..."
+ libtoolize --force --copy
+ fi
+ echo "Running aclocal $aclocalinclude ..."
+ aclocal $aclocalinclude
+ if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
+ echo "Running autoheader..."
+ autoheader
+ fi
+ echo "Running automake --gnu $am_opt ..."
+ automake --add-missing --gnu $am_opt
+ echo "Running autoconf ..."
+ autoconf
+ )
+ fi
+done
+
+#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
+
+if test x$NOCONFIGURE = x; then
+ echo Running $srcdir/configure $conf_flags "$@" ...
+ $srcdir/configure $conf_flags "$@" \
+ && echo Now type \`make\' to compile $PKG_NAME
+else
+ echo Skipping configure process.
+fi
diff --git a/tags/paradiseo-moeo-0.3/configure.in b/tags/paradiseo-moeo-0.3/configure.in
new file mode 100644
index 000000000..253a290ba
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/configure.in
@@ -0,0 +1,43 @@
+AC_INIT(configure.in)
+AM_INIT_AUTOMAKE(moeo, 0.1)
+
+AC_ISC_POSIX
+AC_PROG_CXX
+AM_PROG_CC_STDC
+AC_HEADER_STDC
+AC_PROG_RANLIB
+
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+AC_C_CONST
+AC_C_INLINE
+AC_TYPE_SIZE_T
+
+AC_SUBST(EO_DIR)
+
+dnl EO
+AC_ARG_WITH(EOdir,
+ --with-EOdir : Giving the path of the EO tree.,
+ EO_DIR="$withval"
+ if test ! -d $EO_DIR
+ then
+ echo ""
+ echo "# --with-EOdir Invalid directory $withval"
+ exit 1
+ fi,
+ echo ""
+ echo "# You forgot to give the path of the EO tree !"
+ echo "# Please write something like ... './configure --with-EOdir=\$HOME/eo'"
+ exit 1
+ )
+
+AC_OUTPUT([
+Makefile
+src/Makefile
+docs/Makefile
+tutorials/Makefile
+tutorials/lesson1/Makefile
+tutorials/lesson2/Makefile
+])
diff --git a/tags/paradiseo-moeo-0.3/docs/Makefile.am b/tags/paradiseo-moeo-0.3/docs/Makefile.am
new file mode 100644
index 000000000..254b2661c
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/docs/Makefile.am
@@ -0,0 +1,5 @@
+doc:
+ -@doxygen moeo.doxyfile
+
+clean-local:
+ rm -rf html latex man
diff --git a/tags/paradiseo-moeo-0.3/docs/index.h b/tags/paradiseo-moeo-0.3/docs/index.h
new file mode 100644
index 000000000..d6cf1e04e
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/docs/index.h
@@ -0,0 +1,53 @@
+/** @mainpage Welcome to ParadisEO-MOEO
+
+@section intro Introduction
+
+ParadisEO-MOEO is a white-box object-oriented generic framework dedicated to the flexible design of evolutionary multi-objective algorithms.
+This paradigm-free software embeds some features and techniques for Pareto-based resolution and
+aims to provide a set of classes allowing to ease and speed up the development of computationally efficient programs.
+It is based on a clear conceptual distinction between the solution methods and the multi-objective problems they are intended to solve.
+This separation confers a maximum design and code reuse.
+ParadisEO-MOEO provides a broad range of archive-related features (such as elitism or performance metrics)
+and the most common Pareto-based fitness assignment strategies (MOGA, NSGA, SPEA, IBEA and more).
+Furthermore, parallel and distributed models as well as hybridization mechanisms can be applied to an algorithm designed within ParadisEO-MOEO
+using the whole version of ParadisEO.
+
+
+
+@section tutorials Tutorials
+
+Tutorials for ParadisEO-MOEO are available here.
+
+
+
+@section install Installation
+
+The installation procedure of the package is detailed in the README file in the top-directory of the source-tree.
+
+
+
+@section design Overall Design
+
+For an introduction to the design of ParadisEO-MOEO,
+you can look at the ParadisEO website.
+*/
+
+
+
+/** @page webpages Related webpages
+
+- ParadisEO homepage
+- INRIA GForge project page
+- README
+- NEWS
+*/
+
+
+
+// Local Variables:
+// coding: iso-8859-1
+// mode: C++
+// c-file-style: "Stroustrup"
+// fill-column: 80
+// End:
diff --git a/tags/paradiseo-moeo-0.3/docs/moeo.doxyfile b/tags/paradiseo-moeo-0.3/docs/moeo.doxyfile
new file mode 100644
index 000000000..c5066b5c7
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/docs/moeo.doxyfile
@@ -0,0 +1,237 @@
+# Doxyfile 1.5.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = ParadisEO-MOEO
+PROJECT_NUMBER = 1.0
+OUTPUT_DIRECTORY =
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = "The $name class" \
+ "The $name widget" \
+ "The $name file" \
+ is \
+ provides \
+ specifies \
+ contains \
+ represents \
+ a \
+ an \
+ the
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = NO
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+BUILTIN_STL_SUPPORT = NO
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = NO
+SORT_BRIEF_DOCS = NO
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = NO
+FILE_VERSION_FILTER =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = YES
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_NO_PARAMDOC = NO
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = . ../src
+FILE_PATTERNS = *.cpp \
+ *.h \
+ NEWS README
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = YES
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 3
+IGNORE_PREFIX = moeo
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = YES
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = YES
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES = ../../paradiseo-eo/doc/eo.doxytag=../../../paradiseo-eo/doc/html
+GENERATE_TAGFILE = moeo.doxytag
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+GROUP_GRAPHS = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+CALLER_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = NO
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = YES
diff --git a/tags/paradiseo-moeo-0.3/src/MOEO.h b/tags/paradiseo-moeo-0.3/src/MOEO.h
new file mode 100644
index 000000000..78c4de739
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/MOEO.h
@@ -0,0 +1,291 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// MOEO.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEO_H_
+#define MOEO_H_
+
+#include
+#include
+#include
+#include
+
+/**
+ * Base class allowing to represent a solution (an individual) for multi-objective optimization.
+ * The template argument MOEOObjectiveVector allows to represent the solution in the objective space (it can be a moeoObjectiveVector object).
+ * The template argument MOEOFitness is an object reflecting the quality of the solution in term of convergence (the fitness of a solution is always to be maximized).
+ * The template argument MOEODiversity is an object reflecting the quality of the solution in term of diversity (the diversity of a solution is always to be maximized).
+ * All template arguments must have a void and a copy constructor.
+ * Using some specific representations, you will have to define a copy constructor if the default one is not what you want.
+ * In the same cases, you will also have to define the affectation operator (operator=).
+ * Then, you will explicitly have to call the parent copy constructor and the parent affectation operator at the beginning of the corresponding implementation.
+ * Besides, note that, contrary to the mono-objective case (and to EO) where the fitness value of a solution is confused with its objective value,
+ * the fitness value differs of the objectives values in the multi-objective case.
+ */
+template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity >
+class MOEO : public EO < MOEOObjectiveVector >
+{
+public:
+
+ /** the objective vector type of a solution */
+ typedef MOEOObjectiveVector ObjectiveVector;
+
+ /** the fitness type of a solution */
+ typedef MOEOFitness Fitness;
+
+ /** the diversity type of a solution */
+ typedef MOEODiversity Diversity;
+
+
+ /**
+ * Ctor
+ */
+ MOEO()
+ {
+ // default values for every parameters
+ objectiveVectorValue = ObjectiveVector();
+ fitnessValue = Fitness();
+ diversityValue = Diversity();
+ // invalidate all
+ invalidate();
+ }
+
+
+ /**
+ * Virtual dtor
+ */
+ virtual ~MOEO() {};
+
+
+ /**
+ * Returns the objective vector of the current solution
+ */
+ ObjectiveVector objectiveVector() const
+ {
+ if ( invalidObjectiveVector() )
+ {
+ throw std::runtime_error("invalid objective vector");
+ }
+ return objectiveVectorValue;
+ }
+
+
+ /**
+ * Sets the objective vector of the current solution
+ * @param _objectiveVectorValue the new objective vector
+ */
+ void objectiveVector(const ObjectiveVector & _objectiveVectorValue)
+ {
+ objectiveVectorValue = _objectiveVectorValue;
+ invalidObjectiveVectorValue = false;
+ }
+
+
+ /**
+ * Sets the objective vector as invalid
+ */
+ void invalidateObjectiveVector()
+ {
+ invalidObjectiveVectorValue = true;
+ }
+
+
+ /**
+ * Returns true if the objective vector is invalid, false otherwise
+ */
+ bool invalidObjectiveVector() const
+ {
+ return invalidObjectiveVectorValue;
+ }
+
+
+ /**
+ * Returns the fitness value of the current solution
+ */
+ Fitness fitness() const
+ {
+ if ( invalidFitness() )
+ {
+ throw std::runtime_error("invalid fitness (MOEO)");
+ }
+ return fitnessValue;
+ }
+
+
+ /**
+ * Sets the fitness value of the current solution
+ * @param _fitnessValue the new fitness value
+ */
+ void fitness(const Fitness & _fitnessValue)
+ {
+ fitnessValue = _fitnessValue;
+ invalidFitnessValue = false;
+ }
+
+
+ /**
+ * Sets the fitness value as invalid
+ */
+ void invalidateFitness()
+ {
+ invalidFitnessValue = true;
+ }
+
+
+ /**
+ * Returns true if the fitness value is invalid, false otherwise
+ */
+ bool invalidFitness() const
+ {
+ return invalidFitnessValue;
+ }
+
+
+ /**
+ * Returns the diversity value of the current solution
+ */
+ Diversity diversity() const
+ {
+ if ( invalidDiversity() )
+ {
+ throw std::runtime_error("invalid diversity");
+ }
+ return diversityValue;
+ }
+
+
+ /**
+ * Sets the diversity value of the current solution
+ * @param _diversityValue the new diversity value
+ */
+ void diversity(const Diversity & _diversityValue)
+ {
+ diversityValue = _diversityValue;
+ invalidDiversityValue = false;
+ }
+
+
+ /**
+ * Sets the diversity value as invalid
+ */
+ void invalidateDiversity()
+ {
+ invalidDiversityValue = true;
+ }
+
+
+ /**
+ * Returns true if the diversity value is invalid, false otherwise
+ */
+ bool invalidDiversity() const
+ {
+ return invalidDiversityValue;
+ }
+
+
+ /**
+ * Sets the objective vector, the fitness value and the diversity value as invalid
+ */
+ void invalidate()
+ {
+ invalidateObjectiveVector();
+ invalidateFitness();
+ invalidateDiversity();
+ }
+
+
+ /**
+ * Returns true if the fitness value is invalid, false otherwise
+ */
+ bool invalid() const
+ {
+ return invalidObjectiveVector();
+ }
+
+
+ /**
+ * Returns true if the objective vector of the current solution is smaller than the objective vector of _other on the first objective,
+ * then on the second, and so on (can be usefull for sorting/printing).
+ * You should implement another function in the sub-class of MOEO to have another sorting mecanism.
+ * @param _other the other MOEO object to compare with
+ */
+ bool operator<(const MOEO & _other) const
+ {
+ return objectiveVector() < _other.objectiveVector();
+ }
+
+
+ /**
+ * Return the class id (the class name as a std::string)
+ */
+ virtual std::string className() const
+ {
+ return "MOEO";
+ }
+
+
+ /**
+ * Writing object
+ * @param _os output stream
+ */
+ virtual void printOn(std::ostream & _os) const
+ {
+ if ( invalidObjectiveVector() )
+ {
+ _os << "INVALID\t";
+ }
+ else
+ {
+ _os << objectiveVectorValue << '\t';
+ }
+ }
+
+
+ /**
+ * Reading object
+ * @param _is input stream
+ */
+ virtual void readFrom(std::istream & _is)
+ {
+ std::string objectiveVector_str;
+ int pos = _is.tellg();
+ _is >> objectiveVector_str;
+ if (objectiveVector_str == "INVALID")
+ {
+ invalidateObjectiveVector();
+ }
+ else
+ {
+ invalidObjectiveVectorValue = false;
+ _is.seekg(pos); // rewind
+ _is >> objectiveVectorValue;
+ }
+ }
+
+
+private:
+
+ /** the objective vector of this solution */
+ ObjectiveVector objectiveVectorValue;
+ /** true if the objective vector is invalid */
+ bool invalidObjectiveVectorValue;
+ /** the fitness value of this solution */
+ Fitness fitnessValue;
+ /** true if the fitness value is invalid */
+ bool invalidFitnessValue;
+ /** the diversity value of this solution */
+ Diversity diversityValue;
+ /** true if the diversity value is invalid */
+ bool invalidDiversityValue;
+
+};
+
+#endif /*MOEO_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/Makefile.am b/tags/paradiseo-moeo-0.3/src/Makefile.am
new file mode 100644
index 000000000..ae1e51b3c
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/Makefile.am
@@ -0,0 +1 @@
+# Nothing to compile !
diff --git a/tags/paradiseo-moeo-0.3/src/distance/moeoDistance.h b/tags/paradiseo-moeo-0.3/src/distance/moeoDistance.h
new file mode 100644
index 000000000..0b55890c0
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/distance/moeoDistance.h
@@ -0,0 +1,227 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoDistance.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEODISTANCE_H_
+#define MOEODISTANCE_H_
+
+#include
+#include
+#include
+
+/**
+ * The base class for distance computation.
+ */
+template < class MOEOT , class Type >
+class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
+{
+public:
+
+
+ /**
+ * Nothing to do
+ * @param _pop the population
+ */
+ virtual void setup(const eoPop < MOEOT > & _pop)
+ {}
+
+ /**
+ * Nothing to do
+ * @param _min lower bound
+ * @param _max upper bound
+ * @param _obj the objective index
+ */
+ virtual void setup(double _min, double _max, unsigned _obj)
+ {}
+
+
+ /**
+ * Nothing to do
+ * @param _realInterval the eoRealInterval object
+ * @param _obj the objective index
+ */
+ virtual void setup(eoRealInterval _realInterval, unsigned _obj)
+ {}
+
+};
+
+
+/**
+ * The base class for double distance computation with normalized objective values (i.e. between 0 and 1).
+ */
+template < class MOEOT , class Type = double >
+class moeoNormalizedDistance : public moeoDistance < MOEOT , Type >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Default ctr
+ */
+ moeoNormalizedDistance()
+ {
+ bounds.resize(ObjectiveVector::Traits::nObjectives());
+ // initialize bounds in case someone does not want to use them
+ for (unsigned i=0; i & _pop)
+ {
+ double min, max;
+ for (unsigned i=0; i bounds;
+
+};
+
+
+/**
+ * A class allowing to compute an euclidian distance between two solutions in the objective space with normalized objective values (i.e. between 0 and 1).
+ * A distance value then lies between 0 and sqrt(nObjectives).
+ */
+template < class MOEOT >
+class moeoEuclideanDistance : public moeoNormalizedDistance < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Returns the euclidian distance between _moeo1 and _moeo2 in the objective space
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ double result = 0.0;
+ double tmp1, tmp2;
+ for (unsigned i=0; i :: bounds;
+
+};
+
+/**
+ * A class allowing to compute the Manhattan distance between two solutions in the objective space normalized objective values (i.e. between 0 and 1).
+ * A distance value then lies between 0 and nObjectives.
+ */
+template < class MOEOT >
+class moeoManhattanDistance : public moeoNormalizedDistance < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Returns the Manhattan distance between _moeo1 and _moeo2 in the objective space
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ double result = 0.0;
+ double tmp1, tmp2;
+ for (unsigned i=0; i :: bounds;
+
+};
+
+#endif /*MOEODISTANCE_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/distance/moeoDistanceMatrix.h b/tags/paradiseo-moeo-0.3/src/distance/moeoDistanceMatrix.h
new file mode 100644
index 000000000..ed6c088ce
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/distance/moeoDistanceMatrix.h
@@ -0,0 +1,75 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoDistanceMatrix.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEODISTANCEMATRIX_H_
+#define MOEODISTANCEMATRIX_H_
+
+#include
+#include
+
+/**
+ * A matrix to compute distances between every pair of individuals contained in a population.
+ */
+template < class MOEOT , class Type >
+class moeoDistanceMatrix : public eoUF < const eoPop < MOEOT > &, void > , public std::vector< std::vector < Type > >
+{
+public:
+
+ using std::vector< std::vector < Type > > :: size;
+ using std::vector< std::vector < Type > > :: operator[];
+
+
+ /**
+ * Ctor
+ * @param _size size for every dimension of the matrix
+ * @param _distance the distance to use
+ */
+ moeoDistanceMatrix (unsigned _size, moeoDistance < MOEOT , Type > & _distance) : distance(_distance)
+ {
+ this->resize(_size);
+ for (unsigned i=0; i<_size; i++)
+ {
+ this->operator[](i).resize(_size);
+ }
+ }
+
+
+ /**
+ * Sets the distance between every pair of individuals contained in the population _pop
+ * @param _pop the population
+ */
+ void operator()(const eoPop < MOEOT > & _pop)
+ {
+ // 1 - setup the bounds (if necessary)
+ distance.setup(_pop);
+ // 2 - compute distances
+ this->operator[](0).operator[](0) = Type();
+ for (unsigned i=0; ioperator[](i).operator[](i) = Type();
+ for (unsigned j=0; joperator[](i).operator[](j) = distance(_pop[i], _pop[j]);
+ this->operator[](j).operator[](i) = this->operator[](i).operator[](j);
+ }
+ }
+ }
+
+
+private:
+
+ /** the distance to use */
+ moeoDistance < MOEOT , Type > & distance;
+
+};
+
+#endif /*MOEODISTANCEMATRIX_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/do/make_checkpoint_moeo.h b/tags/paradiseo-moeo-0.3/src/do/make_checkpoint_moeo.h
new file mode 100755
index 000000000..6f92171a0
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/do/make_checkpoint_moeo.h
@@ -0,0 +1,176 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// make_checkpoint_moeo.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MAKE_CHECKPOINT_MOEO_H_
+#define MAKE_CHECKPOINT_MOEO_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+bool testDirRes(std::string _dirName, bool _erase);
+
+/**
+ * This functions allows to build an eoCheckPoint for multi-objective optimization from the parser (partly taken from make_checkpoint_pareto.h)
+ * @param _parser the parser
+ * @param _state to store allocated objects
+ * @param _eval the funtions evaluator
+ * @param _continue the stopping crietria
+ * @param _pop the population
+ * @param _archive the archive of non-dominated solutions
+ */
+template < class MOEOT >
+eoCheckPoint < MOEOT > & do_make_checkpoint_moeo (eoParser & _parser, eoState & _state, eoEvalFuncCounter < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoPop < MOEOT > & _pop, moeoArchive < MOEOT > & _archive)
+{
+ eoCheckPoint < MOEOT > & checkpoint = _state.storeFunctor(new eoCheckPoint < MOEOT > (_continue));
+ /* the objective vector type */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+ ///////////////////
+ // Counters
+ //////////////////
+ // is nb Eval to be used as counter?
+ //bool useEval = _parser.getORcreateParam(true, "useEval", "Use nb of eval. as counter (vs nb of gen.)", '\0', "Output").value();
+ // Create anyway a generation-counter parameter
+ eoValueParam *generationCounter = new eoValueParam(0, "Gen.");
+ // Create an incrementor (sub-class of eoUpdater).
+ eoIncrementor & increment = _state.storeFunctor( new eoIncrementor(generationCounter->value()) );
+ // Add it to the checkpoint
+ checkpoint.add(increment);
+ // dir for DISK output
+ std::string & dirName = _parser.getORcreateParam(std::string("Res"), "resDir", "Directory to store DISK outputs", '\0', "Output").value();
+ // shoudl we empty it if exists
+ eoValueParam& eraseParam = _parser.getORcreateParam(true, "eraseDir", "erase files in dirName if any", '\0', "Output");
+ bool dirOK = false; // not tested yet
+
+ // Dump of the whole population
+ //-----------------------------
+ bool printPop = _parser.getORcreateParam(false, "printPop", "Print sorted pop. every gen.", '\0', "Output").value();
+ eoSortedPopStat * popStat;
+ if ( printPop ) // we do want pop dump
+ {
+ popStat = & _state.storeFunctor(new eoSortedPopStat);
+ checkpoint.add(*popStat);
+ }
+
+ //////////////////////////////////
+ // State savers
+ //////////////////////////////
+ // feed the state to state savers
+ // save state every N generation
+ eoValueParam& saveFrequencyParam = _parser.createParam(unsigned(0), "saveFrequency", "Save every F generation (0 = only final state, absent = never)", '\0', "Persistence" );
+ if (_parser.isItThere(saveFrequencyParam))
+ {
+ // first make sure dirName is OK
+ if (! dirOK )
+ dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
+ unsigned freq = (saveFrequencyParam.value()>0 ? saveFrequencyParam.value() : UINT_MAX );
+#ifdef _MSVC
+ std::string stmp = dirName + "\generations";
+#else
+ std::string stmp = dirName + "/generations";
+#endif
+ eoCountedStateSaver *stateSaver1 = new eoCountedStateSaver(freq, _state, stmp);
+ _state.storeFunctor(stateSaver1);
+ checkpoint.add(*stateSaver1);
+ }
+ // save state every T seconds
+ eoValueParam& saveTimeIntervalParam = _parser.getORcreateParam(unsigned(0), "saveTimeInterval", "Save every T seconds (0 or absent = never)", '\0',"Persistence" );
+ if (_parser.isItThere(saveTimeIntervalParam) && saveTimeIntervalParam.value()>0)
+ {
+ // first make sure dirName is OK
+ if (! dirOK )
+ dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
+#ifdef _MSVC
+ std::string stmp = dirName + "\time";
+#else
+ std::string stmp = dirName + "/time";
+#endif
+ eoTimedStateSaver *stateSaver2 = new eoTimedStateSaver(saveTimeIntervalParam.value(), _state, stmp);
+ _state.storeFunctor(stateSaver2);
+ checkpoint.add(*stateSaver2);
+ }
+
+ ///////////////////
+ // Archive
+ //////////////////
+ // update the archive every generation
+ bool updateArch = _parser.getORcreateParam(true, "updateArch", "Update the archive at each gen.", '\0', "Evolution Engine").value();
+ if (updateArch)
+ {
+ moeoArchiveUpdater < MOEOT > * updater = new moeoArchiveUpdater < MOEOT > (_archive, _pop);
+ _state.storeFunctor(updater);
+ checkpoint.add(*updater);
+ }
+ // store the objective vectors contained in the archive every generation
+ bool storeArch = _parser.getORcreateParam(false, "storeArch", "Store the archive's objective vectors at each gen.", '\0', "Output").value();
+ if (storeArch)
+ {
+ if (! dirOK )
+ dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
+#ifdef _MSVC
+ std::string stmp = dirName + "\arch";
+#else
+ std::string stmp = dirName + "/arch";
+#endif
+ moeoArchiveObjectiveVectorSavingUpdater < MOEOT > * save_updater = new moeoArchiveObjectiveVectorSavingUpdater < MOEOT > (_archive, stmp);
+ _state.storeFunctor(save_updater);
+ checkpoint.add(*save_updater);
+ }
+ // store the contribution of the non-dominated solutions
+ bool cont = _parser.getORcreateParam(false, "contribution", "Store the contribution of the archive at each gen.", '\0', "Output").value();
+ if (cont)
+ {
+ if (! dirOK )
+ dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
+#ifdef _MSVC
+ std::string stmp = dirName + "\contribution";
+#else
+ std::string stmp = dirName + "/contribution";
+#endif
+ moeoContributionMetric < ObjectiveVector > * contribution = new moeoContributionMetric < ObjectiveVector >;
+ moeoBinaryMetricSavingUpdater < MOEOT > * contribution_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*contribution, _archive, stmp);
+ _state.storeFunctor(contribution_updater);
+ checkpoint.add(*contribution_updater);
+ }
+ // store the entropy of the non-dominated solutions
+ bool ent = _parser.getORcreateParam(false, "entropy", "Store the entropy of the archive at each gen.", '\0', "Output").value();
+ if (ent)
+ {
+ if (! dirOK )
+ dirOK = testDirRes(dirName, eraseParam.value()); // TRUE
+#ifdef _MSVC
+ std::string stmp = dirName + "\entropy";
+#else
+ std::string stmp = dirName + "/entropy";
+#endif
+ moeoEntropyMetric < ObjectiveVector > * entropy = new moeoEntropyMetric < ObjectiveVector >;
+ moeoBinaryMetricSavingUpdater < MOEOT > * entropy_updater = new moeoBinaryMetricSavingUpdater < MOEOT > (*entropy, _archive, stmp);
+ _state.storeFunctor(entropy_updater);
+ checkpoint.add(*entropy_updater);
+ }
+
+ // and that's it for the (control and) output
+ return checkpoint;
+}
+
+#endif /*MAKE_CHECKPOINT_MOEO_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/do/make_continue_moeo.h b/tags/paradiseo-moeo-0.3/src/do/make_continue_moeo.h
new file mode 100755
index 000000000..5000c3b0c
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/do/make_continue_moeo.h
@@ -0,0 +1,106 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// make_continue_moeo.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MAKE_CONTINUE_MOEO_H_
+#define MAKE_CONTINUE_MOEO_H_
+
+#include
+#include
+#include
+#include
+#include
+#ifndef _MSC_VER
+#include
+#endif
+#include
+#include
+
+
+/**
+ * Helper function
+ * @param _combined the eoCombinedContinue object
+ * @param _cont the eoContinue to add
+ */
+template
+eoCombinedContinue * make_combinedContinue(eoCombinedContinue *_combined, eoContinue *_cont)
+{
+ if (_combined) // already exists
+ _combined->add(*_cont);
+ else
+ _combined = new eoCombinedContinue(*_cont);
+ return _combined;
+}
+
+
+/**
+ * This functions allows to build a eoContinue for multi-objective optimization from the parser (partly taken from make_continue_pareto.h)
+ * @param _parser the parser
+ * @param _state to store allocated objects
+ * @param _eval the funtions evaluator
+ */
+template
+eoContinue & do_make_continue_moeo(eoParser& _parser, eoState& _state, eoEvalFuncCounter & _eval)
+{
+ // the combined continue - to be filled
+ eoCombinedContinue *continuator = NULL;
+ // First the eoGenContinue - need a default value so you can run blind
+ // but we also need to be able to avoid it <--> 0
+ eoValueParam& maxGenParam = _parser.createParam(unsigned(100), "maxGen", "Maximum number of generations (0 = none)",'G',"Stopping criterion");
+ if (maxGenParam.value()) // positive: -> define and store
+ {
+ eoGenContinue *genCont = new eoGenContinue(maxGenParam.value());
+ _state.storeFunctor(genCont);
+ // and "add" to combined
+ continuator = make_combinedContinue(continuator, genCont);
+ }
+ // maxEval
+ eoValueParam& maxEvalParam = _parser.getORcreateParam((unsigned long)0, "maxEval", "Maximum number of evaluations (0 = none)", 'E', "Stopping criterion");
+ if (maxEvalParam.value())
+ {
+ eoEvalContinue *evalCont = new eoEvalContinue(_eval, maxEvalParam.value());
+ _state.storeFunctor(evalCont);
+ // and "add" to combined
+ continuator = make_combinedContinue(continuator, evalCont);
+ }
+ // maxTime
+ eoValueParam& maxTimeParam = _parser.getORcreateParam((unsigned long)0, "maxTime", "Maximum running time in seconds (0 = none)", 'T', "Stopping criterion");
+ if (maxTimeParam.value()) // positive: -> define and store
+ {
+ eoTimeContinue *timeCont = new eoTimeContinue(maxTimeParam.value());
+ _state.storeFunctor(timeCont);
+ // and "add" to combined
+ continuator = make_combinedContinue(continuator, timeCont);
+ }
+ // CtrlC
+#ifndef _MSC_VER
+ // the CtrlC interception (Linux only I'm afraid)
+ eoCtrlCContinue *ctrlCCont;
+ eoValueParam& ctrlCParam = _parser.createParam(true, "CtrlC", "Terminate current generation upon Ctrl C",'C', "Stopping criterion");
+ if (_parser.isItThere(ctrlCParam))
+ {
+ ctrlCCont = new eoCtrlCContinue;
+ // store
+ _state.storeFunctor(ctrlCCont);
+ // add to combinedContinue
+ continuator = make_combinedContinue(continuator, ctrlCCont);
+ }
+#endif
+ // now check that there is at least one!
+ if (!continuator)
+ throw std::runtime_error("You MUST provide a stopping criterion");
+ // OK, it's there: store in the eoState
+ _state.storeFunctor(continuator);
+ // and return
+ return *continuator;
+}
+
+#endif /*MAKE_CONTINUE_MOEO_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/do/make_ea_moeo.h b/tags/paradiseo-moeo-0.3/src/do/make_ea_moeo.h
new file mode 100755
index 000000000..967f8fffb
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/do/make_ea_moeo.h
@@ -0,0 +1,263 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// make_ea_moeo.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MAKE_EA_MOEO_H_
+#define MAKE_EA_MOEO_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * This functions allows to build a moeoEA from the parser
+ * @param _parser the parser
+ * @param _state to store allocated objects
+ * @param _eval the funtions evaluator
+ * @param _continue the stopping crietria
+ * @param _op the variation operators
+ * @param _archive the archive of non-dominated solutions
+ */
+template < class MOEOT >
+moeoEA < MOEOT > & do_make_ea_moeo(eoParser & _parser, eoState & _state, eoEvalFunc < MOEOT > & _eval, eoContinue < MOEOT > & _continue, eoGenOp < MOEOT > & _op, moeoArchive < MOEOT > & _archive)
+{
+
+ /* the objective vector type */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /* the fitness assignment strategy */
+ string & fitnessParam = _parser.createParam(string("FastNonDominatedSorting"), "fitness",
+ "Fitness assignment scheme: Dummy, FastNonDominatedSorting or IndicatorBased", 'F',
+ "Evolution Engine").value();
+ string & indicatorParam = _parser.createParam(string("Epsilon"), "indicator",
+ "Binary indicator for IndicatorBased: Epsilon, Hypervolume", 'i',
+ "Evolution Engine").value();
+ double rho = _parser.createParam(1.1, "rho", "reference point for the hypervolume indicator", 'r',
+ "Evolution Engine").value();
+ double kappa = _parser.createParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased", 'k',
+ "Evolution Engine").value();
+ moeoFitnessAssignment < MOEOT > * fitnessAssignment;
+ if (fitnessParam == string("Dummy"))
+ {
+ fitnessAssignment = new moeoDummyFitnessAssignment < MOEOT> ();
+ }
+ else if (fitnessParam == string("FastNonDominatedSorting"))
+ {
+ fitnessAssignment = new moeoFastNonDominatedSortingFitnessAssignment < MOEOT> ();
+ }
+ else if (fitnessParam == string("IndicatorBased"))
+ {
+ // metric
+ moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
+ if (indicatorParam == string("Epsilon"))
+ {
+ metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
+ }
+ else if (indicatorParam == string("Hypervolume"))
+ {
+ metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
+ }
+ else
+ {
+ string stmp = string("Invalid binary quality indicator: ") + indicatorParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT > (*metric, kappa);
+ }
+ else
+ {
+ string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(fitnessAssignment);
+
+
+ /* the diversity assignment strategy */
+ eoValueParam & diversityParam = _parser.createParam(eoParamParamType("Dummy"), "diversity",
+ "Diversity assignment scheme: Dummy, Sharing(nicheSize) or Crowding", 'D', "Evolution Engine");
+ eoParamParamType & diversityParamValue = diversityParam.value();
+ moeoDiversityAssignment < MOEOT > * diversityAssignment;
+ if (diversityParamValue.first == string("Dummy"))
+ {
+ diversityAssignment = new moeoDummyDiversityAssignment < MOEOT> ();
+ }
+ else if (diversityParamValue.first == string("Sharing"))
+ {
+ double nicheSize;
+ if (!diversityParamValue.second.size()) // no parameter added
+ {
+ cerr << "WARNING, no niche size given for Sharing, using 0.5" << std::endl;
+ nicheSize = 0.5;
+ diversityParamValue.second.push_back(std::string("0.5"));
+ }
+ else
+ {
+ nicheSize = atoi(diversityParamValue.second[0].c_str());
+ }
+ diversityAssignment = new moeoFrontByFrontSharingDiversityAssignment < MOEOT> (nicheSize);
+ }
+ else if (diversityParamValue.first == string("Crowding"))
+ {
+ diversityAssignment = new moeoFrontByFrontCrowdingDistanceDiversityAssignment < MOEOT> ();
+ }
+ else
+ {
+ string stmp = string("Invalid diversity assignment strategy: ") + diversityParamValue.first;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(diversityAssignment);
+
+
+ /* the comparator strategy */
+ string & comparatorParam = _parser.createParam(string("FitnessThenDiversity"), "comparator",
+ "Comparator scheme: FitnessThenDiversity, DiversityThenFitness or Aggregative", 'C', "Evolution Engine").value();
+ moeoComparator < MOEOT > * comparator;
+ if (comparatorParam == string("FitnessThenDiversity"))
+ {
+ comparator = new moeoFitnessThenDiversityComparator < MOEOT> ();
+ }
+ else if (comparatorParam == string("DiversityThenFitness"))
+ {
+ comparator = new moeoDiversityThenFitnessComparator < MOEOT> ();
+ }
+ else if (comparatorParam == string("Aggregative"))
+ {
+ comparator = new moeoAggregativeComparator < MOEOT> ();
+ }
+ else
+ {
+ string stmp = string("Invalid comparator strategy: ") + comparatorParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(comparator);
+
+
+ /* the selection strategy */
+ eoValueParam < eoParamParamType > & selectionParam = _parser.createParam(eoParamParamType("DetTour(2)"), "selection",
+ "Selection scheme: DetTour(T), StochTour(t) or Random", 'S', "Evolution Engine");
+ eoParamParamType & ppSelect = selectionParam.value();
+ moeoSelectOne < MOEOT > * select;
+ if (ppSelect.first == string("DetTour"))
+ {
+ unsigned tSize;
+ if (!ppSelect.second.size()) // no parameter added
+ {
+ cerr << "WARNING, no parameter passed to DetTour, using 2" << endl;
+ tSize = 2;
+ // put back 2 in parameter for consistency (and status file)
+ ppSelect.second.push_back(string("2"));
+ }
+ else // parameter passed by user as DetTour(T)
+ {
+ tSize = atoi(ppSelect.second[0].c_str());
+ }
+ select = new moeoDetTournamentSelect < MOEOT > (*comparator, tSize);
+ }
+ else if (ppSelect.first == string("StochTour"))
+ {
+ double tRate;
+ if (!ppSelect.second.size()) // no parameter added
+ {
+ cerr << "WARNING, no parameter passed to StochTour, using 1" << endl;
+ tRate = 1;
+ // put back 1 in parameter for consistency (and status file)
+ ppSelect.second.push_back(string("1"));
+ }
+ else // parameter passed by user as StochTour(T)
+ {
+ tRate = atof(ppSelect.second[0].c_str());
+ }
+ select = new moeoStochTournamentSelect < MOEOT > (*comparator, tRate);
+ }
+ /*
+ else if (ppSelect.first == string("Roulette"))
+ {
+ // TO DO !
+ // ...
+ }
+ */
+ else if (ppSelect.first == string("Random"))
+ {
+ select = new moeoRandomSelect ();
+ }
+ else
+ {
+ string stmp = string("Invalid selection strategy: ") + ppSelect.first;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(select);
+
+
+ /* the replacement strategy */
+ string & replacementParam = _parser.createParam(string("Elitist"), "replacement",
+ "Replacement scheme: Elitist, Environmental or Generational", 'R', "Evolution Engine").value();
+ moeoReplacement < MOEOT > * replace;
+ if (replacementParam == string("Elitist"))
+ {
+ replace = new moeoElitistReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
+ }
+ else if (replacementParam == string("Environmental"))
+ {
+ replace = new moeoEnvironmentalReplacement < MOEOT> (*fitnessAssignment, *diversityAssignment, *comparator);
+ }
+ else if (replacementParam == string("Generational"))
+ {
+ replace = new moeoGenerationalReplacement < MOEOT> ();
+ }
+ else
+ {
+ string stmp = string("Invalid replacement strategy: ") + replacementParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(replace);
+
+
+ /* the number of offspring */
+ eoValueParam < eoHowMany > & offspringRateParam = _parser.createParam(eoHowMany(1.0), "nbOffspring",
+ "Number of offspring (percentage or absolute)", 'O', "Evolution Engine");
+
+
+ // the general breeder
+ eoGeneralBreeder < MOEOT > * breed = new eoGeneralBreeder < MOEOT > (*select, _op, offspringRateParam.value());
+ _state.storeFunctor(breed);
+ // the eoEasyEA
+ moeoEA < MOEOT > * algo = new moeoEasyEA < MOEOT > (_continue, _eval, *breed, *replace, *fitnessAssignment, *diversityAssignment);
+ _state.storeFunctor(algo);
+ return *algo;
+
+}
+
+#endif /*MAKE_EA_MOEO_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/do/make_ls_moeo.h b/tags/paradiseo-moeo-0.3/src/do/make_ls_moeo.h
new file mode 100755
index 000000000..680d76fb7
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/do/make_ls_moeo.h
@@ -0,0 +1,120 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// make_ls_moeo.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MAKE_LS_MOEO_H_
+#define MAKE_LS_MOEO_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * This functions allows to build a moeoLS from the parser
+ * @param _parser the parser
+ * @param _state to store allocated objects
+ * @param _eval the funtions evaluator
+ * @param _moveIncrEval the incremental evaluation
+ * @param _continue the stopping crietria
+ * @param _op the variation operators
+ * @param _opInit the initilization operator
+ * @param _moveInit the move initializer
+ * @param _nextMove the move incrementor
+ * @param _archive the archive of non-dominated solutions
+ */
+template < class MOEOT, class Move >
+moeoLS < MOEOT, eoPop & > & do_make_ls_moeo (
+ eoParser & _parser,
+ eoState & _state,
+ eoEvalFunc < MOEOT > & _eval,
+ moeoMoveIncrEval < Move > & _moveIncrEval,
+ eoContinue < MOEOT > & _continue,
+ eoMonOp < MOEOT > & _op,
+ eoMonOp < MOEOT > & _opInit,
+ moMoveInit < Move > & _moveInit,
+ moNextMove < Move > & _nextMove,
+ moeoArchive < MOEOT > & _archive
+)
+{
+ /* the objective vector type */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+ /* the fitness assignment strategy */
+ string & fitnessParam = _parser.getORcreateParam(string("IndicatorBased"), "fitness",
+ "Fitness assignment strategy parameter: IndicatorBased...", 'F',
+ "Evolution Engine").value();
+ string & indicatorParam = _parser.getORcreateParam(string("Epsilon"), "indicator",
+ "Binary indicator to use with the IndicatorBased assignment: Epsilon, Hypervolume", 'i',
+ "Evolution Engine").value();
+ double rho = _parser.getORcreateParam(1.1, "rho", "reference point for the hypervolume indicator",
+ 'r', "Evolution Engine").value();
+ double kappa = _parser.getORcreateParam(0.05, "kappa", "Scaling factor kappa for IndicatorBased",
+ 'k', "Evolution Engine").value();
+ moeoIndicatorBasedFitnessAssignment < MOEOT > * fitnessAssignment;
+ if (fitnessParam == string("IndicatorBased"))
+ {
+ // metric
+ moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > *metric;
+ if (indicatorParam == string("Epsilon"))
+ {
+ metric = new moeoAdditiveEpsilonBinaryMetric < ObjectiveVector >;
+ }
+ else if (indicatorParam == string("Hypervolume"))
+ {
+ metric = new moeoHypervolumeBinaryMetric < ObjectiveVector > (rho);
+ }
+ else
+ {
+ string stmp = string("Invalid binary quality indicator: ") + indicatorParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ fitnessAssignment = new moeoIndicatorBasedFitnessAssignment < MOEOT> (*metric, kappa);
+ }
+ else
+ {
+ string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(fitnessAssignment);
+ // number of iterations
+ unsigned n = _parser.getORcreateParam(1, "n", "Number of iterations for population Initialization", 'n', "Evolution Engine").value();
+ // LS
+ string & lsParam = _parser.getORcreateParam(string("I-IBMOLS"), "ls",
+ "Local Search: IBMOLS, I-IBMOLS (Iterated-IBMOLS)...", 'L',
+ "Evolution Engine").value();
+ moeoLS < MOEOT, eoPop & > * ls;
+ if (lsParam == string("IBMOLS"))
+ {
+ ls = new moeoIndicatorBasedLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue);;
+ }
+ else if (lsParam == string("I-IBMOLS"))
+ {
+ ls = new moeoIteratedIBMOLS < MOEOT, Move > (_moveInit, _nextMove, _eval, _moveIncrEval, *fitnessAssignment, _continue, _op, _opInit, n);
+ }
+ else
+ {
+ string stmp = string("Invalid fitness assignment strategy: ") + fitnessParam;
+ throw std::runtime_error(stmp.c_str());
+ }
+ _state.storeFunctor(ls);
+ // that's it !
+ return *ls;
+}
+
+#endif /*MAKE_LS_MOEO_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/metric/moeoBinaryMetricSavingUpdater.h b/tags/paradiseo-moeo-0.3/src/metric/moeoBinaryMetricSavingUpdater.h
new file mode 100644
index 000000000..b2fb8aa3a
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/metric/moeoBinaryMetricSavingUpdater.h
@@ -0,0 +1,88 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoBinaryMetricSavingUpdater.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOBINARYMETRICSAVINGUPDATER_H_
+#define MOEOBINARYMETRICSAVINGUPDATER_H_
+
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * This class allows to save the progression of a binary metric comparing the objective vectors of the current population (or archive)
+ * with the objective vectors of the population (or archive) of the generation (n-1) into a file
+ */
+template < class MOEOT >
+class moeoBinaryMetricSavingUpdater : public eoUpdater
+{
+public:
+
+ /**
+ * The objective vector type of a solution
+ */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+ /**
+ * Ctor
+ * @param _metric the binary metric comparing two Pareto sets
+ * @param _pop the main population
+ * @param _filename the target filename
+ */
+ moeoBinaryMetricSavingUpdater (moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & _metric, const eoPop < MOEOT > & _pop, std::string _filename) :
+ metric(_metric), pop(_pop), filename(_filename), counter(1)
+ {}
+
+ /**
+ * Saves the metric's value for the current generation
+ */
+ void operator()() {
+ if (pop.size()) {
+ if (firstGen) {
+ firstGen = false;
+ }
+ else {
+ // creation of the two Pareto sets
+ std::vector < ObjectiveVector > from;
+ std::vector < ObjectiveVector > to;
+ for (unsigned i=0; i & metric;
+ /** main population */
+ const eoPop < MOEOT > & pop;
+ /** (n-1) population */
+ eoPop< MOEOT > oldPop;
+ /** target filename */
+ std::string filename;
+ /** is it the first generation ? */
+ bool firstGen;
+ /** counter */
+ unsigned counter;
+
+};
+
+#endif /*MOEOBINARYMETRICSAVINGUPDATER_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/metric/moeoContributionMetric.h b/tags/paradiseo-moeo-0.3/src/metric/moeoContributionMetric.h
new file mode 100644
index 000000000..7e495ed4f
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/metric/moeoContributionMetric.h
@@ -0,0 +1,105 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoContributionMetric.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOCONTRIBUTIONMETRIC_H_
+#define MOEOCONTRIBUTIONMETRIC_H_
+
+#include
+#include
+
+/**
+ * The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set
+ * (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324)
+ */
+template < class ObjectiveVector >
+class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
+{
+public:
+
+ /**
+ * Returns the contribution of the Pareto set '_set1' relatively to the Pareto set '_set2'
+ * @param _set1 the first Pareto set
+ * @param _set2 the second Pareto set
+ */
+ double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
+ unsigned c = card_C(_set1, _set2);
+ unsigned w1 = card_W(_set1, _set2);
+ unsigned n1 = card_N(_set1, _set2);
+ unsigned w2 = card_W(_set2, _set1);
+ unsigned n2 = card_N(_set2, _set1);
+ return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
+ }
+
+
+private:
+
+ /** Functor to compare two objective vectors according to Pareto dominance relation */
+ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
+
+
+ /**
+ * Returns the number of solutions both in '_set1' and '_set2'
+ * @param _set1 the first Pareto set
+ * @param _set2 the second Pareto set
+ */
+ unsigned card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
+ unsigned c=0;
+ for (unsigned i=0; i<_set1.size(); i++)
+ for (unsigned j=0; j<_set2.size(); j++)
+ if (_set1[i] == _set2[j]) {
+ c++;
+ break;
+ }
+ return c;
+ }
+
+ /**
+ * Returns the number of solutions in '_set1' dominating at least one solution of '_set2'
+ * @param _set1 the first Pareto set
+ * @param _set2 the second Pareto set
+ */
+ unsigned card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
+ unsigned w=0;
+ for (unsigned i=0; i<_set1.size(); i++)
+ for (unsigned j=0; j<_set2.size(); j++)
+ if (paretoComparator(_set2[j], _set1[i]))
+ {
+ w++;
+ break;
+ }
+ return w;
+ }
+
+ /**
+ * Returns the number of solutions in '_set1' having no relation of dominance with those from '_set2'
+ * @param _set1 the first Pareto set
+ * @param _set2 the second Pareto set
+ */
+ unsigned card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
+ unsigned n=0;
+ for (unsigned i=0; i<_set1.size(); i++) {
+ bool domin_rel = false;
+ for (unsigned j=0; j<_set2.size(); j++)
+ if ( (paretoComparator(_set2[j], _set1[i])) || (paretoComparator(_set1[i], _set2[j])) )
+ {
+ domin_rel = true;
+ break;
+ }
+ if (! domin_rel)
+ n++;
+ }
+ return n;
+ }
+
+};
+
+#endif /*MOEOCONTRIBUTIONMETRIC_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/metric/moeoEntropyMetric.h b/tags/paradiseo-moeo-0.3/src/metric/moeoEntropyMetric.h
new file mode 100644
index 000000000..6c55a0518
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/metric/moeoEntropyMetric.h
@@ -0,0 +1,180 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoEntropyMetric.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOENTROPYMETRIC_H_
+#define MOEOENTROPYMETRIC_H_
+
+#include
+
+/**
+ * The entropy gives an idea of the diversity of a Pareto set relatively to another
+ * (Basseur, Seynhaeve, Talbi: 'Design of Multi-objective Evolutionary Algorithms: Application to the Flow-shop Scheduling Problem', in Proc. of the 2002 Congress on Evolutionary Computation, IEEE Press, pp. 1155-1156)
+ */
+template < class ObjectiveVector >
+class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
+{
+public:
+
+ /**
+ * Returns the entropy of the Pareto set '_set1' relatively to the Pareto set '_set2'
+ * @param _set1 the first Pareto set
+ * @param _set2 the second Pareto set
+ */
+ double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
+ // normalization
+ std::vector< ObjectiveVector > set1 = _set1;
+ std::vector< ObjectiveVector > set2= _set2;
+ removeDominated (set1);
+ removeDominated (set2);
+ prenormalize (set1);
+ normalize (set1);
+ normalize (set2);
+
+ // making of PO*
+ std::vector< ObjectiveVector > star; // rotf :-)
+ computeUnion (set1, set2, star);
+ removeDominated (star);
+
+ // making of PO1 U PO*
+ std::vector< ObjectiveVector > union_set1_star; // rotf again ...
+ computeUnion (set1, star, union_set1_star);
+
+ unsigned C = union_set1_star.size();
+ float omega=0;
+ float entropy=0;
+
+ for (unsigned i=0 ; i 0) {
+ omega += 1.0 / N_i;
+ entropy += (float) n_i / (N_i * C) * log (((float) n_i / C) / log (2.0));
+ }
+ }
+ entropy /= - log (omega);
+ entropy *= log (2.0);
+ return entropy;
+ }
+
+
+private:
+
+ /** vector of min values */
+ std::vector vect_min_val;
+ /** vector of max values */
+ std::vector vect_max_val;
+ /** Functor to compare two objective vectors according to Pareto dominance relation */
+ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
+
+
+ /**
+ * Removes the dominated individuals contained in _f
+ * @param _f a Pareto set
+ */
+ void removeDominated(std::vector < ObjectiveVector > & _f) {
+ for (unsigned i=0 ; i<_f.size(); i++) {
+ bool dom = false;
+ for (unsigned j=0; j<_f.size(); j++)
+ if (i != j && paretoComparator(_f[i],_f[j]))
+ {
+ dom = true;
+ break;
+ }
+ if (dom) {
+ _f[i] = _f.back();
+ _f.pop_back();
+ i--;
+ }
+ }
+ }
+
+
+ /**
+ * Prenormalization
+ * @param _f a Pareto set
+ */
+ void prenormalize (const std::vector< ObjectiveVector > & _f) {
+ vect_min_val.clear();
+ vect_max_val.clear();
+
+ for (unsigned char i=0 ; imax_val)
+ max_val = _f[j][i];
+ }
+ vect_min_val.push_back(min_val);
+ vect_max_val.push_back (max_val);
+ }
+ }
+
+
+ /**
+ * Normalization
+ * @param _f a Pareto set
+ */
+ void normalize (std::vector< ObjectiveVector > & _f) {
+ for (unsigned i=0 ; i & _f1, const std::vector< ObjectiveVector > & _f2, std::vector< ObjectiveVector > & _f) {
+ _f = _f1 ;
+ for (unsigned i=0; i<_f2.size(); i++) {
+ bool b = false;
+ for (unsigned j=0; j<_f1.size(); j ++)
+ if (_f1[j] == _f2[i]) {
+ b = true;
+ break;
+ }
+ if (! b)
+ _f.push_back(_f2[i]);
+ }
+ }
+
+
+ /**
+ * How many in niche
+ */
+ unsigned howManyInNicheOf (const std::vector< ObjectiveVector > & _f, const ObjectiveVector & _s, unsigned _size) {
+ unsigned n=0;
+ for (unsigned i=0 ; i<_f.size(); i++) {
+ if (euclidianDistance(_f[i], _s) < (_s.size() / (double) _size))
+ n++;
+ }
+ return n;
+ }
+
+
+ /**
+ * Euclidian distance
+ */
+ double euclidianDistance (const ObjectiveVector & _set1, const ObjectiveVector & _to, unsigned _deg = 2) {
+ double dist=0;
+ for (unsigned i=0; i<_set1.size(); i++)
+ dist += pow(fabs(_set1[i] - _to[i]), (int)_deg);
+ return pow(dist, 1.0 / _deg);
+ }
+
+};
+
+#endif /*MOEOENTROPYMETRIC_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/metric/moeoMetric.h b/tags/paradiseo-moeo-0.3/src/metric/moeoMetric.h
new file mode 100644
index 000000000..93917daef
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/metric/moeoMetric.h
@@ -0,0 +1,73 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoMetric.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOMETRIC_H_
+#define MOEOMETRIC_H_
+
+#include
+
+/**
+ * Base class for performance metrics (also known as quality indicators).
+ */
+class moeoMetric : public eoFunctorBase
+ {};
+
+
+/**
+ * Base class for unary metrics.
+ */
+template < class A, class R >
+class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric
+ {};
+
+
+/**
+ * Base class for binary metrics.
+ */
+template < class A1, class A2, class R >
+class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric
+ {};
+
+
+/**
+ * Base class for unary metrics dedicated to the performance evaluation of a single solution's objective vector.
+ */
+template < class ObjectiveVector, class R >
+class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjectiveVector &, R >
+ {};
+
+
+/**
+ * Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of objective vectors)
+ */
+template < class ObjectiveVector, class R >
+class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjectiveVector > &, R >
+ {};
+
+
+/**
+ * Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors.
+ */
+template < class ObjectiveVector, class R >
+class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjectiveVector &, const ObjectiveVector &, R >
+ {};
+
+
+/**
+ * Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of objective vectors)
+ */
+template < class ObjectiveVector, class R >
+class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const std::vector < ObjectiveVector > &, R >
+ {};
+
+
+#endif /*MOEOMETRIC_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h b/tags/paradiseo-moeo-0.3/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h
new file mode 100644
index 000000000..9fb4aef21
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h
@@ -0,0 +1,277 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoNormalizedSolutionVsSolutionBinaryMetric.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
+#define MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
+
+#include
+#include
+#include
+
+
+/**
+ * Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors using normalized values.
+ * Then, indicator values lie in the interval [-1,1].
+ * Note that you have to set the bounds for every objective before using the operator().
+ */
+template < class ObjectiveVector, class R >
+class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < ObjectiveVector, R >
+{
+public:
+
+ /**
+ * Default ctr for any moeoNormalizedSolutionVsSolutionBinaryMetric object
+ */
+ moeoNormalizedSolutionVsSolutionBinaryMetric()
+ {
+ bounds.resize(ObjectiveVector::Traits::nObjectives());
+ // initialize bounds in case someone does not want to use them
+ for (unsigned i=0; i bounds;
+
+};
+
+
+/**
+ * Additive epsilon binary metric allowing to compare two objective vectors as proposed in
+ * Zitzler E., Thiele L., Laumanns M., Fonseca C. M., Grunert da Fonseca V.:
+ * Performance Assessment of Multiobjective Optimizers: An Analysis and Review. IEEE Transactions on Evolutionary Computation 7(2), pp.117–132 (2003).
+ */
+template < class ObjectiveVector >
+class moeoAdditiveEpsilonBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
+{
+public:
+
+ /**
+ * Returns the minimal distance by which the objective vector _o1 must be translated in all objectives
+ * so that it weakly dominates the objective vector _o2
+ * @warning don't forget to set the bounds for every objective before the call of this function
+ * @param _o1 the first objective vector
+ * @param _o2 the second objective vector
+ */
+ double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
+ {
+ // computation of the epsilon value for the first objective
+ double result = epsilon(_o1, _o2, 0);
+ // computation of the epsilon value for the other objectives
+ double tmp;
+ for (unsigned i=1; i :: bounds;
+
+
+ /**
+ * Returns the epsilon value by which the objective vector _o1 must be translated in the objective _obj
+ * so that it dominates the objective vector _o2
+ * @param _o1 the first objective vector
+ * @param _o2 the second objective vector
+ * @param _obj the index of the objective
+ */
+ double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned _obj)
+ {
+ double result;
+ // if the objective _obj have to be minimized
+ if (ObjectiveVector::Traits::minimizing(_obj))
+ {
+ // _o1[_obj] - _o2[_obj]
+ result = ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
+ }
+ // if the objective _obj have to be maximized
+ else
+ {
+ // _o2[_obj] - _o1[_obj]
+ result = ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
+ }
+ return result;
+ }
+
+};
+
+
+/**
+ * Hypervolume binary metric allowing to compare two objective vectors as proposed in
+ * Zitzler E., Künzli S.: Indicator-Based Selection in Multiobjective Search. In Parallel Problem Solving from Nature (PPSN VIII).
+ * Lecture Notes in Computer Science 3242, Springer, Birmingham, UK pp.832–842 (2004).
+ * This indicator is based on the hypervolume concept introduced in
+ * Zitzler, E., Thiele, L.: Multiobjective Optimization Using Evolutionary Algorithms - A Comparative Case Study.
+ * Parallel Problem Solving from Nature (PPSN-V), pp.292-301 (1998).
+ */
+template < class ObjectiveVector >
+class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
+{
+public:
+
+ /**
+ * Ctor
+ * @param _rho value used to compute the reference point from the worst values for each objective (default : 1.1)
+ */
+ moeoHypervolumeBinaryMetric(double _rho = 1.1) : rho(_rho)
+ {
+ // not-a-maximization problem check
+ for (unsigned i=0; i :: bounds;
+ /** Functor to compare two objective vectors according to Pareto dominance relation */
+ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
+
+ /**
+ * Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho for the objective _obj.
+ * @param _o1 the first objective vector
+ * @param _o2 the second objective vector
+ * @param _obj the objective index
+ * @param _flag used for iteration, if _flag=true _o2 is not talen into account (default : false)
+ */
+ double hypervolume(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned _obj, const bool _flag = false)
+ {
+ double result;
+ double range = rho * bounds[_obj].range();
+ double max = bounds[_obj].minimum() + range;
+ // value of _1 for the objective _obj
+ double v1 = _o1[_obj];
+ // value of _2 for the objective _obj (if _flag=true, v2=max)
+ double v2;
+ if (_flag)
+ {
+ v2 = max;
+ }
+ else
+ {
+ v2 = _o2[_obj];
+ }
+ // computation of the volume
+ if (_obj == 0)
+ {
+ if (v1 < v2)
+ {
+ result = (v2 - v1) / range;
+ }
+ else
+ {
+ result = 0;
+ }
+ }
+ else
+ {
+ if (v1 < v2)
+ {
+ result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range );
+ }
+ else
+ {
+ result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range;
+ }
+ }
+ return result;
+ }
+
+};
+
+
+#endif /*MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeo b/tags/paradiseo-moeo-0.3/src/moeo
new file mode 100644
index 000000000..a86933dee
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeo
@@ -0,0 +1,67 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeo
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEO_
+#define MOEO_
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+//#include
+//#include
+#include
+//#include
+#include
+#include
+#include
+#include
+#include
+//#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#endif /*MOEO_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoAchievementFitnessAssignment.h b/tags/paradiseo-moeo-0.3/src/moeoAchievementFitnessAssignment.h
new file mode 100644
index 000000000..ae3a0567a
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoAchievementFitnessAssignment.h
@@ -0,0 +1,144 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoAchievementFitnessAssignment.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOACHIEVEMENTFITNESSASSIGNMENT_H_
+#define MOEOACHIEVEMENTFITNESSASSIGNMENT_H_
+
+#include
+#include
+
+/**
+ * Fitness assignment sheme based on the achievement scalarizing function propozed by Wiersbicki (1980).
+ */
+template < class MOEOT >
+class moeoAchievementFitnessAssignment : public moeoScalarFitnessAssignment < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Default ctor
+ * @param _reference reference point vector
+ * @param _lambdas weighted coefficients vector
+ * @param _spn arbitrary small positive number (0 < _spn << 1)
+ */
+ moeoAchievementFitnessAssignment(ObjectiveVector & _reference, vector < double > & _lambdas, double _spn=0.0001) : reference(_reference), lambdas(_lambdas), spn(_spn)
+ {
+ // consistency check
+ if ((spn < 0.0) || (spn > 1.0))
+ {
+ std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
+ spn = 0.0001;
+ }
+ }
+
+
+ /**
+ * Ctor with default values for lambdas (1/nObjectives)
+ * @param _reference reference point vector
+ * @param _spn arbitrary small positive number (0 < _spn << 1)
+ */
+ moeoAchievementFitnessAssignment(ObjectiveVector & _reference, double _spn=0.0001) : reference(_reference), spn(_spn)
+ {
+ // compute the default values for lambdas
+ lambdas = vector < double > (ObjectiveVector::nObjectives());
+ for (unsigned i=0 ; i 1.0))
+ {
+ std::cout << "Warning, the arbitrary small positive number should be > 0 and <<1, adjusted to 0.0001\n";
+ spn = 0.0001;
+ }
+ }
+
+
+ /**
+ * Sets the fitness values for every solution contained in the population _pop
+ * @param _pop the population
+ */
+ virtual void operator()(eoPop < MOEOT > & _pop)
+ {
+ for (unsigned i=0; i<_pop.size() ; i++)
+ {
+ compute(_pop[i]);
+ }
+ }
+
+
+ /**
+ * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account (nothing to do).
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ // nothing to do ;-)
+ }
+
+
+ /**
+ * Sets the reference point
+ * @param _reference the new reference point
+ */
+ void setReference(const ObjectiveVector & _reference)
+ {
+ reference = _reference;
+ }
+
+
+private:
+
+ /** the reference point */
+ ObjectiveVector reference;
+ /** the weighted coefficients vector */
+ vector < double > lambdas;
+ /** an arbitrary small positive number (0 < _spn << 1) */
+ double spn;
+
+
+ /**
+ * Returns a big value (regarded as infinite)
+ */
+ double inf() const
+ {
+ return std::numeric_limits::max();
+ }
+
+
+ /**
+ * Computes the fitness value for a solution
+ * @param _moeo the solution
+ */
+ void compute(MOEOT & _moeo)
+ {
+ unsigned nobj = MOEOT::ObjectiveVector::nObjectives();
+ double temp;
+ double min = inf();
+ double sum = 0;
+ for (unsigned obj=0; obj
+#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_ */
diff --git a/tags/paradiseo-moeo-0.3/src/moeoArchiveObjectiveVectorSavingUpdater.h b/tags/paradiseo-moeo-0.3/src/moeoArchiveObjectiveVectorSavingUpdater.h
new file mode 100644
index 000000000..ba2413bac
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoArchiveObjectiveVectorSavingUpdater.h
@@ -0,0 +1,93 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoArchiveObjectiveVectorSavingUpdater.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOARCHIVEOBJECTIVEVECTORSAVINGUPDATER_H_
+#define MOEOARCHIVEOBJECTIVEVECTORSAVINGUPDATER_H_
+
+#include
+#include
+#include
+#include
+#include
+
+#define MAX_BUFFER_SIZE 1000
+
+/**
+ * This class allows to save the objective vectors of the solutions contained in an archive into a file at each generation.
+ */
+template < class MOEOT >
+class moeoArchiveObjectiveVectorSavingUpdater : public eoUpdater
+{
+public:
+
+ /**
+ * Ctor
+ * @param _arch local archive
+ * @param _filename target filename
+ * @param _count put this variable to true if you want a new file to be created each time () is called and to false if you only want the file to be updated
+ * @param _id own ID
+ */
+ moeoArchiveObjectiveVectorSavingUpdater (moeoArchive & _arch, const std::string & _filename, bool _count = false, int _id = -1) :
+ arch(_arch), filename(_filename), count(_count), counter(0), id(_id)
+ {}
+
+ /**
+ * Saves the fitness of the archive's members into the file
+ */
+ void operator()() {
+ char buff[MAX_BUFFER_SIZE];
+ if (count)
+ {
+ if (id == -1)
+ {
+ sprintf (buff, "%s.%u", filename.c_str(), counter ++);
+ }
+ else
+ {
+ sprintf (buff, "%s.%u.%u", filename.c_str(), id, counter ++);
+ }
+ }
+ else
+ {
+ if (id == -1)
+ {
+ sprintf (buff, "%s", filename.c_str());
+ }
+ else
+ {
+ sprintf (buff, "%s.%u", filename.c_str(), id);
+ }
+ counter ++;
+ }
+ std::ofstream f(buff);
+ for (unsigned i = 0; i < arch.size (); i++)
+ f << arch[i].objectiveVector() << std::endl;
+ f.close ();
+ }
+
+
+private:
+
+ /** local archive */
+ moeoArchive & arch;
+ /** target filename */
+ std::string filename;
+ /** this variable is set to true if a new file have to be created each time () is called and to false if the file only HAVE to be updated */
+ bool count;
+ /** counter */
+ unsigned counter;
+ /** own ID */
+ int id;
+
+};
+
+#endif /*MOEOARCHIVEOBJECTIVEVECTORSAVINGUPDATER_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoArchiveUpdater.h b/tags/paradiseo-moeo-0.3/src/moeoArchiveUpdater.h
new file mode 100644
index 000000000..73fbdc687
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoArchiveUpdater.h
@@ -0,0 +1,54 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoArchiveUpdater.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOARCHIVEUPDATER_H_
+#define MOEOARCHIVEUPDATER_H_
+
+#include
+#include
+#include
+
+/**
+ * This class allows to update the archive at each generation with newly found non-dominated solutions.
+ */
+template < class MOEOT >
+class moeoArchiveUpdater : public eoUpdater
+{
+public:
+
+ /**
+ * Ctor
+ * @param _arch an archive of non-dominated solutions
+ * @param _pop the main population
+ */
+ moeoArchiveUpdater(moeoArchive < MOEOT > & _arch, const eoPop < MOEOT > & _pop) : arch(_arch), pop(_pop)
+ {}
+
+
+ /**
+ * Updates the archive with newly found non-dominated solutions contained in the main population
+ */
+ void operator()() {
+ arch.update(pop);
+ }
+
+
+private:
+
+ /** the archive of non-dominated solutions */
+ moeoArchive < MOEOT > & arch;
+ /** the main population */
+ const eoPop < MOEOT > & pop;
+
+};
+
+#endif /*MOEOARCHIVEUPDATER_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoCombinedLS.h b/tags/paradiseo-moeo-0.3/src/moeoCombinedLS.h
new file mode 100644
index 000000000..98727f700
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoCombinedLS.h
@@ -0,0 +1,66 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoCombinedLS.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOCOMBINEDLS_H_
+#define MOEOCOMBINEDLS_H_
+
+#include
+#include
+
+/**
+ * This class allows to embed a set of local searches that are sequentially applied,
+ * and so working and updating the same archive of non-dominated solutions.
+ */
+template < class MOEOT, class Type >
+class moeoCombinedLS : public moeoLS < MOEOT, Type >
+{
+public:
+
+ /**
+ * Ctor
+ * @param _first_mols the first multi-objective local search to add
+ */
+ moeoCombinedLS(moeoLS < MOEOT, Type > & _first_mols)
+ {
+ combinedLS.push_back (& _first_mols);
+ }
+
+ /**
+ * Adds a new local search to combine
+ * @param _mols the multi-objective local search to add
+ */
+ void add(moeoLS < MOEOT, Type > & _mols)
+ {
+ combinedLS.push_back(& _mols);
+ }
+
+ /**
+ * Gives a new solution in order to explore the neigborhood.
+ * The new non-dominated solutions are added to the archive
+ * @param _type the object to apply the local search to
+ * @param _arch the archive of non-dominated solutions
+ */
+ void operator () (Type _type, moeoArchive < MOEOT > & _arch)
+ {
+ for (unsigned i=0; i operator()(_type, _arch);
+ }
+
+
+private:
+
+ /** the vector that contains the combined LS */
+ std::vector< moeoLS < MOEOT, Type > * > combinedLS;
+
+};
+
+#endif /*MOEOCOMBINEDLS_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoComparator.h b/tags/paradiseo-moeo-0.3/src/moeoComparator.h
new file mode 100644
index 000000000..75b777062
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoComparator.h
@@ -0,0 +1,182 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoComparator.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOCOMPARATOR_H_
+#define MOEOCOMPARATOR_H_
+
+#include
+
+/**
+ * Functor allowing to compare two solutions.
+ */
+template < class MOEOT >
+class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool >
+ {};
+
+
+/**
+ * Functor allowing to compare two solutions according to their first objective value, then their second, and so on.
+ */
+template < class MOEOT >
+class moeoObjectiveComparator : public moeoComparator < MOEOT >
+{
+public:
+
+ /**
+ * Returns true if _moeo1 < _moeo2 on the first objective, then on the second, and so on
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ return cmp(_moeo1.objectiveVector(), _moeo2.objectiveVector());
+ }
+
+private:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+ /** the corresponding comparator for objective vectors */
+ moeoObjectiveObjectiveVectorComparator < ObjectiveVector > cmp;
+
+};
+
+
+/**
+ * Functor allowing to compare two solutions according to one objective.
+ */
+template < class MOEOT >
+class moeoOneObjectiveComparator : public moeoComparator < MOEOT >
+{
+public:
+
+ /**
+ * Ctor.
+ * @param _obj the index of objective
+ */
+ moeoOneObjectiveComparator(unsigned _obj) : obj(_obj)
+ {
+ if (obj > MOEOT::ObjectiveVector::nObjectives())
+ {
+ throw std::runtime_error("Problem with the index of objective in moeoOneObjectiveComparator");
+ }
+ }
+
+ /**
+ * Returns true if _moeo1 < _moeo2 on the obj objective
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj];
+ }
+
+private:
+ /** the index of objective */
+ unsigned obj;
+
+};
+
+
+/**
+ * Functor allowing to compare two solutions according to their fitness values, then according to their diversity values.
+ */
+template < class MOEOT >
+class moeoFitnessThenDiversityComparator : public moeoComparator < MOEOT >
+{
+public:
+
+ /**
+ * Returns true if _moeo1 < _moeo2 according to their fitness values, then according to their diversity values
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ if (_moeo1.fitness() == _moeo2.fitness())
+ {
+ return _moeo1.diversity() < _moeo2.diversity();
+ }
+ else
+ {
+ return _moeo1.fitness() < _moeo2.fitness();
+ }
+ }
+
+};
+
+
+/**
+ * Functor allowing to compare two solutions according to their diversity values, then according to their fitness values.
+ */
+template < class MOEOT >
+class moeoDiversityThenFitnessComparator : public moeoComparator < MOEOT >
+{
+public:
+
+ /**
+ * Returns true if _moeo1 < _moeo2 according to their diversity values, then according to their fitness values
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ if (_moeo1.diversity() == _moeo2.diversity())
+ {
+ return _moeo1.fitness() < _moeo2.fitness();
+ }
+ else
+ {
+ return _moeo1.diversity() < _moeo2.diversity();
+ }
+ }
+
+};
+
+
+/**
+ * Functor allowing to compare two solutions according to their fitness and diversity values, each according to its aggregative value.
+ */
+template < class MOEOT >
+class moeoAggregativeComparator : public moeoComparator < MOEOT >
+{
+public:
+
+ /**
+ * Ctor.
+ * @param _weightFitness the weight for fitness
+ * @param _weightDiversity the weight for diversity
+ */
+ moeoAggregativeComparator(double _weightFitness = 1.0, double _weightDiversity = 1.0) : weightFitness(_weightFitness), weightDiversity(_weightDiversity)
+ {}
+
+ /**
+ * Returns true if _moeo1 < _moeo2 according to the aggregation of their fitness and diversity values
+ * @param _moeo1 the first solution
+ * @param _moeo2 the second solution
+ */
+ const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() );
+ }
+
+private:
+ /** the weight for fitness */
+ double weightFitness;
+ /** the weight for diversity */
+ double weightDiversity;
+
+};
+
+
+#endif /*MOEOCOMPARATOR_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoConvertPopToObjectiveVectors.h b/tags/paradiseo-moeo-0.3/src/moeoConvertPopToObjectiveVectors.h
new file mode 100644
index 000000000..8afca7a7b
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoConvertPopToObjectiveVectors.h
@@ -0,0 +1,42 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoConvertPopToObjectiveVectors.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOPOPTOOBJECTIVEVECTORS_H_
+#define MOEOPOPTOOBJECTIVEVECTORS_H_
+
+#include
+
+/**
+ * Functor allowing to get a vector of objective vectors from a population
+ */
+template < class MOEOT, class ObjectiveVector = typename MOEOT::ObjectiveVector >
+class moeoConvertPopToObjectiveVectors : public eoUF < const eoPop < MOEOT >, const std::vector < ObjectiveVector > >
+{
+public:
+
+ /**
+ * Returns a vector of the objective vectors from the population _pop
+ * @param _pop the population
+ */
+ const std::vector < ObjectiveVector > operator()(const eoPop < MOEOT > _pop)
+ {
+ std::vector < ObjectiveVector > result;
+ result.resize(_pop.size());
+ for (unsigned i=0; i<_pop.size(); i++)
+ {
+ result.push_back(_pop[i].objectiveVector());
+ }
+ return result;
+ }
+};
+
+#endif /*MOEOPOPTOOBJECTIVEVECTORS_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoCrowdingDistanceDiversityAssignment.h b/tags/paradiseo-moeo-0.3/src/moeoCrowdingDistanceDiversityAssignment.h
new file mode 100755
index 000000000..493c4fe6e
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoCrowdingDistanceDiversityAssignment.h
@@ -0,0 +1,238 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoCrowdingDistanceDiversityAssignment.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOCROWDINGDISTANCEDIVERSITYASSIGNMENT_H_
+#define MOEOCROWDINGDISTANCEDIVERSITYASSIGNMENT_H_
+
+#include
+#include
+#include
+
+/**
+ * Diversity assignment sheme based on crowding distance proposed in:
+ * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
+ */
+template < class MOEOT >
+class moeoCrowdingDistanceDiversityAssignment : public moeoDiversityAssignment < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Returns a big value (regarded as infinite)
+ */
+ double inf() const
+ {
+ return std::numeric_limits::max();
+ }
+
+
+ /**
+ * Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound)
+ */
+ double tiny() const
+ {
+ return 1e-6;
+ }
+
+
+ /**
+ * Computes diversity values for every solution contained in the population _pop
+ * @param _pop the population
+ */
+ void operator()(eoPop < MOEOT > & _pop)
+ {
+ if (_pop.size() <= 2)
+ {
+ for (unsigned i=0; i<_pop.size(); i++)
+ {
+ _pop[i].diversity(inf());
+ }
+ }
+ else
+ {
+ setDistances(_pop);
+ }
+ }
+
+
+ /**
+ * @warning NOT IMPLEMENTED, DO NOTHING !
+ * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ * @warning NOT IMPLEMENTED, DO NOTHING !
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ cout << "WARNING : updateByDeleting not implemented in moeoCrowdingDiversityAssignment" << endl;
+ }
+
+
+protected:
+
+ /**
+ * Sets the distance values
+ * @param _pop the population
+ */
+ virtual void setDistances (eoPop < MOEOT > & _pop)
+ {
+ double min, max, distance;
+ unsigned nObjectives = MOEOT::ObjectiveVector::nObjectives();
+ // set diversity to 0
+ for (unsigned i=0; i<_pop.size(); i++)
+ {
+ _pop[i].diversity(0);
+ }
+ // for each objective
+ for (unsigned obj=0; obj comp(obj);
+ // sort
+ std::sort(_pop.begin(), _pop.end(), comp);
+ // min & max
+ min = _pop[0].objectiveVector()[obj];
+ max = _pop[_pop.size()-1].objectiveVector()[obj];
+ // set the diversity value to infiny for min and max
+ _pop[0].diversity(inf());
+ _pop[_pop.size()-1].diversity(inf());
+ for (unsigned i=1; i<_pop.size()-1; i++)
+ {
+ distance = (_pop[i+1].objectiveVector()[obj] - _pop[i-1].objectiveVector()[obj]) / (max-min);
+ _pop[i].diversity(_pop[i].diversity() + distance);
+ }
+ }
+ }
+
+};
+
+
+/**
+ * Diversity assignment sheme based on crowding distance proposed in:
+ * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
+ * Tis strategy assigns diversity values FRONT BY FRONT. It is, for instance, used in NSGA-II.
+ */
+template < class MOEOT >
+class moeoFrontByFrontCrowdingDistanceDiversityAssignment : public moeoCrowdingDistanceDiversityAssignment < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * @warning NOT IMPLEMENTED, DO NOTHING !
+ * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ * @warning NOT IMPLEMENTED, DO NOTHING !
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ cout << "WARNING : updateByDeleting not implemented in moeoFrontByFrontCrowdingDistanceDiversityAssignment" << endl;
+ }
+
+
+private:
+
+ using moeoCrowdingDistanceDiversityAssignment < MOEOT >::inf;
+ using moeoCrowdingDistanceDiversityAssignment < MOEOT >::tiny;
+
+
+ /**
+ * Sets the distance values
+ * @param _pop the population
+ */
+ void setDistances (eoPop < MOEOT > & _pop)
+ {
+ unsigned a,b;
+ double min, max, distance;
+ unsigned nObjectives = MOEOT::ObjectiveVector::nObjectives();
+ // set diversity to 0 for every individual
+ for (unsigned i=0; i<_pop.size(); i++)
+ {
+ _pop[i].diversity(0.0);
+ }
+ // sort the whole pop according to fitness values
+ moeoFitnessThenDiversityComparator < MOEOT > fitnessComparator;
+ std::sort(_pop.begin(), _pop.end(), fitnessComparator);
+ // compute the crowding distance values for every individual "front" by "front" (front : from a to b)
+ a = 0; // the front starts at a
+ while (a < _pop.size())
+ {
+ b = lastIndex(_pop,a); // the front ends at b
+ // if there is less than 2 individuals in the front...
+ if ((b-a) < 2)
+ {
+ for (unsigned i=a; i<=b; i++)
+ {
+ _pop[i].diversity(inf());
+ }
+ }
+ // else...
+ else
+ {
+ // for each objective
+ for (unsigned obj=0; obj objComp(obj);
+ std::sort(_pop.begin()+a, _pop.begin()+b+1, objComp);
+ // min & max
+ min = _pop[b].objectiveVector()[obj];
+ max = _pop[a].objectiveVector()[obj];
+ // avoid extreme case
+ if (min == max)
+ {
+ min -= tiny();
+ max += tiny();
+ }
+ // set the diversity value to infiny for min and max
+ _pop[a].diversity(inf());
+ _pop[b].diversity(inf());
+ // set the diversity values for the other individuals
+ for (unsigned i=a+1; i & _pop, unsigned _start)
+ {
+ unsigned i=_start;
+ while ( (i<_pop.size()-1) && (_pop[i].fitness()==_pop[i+1].fitness()) )
+ {
+ i++;
+ }
+ return i;
+ }
+
+};
+
+#endif /*MOEOCROWDINGDISTANCEDIVERSITYASSIGNMENT_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoDetTournamentSelect.h b/tags/paradiseo-moeo-0.3/src/moeoDetTournamentSelect.h
new file mode 100644
index 000000000..6c9266b6f
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoDetTournamentSelect.h
@@ -0,0 +1,82 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoDetTournamentSelect.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEODETTOURNAMENTSELECT_H_
+#define MOEODETTOURNAMENTSELECT_H_
+
+#include
+#include
+#include
+
+/**
+ * Selection strategy that selects ONE individual by deterministic tournament.
+ */
+template < class MOEOT > class moeoDetTournamentSelect:public moeoSelectOne < MOEOT >
+{
+public:
+
+ /**
+ * Full Ctor.
+ * @param _comparator the comparator (used to compare 2 individuals)
+ * @param _tSize the number of individuals in the tournament (default: 2)
+ */
+ moeoDetTournamentSelect (moeoComparator < MOEOT > & _comparator, unsigned _tSize = 2) : comparator (_comparator), tSize (_tSize)
+ {
+ // consistency check
+ if (tSize < 2)
+ {
+ std::
+ cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
+ tSize = 2;
+ }
+ }
+
+
+ /**
+ * Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default.
+ * @param _tSize the number of individuals in the tournament (default: 2)
+ */
+ moeoDetTournamentSelect (unsigned _tSize = 2) : comparator (defaultComparator), tSize (_tSize)
+ {
+ // consistency check
+ if (tSize < 2)
+ {
+ std::
+ cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
+ tSize = 2;
+ }
+ }
+
+
+ /**
+ * Apply the tournament to the given population
+ * @param _pop the population
+ */
+ const MOEOT & operator() (const eoPop < MOEOT > &_pop)
+ {
+ // use the selector
+ return mo_deterministic_tournament (_pop, tSize, comparator);
+ }
+
+
+protected:
+
+ /** the comparator (used to compare 2 individuals) */
+ moeoComparator < MOEOT > & comparator;
+ /** a fitness then diversity comparator can be used as default */
+ moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
+ /** the number of individuals in the tournament */
+ unsigned tSize;
+
+};
+
+#endif /*MOEODETTOURNAMENTSELECT_H_ */
diff --git a/tags/paradiseo-moeo-0.3/src/moeoDiversityAssignment.h b/tags/paradiseo-moeo-0.3/src/moeoDiversityAssignment.h
new file mode 100644
index 000000000..66e50dd38
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoDiversityAssignment.h
@@ -0,0 +1,93 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoDiversityAssignment.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEODIVERSITYASSIGNMENT_H_
+#define MOEODIVERSITYASSIGNMENT_H_
+
+#include
+#include
+
+/**
+ * Functor that sets the diversity values of a whole population.
+ */
+template < class MOEOT >
+class moeoDiversityAssignment : public eoUF < eoPop < MOEOT > &, void >
+{
+public:
+
+ /** The type for objective vector */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ virtual void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
+
+
+ /**
+ * Updates the diversity values of the whole population _pop by taking the deletion of the individual _moeo into account.
+ * @param _pop the population
+ * @param _moeo the individual
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, MOEOT & _moeo)
+ {
+ updateByDeleting(_pop, _moeo.objectiveVector());
+ }
+
+};
+
+
+/**
+ * moeoDummyDiversityAssignment is a moeoDiversityAssignment that gives the value '0' as the individual's diversity for a whole population if it is invalid.
+ */
+template < class MOEOT >
+class moeoDummyDiversityAssignment : public moeoDiversityAssignment < MOEOT >
+{
+public:
+
+ /** The type for objective vector */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Sets the diversity to '0' for every individuals of the population _pop if it is invalid
+ * @param _pop the population
+ */
+ void operator () (eoPop < MOEOT > & _pop)
+ {
+ for (unsigned idx = 0; idx<_pop.size (); idx++)
+ {
+ if (_pop[idx].invalidDiversity())
+ {
+ // set the diversity to 0
+ _pop[idx].diversity(0.0);
+ }
+ }
+ }
+
+
+ /**
+ * Updates the diversity values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ // nothing to do... ;-)
+ }
+
+};
+
+#endif /*MOEODIVERSITYASSIGNMENT_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoEA.h b/tags/paradiseo-moeo-0.3/src/moeoEA.h
new file mode 100644
index 000000000..36d115ead
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoEA.h
@@ -0,0 +1,26 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoEA.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOEA_H_
+#define MOEOEA_H_
+
+#include
+#include
+
+/**
+ * Abstract class for multi-objective evolutionary algorithms.
+ */
+template < class MOEOT >
+class moeoEA : public moeoAlgo, public eoAlgo < MOEOT > {};
+
+
+#endif /*MOEOEA_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoEasyEA.h b/tags/paradiseo-moeo-0.3/src/moeoEasyEA.h
new file mode 100755
index 000000000..35fea9598
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoEasyEA.h
@@ -0,0 +1,218 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoEasyEA.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef _MOEOEASYEA_H
+#define _MOEOEASYEA_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+/**
+ * An easy class to design multi-objective evolutionary algorithms.
+ */
+template < class MOEOT >
+class moeoEasyEA: public moeoEA < MOEOT >
+{
+public:
+
+ /**
+ * Ctor taking a breed and merge.
+ * @param _continuator the stopping criteria
+ * @param _eval the evaluation functions
+ * @param _breed the breeder
+ * @param _replace the replacement strategy
+ * @param _fitnessEval the fitness evaluation scheme
+ * @param _diversityEval the diversity evaluation scheme
+ * @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
+ */
+ moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoBreed < MOEOT > & _breed, moeoReplacement < MOEOT > & _replace,
+ moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false)
+ :
+ continuator(_continuator), eval (_eval), loopEval(_eval), popEval(loopEval), selectTransform(dummySelect, dummyTransform), breed(_breed), mergeReduce(dummyMerge, dummyReduce), replace(_replace),
+ fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
+ {}
+
+
+ /**
+ * Ctor taking a breed, a merge and a eoPopEval.
+ * @param _continuator the stopping criteria
+ * @param _popEval the evaluation functions for the whole population
+ * @param _breed the breeder
+ * @param _replace the replacement strategy
+ * @param _fitnessEval the fitness evaluation scheme
+ * @param _diversityEval the diversity evaluation scheme
+ * @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
+ */
+ moeoEasyEA(eoContinue < MOEOT > & _continuator, eoPopEvalFunc < MOEOT > & _popEval, eoBreed < MOEOT > & _breed, moeoReplacement < MOEOT > & _replace,
+ moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false)
+ :
+ continuator(_continuator), eval (dummyEval), loopEval(dummyEval), popEval(_popEval), selectTransform(dummySelect, dummyTransform), breed(_breed), mergeReduce(dummyMerge, dummyReduce), replace(_replace),
+ fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
+ {}
+
+
+ /**
+ * Ctor taking a breed, a merge and a reduce.
+ * @param _continuator the stopping criteria
+ * @param _eval the evaluation functions
+ * @param _breed the breeder
+ * @param _merge the merge scheme
+ * @param _reduce the reduce scheme
+ * @param _fitnessEval the fitness evaluation scheme
+ * @param _diversityEval the diversity evaluation scheme
+ * @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
+ */
+ moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoBreed < MOEOT > & _breed, eoMerge < MOEOT > & _merge, eoReduce< MOEOT > & _reduce,
+ moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false)
+ :
+ continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), selectTransform(dummySelect, dummyTransform), breed(_breed), mergeReduce(_merge,_reduce), replace(mergeReduce),
+ fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
+ {}
+
+
+ /**
+ * Ctor taking a select, a transform and a replacement.
+ * @param _continuator the stopping criteria
+ * @param _eval the evaluation functions
+ * @param _select the selection scheme
+ * @param _transform the tranformation scheme
+ * @param _replace the replacement strategy
+ * @param _fitnessEval the fitness evaluation scheme
+ * @param _diversityEval the diversity evaluation scheme
+ * @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
+ */
+ moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoSelect < MOEOT > & _select, eoTransform < MOEOT > & _transform, moeoReplacement < MOEOT > & _replace,
+ moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false)
+ :
+ continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), selectTransform(_select, _transform), breed(selectTransform), mergeReduce(dummyMerge, dummyReduce), replace(_replace),
+ fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
+ {}
+
+
+ /**
+ * Ctor taking a select, a transform, a merge and a reduce.
+ * @param _continuator the stopping criteria
+ * @param _eval the evaluation functions
+ * @param _select the selection scheme
+ * @param _transform the tranformation scheme
+ * @param _merge the merge scheme
+ * @param _reduce the reduce scheme
+ * @param _fitnessEval the fitness evaluation scheme
+ * @param _diversityEval the diversity evaluation scheme
+ * @param _evalFitAndDivBeforeSelection put this parameter to 'true' if you want to re-evalue the fitness and the diversity of the population before the selection process
+ */
+ moeoEasyEA(eoContinue < MOEOT > & _continuator, eoEvalFunc < MOEOT > & _eval, eoSelect < MOEOT > & _select, eoTransform < MOEOT > & _transform, eoMerge < MOEOT > & _merge, eoReduce< MOEOT > & _reduce,
+ moeoFitnessAssignment < MOEOT > & _fitnessEval, moeoDiversityAssignment < MOEOT > & _diversityEval, bool _evalFitAndDivBeforeSelection = false)
+ :
+ continuator(_continuator), eval(_eval), loopEval(_eval), popEval(loopEval), selectTransform(_select, _transform), breed(selectTransform), mergeReduce(_merge,_reduce), replace(mergeReduce),
+ fitnessEval(_fitnessEval), diversityEval(_diversityEval), evalFitAndDivBeforeSelection(_evalFitAndDivBeforeSelection)
+ {}
+
+
+ /**
+ * Applies a few generation of evolution to the population _pop.
+ * @param _pop the population
+ */
+ virtual void operator()(eoPop < MOEOT > & _pop)
+ {
+ eoPop < MOEOT > offspring, empty_pop;
+ popEval(empty_pop, _pop); // A first eval of pop.
+ bool firstTime = true;
+ do
+ {
+ try
+ {
+ unsigned pSize = _pop.size();
+ offspring.clear(); // new offspring
+ // fitness and diversity assignment (if you want to or if it is the first generation)
+ if (evalFitAndDivBeforeSelection || firstTime)
+ {
+ firstTime = false;
+ fitnessEval(_pop);
+ diversityEval(_pop);
+ }
+ breed(_pop, offspring);
+ popEval(_pop, offspring); // eval of parents + offspring if necessary
+ replace(_pop, offspring); // after replace, the new pop. is in _pop
+ if (pSize > _pop.size())
+ {
+ throw std::runtime_error("Population shrinking!");
+ }
+ else if (pSize < _pop.size())
+ {
+ throw std::runtime_error("Population growing!");
+ }
+ }
+ catch (std::exception& e)
+ {
+ std::string s = e.what();
+ s.append( " in moeoEasyEA");
+ throw std::runtime_error( s );
+ }
+ } while (continuator(_pop));
+ }
+
+
+protected:
+
+ /** the stopping criteria */
+ eoContinue < MOEOT > & continuator;
+ /** the evaluation functions */
+ eoEvalFunc < MOEOT > & eval;
+ /** to evaluate the whole population */
+ eoPopLoopEval < MOEOT > loopEval;
+ /** to evaluate the whole population */
+ eoPopEvalFunc < MOEOT > & popEval;
+ /** breed: a select followed by a transform */
+ eoSelectTransform < MOEOT > selectTransform;
+ /** the breeder */
+ eoBreed < MOEOT > & breed;
+ /** replacement: a merge followed by a reduce */
+ eoMergeReduce < MOEOT > mergeReduce;
+ /** the replacment strategy */
+ moeoReplacement < MOEOT > & replace;
+ /** the fitness assignment strategy */
+ moeoFitnessAssignment < MOEOT > & fitnessEval;
+ /** the diversity assignment strategy */
+ moeoDiversityAssignment < MOEOT > & diversityEval;
+ /** if this parameter is set to 'true', the fitness and the diversity of the whole population will be re-evaluated before the selection process */
+ bool evalFitAndDivBeforeSelection;
+ /** a dummy eval */
+class eoDummyEval : public eoEvalFunc < MOEOT >
+{ public: /** the dummy functor */
+ void operator()(MOEOT &) {}} dummyEval;
+ /** a dummy select */
+class eoDummySelect : public eoSelect < MOEOT >
+{ public: /** the dummy functor */
+ void operator()(const eoPop < MOEOT > &, eoPop < MOEOT > &) {} } dummySelect;
+ /** a dummy transform */
+class eoDummyTransform : public eoTransform < MOEOT >
+{ public: /** the dummy functor */
+ void operator()(eoPop < MOEOT > &) {} } dummyTransform;
+ /** a dummy merge */
+ eoNoElitism < MOEOT > dummyMerge;
+ /** a dummy reduce */
+ eoTruncate < MOEOT > dummyReduce;
+
+};
+
+#endif /*MOEOEASYEA_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoElitistReplacement.h b/tags/paradiseo-moeo-0.3/src/moeoElitistReplacement.h
new file mode 100644
index 000000000..cf6e406c7
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoElitistReplacement.h
@@ -0,0 +1,128 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoElitistReplacement.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOELITISTREPLACEMENT_H_
+#define MOEOELITISTREPLACEMENT_H_
+
+#include
+#include
+#include
+#include
+
+/**
+ * Elitist replacement strategy that consists in keeping the N best individuals.
+ */
+template < class MOEOT > class moeoElitistReplacement:public moeoReplacement < MOEOT >
+{
+public:
+
+ /**
+ * Full constructor.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _diversityAssignment the diversity assignment strategy
+ * @param _comparator the comparator (used to compare 2 individuals)
+ */
+ moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoDiversityAssignment < MOEOT > & _diversityAssignment, moeoComparator < MOEOT > & _comparator) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (_diversityAssignment), comparator (_comparator)
+ {}
+
+
+ /**
+ * Constructor without comparator. A moeoFitThenDivComparator is used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _diversityAssignment the diversity assignment strategy
+ */
+ moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoDiversityAssignment < MOEOT > & _diversityAssignment) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (_diversityAssignment), comparator (defaultComparator)
+ {}
+
+
+ /**
+ * Constructor without moeoDiversityAssignement. A dummy diversity is used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _comparator the comparator (used to compare 2 individuals)
+ */
+ moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoComparator < MOEOT > & _comparator) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (defaultDiversity), comparator (_comparator)
+ {}
+
+
+ /**
+ * Constructor without moeoDiversityAssignement nor moeoComparator.
+ * A moeoFitThenDivComparator and a dummy diversity are used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ */
+ moeoElitistReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (defaultDiversity), comparator (defaultComparator)
+ {}
+
+
+ /**
+ * Replaces the first population by adding the individuals of the second one, sorting with a moeoComparator and resizing the whole population obtained.
+ * @param _parents the population composed of the parents (the population you want to replace)
+ * @param _offspring the offspring population
+ */
+ void operator () (eoPop < MOEOT > &_parents, eoPop < MOEOT > &_offspring)
+ {
+ unsigned sz = _parents.size ();
+ // merges offspring and parents into a global population
+ _parents.reserve (_parents.size () + _offspring.size ());
+ copy (_offspring.begin (), _offspring.end (), back_inserter (_parents));
+ // evaluates the fitness and the diversity of this global population
+ fitnessAssignment (_parents);
+ diversityAssignment (_parents);
+ // sorts the whole population according to the comparator
+ std::sort(_parents.begin(), _parents.end(), comparator);
+ // finally, resize this global population
+ _parents.resize (sz);
+ // and clear the offspring population
+ _offspring.clear ();
+ }
+
+
+protected:
+
+ /** the fitness assignment strategy */
+ moeoFitnessAssignment < MOEOT > & fitnessAssignment;
+ /** the diversity assignment strategy */
+ moeoDiversityAssignment < MOEOT > & diversityAssignment;
+ /** a dummy diversity assignment can be used as default */
+ moeoDummyDiversityAssignment < MOEOT > defaultDiversity;
+ /** a fitness then diversity comparator can be used as default */
+ moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
+ /** this object is used to compare solutions in order to sort the population */
+ class Cmp
+ {
+ public:
+ /**
+ * Ctor.
+ * @param _comparator the comparator
+ */
+ Cmp(moeoComparator < MOEOT > & _comp) : comp(_comp)
+ {}
+ /**
+ * Returns true if _moeo1 is greater than _moeo2 according to the comparator
+ * _moeo1 the first individual
+ * _moeo2 the first individual
+ */
+ bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ return comp(_moeo2,_moeo1);
+ }
+ private:
+ /** the comparator */
+ moeoComparator < MOEOT > & comp;
+ } comparator;
+
+};
+
+#endif /*MOEOELITISTREPLACEMENT_H_ */
diff --git a/tags/paradiseo-moeo-0.3/src/moeoEnvironmentalReplacement.h b/tags/paradiseo-moeo-0.3/src/moeoEnvironmentalReplacement.h
new file mode 100755
index 000000000..78ee0b1fc
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoEnvironmentalReplacement.h
@@ -0,0 +1,145 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoEnvironmentalReplacement.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOENVIRONMENTALREPLACEMENT_H_
+#define MOEOENVIRONMENTALREPLACEMENT_H_
+
+#include
+#include
+#include
+#include
+
+/**
+ * Environmental replacement strategy that consists in keeping the N best individuals by deleting individuals 1 by 1
+ * and by updating the fitness and diversity values after each deletion.
+ */
+template < class MOEOT > class moeoEnvironmentalReplacement:public moeoReplacement < MOEOT >
+{
+public:
+
+ /** The type for objective vector */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Full constructor.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _diversityAssignment the diversity assignment strategy
+ * @param _comparator the comparator (used to compare 2 individuals)
+ */
+ moeoEnvironmentalReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoDiversityAssignment < MOEOT > & _diversityAssignment, moeoComparator < MOEOT > & _comparator) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (_diversityAssignment), comparator (_comparator)
+ {}
+
+
+ /**
+ * Constructor without comparator. A moeoFitThenDivComparator is used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _diversityAssignment the diversity assignment strategy
+ */
+ moeoEnvironmentalReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoDiversityAssignment < MOEOT > & _diversityAssignment) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (_diversityAssignment), comparator (defaultComparator)
+ {}
+
+
+ /**
+ * Constructor without moeoDiversityAssignement. A dummy diversity is used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ * @param _comparator the comparator (used to compare 2 individuals)
+ */
+ moeoEnvironmentalReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment, moeoComparator < MOEOT > & _comparator) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (defaultDiversity), comparator (_comparator)
+ {}
+
+
+ /**
+ * Constructor without moeoDiversityAssignement nor moeoComparator.
+ * A moeoFitThenDivComparator and a dummy diversity are used as default.
+ * @param _fitnessAssignment the fitness assignment strategy
+ */
+ moeoEnvironmentalReplacement (moeoFitnessAssignment < MOEOT > & _fitnessAssignment) :
+ fitnessAssignment (_fitnessAssignment), diversityAssignment (defaultDiversity), comparator (defaultComparator)
+ {}
+
+
+ /**
+ * Replaces the first population by adding the individuals of the second one, sorting with a moeoComparator and resizing the whole population obtained.
+ * @param _parents the population composed of the parents (the population you want to replace)
+ * @param _offspring the offspring population
+ */
+ void operator () (eoPop < MOEOT > &_parents, eoPop < MOEOT > &_offspring)
+ {
+ unsigned sz = _parents.size();
+ // merges offspring and parents into a global population
+ _parents.reserve (_parents.size() + _offspring.size());
+ copy (_offspring.begin(), _offspring.end(), back_inserter(_parents));
+ // evaluates the fitness and the diversity of this global population
+ fitnessAssignment (_parents);
+ diversityAssignment (_parents);
+ // remove individuals 1 by 1 and update the fitness values
+ unsigned worstIdx;
+ ObjectiveVector worstObjVec;
+ while (_parents.size() > sz)
+ {
+ // the individual to delete
+ worstIdx = std::min_element(_parents.begin(), _parents.end(), comparator) - _parents.begin();
+ worstObjVec = _parents[worstIdx].objectiveVector();
+ // remove the woorst individual
+ _parents[worstIdx] = _parents.back();
+ _parents.pop_back();
+ // update of the fitness and diversity values
+ fitnessAssignment.updateByDeleting(_parents, worstObjVec);
+ diversityAssignment.updateByDeleting(_parents, worstObjVec);
+
+ }
+ // clear the offspring population
+ _offspring.clear ();
+ }
+
+
+protected:
+
+ /** the fitness assignment strategy */
+ moeoFitnessAssignment < MOEOT > & fitnessAssignment;
+ /** the diversity assignment strategy */
+ moeoDiversityAssignment < MOEOT > & diversityAssignment;
+ /** a dummy diversity assignment can be used as default */
+ moeoDummyDiversityAssignment < MOEOT > defaultDiversity;
+ /** a fitness then diversity comparator can be used as default */
+ moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
+ /** this object is used to compare solutions in order to sort the population */
+ class Cmp
+ {
+ public:
+ /**
+ * Ctor.
+ * @param _comparator the comparator
+ */
+ Cmp(moeoComparator < MOEOT > & _comp) : comp(_comp)
+ {}
+ /**
+ * Returns true if _moeo1 is greater than _moeo2 according to the comparator
+ * _moeo1 the first individual
+ * _moeo2 the first individual
+ */
+ bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
+ {
+ return comp(_moeo1,_moeo2);
+ }
+ private:
+ /** the comparator */
+ moeoComparator < MOEOT > & comp;
+ } comparator;
+
+};
+
+#endif /*MOEOENVIRONMENTALREPLACEMENT_H_ */
diff --git a/tags/paradiseo-moeo-0.3/src/moeoEvalFunc.h b/tags/paradiseo-moeo-0.3/src/moeoEvalFunc.h
new file mode 100644
index 000000000..1f6b7544d
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoEvalFunc.h
@@ -0,0 +1,24 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoEvalFunc.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOEVALFUNC_H_
+#define MOEOEVALFUNC_H_
+
+#include
+
+/*
+ * Functor that evaluates one MOEO by setting all its objective values.
+ */
+template < class MOEOT >
+class moeoEvalFunc : public eoEvalFunc< MOEOT > {};
+
+#endif /*MOEOEVALFUNC_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoFastNonDominatedSortingFitnessAssignment.h b/tags/paradiseo-moeo-0.3/src/moeoFastNonDominatedSortingFitnessAssignment.h
new file mode 100644
index 000000000..61556537e
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoFastNonDominatedSortingFitnessAssignment.h
@@ -0,0 +1,223 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoFastNonDominatedSortingFitnessAssignment.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_
+#define MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_
+
+#include
+#include
+#include
+#include
+
+/**
+ * Fitness assignment sheme based on Pareto-dominance count proposed in:
+ * N. Srinivas, K. Deb, "Multiobjective Optimization Using Nondominated Sorting in Genetic Algorithms", Evolutionary Computation vol. 2, no. 3, pp. 221-248 (1994)
+ * and in:
+ * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002).
+ * This strategy is, for instance, used in NSGA and NSGA-II.
+ */
+template < class MOEOT >
+class moeoFastNonDominatedSortingFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT >
+{
+public:
+
+ /** the objective vector type of the solutions */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Default ctor
+ */
+ moeoFastNonDominatedSortingFitnessAssignment() : comparator(paretoComparator)
+ {}
+
+
+ /**
+ * Ctor where you can choose your own way to compare objective vectors
+ * @param _comparator the functor used to compare objective vectors
+ */
+ moeoFastNonDominatedSortingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator) : comparator(_comparator)
+ {}
+
+
+ /**
+ * Sets the fitness values for every solution contained in the population _pop
+ * @param _pop the population
+ */
+ void operator()(eoPop < MOEOT > & _pop)
+ {
+ // number of objectives for the problem under consideration
+ unsigned nObjectives = MOEOT::ObjectiveVector::nObjectives();
+ if (nObjectives == 1)
+ {
+ // one objective
+ oneObjective(_pop);
+ }
+ else if (nObjectives == 2)
+ {
+ // two objectives (the two objectives function is still to implement)
+ mObjectives(_pop);
+ }
+ else if (nObjectives > 2)
+ {
+ // more than two objectives
+ mObjectives(_pop);
+ }
+ else
+ {
+ // problem with the number of objectives
+ throw std::runtime_error("Problem with the number of objectives in moeoNonDominatedSortingFitnessAssignment");
+ }
+ // a higher fitness is better, so the values need to be inverted
+ double max = _pop[0].fitness();
+ for (unsigned i=1 ; i<_pop.size() ; i++)
+ {
+ max = std::max(max, _pop[i].fitness());
+ }
+ for (unsigned i=0 ; i<_pop.size() ; i++)
+ {
+ _pop[i].fitness(max - _pop[i].fitness());
+ }
+ }
+
+
+ /**
+ * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ for (unsigned i=0; i<_pop.size(); i++)
+ {
+ // if _pop[i] is dominated by _objVec
+ if ( comparator(_pop[i].objectiveVector(), _objVec) )
+ {
+ _pop[i].fitness(_pop[i].fitness()+1);
+ }
+ }
+ }
+
+
+private:
+
+ /** Functor to compare two objective vectors */
+ moeoObjectiveVectorComparator < ObjectiveVector > & comparator;
+ /** Functor to compare two objective vectors according to Pareto dominance relation */
+ moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
+
+
+
+
+ /**
+ * Sets the fitness values for mono-objective problems
+ * @param _pop the population
+ */
+ void oneObjective (eoPop < MOEOT > & _pop)
+ {
+ // Functor to compare two solutions on the first objective, then on the second, and so on
+ moeoObjectiveComparator < MOEOT > objComparator;
+ // sorts the population in the ascending order
+ std::sort(_pop.begin(), _pop.end(), objComparator);
+ // assign fitness values
+ unsigned rank = 1;
+ _pop[_pop.size()-1].fitness(rank);
+ for (unsigned i=_pop.size()-2; i>=0; i--)
+ {
+ if (_pop[i].objectiveVector() != _pop[i+1].objectiveVector())
+ {
+ rank++;
+ }
+ _pop[i].fitness(rank);
+ }
+ }
+
+
+ /**
+ * Sets the fitness values for bi-objective problems with a complexity of O(n log n), where n stands for the population size
+ * @param _pop the population
+ */
+ void twoObjectives (eoPop < MOEOT > & _pop)
+ {
+ //... TO DO !
+ }
+
+
+ /**
+ * Sets the fitness values for problems with more than two objectives with a complexity of O(n² log n), where n stands for the population size
+ * @param _pop the population
+ */
+ void mObjectives (eoPop < MOEOT > & _pop)
+ {
+ // S[i] = indexes of the individuals dominated by _pop[i]
+ std::vector < std::vector > S(_pop.size());
+ // n[i] = number of individuals that dominate the individual _pop[i]
+ std::vector < unsigned > n(_pop.size(), 0);
+ // fronts: F[i] = indexes of the individuals contained in the ith front
+ std::vector < std::vector > F(_pop.size()+2);
+ // used to store the number of the first front
+ F[1].reserve(_pop.size());
+ for (unsigned p=0; p<_pop.size(); p++)
+ {
+ for (unsigned q=0; q<_pop.size(); q++)
+ {
+ // if q is dominated by p
+ if ( comparator(_pop[q].objectiveVector(), _pop[p].objectiveVector()) )
+ {
+ // add q to the set of solutions dominated by p
+ S[p].push_back(q);
+ }
+ // if p is dominated by q
+ else if ( comparator(_pop[p].objectiveVector(), _pop[q].objectiveVector()) )
+ {
+ // increment the domination counter of p
+ n[p]++;
+ }
+ }
+ // if no individual dominates p
+ if (n[p] == 0)
+ {
+ // p belongs to the first front
+ _pop[p].fitness(1);
+ F[1].push_back(p);
+ }
+ }
+ // front counter
+ unsigned counter=1;
+ unsigned p,q;
+ while (! F[counter].empty())
+ {
+ // used to store the number of the next front
+ F[counter+1].reserve(_pop.size());
+ for (unsigned i=0; i
+#include
+
+/**
+ * Functor that sets the fitness values of a whole population.
+ */
+template < class MOEOT >
+class moeoFitnessAssignment : public eoUF < eoPop < MOEOT > &, void >
+{
+public:
+
+ /** The type for objective vector */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ virtual void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec) = 0;
+
+
+ /**
+ * Updates the fitness values of the whole population _pop by taking the deletion of the individual _moeo into account.
+ * @param _pop the population
+ * @param _moeo the individual
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, MOEOT & _moeo)
+ {
+ updateByDeleting(_pop, _moeo.objectiveVector());
+ }
+
+};
+
+
+/**
+ * moeoDummyFitnessAssignment is a moeoFitnessAssignment that gives the value '0' as the individual's fitness for a whole population if it is invalid.
+ */
+template < class MOEOT >
+class moeoDummyFitnessAssignment : public moeoFitnessAssignment < MOEOT >
+{
+public:
+
+ /** The type for objective vector */
+ typedef typename MOEOT::ObjectiveVector ObjectiveVector;
+
+
+ /**
+ * Sets the fitness to '0' for every individuals of the population _pop if it is invalid
+ * @param _pop the population
+ */
+ void operator () (eoPop < MOEOT > & _pop)
+ {
+ for (unsigned idx = 0; idx<_pop.size (); idx++)
+ {
+ if (_pop[idx].invalidFitness())
+ {
+ // set the diversity to 0
+ _pop[idx].fitness(0.0);
+ }
+ }
+ }
+
+
+ /**
+ * Updates the fitness values of the whole population _pop by taking the deletion of the objective vector _objVec into account.
+ * @param _pop the population
+ * @param _objVec the objective vector
+ */
+ void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
+ {
+ // nothing to do... ;-)
+ }
+
+};
+
+
+/**
+ * moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies.
+ */
+template < class MOEOT >
+class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT >
+ {};
+
+
+/**
+ * moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies.
+ */
+template < class MOEOT >
+class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
+ {};
+
+
+/**
+ * moeoParetoBasedFitnessAssignment is a moeoFitnessAssignment for Pareto-based strategies.
+ */
+template < class MOEOT >
+class moeoParetoBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
+ {};
+
+
+#endif /*MOEOFITNESSASSIGNMENT_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoGenerationalReplacement.h b/tags/paradiseo-moeo-0.3/src/moeoGenerationalReplacement.h
new file mode 100644
index 000000000..b7b800625
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoGenerationalReplacement.h
@@ -0,0 +1,39 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoGenerationalReplacement.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOGENERATIONALREPLACEMENT_H_
+#define MOEOGENERATIONALREPLACEMENT_H_
+
+#include
+#include
+
+/**
+ * Generational replacement: only the new individuals are preserved.
+ */
+template < class MOEOT >
+class moeoGenerationalReplacement : public moeoReplacement < MOEOT >, public eoGenerationalReplacement < MOEOT >
+{
+public:
+
+ /**
+ * Swaps _parents and _offspring
+ * @param _parents the parents population
+ * @param _offspring the offspring population
+ */
+ void operator()(eoPop < MOEOT > & _parents, eoPop < MOEOT > & _offspring)
+ {
+ eoGenerationalReplacement < MOEOT >::operator ()(_parents, _offspring);
+ }
+
+};
+
+#endif /*MOEOGENERATIONALREPLACEMENT_H_*/
diff --git a/tags/paradiseo-moeo-0.3/src/moeoHybridLS.h b/tags/paradiseo-moeo-0.3/src/moeoHybridLS.h
new file mode 100644
index 000000000..95aad42e0
--- /dev/null
+++ b/tags/paradiseo-moeo-0.3/src/moeoHybridLS.h
@@ -0,0 +1,76 @@
+// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
+
+//-----------------------------------------------------------------------------
+// moeoHybridLS.h
+// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
+/*
+ This library...
+
+ Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
+ */
+//-----------------------------------------------------------------------------
+
+#ifndef MOEOHYBRIDLS_H_
+#define MOEOHYBRIDLS_H_
+
+#include
+#include
+#include
+#include
+#include