modif cmake configuration
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1277 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1432128e88
commit
350bdfc7de
1261 changed files with 144616 additions and 0 deletions
4
branches/cmakemodif/paradiseo-mo/src/CMakeLists.txt
Normal file
4
branches/cmakemodif/paradiseo-mo/src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
###############################################################
|
||||
# This is a dummy file
|
||||
###############################################################
|
||||
68
branches/cmakemodif/paradiseo-mo/src/index.h
Normal file
68
branches/cmakemodif/paradiseo-mo/src/index.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/** @mainpage Welcome to PARADISEO-Moving Objects
|
||||
|
||||
@section Introduction
|
||||
|
||||
MO is an extension of the ANSI-C++ compliant evolutionary computation library EO.
|
||||
<BR>
|
||||
It contains classes for almost any kind of one solution based heuristics.
|
||||
|
||||
@section authors AUTHORS
|
||||
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD>Sebastien CAHON</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<A href=http://www.lifl.fr/~boisson TARGET=blank>Jean-Charles BOISSON</A>
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
@section LICENSE
|
||||
|
||||
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
|
||||
|
||||
<A href=http://paradiseo.gforge.inria.fr>http://paradiseo.gforge.inria.fr</A>
|
||||
|
||||
@section Installation
|
||||
|
||||
The installation procedure of the package is detailed in the
|
||||
<a href="../../README">README</a> file in the top-directory of the source-tree.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// coding: iso-8859-1
|
||||
// mode: C++
|
||||
// c-file-style: "Stroustrup"
|
||||
// fill-column: 80
|
||||
// End:
|
||||
41
branches/cmakemodif/paradiseo-mo/src/mo
Executable file
41
branches/cmakemodif/paradiseo-mo/src/mo
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
<mo>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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
|
||||
76
branches/cmakemodif/paradiseo-mo/src/mo.h
Executable file
76
branches/cmakemodif/paradiseo-mo/src/mo.h
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
<mo.h>
|
||||
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 <moComparator.h>
|
||||
#include <moCoolingSchedule.h>
|
||||
#include <moExponentialCoolingSchedule.h>
|
||||
#include <moFirstImprSelect.h>
|
||||
#include <moFitComparator.h>
|
||||
#include <moFitSolContinue.h>
|
||||
#include <moGenSolContinue.h>
|
||||
#include <moHC.h>
|
||||
#include <moHCMoveLoopExpl.h>
|
||||
#include <moILS.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 <moNoFitImprSolContinue.h>
|
||||
#include <moRandImprSelect.h>
|
||||
#include <moRandMove.h>
|
||||
#include <moSA.h>
|
||||
#include <moSimpleMoveTabuList.h>
|
||||
#include <moSimpleSolutionTabuList.h>
|
||||
#include <moSolContinue.h>
|
||||
#include <moSteadyFitSolContinue.h>
|
||||
#include <moTabuList.h>
|
||||
#include <moTS.h>
|
||||
#include <moTSMoveLoopExpl.h>
|
||||
|
||||
#endif
|
||||
49
branches/cmakemodif/paradiseo-mo/src/moAlgo.h
Executable file
49
branches/cmakemodif/paradiseo-mo/src/moAlgo.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moAlgo.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoOp.h>
|
||||
|
||||
//! 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
|
||||
58
branches/cmakemodif/paradiseo-mo/src/moAspirCrit.h
Executable file
58
branches/cmakemodif/paradiseo-mo/src/moAspirCrit.h
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
<moAspirCrit.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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 an aspiration criterion.
|
||||
/*!
|
||||
It can be possible that this procedure does nothing...
|
||||
*/
|
||||
virtual void init () = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
127
branches/cmakemodif/paradiseo-mo/src/moBestImprSelect.h
Executable file
127
branches/cmakemodif/paradiseo-mo/src/moBestImprSelect.h
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
<moBestImprSelect.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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
|
||||
/*!
|
||||
\param _fitness The current fitness.
|
||||
*/
|
||||
void init (const Fitness & _fitness)
|
||||
{
|
||||
//Code only used to avoid warning because _fitness is not used in this procedure.
|
||||
Fitness fitness;
|
||||
fitness=(Fitness)_fitness;
|
||||
|
||||
//std::cout.precision(10);
|
||||
|
||||
//std::cout << "old fitness = " << _fitness << std::endl;
|
||||
|
||||
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 _fitness a fitness linked to the move.
|
||||
\return TRUE if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
if ( first_time || (_fitness > best_fitness) )
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
best_move = _move;
|
||||
|
||||
first_time = false;
|
||||
}
|
||||
|
||||
//std::cout << "best fitness = " << best_fitness << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param _move the current move (result of the procedure).
|
||||
\param _fitness the current fitness (result of the procedure).
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
if(first_time)
|
||||
{
|
||||
throw std::runtime_error("[moBestImprSelect.h]: no move or/and no fitness already saved, update has to be called first.");
|
||||
}
|
||||
|
||||
_move = best_move;
|
||||
_fitness = best_fitness;
|
||||
|
||||
|
||||
//std::cout << "Final fitness = " << best_fitness << std::endl;
|
||||
}
|
||||
|
||||
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_fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
48
branches/cmakemodif/paradiseo-mo/src/moComparator.h
Normal file
48
branches/cmakemodif/paradiseo-mo/src/moComparator.h
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
<moComparator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _moComparator_h
|
||||
#define _moComparator_h
|
||||
|
||||
|
||||
//! Template for classes which need to compare two EOT and indicate if the first is "better" than the second.
|
||||
/*!
|
||||
The objects that extend this template describe how an EOT is "better" than an other.
|
||||
*/
|
||||
template<class EOT>
|
||||
class moComparator: public eoBF<const EOT &, const EOT &, bool>
|
||||
{};
|
||||
|
||||
#endif
|
||||
49
branches/cmakemodif/paradiseo-mo/src/moCoolingSchedule.h
Normal file
49
branches/cmakemodif/paradiseo-mo/src/moCoolingSchedule.h
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moCoolingSchedule.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moExponentialCoolingSchedule.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _temperature the current temperature.
|
||||
\return if the new temperature (current temperature * ratio) is greater than the threshold.
|
||||
*/
|
||||
bool operator() (double & _temperature)
|
||||
{
|
||||
return (_temperature *= ratio) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The decreasing factor of the temperature.
|
||||
double ratio;
|
||||
};
|
||||
|
||||
#endif
|
||||
120
branches/cmakemodif/paradiseo-mo/src/moFirstImprSelect.h
Executable file
120
branches/cmakemodif/paradiseo-mo/src/moFirstImprSelect.h
Executable file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
<moFirstImprSelect.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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.
|
||||
\param _fitness The current fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & _fitness)
|
||||
{
|
||||
valid = false;
|
||||
initial_fitness = _fitness;
|
||||
}
|
||||
|
||||
//!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 _fitness a fitness linked to the move.
|
||||
\return true if the move does not improve the fitness.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
|
||||
if (_fitness > initial_fitness)
|
||||
{
|
||||
|
||||
best_fitness = _fitness;
|
||||
best_move = _move;
|
||||
valid = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Procedure which saved the best move and fitness.
|
||||
/*!
|
||||
\param _move the current move (result of the procedure).
|
||||
\param _fitness the current fitness (result of the procedure).
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
if (valid)
|
||||
{
|
||||
_move = best_move;
|
||||
_fitness = best_fitness;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Allow to know if at least one move has improved the solution.
|
||||
bool valid;
|
||||
|
||||
//! Best stored movement.
|
||||
M best_move;
|
||||
|
||||
//! Initial fitness.
|
||||
Fitness initial_fitness;
|
||||
|
||||
//! Best stored fitness.
|
||||
Fitness best_fitness;
|
||||
};
|
||||
|
||||
#endif
|
||||
62
branches/cmakemodif/paradiseo-mo/src/moFitComparator.h
Normal file
62
branches/cmakemodif/paradiseo-mo/src/moFitComparator.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
<moFitComparator.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _moFitComparator_h
|
||||
#define _moFitComparator_h
|
||||
|
||||
#include <moComparator.h>
|
||||
|
||||
//! Comparison according to the fitness.
|
||||
/*!
|
||||
An EOT is better than an other if its fitness is better.
|
||||
*/
|
||||
template<class EOT>
|
||||
class moFitComparator: public moComparator<EOT>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which makes the comparison and gives the result.
|
||||
/*!
|
||||
\param _solution1 The first solution.
|
||||
\param _solution2 The second solution.
|
||||
\return true if the fitness of the first solution is better than the second solution, false else.
|
||||
*/
|
||||
bool operator()(const EOT & _solution1, const EOT & _solution2)
|
||||
{
|
||||
return _solution1.fitness() > _solution2.fitness();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
90
branches/cmakemodif/paradiseo-mo/src/moFitSolContinue.h
Normal file
90
branches/cmakemodif/paradiseo-mo/src/moFitSolContinue.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
<moFitSolContinue.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _solution the current solution.
|
||||
\return true or false according to the value of the fitness.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moFitSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
return fitness > _solution.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
|
||||
92
branches/cmakemodif/paradiseo-mo/src/moGenSolContinue.h
Executable file
92
branches/cmakemodif/paradiseo-mo/src/moGenSolContinue.h
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
<moGenSolContinue.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _generationMaximumNumber The maximum number of generations.
|
||||
*/
|
||||
moGenSolContinue (unsigned int _generationMaximumNumber): generationMaximumNumber(_generationMaximumNumber), generationNumber(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 _solution The current solution.
|
||||
\return true or false according to the current generation number.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
//code only used for avoiding warning because _sol is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
return (++generationNumber < generationMaximumNumber);
|
||||
}
|
||||
|
||||
//! Procedure which allows to initialise the generation counter.
|
||||
/*!
|
||||
It can also be used to reset the iteration counter.
|
||||
*/
|
||||
void init ()
|
||||
{
|
||||
generationNumber = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Iteration maximum number.
|
||||
unsigned int generationMaximumNumber;
|
||||
|
||||
//! Iteration current number.
|
||||
unsigned int generationNumber;
|
||||
};
|
||||
|
||||
#endif
|
||||
136
branches/cmakemodif/paradiseo-mo/src/moHC.h
Executable file
136
branches/cmakemodif/paradiseo-mo/src/moHC.h
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<moHC.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoEvalFunc.h>
|
||||
|
||||
#include <moAlgo.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_initializer a move initialiser.
|
||||
\param _next_move_generator a neighborhood explorer.
|
||||
\param _incremental_evaluation a (generally) efficient evaluation function.
|
||||
\param _move_selection a move selector.
|
||||
\param _full_evaluation a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection, eoEvalFunc < EOT > & _full_evaluation) :
|
||||
move_explorer(new moHCMoveLoopExpl<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _move_selection)),
|
||||
full_evaluation (_full_evaluation), move_explorer_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Light constructor.
|
||||
/*!
|
||||
This constructor allow to use another moMoveExpl (generally not a moHCMoveLoopExpl).
|
||||
|
||||
\param _move_explorer a complete explorer.
|
||||
\param _full_evaluation a full evaluation function.
|
||||
*/
|
||||
moHC (moMoveExpl < M > & _move_explorer, eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (&_move_explorer), full_evaluation (_full_evaluation), move_explorer_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moHC()
|
||||
{
|
||||
if(move_explorer_memory_allocation)
|
||||
{
|
||||
delete(move_explorer);
|
||||
}
|
||||
}
|
||||
|
||||
//! 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 _solution a current solution to improve.
|
||||
\return true.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
EOT new_solution;
|
||||
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
full_evaluation(_solution);
|
||||
}
|
||||
|
||||
new_solution=_solution;
|
||||
|
||||
do
|
||||
{
|
||||
_solution=new_solution;
|
||||
(*move_explorer) (_solution, new_solution);
|
||||
}
|
||||
while ( new_solution.fitness() > _solution.fitness() );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Complete exploration of the neighborhood.
|
||||
moMoveExpl < M > * move_explorer;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the move_explorer.
|
||||
bool move_explorer_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
138
branches/cmakemodif/paradiseo-mo/src/moHCMoveLoopExpl.h
Executable file
138
branches/cmakemodif/paradiseo-mo/src/moHCMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
<moHCMoveLoopExpl.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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_initializer The move initialiser.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation (generally) Efficient evaluation function.
|
||||
\param _move_selection The move selector.
|
||||
*/
|
||||
moHCMoveLoopExpl (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection) :
|
||||
move_initializer (_move_initializer), next_move_generator (_next_move_generator),
|
||||
incremental_evaluation (_incremental_evaluation), move_selection (_move_selection)
|
||||
{}
|
||||
|
||||
//! Procedure which launches the explorer.
|
||||
/*!
|
||||
The exploration starts from an old solution and provides a new solution.
|
||||
|
||||
\param _old_solution The current solution.
|
||||
\param _new_solution The new solution (result of the procedure).
|
||||
*/
|
||||
void operator () (const EOT & _old_solution, EOT & _new_solution)
|
||||
{
|
||||
M move, best_move;
|
||||
Fitness best_fitness;
|
||||
bool has_next_move, selection_update_is_ok;
|
||||
|
||||
if( _old_solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moHCMoveLoopExpl.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
/*
|
||||
The two following lines are added to avoid compilation warning.
|
||||
<=> current best move fitness is the current fitness.
|
||||
<=> move and best move are empty for the moment.
|
||||
*/
|
||||
best_fitness=_old_solution.fitness();
|
||||
move=best_move;
|
||||
|
||||
//At the begining, the new sol is equivalent to the old one.
|
||||
_new_solution=(EOT)_old_solution;
|
||||
|
||||
// Restarting the exploration of the neighbourhood
|
||||
move_initializer(move, _old_solution);
|
||||
|
||||
move_selection.init(_old_solution.fitness ());
|
||||
|
||||
do
|
||||
{
|
||||
selection_update_is_ok = move_selection.update (move, incremental_evaluation(move, _old_solution) );
|
||||
has_next_move = next_move_generator (move, _old_solution);
|
||||
}
|
||||
while ( selection_update_is_ok && has_next_move);
|
||||
|
||||
//The selecter gives the value of the best move and the corresponding best fitness.
|
||||
move_selection (best_move, best_fitness);
|
||||
|
||||
//The best move is applied on the new solution.
|
||||
best_move(_new_solution);
|
||||
|
||||
//The fitness is set (avoid an additional fitness compuation).
|
||||
_new_solution.fitness (best_fitness);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Move initialiser.
|
||||
moMoveInit < M > & move_initializer;
|
||||
|
||||
//! Neighborhood explorer.
|
||||
moNextMove < M > & next_move_generator;
|
||||
|
||||
//! (generally) Efficient evaluation.
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Move selector.
|
||||
moMoveSelect < M > & move_selection;
|
||||
};
|
||||
|
||||
#endif
|
||||
227
branches/cmakemodif/paradiseo-mo/src/moILS.h
Normal file
227
branches/cmakemodif/paradiseo-mo/src/moILS.h
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
/*
|
||||
<moILS.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _moILS_h
|
||||
#define _moILS_h
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include <moHC.h>
|
||||
#include <moTS.h>
|
||||
#include <moSA.h>
|
||||
|
||||
//! Iterated Local Search (ILS)
|
||||
/*!
|
||||
Class which describes the algorithm for a iterated local search.
|
||||
*/
|
||||
template < class M >
|
||||
class moILS:public moAlgo < typename M::EOType >
|
||||
{
|
||||
//! Alias for the type.
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for the fitness.
|
||||
typedef typename EOT::Fitness Fitness;
|
||||
|
||||
public:
|
||||
|
||||
//! Generic constructor
|
||||
/*!
|
||||
Generic constructor using a moAlgo
|
||||
|
||||
\param _algorithm The solution based heuristic to use.
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moAlgo<EOT> & _algorithm, moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion,
|
||||
eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(& _algorithm), continu(_continue), acceptance_criterion(_acceptance_criterion),
|
||||
perturbation(_perturbation), full_evaluation(_full_evaluation), algorithm_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moHC for the moAlgo
|
||||
/*!
|
||||
\param _move_initializer The move initialisation (for the moHC).
|
||||
\param _next_move_generator The move generator (for the moHC).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moHC).
|
||||
\param _move_selection The move selection strategy (for the moHC).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moMoveSelect < M > & _move_selection,
|
||||
moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion,
|
||||
eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moHC<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _move_selection, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moTS for the moAlgo
|
||||
/*!
|
||||
\param _move_initializer The move initialisation (for the moTS).
|
||||
\param _next_move_generator The move generator (for the moTS).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moTS).
|
||||
\param _tabu_list The tabu list (for the moTS !!!!).
|
||||
\param _aspiration_criterion The aspiration criterion (for the moTS).
|
||||
\param _moTS_continue The stopping criterion (for the moTS).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moMoveInit <M> & _move_initializer, moNextMove <M> & _next_move_generator,
|
||||
moMoveIncrEval <M> & _incremental_evaluation, moTabuList <M> & _tabu_list,
|
||||
moAspirCrit <M> & _aspiration_criterion, moSolContinue <EOT> & _moTS_continue,
|
||||
moSolContinue <EOT> & _continue, moComparator<EOT> & _acceptance_criterion, eoMonOp<EOT> & _perturbation,
|
||||
eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moTS<M>(_move_initializer, _next_move_generator, _incremental_evaluation, _tabu_list, _aspiration_criterion,
|
||||
_moTS_continue, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Constructor for using a moSA for the moAlgo
|
||||
/*!
|
||||
\param _random_move_generator The random move generator (for the moSA).
|
||||
\param _incremental_evaluation The partial evaluation function (for the moSA).
|
||||
\param _moSA_continue The stopping criterion (for the moSA).
|
||||
\param _initial_temperature The initial temperature (for the moSA).
|
||||
\param _cooling_schedule The cooling schedule (for the moSA).
|
||||
\param _continue The stopping criterion.
|
||||
\param _acceptance_criterion The acceptance criterion.
|
||||
\param _perturbation The pertubation generator.
|
||||
\param _full_evaluation The evaluation function.
|
||||
*/
|
||||
moILS (moRandMove<M> & _random_move_generator, moMoveIncrEval <M> & _incremental_evaluation, moSolContinue <EOT> & _moSA_continue,
|
||||
double _initial_temperature, moCoolingSchedule & _cooling_schedule, moSolContinue <EOT> & _continue,
|
||||
moComparator<EOT> & _acceptance_criterion, eoMonOp<EOT> & _perturbation, eoEvalFunc<EOT> & _full_evaluation):
|
||||
algorithm(new moSA<M>(_random_move_generator, _incremental_evaluation, _moSA_continue, _initial_temperature,
|
||||
_cooling_schedule, _full_evaluation) ),
|
||||
continu(_continue), acceptance_criterion(_acceptance_criterion), perturbation(_perturbation), full_evaluation(_full_evaluation),
|
||||
algorithm_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moILS()
|
||||
{
|
||||
if(algorithm_memory_allocation)
|
||||
{
|
||||
delete(algorithm);
|
||||
}
|
||||
}
|
||||
|
||||
//! Function which launches the ILS
|
||||
/*!
|
||||
The ILS has to improve a current solution.
|
||||
As the moSA, the moTS and the moHC, it can be used for HYBRIDATION in an evolutionnary algorithm.
|
||||
|
||||
\param _solution a current solution to improve.
|
||||
\return true.
|
||||
*/
|
||||
bool operator()(EOT & _solution)
|
||||
{
|
||||
EOT _solution_saved;
|
||||
|
||||
if ( _solution.invalid() )
|
||||
{
|
||||
full_evaluation(_solution);
|
||||
}
|
||||
|
||||
_solution_saved=_solution;
|
||||
|
||||
continu.init ();
|
||||
|
||||
// some code has been duplicated in order to avoid one perturbation and one evaluation without adding a test in the loop.
|
||||
// better than a do {} while; with a test in the loop.
|
||||
|
||||
(*algorithm)(_solution);
|
||||
|
||||
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||
{
|
||||
_solution_saved=_solution;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_solution=_solution_saved;
|
||||
}
|
||||
|
||||
while ( continu (_solution) )
|
||||
{
|
||||
perturbation(_solution);
|
||||
full_evaluation(_solution);
|
||||
|
||||
(*algorithm)(_solution);
|
||||
|
||||
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||
{
|
||||
_solution_saved=_solution;
|
||||
}
|
||||
else
|
||||
{
|
||||
_solution=_solution_saved;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The solution based heuristic.
|
||||
moAlgo<EOT> * algorithm;
|
||||
|
||||
//! The stopping criterion.
|
||||
moSolContinue<EOT> & continu;
|
||||
|
||||
//! The acceptance criterion.
|
||||
moComparator<EOT> & acceptance_criterion;
|
||||
|
||||
//! The perturbation generator
|
||||
eoMonOp<EOT> & perturbation;
|
||||
|
||||
//! The full evaluation function
|
||||
eoEvalFunc<EOT> & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the algorithm.
|
||||
bool algorithm_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
105
branches/cmakemodif/paradiseo-mo/src/moImprBestFitAspirCrit.h
Executable file
105
branches/cmakemodif/paradiseo-mo/src/moImprBestFitAspirCrit.h
Executable file
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
<moImprBestFitAspirCrit.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 current fitness is better that the already saved fitness
|
||||
/*!
|
||||
The first time, the function only saved the current move and fitness.
|
||||
|
||||
\param _move A move.
|
||||
\param _fitness A fitness linked to the move.
|
||||
\return true The first time and if _fitntess > best_fitness, else false.
|
||||
*/
|
||||
bool operator () (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
//code only used for avoiding warning because _move is not used in this function.
|
||||
const M move(_move);
|
||||
|
||||
if (first_time)
|
||||
{
|
||||
best_fitness = _fitness;
|
||||
first_time = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_fitness < best_fitness)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
best_fitness = _fitness;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Best fitness found until now
|
||||
Fitness best_fitness;
|
||||
|
||||
//! Indicates that a fitness has been already saved or not
|
||||
bool first_time;
|
||||
};
|
||||
|
||||
#endif
|
||||
102
branches/cmakemodif/paradiseo-mo/src/moItRandNextMove.h
Executable file
102
branches/cmakemodif/paradiseo-mo/src/moItRandNextMove.h
Executable file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
<moItRandNextMove.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _random_move_generator The random move generator.
|
||||
\param _iteration_maximum_number The iteration maximum number.
|
||||
*/
|
||||
moItRandNextMove (moRandMove < M > & _random_move_generator, unsigned int _iteration_maximum_number):
|
||||
random_move_generator(_random_move_generator), iteration_maximum_number(_iteration_maximum_number), iteration_number(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 _solution the current solution.
|
||||
\return false if the maximum number of iteration is reached, else true.
|
||||
*/
|
||||
bool operator () (M & _move, const EOT & _solution)
|
||||
{
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
if (iteration_number > iteration_maximum_number)
|
||||
{
|
||||
iteration_number = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
random_move_generator (_move);
|
||||
iteration_number++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly).
|
||||
moRandMove < M > & random_move_generator;
|
||||
|
||||
//! Iteration maximum number.
|
||||
unsigned int iteration_maximum_number;
|
||||
|
||||
//! Iteration current number.
|
||||
unsigned int iteration_number;
|
||||
};
|
||||
|
||||
#endif
|
||||
83
branches/cmakemodif/paradiseo-mo/src/moLSCheckPoint.h
Executable file
83
branches/cmakemodif/paradiseo-mo/src/moLSCheckPoint.h
Executable file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
<moLSCheckPoint.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _moLSCheckPoint_h
|
||||
#define _moLSCheckPoint_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! 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 _solution a solution.
|
||||
*/
|
||||
void operator () (const M & _move, const typename M::EOType & _solution)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < functions.size (); i++)
|
||||
{
|
||||
functions[i]->operator ()(_move, _solution);
|
||||
}
|
||||
}
|
||||
|
||||
//! Procedure which add a new function to the function vector
|
||||
/*!
|
||||
The new function is added at the end of the vector.
|
||||
\param _function a new function to add.
|
||||
*/
|
||||
void add (eoBF < const M &, const typename M::EOType &, void >& _function)
|
||||
{
|
||||
functions.push_back(& _function);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Vector of functions.
|
||||
std::vector < eoBF < const M &, const typename M::EOType &, void >*> functions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
<moLinearCoolingSchedule.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _current_temperature The current temperature.
|
||||
\return true if the new temperature (current temperature - quantity) is greater than the threshold, false otherwise.
|
||||
*/
|
||||
bool operator() (double & _current_temperature)
|
||||
{
|
||||
return (_current_temperature -= quantity) > threshold;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! The temperature threhold.
|
||||
double threshold;
|
||||
|
||||
//! The quantity that allows the temperature to decrease.
|
||||
double quantity;
|
||||
};
|
||||
|
||||
#endif
|
||||
57
branches/cmakemodif/paradiseo-mo/src/moMove.h
Executable file
57
branches/cmakemodif/paradiseo-mo/src/moMove.h
Executable file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
<moMove.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
49
branches/cmakemodif/paradiseo-mo/src/moMoveExpl.h
Executable file
49
branches/cmakemodif/paradiseo-mo/src/moMoveExpl.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moMoveExpl.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
52
branches/cmakemodif/paradiseo-mo/src/moMoveIncrEval.h
Executable file
52
branches/cmakemodif/paradiseo-mo/src/moMoveIncrEval.h
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
<moMoveIncrEval.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! (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
|
||||
50
branches/cmakemodif/paradiseo-mo/src/moMoveInit.h
Executable file
50
branches/cmakemodif/paradiseo-mo/src/moMoveInit.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moMoveInit.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
50
branches/cmakemodif/paradiseo-mo/src/moMoveLoopExpl.h
Executable file
50
branches/cmakemodif/paradiseo-mo/src/moMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moMoveLoopExpl.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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
|
||||
76
branches/cmakemodif/paradiseo-mo/src/moMoveSelect.h
Executable file
76
branches/cmakemodif/paradiseo-mo/src/moMoveSelect.h
Executable file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
<moMoveSelect.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//! 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 _fitness the current fitness.
|
||||
*/
|
||||
virtual void init (const Fitness & _fitness) = 0;
|
||||
|
||||
//! Function which updates the best solutions.
|
||||
/*!
|
||||
\param _move a new move.
|
||||
\param _fitness 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 & _fitness) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
50
branches/cmakemodif/paradiseo-mo/src/moNextMove.h
Executable file
50
branches/cmakemodif/paradiseo-mo/src/moNextMove.h
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
<moNextMove.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
77
branches/cmakemodif/paradiseo-mo/src/moNoAspirCrit.h
Executable file
77
branches/cmakemodif/paradiseo-mo/src/moNoAspirCrit.h
Executable file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
<moNoAspirCrit.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Function which describes the aspiration criterion behaviour
|
||||
/*!
|
||||
Does nothing.
|
||||
|
||||
\param _move a move.
|
||||
\param _fitness a fitness.
|
||||
\return false.
|
||||
*/
|
||||
bool operator () (const M & _move, const typename M::EOType::Fitness & _fitness)
|
||||
{
|
||||
//Code only used to avoid warning because _move and _fitness are not used in this procedure.
|
||||
const M move(_move);
|
||||
typename M::EOType::Fitness fitness;
|
||||
fitness=(typename M::EOType::Fitness)_fitness;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Procedure which initialises all that needs a moNoAspirCrit.
|
||||
/*!
|
||||
Nothing...
|
||||
*/
|
||||
void init ()
|
||||
{}
|
||||
};
|
||||
|
||||
#endif
|
||||
123
branches/cmakemodif/paradiseo-mo/src/moNoFitImprSolContinue.h
Normal file
123
branches/cmakemodif/paradiseo-mo/src/moNoFitImprSolContinue.h
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
<moNoFitImprSolContinue.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _solution the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if (_solution.invalid())
|
||||
{
|
||||
throw std::runtime_error("[moNoFitImprSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
if (firstFitnessSaved)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
firstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if ( _solution.fitness() > fitness)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||
{
|
||||
std::cout << "[moNoFitImrpSolContinue.h]: 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
|
||||
136
branches/cmakemodif/paradiseo-mo/src/moRandImprSelect.h
Executable file
136
branches/cmakemodif/paradiseo-mo/src/moRandImprSelect.h
Executable file
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
<moRandImprSelect.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <vector>
|
||||
#include <utils/eoRNG.h>
|
||||
#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 _fitness the current best fitness
|
||||
*/
|
||||
void init (const Fitness & _fitness)
|
||||
{
|
||||
initial_fitness = _fitness;
|
||||
better_fitnesses.clear();
|
||||
better_moves.clear();
|
||||
firstTime=true;
|
||||
}
|
||||
|
||||
//! 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 _fitness a new fitness associated to the new move.
|
||||
\return true.
|
||||
*/
|
||||
bool update (const M & _move, const Fitness & _fitness)
|
||||
{
|
||||
firstTime=false;
|
||||
|
||||
if (_fitness > initial_fitness)
|
||||
{
|
||||
better_fitnesses.push_back(_fitness);
|
||||
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 _fitness the reference of the fitness that can be initialised by the function.
|
||||
*/
|
||||
void operator () (M & _move, Fitness & _fitness)
|
||||
{
|
||||
unsigned int index;
|
||||
|
||||
index=0;
|
||||
|
||||
if( (better_fitnesses.size()==0) || (better_moves.size()==0) )
|
||||
{
|
||||
if(firstTime)
|
||||
{
|
||||
throw std::runtime_error("[moRandImprSelect.h]: no move or/and no fitness already saved, update has to be called first.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
index = rng.random (better_fitnesses.size ());
|
||||
|
||||
_move = better_moves[index];
|
||||
_fitness = better_fitnesses[index];
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Fitness of the current solution.
|
||||
Fitness initial_fitness;
|
||||
|
||||
//! Candidate fitnesse vector.
|
||||
std::vector < Fitness > better_fitnesses;
|
||||
|
||||
//! Candidate move vector.
|
||||
std::vector < M > better_moves;
|
||||
|
||||
//! Indicate if update has been called or not.
|
||||
bool firstTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
49
branches/cmakemodif/paradiseo-mo/src/moRandMove.h
Executable file
49
branches/cmakemodif/paradiseo-mo/src/moRandMove.h
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
<moRandMove.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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
|
||||
165
branches/cmakemodif/paradiseo-mo/src/moSA.h
Executable file
165
branches/cmakemodif/paradiseo-mo/src/moSA.h
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
<moSA.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <math.h>
|
||||
|
||||
#include <eoEvalFunc.h>
|
||||
#include <moAlgo.h>
|
||||
#include <moRandMove.h>
|
||||
#include <moMoveIncrEval.h>
|
||||
#include <moCoolingSchedule.h>
|
||||
#include <moSolContinue.h>
|
||||
|
||||
//! 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 _random_move_generator The move generator (generally randomly).
|
||||
\param _incremental_evaluation The (generally) efficient evaluation function
|
||||
\param _continue The stopping criterion.
|
||||
\param _initial_temperature The initial temperature.
|
||||
\param _cooling_schedule The cooling schedule, describes how the temperature is modified.
|
||||
\param _full_evaluation The full evaluation function.
|
||||
*/
|
||||
moSA (moRandMove < M > & _random_move_generator, moMoveIncrEval < M > & _incremental_evaluation,
|
||||
moSolContinue < EOT > & _continue, double _initial_temperature, moCoolingSchedule & _cooling_schedule,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
random_move_generator(_random_move_generator), incremental_evaluation(_incremental_evaluation),
|
||||
continu(_continue), initial_temperature(_initial_temperature),
|
||||
cooling_schedule(_cooling_schedule), full_evaluation(_full_evaluation)
|
||||
{}
|
||||
|
||||
//! function that launches the SA algorithm.
|
||||
/*!
|
||||
As a moTS or a moHC, the SA can be used for HYBRIDATION in an evolutionary algorithm.
|
||||
|
||||
\param _solution A solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
Fitness incremental_fitness, delta_fit;
|
||||
EOT best_solution;
|
||||
double temperature;
|
||||
M move;
|
||||
|
||||
if (_solution.invalid())
|
||||
{
|
||||
full_evaluation (_solution);
|
||||
}
|
||||
|
||||
temperature = initial_temperature;
|
||||
|
||||
best_solution = _solution;
|
||||
|
||||
do
|
||||
{
|
||||
continu.init ();
|
||||
|
||||
do
|
||||
{
|
||||
random_move_generator(move);
|
||||
|
||||
incremental_fitness = incremental_evaluation (move, _solution);
|
||||
|
||||
delta_fit = incremental_fitness - _solution.fitness ();
|
||||
|
||||
if( (_solution.fitness() > incremental_fitness ) && (exp (delta_fit / temperature) > 1.0) )
|
||||
{
|
||||
delta_fit = -delta_fit;
|
||||
}
|
||||
|
||||
if ( (incremental_fitness > _solution.fitness()) || (rng.uniform () < exp (delta_fit / temperature)) )
|
||||
{
|
||||
move(_solution);
|
||||
_solution.fitness(incremental_fitness);
|
||||
|
||||
// Updating the best solution found until now ?
|
||||
if ( _solution.fitness() > best_solution.fitness() )
|
||||
{
|
||||
best_solution = _solution;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
while ( continu (_solution) );
|
||||
}
|
||||
while ( cooling_schedule (temperature) );
|
||||
|
||||
_solution = best_solution;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! A move generator (generally randomly)
|
||||
moRandMove < M > & random_move_generator;
|
||||
|
||||
//! A (generally) efficient evaluation function.
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Stopping criterion before temperature update
|
||||
moSolContinue < EOT > & continu;
|
||||
|
||||
//! Initial temperature
|
||||
double initial_temperature;
|
||||
|
||||
//! The cooling schedule
|
||||
moCoolingSchedule & cooling_schedule;
|
||||
|
||||
//! A full evaluation function.
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
};
|
||||
|
||||
#endif
|
||||
154
branches/cmakemodif/paradiseo-mo/src/moSimpleMoveTabuList.h
Executable file
154
branches/cmakemodif/paradiseo-mo/src/moSimpleMoveTabuList.h
Executable file
|
|
@ -0,0 +1,154 @@
|
|||
/*
|
||||
<moSimpleMoveTabuList.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <list>
|
||||
#include <iterator>
|
||||
|
||||
#include <moTabuList.h>
|
||||
|
||||
//! Class describing a move tabu list with a limited memory.
|
||||
template <class M>
|
||||
class moSimpleMoveTabuList: public moTabuList < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for an iterator of a move list.
|
||||
typedef typename std::list<M>::iterator moveIterator;
|
||||
|
||||
//! Constructor
|
||||
/*
|
||||
\param _size The maximum size of the move tabu list.
|
||||
*/
|
||||
moSimpleMoveTabuList(unsigned int _memory_maximum_size): memory_maximum_size(_memory_maximum_size), memory_size(0)
|
||||
{}
|
||||
|
||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
||||
/*!
|
||||
\param _move A given moMove.
|
||||
\param _solution A solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const M & _move, const EOT & _solution)
|
||||
{
|
||||
moveIterator it;
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
EOT solution=(EOT)_solution;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_move instead of (*it)!=_move because people designing their specific move representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && !((*it)==_move) )
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
return it!=tabuList.end();
|
||||
}
|
||||
|
||||
void add(const M & _move, const EOT & _solution)
|
||||
{
|
||||
//code only used to avoid warning because _solution is not used in this function.
|
||||
const EOT solution(_solution);
|
||||
|
||||
if (memory_size!=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 (memory_size == memory_maximum_size)
|
||||
{
|
||||
tabuList.erase(tabuList.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_size++;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
moveIterator it;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_move instead of (*it)!=_move because people designing their specific move representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && (!((*it)==_move) ))
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
if (it!=tabuList.end())
|
||||
{
|
||||
tabuList.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
//! The maximum size of the tabu list.
|
||||
unsigned int memory_maximum_size;
|
||||
|
||||
//! The current size of the tabu list.
|
||||
unsigned int memory_size;
|
||||
|
||||
//! The move tabu list.
|
||||
std::list<M> tabuList;
|
||||
};
|
||||
|
||||
#endif
|
||||
160
branches/cmakemodif/paradiseo-mo/src/moSimpleSolutionTabuList.h
Executable file
160
branches/cmakemodif/paradiseo-mo/src/moSimpleSolutionTabuList.h
Executable file
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
<moSimpleSolutionTabuList.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <list>
|
||||
#include <iterator>
|
||||
|
||||
#include <moTabuList.h>
|
||||
|
||||
//! Class describing a solution tabu list with limited length.
|
||||
template <class M>
|
||||
class moSimpleSolutionTabuList: public moTabuList < M >
|
||||
{
|
||||
public:
|
||||
|
||||
//! Alias for the type
|
||||
typedef typename M::EOType EOT;
|
||||
|
||||
//! Alias for an iterator of a solution list.
|
||||
typedef typename std::list<EOT>::iterator solutionIterator;
|
||||
|
||||
//! Constructor
|
||||
/*!
|
||||
\param _memory_maximum_size The maximum size of the solution tabu list.
|
||||
*/
|
||||
moSimpleSolutionTabuList(unsigned int _memory_maximum_size): memory_maximum_size(_memory_maximum_size), memory_size(0)
|
||||
{}
|
||||
|
||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
||||
/*!
|
||||
\param _move A given moMove.
|
||||
\param _solution A solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const M & _move, const EOT & _solution)
|
||||
{
|
||||
M move((M)_move);
|
||||
EOT solution((EOT)_solution);
|
||||
|
||||
solutionIterator it;
|
||||
|
||||
move(solution);
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_solution instead of (*it)!=_solution because people designing their specific solution representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while (it!=tabuList.end()&&(!((*it)==solution)))
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
return it!=tabuList.end();
|
||||
}
|
||||
|
||||
void add (const M & _move, const EOT & _solution)
|
||||
{
|
||||
M move=(M)_move;
|
||||
EOT solution=(EOT) _solution;
|
||||
|
||||
move(solution);
|
||||
|
||||
if (memory_size!=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(_solution);
|
||||
}
|
||||
|
||||
tabuList.push_back(_solution);
|
||||
|
||||
if (memory_size == memory_maximum_size)
|
||||
{
|
||||
tabuList.erase(tabuList.begin());
|
||||
}
|
||||
else
|
||||
{
|
||||
memory_size++;
|
||||
}
|
||||
}
|
||||
|
||||
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 _solution A given solution.
|
||||
*/
|
||||
void removeSolution(const EOT & _solution)
|
||||
{
|
||||
solutionIterator it;
|
||||
|
||||
it=tabuList.begin();
|
||||
// The code is !(*it)==_solution instead of (*it)!=_solution because people designing their specific solution representation
|
||||
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||
while ( it!=tabuList.end() && !((*it)==_solution) )
|
||||
{
|
||||
it++;
|
||||
}
|
||||
|
||||
if (it!=tabuList.end())
|
||||
{
|
||||
tabuList.erase(it);
|
||||
memory_size--;
|
||||
}
|
||||
}
|
||||
|
||||
//! The maximum size of the tabu list.
|
||||
unsigned int memory_maximum_size;
|
||||
|
||||
//! The current size of the tabu list.
|
||||
unsigned int memory_size;
|
||||
|
||||
//! The solution tabu list.
|
||||
std::list<EOT> tabuList;
|
||||
};
|
||||
|
||||
#endif
|
||||
58
branches/cmakemodif/paradiseo-mo/src/moSolContinue.h
Executable file
58
branches/cmakemodif/paradiseo-mo/src/moSolContinue.h
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
<moSolContinue.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
#include <stdexcept>
|
||||
|
||||
//! 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
|
||||
142
branches/cmakemodif/paradiseo-mo/src/moSteadyFitSolContinue.h
Normal file
142
branches/cmakemodif/paradiseo-mo/src/moSteadyFitSolContinue.h
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
<moSteadyFitSolContinue.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 _solution the current solution.
|
||||
\return true or false.
|
||||
*/
|
||||
bool operator () (const EOT & _solution)
|
||||
{
|
||||
if (!maxNumberOfIterationsReached)
|
||||
{
|
||||
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
||||
if (maxNumberOfIterationsReached)
|
||||
{
|
||||
std::cout << "[moSteadyFitSolContinue.h]: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_solution.invalid())
|
||||
{
|
||||
throw std::runtime_error("[moSteadyFitSolContinue.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
if (firstFitnessSaved)
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
firstFitnessSaved=false;
|
||||
return true;
|
||||
}
|
||||
|
||||
counter++;
|
||||
|
||||
if ( _solution.fitness() > fitness )
|
||||
{
|
||||
fitness=_solution.fitness();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||
{
|
||||
std::cout << "[moSteadyFitSolContinue.h]: 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
|
||||
163
branches/cmakemodif/paradiseo-mo/src/moTS.h
Executable file
163
branches/cmakemodif/paradiseo-mo/src/moTS.h
Executable file
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
<moTS.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoEvalFunc.h>
|
||||
|
||||
#include <moAlgo.h>
|
||||
#include <moSolContinue.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_initializer The move initializer.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation The (generally) efficient evaluation.
|
||||
\param _tabu_list The tabu list.
|
||||
\param _aspiration_criterion An aspiration criterion.
|
||||
\param _continue The stopping criterion.
|
||||
\param _full_evaluation A full evaluation function.
|
||||
*/
|
||||
moTS (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
|
||||
moAspirCrit < M > & _aspiration_criterion, moSolContinue < EOT > & _continue,
|
||||
eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (new moTSMoveLoopExpl < M >(_move_initializer, _next_move_generator, _incremental_evaluation,
|
||||
_tabu_list,_aspiration_criterion) ),
|
||||
continu (_continue), full_evaluation (_full_evaluation), move_explorer_memory_allocation(true)
|
||||
{}
|
||||
|
||||
//! Constructor with less parameters
|
||||
/*!
|
||||
The explorer is given in the parameters.
|
||||
|
||||
\param _move_explorer The explorer (generally different that a moTSMoveLoopExpl).
|
||||
\param _continue The stopping criterion.
|
||||
\param _full_evaluation A full evaluation function.
|
||||
*/
|
||||
moTS (moMoveExpl < M > & _move_explorer, moSolContinue < EOT > & _continue, eoEvalFunc < EOT > & _full_evaluation):
|
||||
move_explorer (&_move_explorer), continu (_continue), full_evaluation (_full_evaluation), move_explorer_memory_allocation(false)
|
||||
{}
|
||||
|
||||
//! Destructor
|
||||
~moTS()
|
||||
{
|
||||
if(move_explorer_memory_allocation)
|
||||
{
|
||||
delete(move_explorer);
|
||||
}
|
||||
}
|
||||
|
||||
//! 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 _solution a solution to improve.
|
||||
\return TRUE.
|
||||
*/
|
||||
bool operator ()(EOT & _solution)
|
||||
{
|
||||
M move;
|
||||
|
||||
EOT best_solution, new_solution;
|
||||
|
||||
if ( _solution.invalid () )
|
||||
{
|
||||
full_evaluation (_solution);
|
||||
}
|
||||
|
||||
best_solution=_solution;
|
||||
|
||||
// code used for avoiding warning because new_solution is indirectly initialized by move_expl.
|
||||
new_solution=_solution;
|
||||
|
||||
continu.init ();
|
||||
|
||||
do
|
||||
{
|
||||
(*move_explorer) (_solution, new_solution);
|
||||
|
||||
// Updating the best solution found until now ?
|
||||
if (new_solution.fitness() > _solution.fitness())
|
||||
{
|
||||
best_solution = new_solution;
|
||||
}
|
||||
|
||||
_solution = new_solution;
|
||||
}
|
||||
while ( continu (_solution) );
|
||||
|
||||
_solution = best_solution;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Neighborhood explorer
|
||||
moMoveExpl < M > * move_explorer;
|
||||
|
||||
//! Stop criterion
|
||||
moSolContinue < EOT > & continu;
|
||||
|
||||
//! Full evaluation function
|
||||
eoEvalFunc < EOT > & full_evaluation;
|
||||
|
||||
//! Indicate if the memory has been allocated for the move_explorer.
|
||||
bool move_explorer_memory_allocation;
|
||||
};
|
||||
|
||||
#endif
|
||||
165
branches/cmakemodif/paradiseo-mo/src/moTSMoveLoopExpl.h
Executable file
165
branches/cmakemodif/paradiseo-mo/src/moTSMoveLoopExpl.h
Executable file
|
|
@ -0,0 +1,165 @@
|
|||
/*
|
||||
<moTSMoveLoopExpl.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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_initializer The move initializer.
|
||||
\param _next_move_generator The neighbourhood explorer.
|
||||
\param _incremental_evaluation A (generally) efficient evaluation.
|
||||
\param _tabu_list The tabu list.
|
||||
\param _aspiration_criterion An aspiration criterion.
|
||||
*/
|
||||
moTSMoveLoopExpl (moMoveInit < M > & _move_initializer, moNextMove < M > & _next_move_generator,
|
||||
moMoveIncrEval < M > & _incremental_evaluation, moTabuList < M > & _tabu_list,
|
||||
moAspirCrit < M > & _aspiration_criterion):
|
||||
move_initializer(_move_initializer), next_move_generator(_next_move_generator), incremental_evaluation(_incremental_evaluation),
|
||||
tabu_list(_tabu_list), aspiration_criterion(_aspiration_criterion)
|
||||
{
|
||||
tabu_list.init ();
|
||||
aspiration_criterion.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_solution the initial solution
|
||||
\param _new_solution the new solution
|
||||
*/
|
||||
void operator () (const EOT & _old_solution, EOT & _new_solution)
|
||||
{
|
||||
M move, best_move;
|
||||
Fitness fitness, best_move_fitness;
|
||||
|
||||
bool move_is_tabu, aspiration_criterion_is_verified, selection_update_is_ok, has_next_move;
|
||||
|
||||
if( _old_solution.invalid() )
|
||||
{
|
||||
throw std::runtime_error("[moTSMoveLoopExpl.h]: The current solution has not been evaluated.");
|
||||
}
|
||||
|
||||
//At the begining, the new solution is equivalent to the old one.
|
||||
_new_solution=(EOT)_old_solution;
|
||||
|
||||
// Restarting the exploration of of the neighborhood !
|
||||
move_initializer (move, _old_solution);
|
||||
|
||||
move_selection.init( _old_solution.fitness() );
|
||||
|
||||
selection_update_is_ok=true;
|
||||
|
||||
do
|
||||
{
|
||||
fitness = incremental_evaluation(move, _old_solution);
|
||||
|
||||
move_is_tabu = tabu_list(move, _old_solution);
|
||||
|
||||
aspiration_criterion_is_verified = aspiration_criterion(move, fitness);
|
||||
|
||||
if( !move_is_tabu || aspiration_criterion_is_verified )
|
||||
{
|
||||
selection_update_is_ok = move_selection.update(move, fitness);
|
||||
}
|
||||
|
||||
has_next_move = next_move_generator(move, _old_solution);
|
||||
}
|
||||
while( has_next_move && selection_update_is_ok );
|
||||
|
||||
move_selection(best_move, best_move_fitness);
|
||||
|
||||
// Apply the best move.
|
||||
best_move(_new_solution);
|
||||
|
||||
// The fitness is set to avoid an additionnal fitness computation.
|
||||
_new_solution.fitness(best_move_fitness);
|
||||
|
||||
// Removing moves that are no more tabu.
|
||||
tabu_list.update ();
|
||||
|
||||
// Updating the tabu list
|
||||
tabu_list.add(best_move, _new_solution);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! Move initialisation
|
||||
moMoveInit < M > & move_initializer;
|
||||
|
||||
//! Neighborhood explorer
|
||||
moNextMove < M > & next_move_generator;
|
||||
|
||||
//! Efficient evaluation
|
||||
moMoveIncrEval < M > & incremental_evaluation;
|
||||
|
||||
//! Move selector
|
||||
moBestImprSelect < M > move_selection;
|
||||
|
||||
//! Tabu list
|
||||
moTabuList < M > & tabu_list;
|
||||
|
||||
//! Aspiration criterion
|
||||
moAspirCrit < M > & aspiration_criterion;
|
||||
};
|
||||
|
||||
#endif
|
||||
75
branches/cmakemodif/paradiseo-mo/src/moTabuList.h
Executable file
75
branches/cmakemodif/paradiseo-mo/src/moTabuList.h
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
<moTabuList.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
(C) OPAC Team, LIFL, 2002-2008
|
||||
|
||||
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 <eoFunctor.h>
|
||||
|
||||
//! 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 _solution the origianl solution associated to this move.
|
||||
*/
|
||||
virtual void add(const M & _move, const EOT & _solution) = 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue