From 0dc5151ef0517ab4d7a0f69a491d77d294855d9d Mon Sep 17 00:00:00 2001 From: legrand Date: Mon, 8 Oct 2007 08:15:25 +0000 Subject: [PATCH] added source files without ILS git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@651 331e1502-861f-0410-8da2-ba01fb791d7f --- .../paradiseo-mo/src/index.h | 66 +++++++ tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo | 41 +++++ tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo.h | 71 +++++++ .../paradiseo-mo/src/moAlgo.h | 51 +++++ .../paradiseo-mo/src/moAspirCrit.h | 62 +++++++ .../paradiseo-mo/src/moBestImprSelect.h | 118 ++++++++++++ .../paradiseo-mo/src/moCoolingSchedule.h | 52 ++++++ .../src/moExponentialCoolingSchedule.h | 80 ++++++++ .../paradiseo-mo/src/moFirstImprSelect.h | 129 +++++++++++++ .../paradiseo-mo/src/moFitSolContinue.h | 91 +++++++++ .../paradiseo-mo/src/moGenSolContinue.h | 94 ++++++++++ .../paradiseo-mo/src/moHC.h | 157 ++++++++++++++++ .../paradiseo-mo/src/moHCMoveLoopExpl.h | 133 +++++++++++++ .../paradiseo-mo/src/moImprBestFitAspirCrit.h | 109 +++++++++++ .../paradiseo-mo/src/moItRandNextMove.h | 109 +++++++++++ .../paradiseo-mo/src/moLSCheckPoint.h | 91 +++++++++ .../src/moLinearCoolingSchedule.h | 80 ++++++++ .../paradiseo-mo/src/moMove.h | 57 ++++++ .../paradiseo-mo/src/moMoveExpl.h | 54 ++++++ .../paradiseo-mo/src/moMoveIncrEval.h | 57 ++++++ .../paradiseo-mo/src/moMoveInit.h | 53 ++++++ .../paradiseo-mo/src/moMoveLoopExpl.h | 51 +++++ .../paradiseo-mo/src/moMoveSelect.h | 90 +++++++++ .../paradiseo-mo/src/moNextMove.h | 54 ++++++ .../paradiseo-mo/src/moNoAspirCrit.h | 73 ++++++++ .../paradiseo-mo/src/moNoFitImprSolContinue.h | 123 +++++++++++++ .../paradiseo-mo/src/moRandImprSelect.h | 129 +++++++++++++ .../paradiseo-mo/src/moRandMove.h | 51 +++++ .../paradiseo-mo/src/moSA.h | 174 ++++++++++++++++++ .../paradiseo-mo/src/moSimpleMoveTabuList.h | 151 +++++++++++++++ .../src/moSimpleSolutionTabuList.h | 160 ++++++++++++++++ .../paradiseo-mo/src/moSolContinue.h | 58 ++++++ .../paradiseo-mo/src/moSteadyFitSolContinue.h | 143 ++++++++++++++ .../paradiseo-mo/src/moTS.h | 169 +++++++++++++++++ .../paradiseo-mo/src/moTSMoveLoopExpl.h | 157 ++++++++++++++++ .../paradiseo-mo/src/moTabuList.h | 81 ++++++++ 36 files changed, 3419 insertions(+) create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/index.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAlgo.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAspirCrit.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moBestImprSelect.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moCoolingSchedule.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moExponentialCoolingSchedule.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFirstImprSelect.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFitSolContinue.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moGenSolContinue.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHC.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHCMoveLoopExpl.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moImprBestFitAspirCrit.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moItRandNextMove.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLSCheckPoint.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLinearCoolingSchedule.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMove.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveExpl.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveIncrEval.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveInit.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveLoopExpl.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveSelect.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNextMove.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoAspirCrit.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoFitImprSolContinue.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandImprSelect.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandMove.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSA.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleMoveTabuList.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleSolutionTabuList.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSolContinue.h create mode 100644 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSteadyFitSolContinue.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTS.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTSMoveLoopExpl.h create mode 100755 tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTabuList.h diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/index.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/index.h new file mode 100644 index 000000000..46c86bb55 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/index.h @@ -0,0 +1,66 @@ +/** @mainpage Welcome to PARADISEO-Moving Objects + +@section Introduction + +MO is an extension of the ANSI-C++ compliant evolutionary computation library EO. +
+It contains classes for almost any kind of one solution based heuristics. + +@section authors AUTHORS + + + + + + + + +
Sebastien CAHON
Jean-Charles BOISSON
+ +@section LICENCE + + This software is governed by the CeCILL license under French law and + abiding by the rules of distribution of free software. You can use, + modify and/ or redistribute the software under the terms of the CeCILL + license as circulated by CEA, CNRS and INRIA at the following URL + "http://www.cecill.info". + + As a counterpart to the access to the source code and rights to copy, + modify and redistribute granted by the license, users are provided only + with a limited warranty and the software's author, the holder of the + economic rights, and the successive licensors have only limited liability. + + In this respect, the user's attention is drawn to the risks associated + with loading, using, modifying and/or developing or reproducing the + software by the user in light of its specific status of free software, + that may mean that it is complicated to manipulate, and that also + therefore means that it is reserved for developers and experienced + professionals having in-depth computer knowledge. Users are therefore + encouraged to load and test the software's suitability as regards their + requirements in conditions enabling the security of their systems and/or + data to be ensured and, more generally, to use and operate it in the + same conditions as regards security. + The fact that you are presently reading this means that you have had + knowledge of the CeCILL license and that you accept its terms. + + ParadisEO WebSite : http://paradiseo.gforge.inria.fr + Contact: paradiseo-help@lists.gforge.inria.fr + + +@section Paradiseo Home Page + +http://paradiseo.gforge.inria.fr + +@section Installation + +The installation procedure of the package is detailed in the +README file in the top-directory of the source-tree. + +*/ + + +// coding: iso-8859-1 +// mode: C++ +// c-file-style: "Stroustrup" +// fill-column: 80 +// End: diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo new file mode 100755 index 000000000..b77209648 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo @@ -0,0 +1,41 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +#ifndef __mo +#define __mo + +#include "mo.h" + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo.h new file mode 100755 index 000000000..da19d6168 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/mo.h @@ -0,0 +1,71 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __mo_h +#define __mo_h + +#include "moAlgo.h" +#include "moAspirCrit.h" +#include "moBestImprSelect.h" +#include "moCoolingSchedule.h" +#include "moExponentialCoolingSchedule.h" +#include "moFirstImprSelect.h" +#include "moGenSolContinue.h" +#include "moHC.h" +#include "moHCMoveLoopExpl.h" +#include "moImprBestFitAspirCrit.h" +#include "moItRandNextMove.h" +#include "moLinearCoolingSchedule.h" +#include "moLSCheckPoint.h" +#include "moMoveExpl.h" +#include "moMove.h" +#include "moMoveIncrEval.h" +#include "moMoveInit.h" +#include "moMoveLoopExpl.h" +#include "moMoveSelect.h" +#include "moNextMove.h" +#include "moNoAspirCrit.h" +#include "moRandImprSelect.h" +#include "moRandMove.h" +#include "moSA.h" +#include "moSimpleMoveTabuList.h" +#include "moSimpleSolutionTabuList.h" +#include "moSolContinue.h" +#include "moTabuList.h" +#include "moTS.h" +#include "moTSMoveLoopExpl.h" + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAlgo.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAlgo.h new file mode 100755 index 000000000..c9886dee6 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAlgo.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moAlgo_h +#define __moAlgo_h + +#include + +//! Description of an algorithm of the paradiseo-mo library +/*! + moHC, moTS and moSA are 3 examples of algorithm of the paradiseo-mo library. + */ +template < class EOT > class moAlgo:public eoMonOp < EOT > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAspirCrit.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAspirCrit.h new file mode 100755 index 000000000..e8390aed8 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moAspirCrit.h @@ -0,0 +1,62 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moAspirCrit_h +#define __moAspirCrit_h + +#include + +//! Description of the conditions in which a tabu move could be accepted +/*! + It is only a description... An object that herits from this class is needed to be used in a moTS. + See moNoAspriCrit for example. + */ +template < class M > class moAspirCrit:public eoBF < const M &, const typename + M::EOType::Fitness &, + bool > +{ + +public: + //! Procedure which initialises all that needs a aspiration criterion. + /*! + It can be possible that this procedure do nothing... + */ + virtual void + init () = 0; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moBestImprSelect.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moBestImprSelect.h new file mode 100755 index 000000000..715ab6149 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moBestImprSelect.h @@ -0,0 +1,118 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moBestImprSelect_h +#define __moBestImprSelect_h + +#include "moMoveSelect.h" + +//! One of the possible moMoveSelect. +/*! + All neighbors are considered, and the movement + which enables the best improvement is selected. +*/ +template < class M > class moBestImprSelect:public moMoveSelect < M > +{ + +public: + + //! Alias for the fitness. + typedef typename M::EOType::Fitness Fitness; + + //! Procedure which initialise the exploration + void init (const Fitness & __fit) + { + + first_time = true; + } + + + //!Function that indicates if the current move has not improved the fitness. + /*! + If the given fitness enables an improvment, + the move (moMove) and the fitness linked to this move are saved. + + \param __move a move. + \param __fit a fitness linked to the move. + \return TRUE if the move does not improve the fitness. + */ + bool update (const M & __move, const Fitness & __fit) + { + + if (first_time || __fit > best_fit) + { + + best_fit = __fit; + best_move = __move; + + first_time = false; + } + + return true; + } + + //! Procedure which saved the best move and fitness. + /*! + \param __move the current move (result of the procedure). + \param __fit the current fitness (result of the procedure). + \throws EmptySelection if no move has improved the fitness. + */ + void operator () (M & __move, Fitness & __fit) throw (EmptySelection) + { + + if (!first_time) + { + __move = best_move; + __fit = best_fit; + } + else + throw EmptySelection (); + } + +private: + + //! Allowing to know if at least one move has been generated. + bool first_time; + + //! The best move. + M best_move; + + //! The best fitness. + Fitness best_fit; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moCoolingSchedule.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moCoolingSchedule.h new file mode 100644 index 000000000..a757fde04 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moCoolingSchedule.h @@ -0,0 +1,52 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moCoolingSchedule_h +#define __moCoolingSchedule_h + +#include + +//! This class gives the description of a cooling schedule. +/*! + It is only a description... An object that herits from this class is needed to be used in a moSA. + See moExponentialCoolingSchedule or moLinearCoolingSchedule for example. +*/ +class moCoolingSchedule:public eoUF < double &, bool > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moExponentialCoolingSchedule.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moExponentialCoolingSchedule.h new file mode 100644 index 000000000..5a717b735 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moExponentialCoolingSchedule.h @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moExponentialCoolingSchedule_h +#define __moExponentialCoolingSchedule_h + +#include "moCoolingSchedule.h" + +//! One of the possible moCoolingSchedule +/*! + An other very simple cooling schedule, the temperature decrease according to a ratio while + the temperature is greater than a given threshold. + */ +class moExponentialCoolingSchedule: public moCoolingSchedule +{ + +public: + //! Simple constructor + /*! + \param __threshold the threshold. + \param __ratio the ratio used to descrease the temperature. + */ + moExponentialCoolingSchedule (double __threshold, double __ratio):threshold (__threshold), ratio (__ratio) + {} + + //! Function which proceeds to the cooling. + /*! + It decreases the temperature and indicates if it is greater than the threshold. + + \param __temp the current temperature. + \return if the new temperature (current temperature * ratio) is greater than the threshold. + */ + bool operator() (double &__temp) + { + return (__temp *= ratio) > threshold; + } + +private: + + //! The temperature threhold. + double threshold; + + //! The decreasing factor of the temperature. + double ratio; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFirstImprSelect.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFirstImprSelect.h new file mode 100755 index 000000000..6f4b91a02 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFirstImprSelect.h @@ -0,0 +1,129 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moFirstImprSelect_h +#define __moFirstImprSelect_h + +#include "moMoveSelect.h" + +//! One possible moMoveSelect. +/*! + The neighborhood is explored until + a move enables an improvment of the + current solution. +*/ +template < class M > class moFirstImprSelect:public moMoveSelect < M > +{ + +public: + + //! Alias for the fitness. + typedef typename M::EOType::Fitness Fitness; + + //! Procedure which initialise the exploration. + /*! + It save the current fitness as the initial value for the fitness. + */ + virtual void init (const Fitness & __fit) + { + + valid = false; + init_fit = __fit; + } + + + //!Function that indicates if the current move has not improved the fitness. + /*! + If the given fitness enables an improvment, + the move (moMove) should be applied to the current solution. + + \param __move a move. + \param __fit a fitness linked to the move. + \return TRUE if the move does not improve the fitness. + */ + bool update (const M & __move, const typename M::EOType::Fitness & __fit) + { + + if (__fit > init_fit) + { + + best_fit = __fit; + best_move = __move; + valid = true; + + return false; + } + else + { + return true; + } + } + + //! Procedure which saved the best move and fitness. + /*! + \param __move the current move (result of the procedure). + \param __fit the current fitness (result of the procedure). + \throws EmptySelection if no move has improved the fitness. + */ + void operator () (M & __move, Fitness & __fit) throw (EmptySelection) + { + + if (valid) + { + __move = best_move; + __fit = best_fit; + } + else + throw EmptySelection (); + } + +private: + + //! Allow to know if at least one move has improved the solution. + bool valid; + + //! Best stored movement. + M best_move; + + //! Initial fitness. + Fitness init_fit; + + //! Best stored fitness. + Fitness best_fit; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFitSolContinue.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFitSolContinue.h new file mode 100644 index 000000000..e3f6be592 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moFitSolContinue.h @@ -0,0 +1,91 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moFitSolContinue_h +#define __moFitSolContinue_h + +#include "moSolContinue.h" + +//! One possible stop criterion for a solution-based heuristic. +/*! + The stop criterion corresponds to a fitness threshold gained. + */ +template < class EOT > class moFitSolContinue:public moSolContinue < EOT > +{ + +public: + + //! Alias for the fitness. + typedef typename EOT::Fitness Fitness; + + //! Basic constructor. + /*! + \param __fitness The fitness to reach. + */ + moFitSolContinue (Fitness __fitness): fitness (__fitness) + {} + + //! Function that activates the stopping criterion. + /*! + Indicates if the fitness threshold has not yet been reached. + + \param __sol the current solution. + \return true or false according to the value of the fitness. + */ + bool operator () (const EOT & __sol) + { + if(__sol.invalid()) + { + return true; + } + + return __sol.fitness() < fitness; + } + + //! Procedure which allows to initialise all the stuff needed. + /*! + It can be also used to reinitialize all the needed things. + */ + void init () + {} + +private: + + //! Fitness target. + Fitness fitness; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moGenSolContinue.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moGenSolContinue.h new file mode 100755 index 000000000..0e18e18a5 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moGenSolContinue.h @@ -0,0 +1,94 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moGenSolContinue_h +#define __moGenSolContinue_h + +#include "moSolContinue.h" + +//! One possible stop criterion for a solution-based heuristic. +/*! + The stop criterion corresponds to a maximum number of iteration. + */ +template < class EOT > class moGenSolContinue:public moSolContinue < EOT > +{ + +public: + + //! Simple constructor. + /*! + \param __maxNumGen the maximum number of generation. + */ + moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0) + { + + } + + //! Function that activates the stop criterion. + /*! + Increments the counter and returns TRUE if the + current number of iteration is lower than the given + maximum number of iterations. + + \param __sol the current solution. + \return TRUE or FALSE according to the current generation number. + */ + bool operator () (const EOT & __sol) + { + + return (++numGen < maxNumGen); + } + + //! Procedure which allows to initialise the generation counter. + /*! + It can also be used to reset the iteration counter. + */ + void init () + { + + numGen = 0; + } + +private: + + //! Iteration maximum number. + unsigned int maxNumGen; + + //! Iteration current number. + unsigned int numGen; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHC.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHC.h new file mode 100755 index 000000000..e2f1e9b64 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHC.h @@ -0,0 +1,157 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moHC_h +#define __moHC_h + +#include + +#include "moAlgo.h" +#include "moMoveExpl.h" +#include "moHCMoveLoopExpl.h" + +//! Hill Climbing (HC) +/*! + Class which describes the algorithm for a hill climbing. + */ +template < class M > class moHC:public moAlgo < typename M::EOType > +{ + + //! Alias for the type. + typedef + typename + M::EOType + EOT; + + //! Alias for the fitness. + typedef + typename + EOT::Fitness + Fitness; + +public: + + //! Full constructor. + /*! + All the boxes are given in order the HC to use a moHCMoveLoopExpl. + + \param __move_init a move initialiser. + \param __next_move a neighborhood explorer. + \param __incr_eval a (generally) efficient evaluation function. + \param __move_select a move selector. + \param __full_eval a full evaluation function. + */ +moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M > + (__move_init, __next_move, __incr_eval, __move_select)), + full_eval (__full_eval) + { + + } + + //! Light constructor. + /*! + This constructor allow to use another moMoveExpl (generally not a moHCMoveLoopExpl). + + \param __move_expl a complete explorer. + \param __full_eval a full evaluation function. + */ +moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl), + full_eval + (__full_eval) + { + + } + + //! Function which launches the HC + /*! + The HC has to improve a current solution. + As the moSA and the mo TS, it can be used for HYBRIDATION in an evolutionnary algorithm. + + \param __sol a current solution to improve. + \return TRUE. + */ + bool operator ()(EOT & __sol) + { + + if (__sol.invalid ()) + { + full_eval (__sol); + } + + EOT new_sol; + + do + { + + new_sol = __sol; + + try + { + + move_expl (__sol, new_sol); + + } + catch (EmptySelection & __ex) + { + + break; + } + + if (new_sol.fitness () > __sol.fitness ()) + { + __sol = new_sol; + } + else + { + break; + } + + } + while (true); + + return true; + } + +private: + + //! Complete exploration of the neighborhood. + moMoveExpl < M > &move_expl; + + //! A full evaluation function. + eoEvalFunc < EOT > &full_eval; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHCMoveLoopExpl.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHCMoveLoopExpl.h new file mode 100755 index 000000000..42db68647 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moHCMoveLoopExpl.h @@ -0,0 +1,133 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moHCMoveLoopExpl_h +#define __moHCMoveLoopExpl_h + +#include "moMoveLoopExpl.h" + +#include "moMoveInit.h" +#include "moNextMove.h" +#include "moMoveIncrEval.h" +#include "moMoveSelect.h" + +//! Iterative explorer used by a moHC. +template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M > +{ + + //! Alias for the type. + typedef typename M::EOType EOT; + + //! Alias for the fitness. + typedef typename M::EOType::Fitness Fitness; + +public: + + //! Constructor. + /*! + All the boxes have to be specified. + + \param __move_init the move initialiser. + \param __next_move the neighborhood explorer. + \param __incr_eval (generally) efficient evaluation function. + \param __move_select the move selector. + */ +moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select): + + move_init (__move_init), + next_move (__next_move), + incr_eval (__incr_eval), move_select (__move_select) + { + + } + + //! Procedure which launches the explorer. + /*! + The exploration starts from an old solution and provides a new solution. + + \param __old_sol the current solution. + \param __new_sol the new_sol (result of the procedure). + */ + void operator () (const EOT & __old_sol, EOT & __new_sol) + { + + M move; + + // + move_init (move, __old_sol); /* Restarting the exploration of + of the neighborhood ! */ + + move_select.init (__old_sol.fitness ()); + + while (move_select.update (move, incr_eval (move, __old_sol)) + && next_move (move, __old_sol)); + + try + { + + M best_move; + + Fitness best_move_fit; + + move_select (best_move, best_move_fit); + __new_sol.fitness (best_move_fit); + best_move (__new_sol); + + } + catch (EmptySelection & __ex) + { + + // ? + } + } + +private: + + //! Move initialiser. + moMoveInit < M > &move_init; + + //! Neighborhood explorer. + moNextMove < M > &next_move; + + //! (generally) Efficient evaluation. + moMoveIncrEval < M > &incr_eval; + + //! Move selector. + moMoveSelect < M > &move_select; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moImprBestFitAspirCrit.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moImprBestFitAspirCrit.h new file mode 100755 index 000000000..0a808d822 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moImprBestFitAspirCrit.h @@ -0,0 +1,109 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moImprBestFitAspirCrit_h +#define __moImprBestFitAspirCrit_h + +#include "moAspirCrit.h" + +//! One of the possible moAspirCrit +/*! + This criterion is satisfied when a given fitness + is the best ever considered. +*/ +template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M > +{ + +public: + + //! Alias for the fitness + typedef typename M::EOType::Fitness Fitness; + + //! Contructor + moImprBestFitAspirCrit () + { + + first_time = true; + } + + //! Initialisation procedure + void init () + { + + first_time = true; + } + + //! Function that indicates if the fit is better that the already saved fit + /*! + The first time, the function only saved the current move and fitness. + + \param __move a move. + \param __fit a fitnes linked to the move. + \return TRUE the first time and if __fit > best_fit, else FALSE. + */ + bool operator () (const M & __move, const Fitness & __fit) + { + + if (first_time) + { + + best_fit = __fit; + first_time = false; + + return true; + } + else if (__fit < best_fit) + return false; + + else + { + + best_fit = __fit; + + return true; + } + } + +private: + + //! Best fitness found until now + Fitness best_fit; + + //! Indicates that a fitness has been already saved or not + bool first_time; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moItRandNextMove.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moItRandNextMove.h new file mode 100755 index 000000000..00e0f2aea --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moItRandNextMove.h @@ -0,0 +1,109 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moItRandNextMove_h +#define __moItRandNextMove_h + +#include "moNextMove.h" +#include "moRandMove.h" + +//! One of the possible moNextMove. +/*! + This class is a move (moMove) generator with a bound for the maximum number of iterations. +*/ +template < class M > class moItRandNextMove:public moNextMove < M > +{ + + //! Alias for the type. + typedef typename M::EOType EOT; + +public: + + //! The constructor. + /*! + Parameters only for initialising the attributes. + + \param __rand_move the random move generator. + \param __max_iter the iteration maximum number. + */ + moItRandNextMove (moRandMove < M > &__rand_move, + unsigned int __max_iter):rand_move (__rand_move), + max_iter (__max_iter), num_iter (0) + { + + } + + //! Generation of a new move + /*! + If the maximum number is not already reached, the current move is forgotten and remplaced by another one. + + \param __move the current move. + \param __sol the current solution. + \return FALSE if the maximum number of iteration is reached, else TRUE. + */ + bool operator () (M & __move, const EOT & __sol) + { + + if (num_iter++ > max_iter) + { + + num_iter = 0; + return false; + } + else + { + + /* The given solution is discarded here */ + rand_move (__move); + num_iter++; + return true; + } + } + +private: + + //! A move generator (generally randomly). + moRandMove < M > &rand_move; + + //! Iteration maximum number. + unsigned int max_iter; + + //! Iteration current number. + unsigned int num_iter; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLSCheckPoint.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLSCheckPoint.h new file mode 100755 index 000000000..9a41e28a2 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLSCheckPoint.h @@ -0,0 +1,91 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSolUpdater_h +#define __moSolUpdater_h + +#include + +//! Class which allows a checkpointing system. +/*! + Thanks to this class, at each iteration, additionnal function can be used (and not only one). +*/ +template < class M > class moLSCheckPoint:public eoBF < const M &, const typename + M::EOType &, void > +{ + +public: + //! Function which launches the checkpointing + /*! + Each saved function is used on the current move and the current solution. + + \param __move a move. + \param __sol a solution. + */ + void + operator () (const M & __move, const typename M::EOType & __sol) + { + + for (unsigned int i = 0; i < func.size (); i++) + { + func[i]->operator ()(__move, __sol); + } + } + + //! Procedure which add a new function to the function vector + /*! + The new function is added at the end of the vector. + \param __f a new function to add. + */ + void + add (eoBF < const M &, const typename M::EOType &, void >&__f) + { + + func.push_back (&__f); + } + +private: + + //! vector of function + std::vector < eoBF < const + M &, const + typename + M::EOType &, void >*> + func; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLinearCoolingSchedule.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLinearCoolingSchedule.h new file mode 100644 index 000000000..6c4e213d1 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moLinearCoolingSchedule.h @@ -0,0 +1,80 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moLinearCoolingSchedule_h +#define __moLinearCoolingSchedule_h + +#include "moCoolingSchedule.h" + +//! One of the possible moCoolingSchedule +/*! + An another very simple cooling schedule, the temperature decrease according to a quantity while + the temperature is greater than a threshold. + */ +class moLinearCoolingSchedule: public moCoolingSchedule +{ + +public: + //! Simple constructor + /*! + \param __threshold the threshold. + \param __quantity the quantity used to descrease the temperature. + */ + moLinearCoolingSchedule (double __threshold, double __quantity):threshold (__threshold), quantity (__quantity) + {} + + //! Function which proceeds to the cooling. + /*! + It decreases the temperature and indicates if it is greater than the threshold. + + \param __temp the current temperature. + \return if the new temperature (current temperature - quantity) is greater than the threshold. + */ + bool operator() (double &__temp) + { + return (__temp -= quantity) > threshold; + } + +private: + + //! The temperature threhold. + double threshold; + + //! The quantity that allows the temperature to decrease. + double quantity; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMove.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMove.h new file mode 100755 index 000000000..991114005 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMove.h @@ -0,0 +1,57 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMove_h +#define __moMove_h + +#include + +//! Definition of a move. + +/*! + A move transforms a solution to another close solution. + It describes how a solution can be modified to another one. +*/ +template < class EOT > class moMove:public eoUF < EOT &, void > +{ + +public: + //! Alias for the type + typedef EOT EOType; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveExpl.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveExpl.h new file mode 100755 index 000000000..462cae8bb --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveExpl.h @@ -0,0 +1,54 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMoveExpl_h +#define __moMoveExpl_h + +#include + +//! Description of a move (moMove) explorer +/*! + Only a description...See moMoveLoopExpl. + */ +template < class M > class moMoveExpl:public eoBF < const typename + M::EOType &, + typename +M::EOType &, void > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveIncrEval.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveIncrEval.h new file mode 100755 index 000000000..f3b6385c5 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveIncrEval.h @@ -0,0 +1,57 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMoveIncrEval_h +#define __moMoveIncrEval_h + +#include + +//! (generally) Efficient evaluation function based a move and a solution. + +/*! + From a move and a solution, it computes + a new fitness that could be associated to + the solution if this one is updated. +*/ +template < class M > class moMoveIncrEval:public eoBF < const M &, const typename + M::EOType &, + typename + M::EOType::Fitness > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveInit.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveInit.h new file mode 100755 index 000000000..26d922a45 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveInit.h @@ -0,0 +1,53 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMoveInit_h +#define __moMoveInit_h + +#include + +//! Move (moMove) initializer +/*! + Class which allows to initiase a move. + Only a description... An object that herits from this class needs to be designed to be used. + */ +template < class M > class moMoveInit:public eoBF < M &, const typename +M::EOType &, void > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveLoopExpl.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveLoopExpl.h new file mode 100755 index 000000000..80947b896 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveLoopExpl.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMoveLoopExpl_h +#define __moMoveLoopExpl_h + +#include "moMoveExpl.h" + +//! Class which describes an iterative explorer +/*! + Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl. + */ +template < class M > class moMoveLoopExpl:public moMoveExpl < M > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveSelect.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveSelect.h new file mode 100755 index 000000000..309ddc021 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moMoveSelect.h @@ -0,0 +1,90 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moMoveSelect_h +#define __moMoveSelect_h + +#include + +//! Special class that describes the case of no selection. +/*! + This class is used as an exception that can be thrown if a solution selector has completly failed. + */ +class EmptySelection +{ + +}; + +//! Class that describes a move selector (moMove). +/*! + It iteratively considers some moves (moMove) and their + associated fitnesses. The best move is so regularly updated. + At any time, it could be accessed. +*/ +template < class M > class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &, + void > +{ +public: + //! Alias for the fitness + typedef + typename + M::EOType::Fitness + Fitness; + + //! Procedure which initialises all that the move selector needs including the initial fitness. + /*! + In order to know the fitness of the solution, + for which the neighborhood will + be soon explored + + \param __fit the current fitness. + */ + virtual void + init (const Fitness & __fit) = 0; + + //! Function which updates the best solutions. + /*! + \param __move a new move. + \param __fit a fitness linked to the new move. + \return a boolean that expresses the need to resume the exploration. + */ + virtual + bool + update (const M & __move, const Fitness & __fit) = 0; + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNextMove.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNextMove.h new file mode 100755 index 000000000..6a6a5659a --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNextMove.h @@ -0,0 +1,54 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moNextMove_h +#define __moNextMove_h + +#include + +//! Class which allows to generate a new move (moMove). +/*! + Useful for the explorer (for moTS or moHC). + Does nothing... An object that herits from this class needs to be designed for being used. + */ +template < class M > class moNextMove:public eoBF < M &, const typename + M::EOType &, + bool > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoAspirCrit.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoAspirCrit.h new file mode 100755 index 000000000..4f4d1d4a3 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoAspirCrit.h @@ -0,0 +1,73 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moNoAspirCrit_h +#define __moNoAspirCrit_h + +#include "moAspirCrit.h" + +//! One of the possible aspiration criterion (moAspirCrit) +/*! + The simplest : never satisfied. + */ +template < class M > class moNoAspirCrit:public moAspirCrit < M > +{ + + //! Function which describes the aspiration criterion behaviour + /*! + Does nothing. + + \param __move a move. + \param __sol a fitness. + \return FALSE. + */ + bool operator () (const M & __move, + const typename M::EOType::Fitness & __sol) + { + + return false; + } + + //! Procedure which initialises all that needs a moNoAspirCrit + /*! + Nothing... + */ + void init () + { + } +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoFitImprSolContinue.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoFitImprSolContinue.h new file mode 100644 index 000000000..110458865 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moNoFitImprSolContinue.h @@ -0,0 +1,123 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moNoFitImprSolContinue_h +#define __moNoFitImprSolContinue_h + +#include "moSolContinue.h" + +//! One possible stop criterion for a solution-based heuristic. +/*! + The stop criterion corresponds to a maximum number of iterations without improvement. + */ +template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT > +{ + +public: + + //! Alias for the fitness. + typedef typename EOT::Fitness Fitness; + + //! Basic constructor. + /*! + \param __maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop. + */ + moNoFitImprSolContinue (unsigned int __maxNumberOfIterationWithoutImprovement) + : maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement), firstFitnessSaved(true), counter(0) + {} + + //! Function that activates the stopping criterion. + /*! + Indicates if the fitness has not been improved since a given number of iterations (after a minimum of iterations). + \param __sol the current solution. + \return true or false. + */ + bool operator () (const EOT & __sol) + { + if(__sol.invalid()) + { + return true; + } + + if(firstFitnessSaved) + { + fitness=__sol.fitness(); + counter=0; + firstFitnessSaved=false; + return true; + } + + counter++; + + if( __sol.fitness() > fitness) + { + fitness=__sol.fitness(); + counter=0; + } + + if(counter==maxNumberOfIterationsWithoutImprovement) + { + std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl; + } + return counter!=maxNumberOfIterationsWithoutImprovement; + } + + //! Procedure which allows to initialise all the stuff needed. + /*! + It can be also used to reinitialize all the needed things. + */ + void init () + { + firstFitnessSaved=true; + counter=0; + } + +private: + + //! Maximum number of iterations without improvement allowed. + unsigned int maxNumberOfIterationsWithoutImprovement; + + //! Flag that this is the first time that the fitness is used. + bool firstFitnessSaved; + + //! Current Fitness. + Fitness fitness; + + //! The iteration couter. + unsigned int counter; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandImprSelect.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandImprSelect.h new file mode 100755 index 000000000..db8b4b474 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandImprSelect.h @@ -0,0 +1,129 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moRandImprSelect_h +#define __moRandImprSelect_h + +#include + +#include +#include "moMoveSelect.h" + +//! One of the possible moMove selector (moMoveSelect) +/*! + All the neighbors are considered. + One of them that enables an improvment of the objective function is choosen. +*/ +template < class M > class moRandImprSelect:public moMoveSelect < M > +{ + +public: + + //! Alias for the fitness + typedef typename M::EOType::Fitness Fitness; + + //!Procedure which all that needs a moRandImprSelect + /*! + Give a value to the initialise fitness. + Clean the move and fitness vectors. + + \param __fit the current best fitness + */ + void init (const Fitness & __fit) + { + init_fit = __fit; + vect_better_fit.clear (); + vect_better_moves.clear (); + } + + //! Function that updates the fitness and move vectors + /*! + if a move give a better fitness than the initial fitness, + it is saved and the fitness too. + + \param __move a new move. + \param __fit a new fitness associated to the new move. + \return TRUE. + */ + bool update (const M & __move, const Fitness & __fit) + { + + if (__fit > init_fit) + { + + vect_better_fit.push_back (__fit); + vect_better_moves.push_back (__move); + } + + return true; + } + + //! The move selection + /*! + One the saved move is randomly chosen. + + \param __move the reference of the move that can be initialised by the function. + \param __fit the reference of the fitness that can be initialised by the function. + \throws EmptySelection If no move which improves the current fitness are found. + */ + void operator () (M & __move, Fitness & __fit) throw (EmptySelection) + { + + if (!vect_better_fit.empty ()) + { + + unsigned n = rng.random (vect_better_fit.size ()); + + __move = vect_better_moves[n]; + __fit = vect_better_fit[n]; + } + else + throw EmptySelection (); + } + +private: + + //! Fitness of the current solution. + Fitness init_fit; + + //! Candidate fitnesse vector. + std::vector < Fitness > vect_better_fit; + + //! Candidate move vector. + std::vector < M > vect_better_moves; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandMove.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandMove.h new file mode 100755 index 000000000..2c11e9aea --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moRandMove.h @@ -0,0 +1,51 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moRandMove_h +#define __moRandMove_h + +#include + +//! Random move generator +/*! + Only a description... An object that herits from this class needs to be designed in order to use a moSA. + */ +template < class M > class moRandMove:public eoUF < M &, void > +{ + +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSA.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSA.h new file mode 100755 index 000000000..2b980c044 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSA.h @@ -0,0 +1,174 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSA_h +#define __moSA_h + +#include +#include + +#include "moAlgo.h" +#include "moRandMove.h" +#include "moMoveIncrEval.h" +#include "moCoolingSchedule.h" +#include "moSolContinue.h" + +#include + +//! Simulated Annealing (SA) +/*! + Class that describes a Simulated Annealing algorithm. +*/ +template < class M > class moSA:public moAlgo < typename M::EOType > +{ + + //! Alias for the type + typedef + typename + M::EOType + EOT; + + //! Alias for the fitness + typedef + typename + EOT::Fitness + Fitness; + +public: + + //! SA constructor + /*! + All the boxes used by a SA need to be given. + + \param __move_rand a move generator (generally randomly). + \param __incr_eval a (generaly) efficient evaluation function + \param __cont a stopping criterion. + \param __init_temp the initial temperature. + \param __cool_sched a cooling schedule, describes how the temperature is modified. + \param __full_eval a full evaluation function. + */ + moSA (moRandMove < M > &__move_rand, + moMoveIncrEval < M > &__incr_eval, + moSolContinue < EOT > &__cont, + double __init_temp, + moCoolingSchedule & __cool_sched, eoEvalFunc < EOT > &__full_eval): + move_rand (__move_rand), + incr_eval (__incr_eval), + cont (__cont), + init_temp (__init_temp), + cool_sched (__cool_sched), + full_eval (__full_eval) + { + + } + + //! function that launches the SA algorithm. + /*! + As a moTS or a moHC, the SA can be used for HYBRIDATION in an evolutionary algorithm. + + \param __sol a solution to improve. + \return TRUE. + */ + bool operator ()(EOT & __sol) + { + + if (__sol.invalid ()) + { + full_eval (__sol); + } + + double temp = init_temp; + + M move; + + EOT best_sol = __sol; + + do + { + + cont.init (); + do + { + + move_rand (move); + + Fitness delta_fit = incr_eval (move, __sol) - __sol.fitness (); + + if (delta_fit > 0 || rng.uniform () < exp (delta_fit / temp)) + { + + __sol.fitness (incr_eval (move, __sol)); + move (__sol); + + /* Updating the best solution found + until now ? */ + if (__sol.fitness () > best_sol.fitness ()) + best_sol = __sol; + } + + } + while (cont (__sol)); + + } + while (cool_sched (temp)); + + __sol = best_sol; + + return true; + } + +private: + + //! A move generator (generally randomly) + moRandMove < M > &move_rand; + + //! A (generally) efficient evaluation function. + moMoveIncrEval < M > &incr_eval; + + //! Stopping criterion before temperature update + moSolContinue < EOT > &cont; + + //! Initial temperature + double init_temp; + + //! The cooling schedule + moCoolingSchedule & cool_sched; + + //! A full evaluation function. + eoEvalFunc < EOT > &full_eval; // Full evaluator. +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleMoveTabuList.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleMoveTabuList.h new file mode 100755 index 000000000..1f29c88fc --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleMoveTabuList.h @@ -0,0 +1,151 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSimpleMoveTabuList_h +#define __moSimpleMoveTabuList_h + +#include +#include + +#include "moTabuList.h" + +//! Class describing a move tabu list with a limited memory. +template +class moSimpleMoveTabuList: public moTabuList < M > +{ + +public: + + //! Alias for the type + typedef typename M::EOType EOT; + + //! Constructor + /* + \param __size The maximum size of the move tabu list. + */ + moSimpleMoveTabuList(unsigned int __size): maxSize(__size) + { + currentSize=0; + } + + //! Function that indicates if, in a given state, the _move is tabu or not. + /*! + \param __move A given moMove. + \param __sol A solution. + \return true or false. + */ + bool + operator () (const M & __move, const EOT & __sol) + { + typename std::list::iterator it; + + it=tabuList.begin(); + while(it!=tabuList.end()&&(!((*it)==__move))) + { + it++; + } + + return it!=tabuList.end(); + } + + void + add (const M & __move, const EOT & __sol) + { + if(currentSize!=0) + { + // Useful in the case of a move has been kept thanks to the moAspirCrit. + // In this case, the move can already be in the tabuList. + removeMove(__move); + } + + tabuList.push_back(__move); + + if(currentSize==maxSize) + { + tabuList.erase(tabuList.begin()); + } + else + { + currentSize++; + } + } + + void + update () + { + //nothing to do + } + + void + init () + { + //nothing to do + } + +private: + + //! Procedure that removes a given move from the tabu list (if it is into, else do nothing). + /*! + \param __move A given moMove. + */ + void + removeMove(const M & __move) + { + typename std::list::iterator it; + + it=tabuList.begin(); + while(it!=tabuList.end()&&(!((*it)==__move))) + { + it++; + } + + if(it!=tabuList.end()) + { + tabuList.erase(it); + } + } + + //! The maximum size of the tabu list. + unsigned int maxSize; + + //! The current size of the tabu list. + unsigned int currentSize; + + //! The move tabu list. + std::list tabuList; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleSolutionTabuList.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleSolutionTabuList.h new file mode 100755 index 000000000..8dac7d880 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSimpleSolutionTabuList.h @@ -0,0 +1,160 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSimpleSolutionTabuList_h +#define __moSimpleSolutionTabuList_h + +#include +#include + +#include "moTabuList.h" + +//! Class describing a solution tabu list with limited length. +template +class moSimpleSolutionTabuList: public moTabuList < M > +{ + +public: + + //! Alias for the type + typedef typename M::EOType EOT; + + //! Constructor + /*! + \param __size The maximum size of the solution tabu list. + */ + moSimpleSolutionTabuList(unsigned int __size): maxSize(__size) + { + currentSize=0; + } + + //! Function that indicates if, in a given state, the _move is tabu or not. + /*! + \param __move A given moMove. + \param __sol A solution. + \return true or false. + */ + bool operator () (const M & __move, const EOT & __sol) + { + typename std::list::iterator it; + + M _move=(M)__move; + EOT _sol=(EOT) __sol; + + _move(_sol); + + it=tabuList.begin(); + while(it!=tabuList.end()&&(!((*it)==_sol))) + { + it++; + } + + return it!=tabuList.end(); + } + + void + add (const M & __move, const EOT & __sol) + { + M _move=(M)__move; + EOT _sol=(EOT) _sol; + + _move(_sol); + + if(currentSize!=0) + { + // Useful in the case of a solution has been kept thanks to the moAspirCrit. + // In this case, the solution can already be in the tabuList. + removeSolution(_sol); + } + + tabuList.push_back(_sol); + + if(currentSize==maxSize) + { + tabuList.erase(tabuList.begin()); + } + else + { + currentSize++; + } + } + + void + update () + { + //nothing to do + } + + void + init () + { + //nothing to do + } + +private: + + //! Procedure that removes a given solution from the tabu list (if it is into, else does nothing). + /*! + \param __sol A given solution. + */ + void + removeSolution(const EOT & __sol) + { + typename std::list::iterator it; + + it=tabuList.begin(); + while(it!=tabuList.end()&&(!((*it)==__sol))) + { + it++; + } + + if(it!=tabuList.end()) + { + tabuList.erase(it); + } + } + + //! The maximum size of the tabu list. + unsigned int maxSize; + + //! The current size of the tabu list. + unsigned int currentSize; + + //! The solution tabu list. + std::list tabuList; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSolContinue.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSolContinue.h new file mode 100755 index 000000000..c63006d61 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSolContinue.h @@ -0,0 +1,58 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSolContinue_h +#define __moSolContinue_h + +#include + +//! Class that describes a stop criterion for a solution-based heuristic + +/*! + It allows to add an initialisation procedure to an object that is a unary function (eoUF). +*/ +template < class EOT > class moSolContinue:public eoUF < const EOT &, bool > +{ + +public: + //! Procedure which initialises all that the stop criterion needs + /*! + Generally, it allocates some data structures or initialises some counters. + */ + virtual void init () = 0; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSteadyFitSolContinue.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSteadyFitSolContinue.h new file mode 100644 index 000000000..6808ee54a --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moSteadyFitSolContinue.h @@ -0,0 +1,143 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moSteadyFitSolContinue_h +#define __moSteadyFitSolContinue_h + +#include "moSolContinue.h" + +//! One possible stopping criterion for a solution-based heuristic. +/*! + The stop criterion corresponds to a maximum number of iterations without improvement (after a minimum number of iterations). + */ +template < class EOT > class moSteadyFitSolContinue:public moSolContinue < EOT > +{ + +public: + + //! Alias for the fitness. + typedef typename EOT::Fitness Fitness; + + //! Basic constructor. + /*! + \param __maxNumberOfIterations The number of iterations to reach before looking for the fitness. + \param __maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop. + */ + moSteadyFitSolContinue (unsigned int __maxNumberOfIterations, unsigned int __maxNumberOfIterationWithoutImprovement) + : maxNumberOfIterations (__maxNumberOfIterations), maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement), + maxNumberOfIterationsReached(false), firstFitnessSaved(true), counter(0) + {} + + //! Function that activates the stopping criterion. + /*! + Indicates if the fitness has not been improved since a number of iterations (after a minimum of iterations). + + \param __sol the current solution. + \return true or false. + */ + bool operator () (const EOT & __sol) + { + if(!maxNumberOfIterationsReached) + { + maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations); + if(maxNumberOfIterationsReached) + { + std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl; + } + return true; + } + + if(__sol.invalid()) + { + return true; + } + + if(firstFitnessSaved) + { + fitness=__sol.fitness(); + counter=0; + firstFitnessSaved=false; + return true; + } + + counter++; + + if( __sol.fitness() > fitness ) + { + fitness=__sol.fitness(); + counter=0; + } + + if(counter==maxNumberOfIterationsWithoutImprovement) + { + std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl; + } + return counter!=maxNumberOfIterationsWithoutImprovement; + } + + //! Procedure which allows to initialise the stuff needed. + /*! + It can be also used to reinitialize the counter all the needed things. + */ + void init () + { + maxNumberOfIterationsReached=false; + counter=0; + firstFitnessSaved=true; + } + +private: + + //! Maximum number of iterations before considering the fitness. + unsigned int maxNumberOfIterations; + + //! Maximum number of iterations without improvement allowed. + unsigned int maxNumberOfIterationsWithoutImprovement; + + //! Flag that indicates that the maxNumberIteration have been reached. + bool maxNumberOfIterationsReached; + + //! Flag that this is the first time that the fitness is used. + bool firstFitnessSaved; + + //! Current Fitness. + Fitness fitness; + + //! The iteration couter. + unsigned int counter; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTS.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTS.h new file mode 100755 index 000000000..e83795d1b --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTS.h @@ -0,0 +1,169 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moTS_h +#define __moTS_h + +#include +#include + +#include "moAlgo.h" +#include "moSolContinue.h" + +#include "moMoveExpl.h" +#include "moTSMoveLoopExpl.h" + + +//! Tabu Search (TS) +/*! + Generic algorithm that describes a tabu search. + */ +template < class M > class moTS:public moAlgo < typename M::EOType > +{ + + //!Alias for the type + typedef + typename + M::EOType + EOT; + + //!Alias for the fitness + typedef + typename + EOT::Fitness + Fitness; + +public: + + //!Constructor of a moTS specifying all the boxes + /*! + In this constructor, a moTSMoveLoopExpl is instanciated. + + \param __move_init move initialisation + \param __next_move neighborhood explorer + \param __incr_eval efficient evaluation + \param __tabu_list tabu list + \param __aspir_crit aspiration criterion + \param __cont stop criterion + \param __full_eval full evaluation function + */ +moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M > + (__move_init, __next_move, __incr_eval, __tabu_list, + __aspir_crit)), cont (__cont), full_eval (__full_eval) + {} + + //! Constructor with less parameters + /*! + The explorer is given in the parameters. + + \param __move_expl the explorer (generally different that a moTSMoveLoopExpl) + \param __cont stop criterion + \param __full_eval full evaluation function + */ +moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl), + cont (__cont), + full_eval (__full_eval) + {} + + //! Function which launchs the Tabu Search + /*! + Algorithm of the tabu search. + As a moSA or a moHC, it can be used for HYBRIDATION in an evolutionary algorithm. + For security a lock (pthread_mutex_t) is closed during the algorithm. + + \param __sol a solution to improve. + \return TRUE. + */ + bool operator ()(EOT & __sol) + { + if (__sol.invalid ()) + { + full_eval (__sol); + } + + M move; + + EOT best_sol = __sol, new_sol; + + cont.init (); + + do + { + + new_sol = __sol; + + try + { + + move_expl (__sol, new_sol); + + } + catch (EmptySelection & __ex) + { + + break; + } + + /* Updating the best solution + found until now ? */ + if (new_sol.fitness () > __sol.fitness ()) + { + best_sol = new_sol; + } + + __sol = new_sol; + + } + while (cont (__sol)); + + __sol = best_sol; + + return true; + } + +private: + + //! Neighborhood explorer + moMoveExpl < M > &move_expl; + + //! Stop criterion + moSolContinue < EOT > &cont; + + //! Full evaluation function + eoEvalFunc < EOT > &full_eval; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTSMoveLoopExpl.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTSMoveLoopExpl.h new file mode 100755 index 000000000..c9ae4b986 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTSMoveLoopExpl.h @@ -0,0 +1,157 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moTSMoveLoopExpl_h +#define __moTSMoveLoopExpl_h + +#include "moMoveLoopExpl.h" + +#include "moMoveInit.h" +#include "moNextMove.h" +#include "moMoveIncrEval.h" +#include "moMoveSelect.h" + +#include "moTabuList.h" +#include "moAspirCrit.h" +#include "moBestImprSelect.h" + +//! Explorer for a Tabu Search algorithm +/*! + It is used by a moTS. + */ +template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M > +{ + + //!Alias for the type + typedef typename M::EOType EOT; + + //!Alias for the fitness + typedef typename M::EOType::Fitness Fitness; + +public: + + //!Constructor + /*! + \param __move_init move initialisation + \param __next_move neighborhood explorer + \param __incr_eval efficient evaluation + \param __tabu_list tabu list + \param __aspir_crit aspiration criterion + */ +moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit): + move_init (__move_init), + next_move (__next_move), + incr_eval (__incr_eval), + tabu_list (__tabu_list), aspir_crit (__aspir_crit) + { + + tabu_list.init (); + aspir_crit.init (); + } + + //!Procedure which lauches the exploration + /*! + The exploration continues while the chosen move is not in the tabu list + or the aspiration criterion is true. If these 2 conditions are not true, the + exploration stops if the move selector update function returns false. + + \param __old_sol the initial solution + \param __new_sol the new solution + */ + void operator () (const EOT & __old_sol, EOT & __new_sol) + { + + M move; + + + move_init (move, __old_sol); /* Restarting the exploration of + of the neighborhood ! */ + + move_select.init (__old_sol.fitness ()); + + do + { + + Fitness fit = incr_eval (move, __old_sol); + + if (!tabu_list (move, __old_sol) || aspir_crit (move, fit)) + { + if (!move_select.update (move, fit)) + break; + } + + } + while (next_move (move, __old_sol)); + + M best_move; + + Fitness best_move_fit; + + move_select (best_move, best_move_fit); + + __new_sol.fitness (best_move_fit); + best_move (__new_sol); + + /* Removing moves that are + no more tabu */ + tabu_list.update (); + + // Updating the tabu list + tabu_list.add (best_move, __new_sol); + } + +private: + + //!Move initialisation + moMoveInit < M > &move_init; + + //!Neighborhood explorer + moNextMove < M > &next_move; + + //!Efficient evaluation + moMoveIncrEval < M > &incr_eval; + + //!Move selector + moBestImprSelect < M > move_select; + + //!Tabu list + moTabuList < M > &tabu_list; + + //!Aspiration criterion + moAspirCrit < M > &aspir_crit; +}; + +#endif diff --git a/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTabuList.h b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTabuList.h new file mode 100755 index 000000000..9b7cb3c16 --- /dev/null +++ b/tags/paradiseo-ix86-1.0/paradiseo-mo/src/moTabuList.h @@ -0,0 +1,81 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007 +* (C) OPAC Team, LIFL, 2002-2007 +* +* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr) +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ + +#ifndef __moTabuList_h +#define __moTabuList_h + +#include + +//! Class describing a tabu list that a moTS uses. +/*! + It is only a description, does nothing... A new object that herits from this class has to be defined in order + to be used in a moTS. + */ +template < class M > class moTabuList:public eoBF < const M &, const typename + M::EOType &, + bool > +{ + +public: + //! Alias for the type + typedef typename M::EOType EOT; + + //! Procedure to add a move in the tabu list + /*! + The two parameters have not to be modified so they are constant parameters. + + \param __move a new tabu move. + \param __sol the origianl solution associated to this move. + */ + virtual void + add (const M & __move, const EOT & __sol) = 0; + + //! Procedure that updates the tabu list content. + /*! + Generally, a counter associated to each saved move is decreased by one. + */ + virtual void + update () = 0; + + //! Procedure which initialises the tabu list. + /*! + Can be useful if the data structure needs to be allocated before being used. + */ + virtual void + init () = 0; +}; + +#endif