Big source code update: simplification, accessibility, include, date, ... All .h have been verified and updated
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@877 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
ff55f03920
commit
a94380fadb
39 changed files with 3045 additions and 3155 deletions
|
|
@ -1,60 +1,62 @@
|
||||||
/** @mainpage Welcome to PARADISEO-Moving Objects
|
/** @mainpage Welcome to PARADISEO-Moving Objects
|
||||||
|
|
||||||
@section Introduction
|
@section Introduction
|
||||||
|
|
||||||
MO is an extension of the ANSI-C++ compliant evolutionary computation library EO.
|
MO is an extension of the ANSI-C++ compliant evolutionary computation library EO.
|
||||||
<br>
|
<BR>
|
||||||
It contains classes for almost any kind of one solution based heuristics.
|
It contains classes for almost any kind of one solution based heuristics.
|
||||||
|
|
||||||
@section authors AUTHORS
|
@section authors AUTHORS
|
||||||
|
|
||||||
<TABLE>
|
<TABLE>
|
||||||
<TR>
|
<TR>
|
||||||
<TD>Sebastien CAHON</TD>
|
<TD>Sebastien CAHON</TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
<TD><A href=http://www.lifl.fr/~boisson TARGET=blank>Jean-Charles BOISSON</A></TD>
|
<TD>
|
||||||
</TR>
|
<A href=http://www.lifl.fr/~boisson TARGET=blank>Jean-Charles BOISSON</A>
|
||||||
</TABLE>
|
</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
|
||||||
@section LICENSE
|
@section LICENSE
|
||||||
|
|
||||||
This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
"http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
|
|
||||||
As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
|
|
||||||
In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
same conditions as regards security.
|
same conditions as regards security.
|
||||||
The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
|
|
||||||
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
|
|
||||||
|
|
||||||
@section Paradiseo Home Page
|
@section Paradiseo Home Page
|
||||||
|
|
||||||
<A href=http://paradiseo.gforge.inria.fr>http://paradiseo.gforge.inria.fr</A>
|
<A href=http://paradiseo.gforge.inria.fr>http://paradiseo.gforge.inria.fr</A>
|
||||||
|
|
||||||
@section Installation
|
@section Installation
|
||||||
|
|
||||||
The installation procedure of the package is detailed in the
|
The installation procedure of the package is detailed in the
|
||||||
<a href="../../README">README</a> file in the top-directory of the source-tree.
|
<a href="../../README">README</a> file in the top-directory of the source-tree.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +1,38 @@
|
||||||
/*
|
/*
|
||||||
* <mo>
|
<mo>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __mo
|
#ifndef __mo
|
||||||
#define __mo
|
#define __mo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,77 +1,76 @@
|
||||||
/*
|
/*
|
||||||
* <mo.h>
|
<mo.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2007
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __mo_h
|
#ifndef _mo_h
|
||||||
#define __mo_h
|
#define _mo_h
|
||||||
|
|
||||||
#include "moAlgo.h"
|
#include <moAlgo.h>
|
||||||
#include "moAspirCrit.h"
|
#include <moAspirCrit.h>
|
||||||
#include "moBestImprSelect.h"
|
#include <moBestImprSelect.h>
|
||||||
#include "moComparator.h"
|
#include <moComparator.h>
|
||||||
#include "moCoolingSchedule.h"
|
#include <moCoolingSchedule.h>
|
||||||
#include "moExponentialCoolingSchedule.h"
|
#include <moExponentialCoolingSchedule.h>
|
||||||
#include "moFirstImprSelect.h"
|
#include <moFirstImprSelect.h>
|
||||||
#include "moFitComparator.h"
|
#include <moFitComparator.h>
|
||||||
#include "moFitSolContinue.h"
|
#include <moFitSolContinue.h>
|
||||||
#include "moGenSolContinue.h"
|
#include <moGenSolContinue.h>
|
||||||
#include "moHC.h"
|
#include <moHC.h>
|
||||||
#include "moHCMoveLoopExpl.h"
|
#include <moHCMoveLoopExpl.h>
|
||||||
#include "moILS.h"
|
#include <moILS.h>
|
||||||
#include "moImprBestFitAspirCrit.h"
|
#include <moImprBestFitAspirCrit.h>
|
||||||
#include "moItRandNextMove.h"
|
#include <moItRandNextMove.h>
|
||||||
#include "moLinearCoolingSchedule.h"
|
#include <moLinearCoolingSchedule.h>
|
||||||
#include "moLSCheckPoint.h"
|
#include <moLSCheckPoint.h>
|
||||||
#include "moMoveExpl.h"
|
#include <moMoveExpl.h>
|
||||||
#include "moMove.h"
|
#include <moMove.h>
|
||||||
#include "moMoveIncrEval.h"
|
#include <moMoveIncrEval.h>
|
||||||
#include "moMoveInit.h"
|
#include <moMoveInit.h>
|
||||||
#include "moMoveLoopExpl.h"
|
#include <moMoveLoopExpl.h>
|
||||||
#include "moMoveSelect.h"
|
#include <moMoveSelect.h>
|
||||||
#include "moNextMove.h"
|
#include <moNextMove.h>
|
||||||
#include "moNoAspirCrit.h"
|
#include <moNoAspirCrit.h>
|
||||||
#include "moNoFitImprSolContinue.h"
|
#include <moNoFitImprSolContinue.h>
|
||||||
#include "moRandImprSelect.h"
|
#include <moRandImprSelect.h>
|
||||||
#include "moRandMove.h"
|
#include <moRandMove.h>
|
||||||
#include "moSA.h"
|
#include <moSA.h>
|
||||||
#include "moSimpleMoveTabuList.h"
|
#include <moSimpleMoveTabuList.h>
|
||||||
#include "moSimpleSolutionTabuList.h"
|
#include <moSimpleSolutionTabuList.h>
|
||||||
#include "moSolContinue.h"
|
#include <moSolContinue.h>
|
||||||
#include "moSteadyFitSolContinue.h"
|
#include <moSteadyFitSolContinue.h>
|
||||||
#include "moTabuList.h"
|
#include <moTabuList.h>
|
||||||
#include "moTS.h"
|
#include <moTS.h>
|
||||||
#include "moTSMoveLoopExpl.h"
|
#include <moTSMoveLoopExpl.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,49 @@
|
||||||
/*
|
/*
|
||||||
* <moAlgo.h>
|
<moAlgo.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moAlgo_h
|
#ifndef _moAlgo_h
|
||||||
#define __moAlgo_h
|
#define _moAlgo_h
|
||||||
|
|
||||||
#include <eoOp.h>
|
#include <eoOp.h>
|
||||||
|
|
||||||
//! Description of an algorithm of the paradiseo-mo library
|
//! Description of an algorithm of the paradiseo-mo library
|
||||||
/*!
|
/*!
|
||||||
moHC, moTS and moSA are 3 examples of 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 >
|
template < class EOT > class moAlgo:public eoMonOp < EOT >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moAspirCrit.h>
|
<moAspirCrit.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moAspirCrit_h
|
#ifndef _moAspirCrit_h
|
||||||
#define __moAspirCrit_h
|
#define _moAspirCrit_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -43,20 +42,17 @@
|
||||||
/*!
|
/*!
|
||||||
It is only a description... An object that herits from this class is needed to be used in a moTS.
|
It is only a description... An object that herits from this class is needed to be used in a moTS.
|
||||||
See moNoAspriCrit for example.
|
See moNoAspriCrit for example.
|
||||||
*/
|
*/
|
||||||
template < class M > class moAspirCrit:public eoBF < const M &, const typename
|
template < class M >
|
||||||
M::EOType::Fitness &,
|
class moAspirCrit: public eoBF < const M &, const typename M::EOType::Fitness &, bool >
|
||||||
bool >
|
{
|
||||||
{
|
public:
|
||||||
|
|
||||||
public:
|
//! Procedure which initialises all that needs an aspiration criterion.
|
||||||
//! Procedure which initialises all that needs a aspiration criterion.
|
/*!
|
||||||
/*!
|
It can be possible that this procedure does nothing...
|
||||||
It can be possible that this procedure do nothing...
|
*/
|
||||||
*/
|
virtual void init () = 0;
|
||||||
virtual void
|
};
|
||||||
init () = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,118 +1,117 @@
|
||||||
/*
|
/*
|
||||||
* <moBestImprSelect.h>
|
<moBestImprSelect.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moBestImprSelect_h
|
#ifndef _moBestImprSelect_h
|
||||||
#define __moBestImprSelect_h
|
#define _moBestImprSelect_h
|
||||||
|
|
||||||
#include "moMoveSelect.h"
|
#include <moMoveSelect.h>
|
||||||
|
|
||||||
//! One of the possible moMoveSelect.
|
//! One of the possible moMoveSelect.
|
||||||
/*!
|
/*!
|
||||||
All neighbors are considered, and the movement
|
All neighbors are considered, and the movement
|
||||||
which enables the best improvement is selected.
|
which enables the best improvement is selected.
|
||||||
*/
|
*/
|
||||||
template < class M > class moBestImprSelect:public moMoveSelect < M >
|
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;
|
||||||
|
|
||||||
public:
|
first_time = true;
|
||||||
|
}
|
||||||
//! Alias for the fitness.
|
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
|
||||||
|
|
||||||
//! Procedure which initialise the exploration
|
|
||||||
void init (const Fitness & __fit)
|
|
||||||
{
|
|
||||||
|
|
||||||
first_time = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//!Function that indicates if the current move has not improved the fitness.
|
//!Function that indicates if the current move has not improved the fitness.
|
||||||
/*!
|
/*!
|
||||||
If the given fitness enables an improvment,
|
If the given fitness enables an improvment,
|
||||||
the move (moMove) and the fitness linked to this move are saved.
|
the move (moMove) and the fitness linked to this move are saved.
|
||||||
|
|
||||||
\param __move a move.
|
\param _move a move.
|
||||||
\param __fit a fitness linked to the move.
|
\param _fitness a fitness linked to the move.
|
||||||
\return TRUE if the move does not improve the fitness.
|
\return TRUE if the move does not improve the fitness.
|
||||||
*/
|
*/
|
||||||
bool update (const M & __move, const Fitness & __fit)
|
bool update (const M & _move, const Fitness & _fitness)
|
||||||
{
|
{
|
||||||
|
if ( first_time || (_fitness > best_fitness) )
|
||||||
|
{
|
||||||
|
best_fitness = _fitness;
|
||||||
|
best_move = _move;
|
||||||
|
|
||||||
|
first_time = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (first_time || __fit > best_fit)
|
return true;
|
||||||
{
|
}
|
||||||
|
|
||||||
best_fit = __fit;
|
//! Procedure which saved the best move and fitness.
|
||||||
best_move = __move;
|
/*!
|
||||||
|
\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.");
|
||||||
|
}
|
||||||
|
|
||||||
first_time = false;
|
_move = best_move;
|
||||||
}
|
_fitness = best_fitness;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
private:
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which saved the best move and fitness.
|
//! Allowing to know if at least one move has been generated.
|
||||||
/*!
|
bool first_time;
|
||||||
\param __move the current move (result of the procedure).
|
|
||||||
\param __fit the current fitness (result of the procedure).
|
|
||||||
\throws EmptySelection if no move has improved the fitness.
|
|
||||||
*/
|
|
||||||
void operator () (M & __move, Fitness & __fit) throw (EmptySelection)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!first_time)
|
//! The best move.
|
||||||
{
|
M best_move;
|
||||||
__move = best_move;
|
|
||||||
__fit = best_fit;
|
//! The best fitness.
|
||||||
}
|
Fitness best_fitness;
|
||||||
else
|
};
|
||||||
throw EmptySelection ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Allowing to know if at least one move has been generated.
|
|
||||||
bool first_time;
|
|
||||||
|
|
||||||
//! The best move.
|
|
||||||
M best_move;
|
|
||||||
|
|
||||||
//! The best fitness.
|
|
||||||
Fitness best_fit;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,48 @@
|
||||||
/*
|
/*
|
||||||
* <moComparator.h>
|
<moComparator.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moComparator_h
|
#ifndef _moComparator_h
|
||||||
#define __moComparator_h
|
#define _moComparator_h
|
||||||
|
|
||||||
|
|
||||||
//! Template for classes which need to compare two EOT and indicate if the first is "better" than the second.
|
//! 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.
|
The objects that extend this template describe how an EOT is "better" than an other.
|
||||||
*/
|
*/
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class moComparator: public eoBF<const EOT&, const EOT&, bool>
|
class moComparator: public eoBF<const EOT &, const EOT &, bool>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moCoolingSchedule.h>
|
<moCoolingSchedule.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moCoolingSchedule_h
|
#ifndef _moCoolingSchedule_h
|
||||||
#define __moCoolingSchedule_h
|
#define _moCoolingSchedule_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -44,7 +43,7 @@
|
||||||
It is only a description... An object that herits from this class is needed to be used in a moSA.
|
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.
|
See moExponentialCoolingSchedule or moLinearCoolingSchedule for example.
|
||||||
*/
|
*/
|
||||||
class moCoolingSchedule:public eoUF < double &, bool >
|
class moCoolingSchedule : public eoUF < double &, bool >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,79 @@
|
||||||
/*
|
/*
|
||||||
* <moExponentialCoolingSchedule.h>
|
<moExponentialCoolingSchedule.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moExponentialCoolingSchedule_h
|
#ifndef _moExponentialCoolingSchedule_h
|
||||||
#define __moExponentialCoolingSchedule_h
|
#define _moExponentialCoolingSchedule_h
|
||||||
|
|
||||||
#include "moCoolingSchedule.h"
|
#include <moCoolingSchedule.h>
|
||||||
|
|
||||||
//! One of the possible moCoolingSchedule
|
//! One of the possible moCoolingSchedule
|
||||||
/*!
|
/*!
|
||||||
An other very simple cooling schedule, the temperature decrease according to a ratio while
|
An other very simple cooling schedule, the temperature decrease according to a ratio while
|
||||||
the temperature is greater than a given threshold.
|
the temperature is greater than a given threshold.
|
||||||
*/
|
*/
|
||||||
class moExponentialCoolingSchedule: public moCoolingSchedule
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
private:
|
||||||
//! Simple constructor
|
|
||||||
/*!
|
//! The temperature threhold.
|
||||||
\param __threshold the threshold.
|
double threshold;
|
||||||
\param __ratio the ratio used to descrease the temperature.
|
|
||||||
*/
|
//! The decreasing factor of the temperature.
|
||||||
moExponentialCoolingSchedule (double __threshold, double __ratio):threshold (__threshold), ratio (__ratio)
|
double ratio;
|
||||||
{}
|
};
|
||||||
|
|
||||||
//! Function which proceeds to the cooling.
|
|
||||||
/*!
|
|
||||||
It decreases the temperature and indicates if it is greater than the threshold.
|
|
||||||
|
|
||||||
\param __temp the current temperature.
|
|
||||||
\return if the new temperature (current temperature * ratio) is greater than the threshold.
|
|
||||||
*/
|
|
||||||
bool operator() (double &__temp)
|
|
||||||
{
|
|
||||||
return (__temp *= ratio) > threshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! The temperature threhold.
|
|
||||||
double threshold;
|
|
||||||
|
|
||||||
//! The decreasing factor of the temperature.
|
|
||||||
double ratio;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,42 @@
|
||||||
/*
|
/*
|
||||||
* <moFirstImprSelect.h>
|
<moFirstImprSelect.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moFirstImprSelect_h
|
#ifndef _moFirstImprSelect_h
|
||||||
#define __moFirstImprSelect_h
|
#define _moFirstImprSelect_h
|
||||||
|
|
||||||
#include "moMoveSelect.h"
|
#include <moMoveSelect.h>
|
||||||
|
|
||||||
//! One possible moMoveSelect.
|
//! One possible moMoveSelect.
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -45,85 +44,77 @@
|
||||||
a move enables an improvment of the
|
a move enables an improvment of the
|
||||||
current solution.
|
current solution.
|
||||||
*/
|
*/
|
||||||
template < class M > class moFirstImprSelect:public moMoveSelect < M >
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
if (_fitness > initial_fitness)
|
||||||
|
{
|
||||||
|
|
||||||
//! Alias for the fitness.
|
best_fitness = _fitness;
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
best_move = _move;
|
||||||
|
valid = true;
|
||||||
|
|
||||||
//! Procedure which initialise the exploration.
|
return false;
|
||||||
/*!
|
}
|
||||||
It save the current fitness as the initial value for the fitness.
|
|
||||||
*/
|
|
||||||
virtual void init (const Fitness & __fit)
|
|
||||||
{
|
|
||||||
|
|
||||||
valid = false;
|
return true;
|
||||||
init_fit = __fit;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//! 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//!Function that indicates if the current move has not improved the fitness.
|
private:
|
||||||
/*!
|
|
||||||
If the given fitness enables an improvment,
|
//! Allow to know if at least one move has improved the solution.
|
||||||
the move (moMove) should be applied to the current solution.
|
bool valid;
|
||||||
|
|
||||||
\param __move a move.
|
//! Best stored movement.
|
||||||
\param __fit a fitness linked to the move.
|
M best_move;
|
||||||
\return TRUE if the move does not improve the fitness.
|
|
||||||
*/
|
|
||||||
bool update (const M & __move, const typename M::EOType::Fitness & __fit)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (__fit > init_fit)
|
//! Initial fitness.
|
||||||
{
|
Fitness initial_fitness;
|
||||||
|
|
||||||
best_fit = __fit;
|
//! Best stored fitness.
|
||||||
best_move = __move;
|
Fitness best_fitness;
|
||||||
valid = true;
|
};
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which saved the best move and fitness.
|
|
||||||
/*!
|
|
||||||
\param __move the current move (result of the procedure).
|
|
||||||
\param __fit the current fitness (result of the procedure).
|
|
||||||
\throws EmptySelection if no move has improved the fitness.
|
|
||||||
*/
|
|
||||||
void operator () (M & __move, Fitness & __fit) throw (EmptySelection)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (valid)
|
|
||||||
{
|
|
||||||
__move = best_move;
|
|
||||||
__fit = best_fit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw EmptySelection ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Allow to know if at least one move has improved the solution.
|
|
||||||
bool valid;
|
|
||||||
|
|
||||||
//! Best stored movement.
|
|
||||||
M best_move;
|
|
||||||
|
|
||||||
//! Initial fitness.
|
|
||||||
Fitness init_fit;
|
|
||||||
|
|
||||||
//! Best stored fitness.
|
|
||||||
Fitness best_fit;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1,62 @@
|
||||||
/*
|
/*
|
||||||
* <moFitComparator.h>
|
<moFitComparator.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moFitComparator_h
|
#ifndef _moFitComparator_h
|
||||||
#define __moFitComparator_h
|
#define _moFitComparator_h
|
||||||
|
|
||||||
|
#include <moComparator.h>
|
||||||
|
|
||||||
//! Comparison according to the fitness.
|
//! Comparison according to the fitness.
|
||||||
/*!
|
/*!
|
||||||
An EOT is better than an other if its fitness is better.
|
An EOT is better than an other if its fitness is better.
|
||||||
*/
|
*/
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class moFitComparator: public moComparator<EOT>
|
class moFitComparator: public moComparator<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Function which makes the comparison and gives the result.
|
//! Function which makes the comparison and gives the result.
|
||||||
/*!
|
/*!
|
||||||
\param _solution1 The first solution.
|
\param _solution1 The first solution.
|
||||||
\param _solution2 The second solution.
|
\param _solution2 The second solution.
|
||||||
\return true if the fitness of the first solution is better than the second solution, false else.
|
\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)
|
bool operator()(const EOT & _solution1, const EOT & _solution2)
|
||||||
{
|
{
|
||||||
return _solution1.fitness()>_solution2.fitness();
|
return _solution1.fitness() > _solution2.fitness();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,91 +1,90 @@
|
||||||
/*
|
/*
|
||||||
* <moFitSolContinue.h>
|
<moFitSolContinue.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moFitSolContinue_h
|
#ifndef _moFitSolContinue_h
|
||||||
#define __moFitSolContinue_h
|
#define _moFitSolContinue_h
|
||||||
|
|
||||||
#include "moSolContinue.h"
|
#include <moSolContinue.h>
|
||||||
|
|
||||||
//! One possible stop criterion for a solution-based heuristic.
|
//! One possible stop criterion for a solution-based heuristic.
|
||||||
/*!
|
/*!
|
||||||
The stop criterion corresponds to a fitness threshold gained.
|
The stop criterion corresponds to a fitness threshold gained.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moFitSolContinue:public moSolContinue < EOT >
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
return fitness > _solution.fitness();
|
||||||
|
}
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Procedure which allows to initialise all the stuff needed.
|
||||||
typedef typename EOT::Fitness Fitness;
|
/*!
|
||||||
|
It can be also used to reinitialize all the needed things.
|
||||||
|
*/
|
||||||
|
void init ()
|
||||||
|
{}
|
||||||
|
|
||||||
//! Basic constructor.
|
private:
|
||||||
/*!
|
|
||||||
\param __fitness The fitness to reach.
|
|
||||||
*/
|
|
||||||
moFitSolContinue (Fitness __fitness): fitness (__fitness)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Function that activates the stopping criterion.
|
//! Fitness target.
|
||||||
/*!
|
Fitness fitness;
|
||||||
Indicates if the fitness threshold has not yet been reached.
|
};
|
||||||
|
|
||||||
\param __sol the current solution.
|
|
||||||
\return true or false according to the value of the fitness.
|
|
||||||
*/
|
|
||||||
bool operator () (const EOT & __sol)
|
|
||||||
{
|
|
||||||
if (__sol.invalid())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return __sol.fitness() < fitness;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which allows to initialise all the stuff needed.
|
|
||||||
/*!
|
|
||||||
It can be also used to reinitialize all the needed things.
|
|
||||||
*/
|
|
||||||
void init ()
|
|
||||||
{}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Fitness target.
|
|
||||||
Fitness fitness;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,92 +1,92 @@
|
||||||
/*
|
/*
|
||||||
* <moGenSolContinue.h>
|
<moGenSolContinue.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moGenSolContinue_h
|
#ifndef _moGenSolContinue_h
|
||||||
#define __moGenSolContinue_h
|
#define _moGenSolContinue_h
|
||||||
|
|
||||||
#include "moSolContinue.h"
|
#include "moSolContinue.h"
|
||||||
|
|
||||||
//! One possible stop criterion for a solution-based heuristic.
|
//! One possible stop criterion for a solution-based heuristic.
|
||||||
/*!
|
/*!
|
||||||
The stop criterion corresponds to a maximum number of iteration.
|
The stop criterion corresponds to a maximum number of iteration.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moGenSolContinue:public moSolContinue < EOT >
|
template < class EOT >
|
||||||
{
|
class moGenSolContinue:public moSolContinue < EOT >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
//! Simple constructor.
|
||||||
|
/*!
|
||||||
//! Simple constructor.
|
\param _generationMaximumNumber The maximum number of generations.
|
||||||
/*!
|
*/
|
||||||
\param __maxNumGen the maximum number of generation.
|
moGenSolContinue (unsigned int _generationMaximumNumber): generationMaximumNumber(_generationMaximumNumber), generationNumber(0)
|
||||||
*/
|
|
||||||
moGenSolContinue (unsigned int __maxNumGen):maxNumGen (__maxNumGen), numGen (0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Function that activates the stop criterion.
|
//! Function that activates the stop criterion.
|
||||||
/*!
|
/*!
|
||||||
Increments the counter and returns TRUE if the
|
Increments the counter and returns TRUE if the
|
||||||
current number of iteration is lower than the given
|
current number of iteration is lower than the given
|
||||||
maximum number of iterations.
|
maximum number of iterations.
|
||||||
|
|
||||||
\param __sol the current solution.
|
\param _solution The current solution.
|
||||||
\return TRUE or FALSE according to the current generation number.
|
\return true or false according to the current generation number.
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & _solution)
|
||||||
{
|
{
|
||||||
|
//code only used for avoiding warning because _sol is not used in this function.
|
||||||
|
EOT solution=(EOT)_solution;
|
||||||
|
|
||||||
return (++numGen < maxNumGen);
|
return (++generationNumber < generationMaximumNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Procedure which allows to initialise the generation counter.
|
//! Procedure which allows to initialise the generation counter.
|
||||||
/*!
|
/*!
|
||||||
It can also be used to reset the iteration counter.
|
It can also be used to reset the iteration counter.
|
||||||
*/
|
*/
|
||||||
void init ()
|
void init ()
|
||||||
{
|
{
|
||||||
|
generationNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
numGen = 0;
|
private:
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
//! Iteration maximum number.
|
||||||
|
unsigned int generationMaximumNumber;
|
||||||
|
|
||||||
//! Iteration maximum number.
|
//! Iteration current number.
|
||||||
unsigned int maxNumGen;
|
unsigned int generationNumber;
|
||||||
|
};
|
||||||
//! Iteration current number.
|
|
||||||
unsigned int numGen;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,36 @@
|
||||||
/*
|
/*
|
||||||
* <moHC.h>
|
<moHC.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moHC_h
|
#ifndef __moHC_h
|
||||||
|
|
@ -39,115 +38,87 @@
|
||||||
|
|
||||||
#include <eoEvalFunc.h>
|
#include <eoEvalFunc.h>
|
||||||
|
|
||||||
#include "moAlgo.h"
|
#include <moAlgo.h>
|
||||||
#include "moMoveExpl.h"
|
#include <moHCMoveLoopExpl.h>
|
||||||
#include "moHCMoveLoopExpl.h"
|
|
||||||
|
|
||||||
//! Hill Climbing (HC)
|
//! Hill Climbing (HC)
|
||||||
/*!
|
/*!
|
||||||
Class which describes the algorithm for a hill climbing.
|
Class which describes the algorithm for a hill climbing.
|
||||||
*/
|
*/
|
||||||
template < class M > class moHC:public moAlgo < typename M::EOType >
|
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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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;
|
||||||
|
}
|
||||||
|
|
||||||
//! Alias for the type.
|
private:
|
||||||
typedef
|
|
||||||
typename
|
|
||||||
M::EOType
|
|
||||||
EOT;
|
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Complete exploration of the neighborhood.
|
||||||
typedef
|
moMoveExpl < M > & move_explorer;
|
||||||
typename
|
|
||||||
EOT::Fitness
|
|
||||||
Fitness;
|
|
||||||
|
|
||||||
public:
|
//! A full evaluation function.
|
||||||
|
eoEvalFunc < EOT > & full_evaluation;
|
||||||
//! Full constructor.
|
};
|
||||||
/*!
|
|
||||||
All the boxes are given in order the HC to use a moHCMoveLoopExpl.
|
|
||||||
|
|
||||||
\param __move_init a move initialiser.
|
|
||||||
\param __next_move a neighborhood explorer.
|
|
||||||
\param __incr_eval a (generally) efficient evaluation function.
|
|
||||||
\param __move_select a move selector.
|
|
||||||
\param __full_eval a full evaluation function.
|
|
||||||
*/
|
|
||||||
moHC (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select, eoEvalFunc < EOT > &__full_eval):move_expl (*new moHCMoveLoopExpl < M >
|
|
||||||
(__move_init, __next_move, __incr_eval, __move_select)),
|
|
||||||
full_eval (__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Light constructor.
|
|
||||||
/*!
|
|
||||||
This constructor allow to use another moMoveExpl (generally not a moHCMoveLoopExpl).
|
|
||||||
|
|
||||||
\param __move_expl a complete explorer.
|
|
||||||
\param __full_eval a full evaluation function.
|
|
||||||
*/
|
|
||||||
moHC (moMoveExpl < M > &__move_expl, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
|
||||||
full_eval
|
|
||||||
(__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Function which launches the HC
|
|
||||||
/*!
|
|
||||||
The HC has to improve a current solution.
|
|
||||||
As the moSA and the mo TS, it can be used for HYBRIDATION in an evolutionnary algorithm.
|
|
||||||
|
|
||||||
\param __sol a current solution to improve.
|
|
||||||
\return TRUE.
|
|
||||||
*/
|
|
||||||
bool operator ()(EOT & __sol)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (__sol.invalid ())
|
|
||||||
{
|
|
||||||
full_eval (__sol);
|
|
||||||
}
|
|
||||||
|
|
||||||
EOT new_sol;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
new_sol = __sol;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
move_expl (__sol, new_sol);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (EmptySelection & __ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_sol.fitness () > __sol.fitness ())
|
|
||||||
{
|
|
||||||
__sol = new_sol;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
while (true);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Complete exploration of the neighborhood.
|
|
||||||
moMoveExpl < M > &move_expl;
|
|
||||||
|
|
||||||
//! A full evaluation function.
|
|
||||||
eoEvalFunc < EOT > &full_eval;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,131 +1,138 @@
|
||||||
/*
|
/*
|
||||||
* <moHCMoveLoopExpl.h>
|
<moHCMoveLoopExpl.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moHCMoveLoopExpl_h
|
#ifndef __moHCMoveLoopExpl_h
|
||||||
#define __moHCMoveLoopExpl_h
|
#define __moHCMoveLoopExpl_h
|
||||||
|
|
||||||
#include "moMoveLoopExpl.h"
|
#include <moMoveLoopExpl.h>
|
||||||
|
#include <moMoveInit.h>
|
||||||
#include "moMoveInit.h"
|
#include <moNextMove.h>
|
||||||
#include "moNextMove.h"
|
#include <moMoveIncrEval.h>
|
||||||
#include "moMoveIncrEval.h"
|
#include <moMoveSelect.h>
|
||||||
#include "moMoveSelect.h"
|
|
||||||
|
|
||||||
//! Iterative explorer used by a moHC.
|
//! Iterative explorer used by a moHC.
|
||||||
template < class M > class moHCMoveLoopExpl:public moMoveLoopExpl < M >
|
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;
|
||||||
|
|
||||||
//! Alias for the type.
|
if( _old_solution.invalid() )
|
||||||
typedef typename M::EOType EOT;
|
{
|
||||||
|
throw std::runtime_error("[moHCMoveLoopExpl.h]: The current solution has not been evaluated.");
|
||||||
|
}
|
||||||
|
|
||||||
//! Alias for the fitness.
|
/*
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
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;
|
||||||
|
|
||||||
public:
|
//At the begining, the new sol is equivalent to the old one.
|
||||||
|
_new_solution=(EOT)_old_solution;
|
||||||
|
|
||||||
//! Constructor.
|
// Restarting the exploration of the neighbourhood
|
||||||
/*!
|
move_initializer(move, _old_solution);
|
||||||
All the boxes have to be specified.
|
|
||||||
|
|
||||||
\param __move_init the move initialiser.
|
move_selection.init(_old_solution.fitness ());
|
||||||
\param __next_move the neighborhood explorer.
|
|
||||||
\param __incr_eval (generally) efficient evaluation function.
|
|
||||||
\param __move_select the move selector.
|
|
||||||
*/
|
|
||||||
moHCMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moMoveSelect < M > &__move_select):
|
|
||||||
|
|
||||||
move_init (__move_init),
|
do
|
||||||
next_move (__next_move),
|
{
|
||||||
incr_eval (__incr_eval), move_select (__move_select)
|
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);
|
||||||
|
|
||||||
//! Procedure which launches the explorer.
|
//The selecter gives the value of the best move and the corresponding best fitness.
|
||||||
/*!
|
move_selection (best_move, best_fitness);
|
||||||
The exploration starts from an old solution and provides a new solution.
|
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
\param __old_sol the current solution.
|
private:
|
||||||
\param __new_sol the new_sol (result of the procedure).
|
|
||||||
*/
|
|
||||||
void operator () (const EOT & __old_sol, EOT & __new_sol)
|
|
||||||
{
|
|
||||||
|
|
||||||
M move;
|
//! Move initialiser.
|
||||||
|
moMoveInit < M > & move_initializer;
|
||||||
|
|
||||||
//
|
//! Neighborhood explorer.
|
||||||
move_init (move, __old_sol); /* Restarting the exploration of
|
moNextMove < M > & next_move_generator;
|
||||||
of the neighborhood ! */
|
|
||||||
|
|
||||||
move_select.init (__old_sol.fitness ());
|
//! (generally) Efficient evaluation.
|
||||||
|
moMoveIncrEval < M > & incremental_evaluation;
|
||||||
|
|
||||||
while (move_select.update (move, incr_eval (move, __old_sol))
|
//! Move selector.
|
||||||
&& next_move (move, __old_sol));
|
moMoveSelect < M > & move_selection;
|
||||||
|
};
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
M best_move;
|
|
||||||
|
|
||||||
Fitness best_move_fit;
|
|
||||||
|
|
||||||
move_select (best_move, best_move_fit);
|
|
||||||
best_move (__new_sol);
|
|
||||||
__new_sol.fitness (best_move_fit);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (EmptySelection & __ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
// ?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Move initialiser.
|
|
||||||
moMoveInit < M > &move_init;
|
|
||||||
|
|
||||||
//! Neighborhood explorer.
|
|
||||||
moNextMove < M > &next_move;
|
|
||||||
|
|
||||||
//! (generally) Efficient evaluation.
|
|
||||||
moMoveIncrEval < M > &incr_eval;
|
|
||||||
|
|
||||||
//! Move selector.
|
|
||||||
moMoveSelect < M > &move_select;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,203 +1,205 @@
|
||||||
/*
|
/*
|
||||||
* <moILS.h>
|
<moILS.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moILS_h
|
#ifndef _moILS_h
|
||||||
#define __moILS_h
|
#define _moILS_h
|
||||||
|
|
||||||
#include <eoEvalFunc.h>
|
#include <eoEvalFunc.h>
|
||||||
|
|
||||||
#include "moHC.h"
|
#include <moHC.h>
|
||||||
#include "moTS.h"
|
#include <moTS.h>
|
||||||
#include "moSA.h"
|
#include <moSA.h>
|
||||||
|
|
||||||
//! Iterated Local Search (ILS)
|
//! Iterated Local Search (ILS)
|
||||||
/*!
|
/*!
|
||||||
Class which describes the algorithm for a iterated local search.
|
Class which describes the algorithm for a iterated local search.
|
||||||
*/
|
*/
|
||||||
template < class M > class moILS:public moAlgo < typename M::EOType >
|
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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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=_solution;
|
||||||
|
|
||||||
//! Alias for the type.
|
continu.init ();
|
||||||
typedef typename M::EOType EOT;
|
|
||||||
|
|
||||||
//! Alias for the fitness.
|
// some code has been duplicated in order to avoid one perturbation and one evaluation without adding a test in the loop.
|
||||||
typedef typename EOT::Fitness Fitness;
|
// better than a do {} while; with a test in the loop.
|
||||||
|
|
||||||
|
algorithm(_solution);
|
||||||
|
|
||||||
public:
|
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||||
|
{
|
||||||
|
_solution_saved=_solution;
|
||||||
|
|
||||||
//! Generic constructor
|
}
|
||||||
/*!
|
else
|
||||||
Generic constructor using a moAlgo
|
{
|
||||||
|
_solution=_solution_saved;
|
||||||
|
}
|
||||||
|
|
||||||
\param __algo The solution based heuristic to use.
|
while ( continu (_solution) )
|
||||||
\param __continue The stopping criterion.
|
{
|
||||||
\param __acceptance_criterion The acceptance criterion.
|
perturbation(_solution);
|
||||||
\param __perturbation The pertubation generator.
|
full_evaluation(_solution);
|
||||||
\param __full_eval The evaluation function.
|
|
||||||
*/
|
|
||||||
moILS (moAlgo<EOT> &__algo, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion, eoMonOp<EOT> &__perturbation,
|
|
||||||
eoEvalFunc<EOT> &__full_eval):
|
|
||||||
algo(__algo), cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Constructor for using a moHC for the moAlgo
|
algorithm(_solution);
|
||||||
/*!
|
|
||||||
\param __move_init The move initialisation (for the moHC).
|
|
||||||
\param __next_move The move generator (for the moHC).
|
|
||||||
\param __incr_eval The partial evaluation function (for the moHC).
|
|
||||||
\param __move_select 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_eval The evaluation function.
|
|
||||||
*/
|
|
||||||
moILS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval,
|
|
||||||
moMoveSelect < M > &__move_select, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion,
|
|
||||||
eoMonOp<EOT> &__perturbation, eoEvalFunc<EOT> &__full_eval):
|
|
||||||
algo(*new moHC<M>(__move_init, __next_move, __incr_eval, __move_select, __full_eval)), cont(__continue),
|
|
||||||
acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Constructor for using a moTS for the moAlgo
|
if ( acceptance_criterion(_solution, _solution_saved) )
|
||||||
/*!
|
{
|
||||||
\param __move_init The move initialisation (for the moTS).
|
_solution_saved=_solution;
|
||||||
\param __next_move The move generator (for the moTS).
|
}
|
||||||
\param __incr_eval The partial evaluation function (for the moTS).
|
else
|
||||||
\param __tabu_list The tabu list (for the moTS !!!!).
|
{
|
||||||
\param __aspir_crit The aspiration criterion (for the moTS).
|
_solution=_solution_saved;
|
||||||
\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_eval The evaluation function.
|
|
||||||
*/
|
|
||||||
moILS (moMoveInit <M> &__move_init, moNextMove <M> &__next_move, moMoveIncrEval <M> &__incr_eval,
|
|
||||||
moTabuList <M> &__tabu_list, moAspirCrit <M> &__aspir_crit, moSolContinue <EOT> &__moTS_continue,
|
|
||||||
moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion, eoMonOp<EOT> &__perturbation,
|
|
||||||
eoEvalFunc<EOT> &__full_eval):
|
|
||||||
algo(*new moTS<M>(__move_init, __next_move, __incr_eval, __tabu_list, __aspir_crit, __moTS_continue, __full_eval)),
|
|
||||||
cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Constructor for using a moSA for the moAlgo
|
return true;
|
||||||
/*!
|
}
|
||||||
\param __move_rand The random move generator (for the moSA).
|
|
||||||
\param __incr_eval The partial evaluation function (for the moSA).
|
|
||||||
\param __moSA_continue The stopping criterion (for the moSA).
|
|
||||||
\param __init_temp The initial temperature (for the moSA).
|
|
||||||
\param __cool_sched The cooling scheduler (for the moSA).
|
|
||||||
\param __continue The stopping criterion.
|
|
||||||
\param __acceptance_criterion The acceptance criterion.
|
|
||||||
\param __perturbation The pertubation generator.
|
|
||||||
\param __full_eval The evaluation function.
|
|
||||||
*/
|
|
||||||
moILS (moRandMove<M> &__move_rand, moMoveIncrEval <M> &__incr_eval, moSolContinue <EOT> &__moSA_continue, double __init_temp,
|
|
||||||
moCoolingSchedule & __cool_sched, moSolContinue <EOT> &__continue, moComparator<EOT> &__acceptance_criterion,
|
|
||||||
eoMonOp<EOT> &__perturbation, eoEvalFunc<EOT> &__full_eval):
|
|
||||||
algo(*new moSA<M>(__move_rand, __incr_eval, __moSA_continue, __init_temp, __cool_sched, __full_eval)),
|
|
||||||
cont(__continue), acceptance_criterion(__acceptance_criterion), perturbation(__perturbation), full_eval(__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//! The solution based heuristic.
|
||||||
|
moAlgo<EOT> & algorithm;
|
||||||
|
|
||||||
//! Function which launches the ILS
|
//! The stopping criterion.
|
||||||
/*!
|
moSolContinue<EOT> & continu;
|
||||||
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 __sol a current solution to improve.
|
//! The acceptance criterion.
|
||||||
\return TRUE.
|
moComparator<EOT> & acceptance_criterion;
|
||||||
*/
|
|
||||||
bool operator()(EOT & __sol)
|
|
||||||
{
|
|
||||||
EOT __sol_saved=__sol;
|
|
||||||
|
|
||||||
cont.init ();
|
//! The perturbation generator
|
||||||
|
eoMonOp<EOT> & perturbation;
|
||||||
|
|
||||||
//some code has been duplicated in order to avoid one perturbation and one evaluation without adding a test in the loop.
|
//! The full evaluation function
|
||||||
// better than a do {} while; with a test in the loop.
|
eoEvalFunc<EOT> & full_evaluation;
|
||||||
|
};
|
||||||
algo(__sol);
|
|
||||||
|
|
||||||
if (acceptance_criterion(__sol, __sol_saved))
|
|
||||||
{
|
|
||||||
__sol_saved=__sol;
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__sol=__sol_saved;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (cont (__sol))
|
|
||||||
{
|
|
||||||
perturbation(__sol);
|
|
||||||
full_eval(__sol);
|
|
||||||
|
|
||||||
algo(__sol);
|
|
||||||
|
|
||||||
if (acceptance_criterion(__sol, __sol_saved))
|
|
||||||
{
|
|
||||||
__sol_saved=__sol;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
__sol=__sol_saved;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! The solution based heuristic.
|
|
||||||
moAlgo<EOT> &algo;
|
|
||||||
|
|
||||||
//! The stopping criterion.
|
|
||||||
moSolContinue<EOT> &cont;
|
|
||||||
|
|
||||||
//! The acceptance criterion.
|
|
||||||
moComparator<EOT> &acceptance_criterion;
|
|
||||||
|
|
||||||
//! The perturbation generator
|
|
||||||
eoMonOp<EOT> &perturbation;
|
|
||||||
|
|
||||||
//! The full evaluation function
|
|
||||||
eoEvalFunc<EOT> &full_eval;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,109 +1,104 @@
|
||||||
/*
|
/*
|
||||||
* <moImprBestFitAspirCrit.h>
|
<moImprBestFitAspirCrit.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moImprBestFitAspirCrit_h
|
#ifndef _moImprBestFitAspirCrit_h
|
||||||
#define __moImprBestFitAspirCrit_h
|
#define _moImprBestFitAspirCrit_h
|
||||||
|
|
||||||
#include "moAspirCrit.h"
|
#include <moAspirCrit.h>
|
||||||
|
|
||||||
//! One of the possible moAspirCrit
|
//! One of the possible moAspirCrit
|
||||||
/*!
|
/*!
|
||||||
This criterion is satisfied when a given fitness
|
This criterion is satisfied when a given fitness
|
||||||
is the best ever considered.
|
is the best ever considered.
|
||||||
*/
|
*/
|
||||||
template < class M > class moImprBestFitAspirCrit:public moAspirCrit < M >
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
//! 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.
|
||||||
|
|
||||||
//! Alias for the fitness
|
\param _move A move.
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
\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)
|
||||||
|
{
|
||||||
|
if (first_time)
|
||||||
|
{
|
||||||
|
best_fitness = _fitness;
|
||||||
|
first_time = false;
|
||||||
|
|
||||||
//! Contructor
|
return true;
|
||||||
moImprBestFitAspirCrit ()
|
}
|
||||||
{
|
|
||||||
|
|
||||||
first_time = true;
|
if (_fitness < best_fitness)
|
||||||
}
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
best_fitness = _fitness;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//! Initialisation procedure
|
private:
|
||||||
void init ()
|
|
||||||
{
|
|
||||||
|
|
||||||
first_time = true;
|
//! Best fitness found until now
|
||||||
}
|
Fitness best_fitness;
|
||||||
|
|
||||||
//! Function that indicates if the fit is better that the already saved fit
|
//! Indicates that a fitness has been already saved or not
|
||||||
/*!
|
bool first_time;
|
||||||
The first time, the function only saved the current move and fitness.
|
};
|
||||||
|
|
||||||
\param __move a move.
|
|
||||||
\param __fit a fitnes linked to the move.
|
|
||||||
\return TRUE the first time and if __fit > best_fit, else FALSE.
|
|
||||||
*/
|
|
||||||
bool operator () (const M & __move, const Fitness & __fit)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (first_time)
|
|
||||||
{
|
|
||||||
|
|
||||||
best_fit = __fit;
|
|
||||||
first_time = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (__fit < best_fit)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
best_fit = __fit;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Best fitness found until now
|
|
||||||
Fitness best_fit;
|
|
||||||
|
|
||||||
//! Indicates that a fitness has been already saved or not
|
|
||||||
bool first_time;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,107 +1,102 @@
|
||||||
/*
|
/*
|
||||||
* <moItRandNextMove.h>
|
<moItRandNextMove.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moItRandNextMove_h
|
#ifndef _moItRandNextMove_h
|
||||||
#define __moItRandNextMove_h
|
#define _moItRandNextMove_h
|
||||||
|
|
||||||
#include "moNextMove.h"
|
#include <moNextMove.h>
|
||||||
#include "moRandMove.h"
|
#include <moRandMove.h>
|
||||||
|
|
||||||
//! One of the possible moNextMove.
|
//! One of the possible moNextMove.
|
||||||
/*!
|
/*!
|
||||||
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
This class is a move (moMove) generator with a bound for the maximum number of iterations.
|
||||||
*/
|
*/
|
||||||
template < class M > class moItRandNextMove:public moNextMove < M >
|
template < class M >
|
||||||
{
|
class moItRandNextMove:public moNextMove < M >
|
||||||
|
{
|
||||||
|
//! Alias for the type.
|
||||||
|
typedef typename M::EOType EOT;
|
||||||
|
|
||||||
//! Alias for the type.
|
public:
|
||||||
typedef typename M::EOType EOT;
|
|
||||||
|
|
||||||
public:
|
//! The constructor.
|
||||||
|
/*!
|
||||||
|
Parameters only for initialising the attributes.
|
||||||
|
|
||||||
//! The constructor.
|
\param _random_move_generator The random move generator.
|
||||||
/*!
|
\param _iteration_maximum_number The iteration maximum number.
|
||||||
Parameters only for initialising the attributes.
|
*/
|
||||||
|
moItRandNextMove (moRandMove < M > & _random_move_generator, unsigned int _iteration_maximum_number):
|
||||||
\param __rand_move the random move generator.
|
random_move_generator(_random_move_generator), iteration_maximum_number(_iteration_maximum_number), iteration_number(0)
|
||||||
\param __max_iter the iteration maximum number.
|
|
||||||
*/
|
|
||||||
moItRandNextMove (moRandMove < M > &__rand_move,
|
|
||||||
unsigned int __max_iter):rand_move (__rand_move),
|
|
||||||
max_iter (__max_iter), num_iter (0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Generation of a new move
|
//! Generation of a new move
|
||||||
/*!
|
/*!
|
||||||
If the maximum number is not already reached, the current move is forgotten and remplaced by another one.
|
If the maximum number is not already reached, the current move is forgotten and remplaced by another one.
|
||||||
|
|
||||||
\param __move the current move.
|
\param _move the current move.
|
||||||
\param __sol the current solution.
|
\param _solution the current solution.
|
||||||
\return FALSE if the maximum number of iteration is reached, else TRUE.
|
\return false if the maximum number of iteration is reached, else true.
|
||||||
*/
|
*/
|
||||||
bool operator () (M & __move, const EOT & __sol)
|
bool operator () (M & _move, const EOT & _solution)
|
||||||
{
|
{
|
||||||
|
//code only used to avoid warning because _solution is not used in this function.
|
||||||
|
EOT solution=(EOT)_solution;
|
||||||
|
|
||||||
|
if (iteration_number++ > iteration_maximum_number)
|
||||||
|
{
|
||||||
|
iteration_number = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
random_move_generator (_move);
|
||||||
|
iteration_number++;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (num_iter++ > max_iter)
|
private:
|
||||||
{
|
|
||||||
|
|
||||||
num_iter = 0;
|
//! A move generator (generally randomly).
|
||||||
return false;
|
moRandMove < M > & random_move_generator;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
/* The given solution is discarded here */
|
//! Iteration maximum number.
|
||||||
rand_move (__move);
|
unsigned int iteration_maximum_number;
|
||||||
num_iter++;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
//! Iteration current number.
|
||||||
|
unsigned int iteration_number;
|
||||||
//! A move generator (generally randomly).
|
};
|
||||||
moRandMove < M > &rand_move;
|
|
||||||
|
|
||||||
//! Iteration maximum number.
|
|
||||||
unsigned int max_iter;
|
|
||||||
|
|
||||||
//! Iteration current number.
|
|
||||||
unsigned int num_iter;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moLSCheckPoint.h>
|
<moLSCheckPoint.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSolUpdater_h
|
#ifndef _moLSCheckPoint_h
|
||||||
#define __moSolUpdater_h
|
#define _moLSCheckPoint_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -43,49 +42,42 @@
|
||||||
/*!
|
/*!
|
||||||
Thanks to this class, at each iteration, additionnal function can be used (and not only one).
|
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
|
template < class M >
|
||||||
M::EOType &, void >
|
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;
|
||||||
public:
|
|
||||||
//! Function which launches the checkpointing
|
for (i = 0; i < functions.size (); i++)
|
||||||
/*!
|
|
||||||
Each saved function is used on the current move and the current solution.
|
|
||||||
|
|
||||||
\param __move a move.
|
|
||||||
\param __sol a solution.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
operator () (const M & __move, const typename M::EOType & __sol)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < func.size (); i++)
|
|
||||||
{
|
|
||||||
func[i]->operator ()(__move, __sol);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which add a new function to the function vector
|
|
||||||
/*!
|
|
||||||
The new function is added at the end of the vector.
|
|
||||||
\param __f a new function to add.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
add (eoBF < const M &, const typename M::EOType &, void >&__f)
|
|
||||||
{
|
{
|
||||||
|
functions[i]->operator ()(_move, _solution);
|
||||||
func.push_back (&__f);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
//! 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 function
|
//! Vector of functions.
|
||||||
std::vector < eoBF < const
|
std::vector < eoBF < const M &, const typename M::EOType &, void >*> functions;
|
||||||
M &, const
|
};
|
||||||
typename
|
|
||||||
M::EOType &, void >*>
|
|
||||||
func;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,80 +1,79 @@
|
||||||
/*
|
/*
|
||||||
* <moLinearCoolingSchedule.h>
|
<moLinearCoolingSchedule.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moLinearCoolingSchedule_h
|
#ifndef _moLinearCoolingSchedule_h
|
||||||
#define __moLinearCoolingSchedule_h
|
#define _moLinearCoolingSchedule_h
|
||||||
|
|
||||||
#include "moCoolingSchedule.h"
|
#include <moCoolingSchedule.h>
|
||||||
|
|
||||||
//! One of the possible moCoolingSchedule
|
//! One of the possible moCoolingSchedule
|
||||||
/*!
|
/*!
|
||||||
An another very simple cooling schedule, the temperature decrease according to a quantity while
|
An another very simple cooling schedule, the temperature decrease according to a quantity while
|
||||||
the temperature is greater than a threshold.
|
the temperature is greater than a threshold.
|
||||||
*/
|
*/
|
||||||
class moLinearCoolingSchedule: public moCoolingSchedule
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
private:
|
||||||
//! 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.
|
//! The temperature threhold.
|
||||||
/*!
|
double threshold;
|
||||||
It decreases the temperature and indicates if it is greater than the threshold.
|
|
||||||
|
|
||||||
\param __temp the current temperature.
|
//! The quantity that allows the temperature to decrease.
|
||||||
\return if the new temperature (current temperature - quantity) is greater than the threshold.
|
double quantity;
|
||||||
*/
|
};
|
||||||
bool operator() (double &__temp)
|
|
||||||
{
|
|
||||||
return (__temp -= quantity) > threshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! The temperature threhold.
|
|
||||||
double threshold;
|
|
||||||
|
|
||||||
//! The quantity that allows the temperature to decrease.
|
|
||||||
double quantity;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,41 @@
|
||||||
/*
|
/*
|
||||||
* <moMove.h>
|
<moMove.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMove_h
|
#ifndef _moMove_h
|
||||||
#define __moMove_h
|
#define _moMove_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -45,13 +45,13 @@
|
||||||
A move transforms a solution to another close solution.
|
A move transforms a solution to another close solution.
|
||||||
It describes how a solution can be modified to another one.
|
It describes how a solution can be modified to another one.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moMove:public eoUF < EOT &, void >
|
template < class EOT >
|
||||||
{
|
class moMove:public eoUF < EOT &, void >
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Alias for the type
|
|
||||||
typedef EOT EOType;
|
//! Alias for the type
|
||||||
|
typedef EOT EOType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,49 @@
|
||||||
/*
|
/*
|
||||||
* <moMoveExpl.h>
|
<moMoveExpl.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMoveExpl_h
|
#ifndef _moMoveExpl_h
|
||||||
#define __moMoveExpl_h
|
#define _moMoveExpl_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
//! Description of a move (moMove) explorer
|
//! Description of a move (moMove) explorer
|
||||||
/*!
|
/*!
|
||||||
Only a description...See moMoveLoopExpl.
|
Only a description...See moMoveLoopExpl.
|
||||||
*/
|
*/
|
||||||
template < class M > class moMoveExpl:public eoBF < const typename
|
template < class M > class
|
||||||
M::EOType &,
|
moMoveExpl : public eoBF < const typename M::EOType &, typename M::EOType &, void >
|
||||||
typename
|
{};
|
||||||
M::EOType &, void >
|
|
||||||
{};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moMoveIncrEval.h>
|
<moMoveIncrEval.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMoveIncrEval_h
|
#ifndef _moMoveIncrEval_h
|
||||||
#define __moMoveIncrEval_h
|
#define _moMoveIncrEval_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -46,10 +45,8 @@
|
||||||
a new fitness that could be associated to
|
a new fitness that could be associated to
|
||||||
the solution if this one is updated.
|
the solution if this one is updated.
|
||||||
*/
|
*/
|
||||||
template < class M > class moMoveIncrEval:public eoBF < const M &, const typename
|
template < class M >
|
||||||
M::EOType &,
|
class moMoveIncrEval:public eoBF < const M &, const typename M::EOType &, typename M::EOType::Fitness >
|
||||||
typename
|
{};
|
||||||
M::EOType::Fitness >
|
|
||||||
{};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moMoveInit.h>
|
<moMoveInit.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMoveInit_h
|
#ifndef _moMoveInit_h
|
||||||
#define __moMoveInit_h
|
#define _moMoveInit_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -43,9 +42,9 @@
|
||||||
/*!
|
/*!
|
||||||
Class which allows to initiase a move.
|
Class which allows to initiase a move.
|
||||||
Only a description... An object that herits from this class needs to be designed to be used.
|
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
|
template < class M >
|
||||||
M::EOType &, void >
|
class moMoveInit:public eoBF < M &, const typename M::EOType &, void >
|
||||||
{};
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,50 @@
|
||||||
/*
|
/*
|
||||||
* <moMoveLoopExpl.h>
|
<moMoveLoopExpl.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMoveLoopExpl_h
|
#ifndef _moMoveLoopExpl_h
|
||||||
#define __moMoveLoopExpl_h
|
#define _moMoveLoopExpl_h
|
||||||
|
|
||||||
#include "moMoveExpl.h"
|
#include <moMoveExpl.h>
|
||||||
|
|
||||||
//! Class which describes an iterative explorer
|
//! Class which describes an iterative explorer
|
||||||
/*!
|
/*!
|
||||||
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
|
Only a description... moHCMoveLoopExpl and moTSMoveLoopExpl are exemples of class that are a moMoveLoopExpl.
|
||||||
*/
|
*/
|
||||||
template < class M > class moMoveLoopExpl:public moMoveExpl < M >
|
template < class M >
|
||||||
{};
|
class moMoveLoopExpl:public moMoveExpl < M >
|
||||||
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,44 @@
|
||||||
/*
|
/*
|
||||||
* <moMoveSelect.h>
|
<moMoveSelect.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moMoveSelect_h
|
#ifndef _moMoveSelect_h
|
||||||
#define __moMoveSelect_h
|
#define _moMoveSelect_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
#include <stdexcept>
|
||||||
//! Special class that describes the case of no selection.
|
|
||||||
/*!
|
|
||||||
This class is used as an exception that can be thrown if a solution selector has completly failed.
|
|
||||||
*/
|
|
||||||
class EmptySelection
|
|
||||||
{};
|
|
||||||
|
|
||||||
//! Class that describes a move selector (moMove).
|
//! Class that describes a move selector (moMove).
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -52,37 +46,31 @@ class EmptySelection
|
||||||
associated fitnesses. The best move is so regularly updated.
|
associated fitnesses. The best move is so regularly updated.
|
||||||
At any time, it could be accessed.
|
At any time, it could be accessed.
|
||||||
*/
|
*/
|
||||||
template < class M > class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &,
|
template < class M >
|
||||||
void >
|
class moMoveSelect:public eoBF < M &, typename M::EOType::Fitness &, void >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Alias for the fitness
|
//! Alias for the fitness
|
||||||
typedef
|
typedef typename M::EOType::Fitness Fitness;
|
||||||
typename
|
|
||||||
M::EOType::Fitness
|
//! Procedure which initialises all that the move selector needs including the initial fitness.
|
||||||
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;
|
||||||
|
|
||||||
//! Procedure which initialises all that the move selector needs including the initial fitness.
|
//! Function which updates the best solutions.
|
||||||
/*!
|
/*!
|
||||||
In order to know the fitness of the solution,
|
\param _move a new move.
|
||||||
for which the neighborhood will
|
\param _fitness a fitness linked to the new move.
|
||||||
be soon explored
|
\return a boolean that expresses the need to resume the exploration.
|
||||||
|
*/
|
||||||
|
virtual bool update (const M & _move, const Fitness & _fitness) = 0;
|
||||||
|
|
||||||
\param __fit the current fitness.
|
};
|
||||||
*/
|
|
||||||
virtual void
|
|
||||||
init (const Fitness & __fit) = 0;
|
|
||||||
|
|
||||||
//! Function which updates the best solutions.
|
|
||||||
/*!
|
|
||||||
\param __move a new move.
|
|
||||||
\param __fit a fitness linked to the new move.
|
|
||||||
\return a boolean that expresses the need to resume the exploration.
|
|
||||||
*/
|
|
||||||
virtual
|
|
||||||
bool
|
|
||||||
update (const M & __move, const Fitness & __fit) = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moNextMove.h>
|
<moNextMove.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moNextMove_h
|
#ifndef _moNextMove_h
|
||||||
#define __moNextMove_h
|
#define _moNextMove_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -43,10 +42,9 @@
|
||||||
/*!
|
/*!
|
||||||
Useful for the explorer (for moTS or moHC).
|
Useful for the explorer (for moTS or moHC).
|
||||||
Does nothing... An object that herits from this class needs to be designed for being used.
|
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
|
template < class M >
|
||||||
M::EOType &,
|
class moNextMove:public eoBF < M &, const typename M::EOType &, bool >
|
||||||
bool >
|
{};
|
||||||
{};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,72 +1,70 @@
|
||||||
/*
|
/*
|
||||||
* <moNoAspirCrit.h>
|
<moNoAspirCrit.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moNoAspirCrit_h
|
#ifndef _moNoAspirCrit_h
|
||||||
#define __moNoAspirCrit_h
|
#define _moNoAspirCrit_h
|
||||||
|
|
||||||
#include "moAspirCrit.h"
|
#include <moAspirCrit.h>
|
||||||
|
|
||||||
//! One of the possible aspiration criterion (moAspirCrit)
|
//! One of the possible aspiration criterion (moAspirCrit)
|
||||||
/*!
|
/*!
|
||||||
The simplest : never satisfied.
|
The simplest : never satisfied.
|
||||||
*/
|
*/
|
||||||
template < class M > class moNoAspirCrit:public moAspirCrit < M >
|
template < class M >
|
||||||
|
class moNoAspirCrit:public moAspirCrit < M >
|
||||||
|
{
|
||||||
|
//! 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)
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//! Function which describes the aspiration criterion behaviour
|
//! Procedure which initialises all that needs a moNoAspirCrit.
|
||||||
/*!
|
/*!
|
||||||
Does nothing.
|
Nothing...
|
||||||
|
*/
|
||||||
\param __move a move.
|
void init ()
|
||||||
\param __sol a fitness.
|
{}
|
||||||
\return FALSE.
|
};
|
||||||
*/
|
|
||||||
bool operator () (const M & __move,
|
|
||||||
const typename M::EOType::Fitness & __sol)
|
|
||||||
{
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which initialises all that needs a moNoAspirCrit
|
|
||||||
/*!
|
|
||||||
Nothing...
|
|
||||||
*/
|
|
||||||
void init ()
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,123 +1,123 @@
|
||||||
/*
|
/*
|
||||||
* <moNoFitImprSolContinue.h>
|
<moNoFitImprSolContinue.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moNoFitImprSolContinue_h
|
#ifndef _moNoFitImprSolContinue_h
|
||||||
#define __moNoFitImprSolContinue_h
|
#define _moNoFitImprSolContinue_h
|
||||||
|
|
||||||
#include "moSolContinue.h"
|
#include <moSolContinue.h>
|
||||||
|
|
||||||
//! One possible stop criterion for a solution-based heuristic.
|
//! One possible stop criterion for a solution-based heuristic.
|
||||||
/*!
|
/*!
|
||||||
The stop criterion corresponds to a maximum number of iterations without improvement.
|
The stop criterion corresponds to a maximum number of iterations without improvement.
|
||||||
*/
|
*/
|
||||||
template < class EOT > class moNoFitImprSolContinue:public moSolContinue < EOT >
|
template < class EOT >
|
||||||
{
|
class moNoFitImprSolContinue:public moSolContinue < EOT >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
//! Alias for the fitness.
|
||||||
|
typedef typename EOT::Fitness Fitness;
|
||||||
|
|
||||||
//! Alias for the fitness.
|
//! Basic constructor.
|
||||||
typedef typename EOT::Fitness Fitness;
|
/*!
|
||||||
|
\param _maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
|
||||||
//! Basic constructor.
|
*/
|
||||||
/*!
|
moNoFitImprSolContinue (unsigned int _maxNumberOfIterationWithoutImprovement)
|
||||||
\param __maxNumberOfIterationWithoutImprovement The number of iterations without fitness improvement to reach for stop.
|
: maxNumberOfIterationsWithoutImprovement(_maxNumberOfIterationWithoutImprovement), firstFitnessSaved(true), counter(0)
|
||||||
*/
|
|
||||||
moNoFitImprSolContinue (unsigned int __maxNumberOfIterationWithoutImprovement)
|
|
||||||
: maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement), firstFitnessSaved(true), counter(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Function that activates the stopping criterion.
|
//! 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).
|
Indicates if the fitness has not been improved since a given number of iterations (after a minimum of iterations).
|
||||||
\param __sol the current solution.
|
\param _solution the current solution.
|
||||||
\return true or false.
|
\return true or false.
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & _solution)
|
||||||
{
|
{
|
||||||
if (__sol.invalid())
|
if (_solution.invalid())
|
||||||
{
|
{
|
||||||
return true;
|
throw std::runtime_error("[moNoFitImprSolContinue.h]: The current solution has not been evaluated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (firstFitnessSaved)
|
||||||
|
{
|
||||||
|
fitness=_solution.fitness();
|
||||||
|
counter=0;
|
||||||
|
firstFitnessSaved=false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (firstFitnessSaved)
|
counter++;
|
||||||
{
|
|
||||||
fitness=__sol.fitness();
|
|
||||||
counter=0;
|
|
||||||
firstFitnessSaved=false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
counter++;
|
if ( _solution.fitness() > fitness)
|
||||||
|
{
|
||||||
|
fitness=_solution.fitness();
|
||||||
|
counter=0;
|
||||||
|
}
|
||||||
|
|
||||||
if ( __sol.fitness() > fitness)
|
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
std::cout << "[moNoFitImrpSolContinue.h]: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||||
counter=0;
|
}
|
||||||
}
|
|
||||||
|
return counter!=maxNumberOfIterationsWithoutImprovement;
|
||||||
|
}
|
||||||
|
|
||||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
//! Procedure which allows to initialise all the stuff needed.
|
||||||
{
|
/*!
|
||||||
std::cout << "moNoFitImrpSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
It can be also used to reinitialize all the needed things.
|
||||||
}
|
*/
|
||||||
return counter!=maxNumberOfIterationsWithoutImprovement;
|
void init ()
|
||||||
}
|
{
|
||||||
|
firstFitnessSaved=true;
|
||||||
|
counter=0;
|
||||||
|
}
|
||||||
|
|
||||||
//! Procedure which allows to initialise all the stuff needed.
|
private:
|
||||||
/*!
|
|
||||||
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;
|
||||||
|
|
||||||
//! Maximum number of iterations without improvement allowed.
|
//! Flag that this is the first time that the fitness is used.
|
||||||
unsigned int maxNumberOfIterationsWithoutImprovement;
|
bool firstFitnessSaved;
|
||||||
|
|
||||||
//! Flag that this is the first time that the fitness is used.
|
//! Current Fitness.
|
||||||
bool firstFitnessSaved;
|
Fitness fitness;
|
||||||
|
|
||||||
//! Current Fitness.
|
//! The iteration couter.
|
||||||
Fitness fitness;
|
unsigned int counter;
|
||||||
|
};
|
||||||
//! The iteration couter.
|
|
||||||
unsigned int counter;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,129 +1,127 @@
|
||||||
/*
|
/*
|
||||||
* <moRandImprSelect.h>
|
<moRandImprSelect.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moRandImprSelect_h
|
#ifndef _moRandImprSelect_h
|
||||||
#define __moRandImprSelect_h
|
#define _moRandImprSelect_h
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <utils/eoRNG.h>
|
#include <utils/eoRNG.h>
|
||||||
#include "moMoveSelect.h"
|
#include <moMoveSelect.h>
|
||||||
|
|
||||||
//! One of the possible moMove selector (moMoveSelect)
|
//! One of the possible moMove selector (moMoveSelect)
|
||||||
/*!
|
/*!
|
||||||
All the neighbors are considered.
|
All the neighbors are considered.
|
||||||
One of them that enables an improvment of the objective function is choosen.
|
One of them that enables an improvment of the objective function is choosen.
|
||||||
*/
|
*/
|
||||||
template < class M > class moRandImprSelect:public moMoveSelect < M >
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
if (_fitness > initial_fitness)
|
||||||
|
{
|
||||||
|
better_fitnesses.push_back(_fitness);
|
||||||
|
better_moves.push_back(_move);
|
||||||
|
}
|
||||||
|
|
||||||
//! Alias for the fitness
|
return true;
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
}
|
||||||
|
|
||||||
//!Procedure which all that needs a moRandImprSelect
|
//! The move selection
|
||||||
/*!
|
/*!
|
||||||
Give a value to the initialise fitness.
|
One the saved move is randomly chosen.
|
||||||
Clean the move and fitness vectors.
|
|
||||||
|
|
||||||
\param __fit the current best fitness
|
\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 init (const Fitness & __fit)
|
*/
|
||||||
{
|
void operator () (M & _move, Fitness & _fitness)
|
||||||
init_fit = __fit;
|
{
|
||||||
vect_better_fit.clear ();
|
unsigned int index;
|
||||||
vect_better_moves.clear ();
|
|
||||||
}
|
index=0;
|
||||||
|
|
||||||
//! Function that updates the fitness and move vectors
|
if( (better_fitnesses.size()==0) || (better_moves.size()==0) )
|
||||||
/*!
|
{
|
||||||
if a move give a better fitness than the initial fitness,
|
std::cout << "[moRandImprSelect.h]: no move or/and no fitness already saved, update has to be called first." << std::endl;
|
||||||
it is saved and the fitness too.
|
}
|
||||||
|
|
||||||
\param __move a new move.
|
index = rng.random (better_fitnesses.size ());
|
||||||
\param __fit a new fitness associated to the new move.
|
|
||||||
\return TRUE.
|
_move = better_moves[index];
|
||||||
*/
|
_fitness = better_fitnesses[index];
|
||||||
bool update (const M & __move, const Fitness & __fit)
|
}
|
||||||
{
|
|
||||||
|
|
||||||
if (__fit > init_fit)
|
private:
|
||||||
{
|
|
||||||
|
|
||||||
vect_better_fit.push_back (__fit);
|
//! Fitness of the current solution.
|
||||||
vect_better_moves.push_back (__move);
|
Fitness initial_fitness;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
//! Candidate fitnesse vector.
|
||||||
}
|
std::vector < Fitness > better_fitnesses;
|
||||||
|
|
||||||
//! The move selection
|
//! Candidate move vector.
|
||||||
/*!
|
std::vector < M > better_moves;
|
||||||
One the saved move is randomly chosen.
|
};
|
||||||
|
|
||||||
\param __move the reference of the move that can be initialised by the function.
|
|
||||||
\param __fit the reference of the fitness that can be initialised by the function.
|
|
||||||
\throws EmptySelection If no move which improves the current fitness are found.
|
|
||||||
*/
|
|
||||||
void operator () (M & __move, Fitness & __fit) throw (EmptySelection)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!vect_better_fit.empty ())
|
|
||||||
{
|
|
||||||
|
|
||||||
unsigned n = rng.random (vect_better_fit.size ());
|
|
||||||
|
|
||||||
__move = vect_better_moves[n];
|
|
||||||
__fit = vect_better_fit[n];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw EmptySelection ();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Fitness of the current solution.
|
|
||||||
Fitness init_fit;
|
|
||||||
|
|
||||||
//! Candidate fitnesse vector.
|
|
||||||
std::vector < Fitness > vect_better_fit;
|
|
||||||
|
|
||||||
//! Candidate move vector.
|
|
||||||
std::vector < M > vect_better_moves;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,49 @@
|
||||||
/*
|
/*
|
||||||
* <moRandMove.h>
|
<moRandMove.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moRandMove_h
|
#ifndef _moRandMove_h
|
||||||
#define __moRandMove_h
|
#define _moRandMove_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
//! Random move generator
|
//! Random move generator
|
||||||
/*!
|
/*!
|
||||||
Only a description... An object that herits from this class needs to be designed in order to use a moSA.
|
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 >
|
template < class M >
|
||||||
{};
|
class moRandMove:public eoUF < M &, void >
|
||||||
|
{};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,174 +1,165 @@
|
||||||
/*
|
/*
|
||||||
* <moSA.h>
|
<moSA.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSA_h
|
#ifndef _moSA_h
|
||||||
#define __moSA_h
|
#define _moSA_h
|
||||||
|
|
||||||
#include <eoOp.h>
|
|
||||||
#include <eoEvalFunc.h>
|
|
||||||
|
|
||||||
#include "moAlgo.h"
|
|
||||||
#include "moRandMove.h"
|
|
||||||
#include "moMoveIncrEval.h"
|
|
||||||
#include "moCoolingSchedule.h"
|
|
||||||
#include "moSolContinue.h"
|
|
||||||
|
|
||||||
#include <math.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)
|
//! Simulated Annealing (SA)
|
||||||
/*!
|
/*!
|
||||||
Class that describes a Simulated Annealing algorithm.
|
Class that describes a Simulated Annealing algorithm.
|
||||||
*/
|
*/
|
||||||
template < class M > class moSA:public moAlgo < typename M::EOType >
|
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;
|
||||||
|
|
||||||
//! Alias for the type
|
if (_solution.invalid())
|
||||||
typedef typename M::EOType EOT;
|
{
|
||||||
|
full_evaluation (_solution);
|
||||||
|
}
|
||||||
|
|
||||||
//! Alias for the fitness
|
temperature = initial_temperature;
|
||||||
typedef typename EOT::Fitness Fitness;
|
|
||||||
|
|
||||||
public:
|
best_solution = _solution;
|
||||||
|
|
||||||
//! SA constructor
|
do
|
||||||
/*!
|
{
|
||||||
All the boxes used by a SA need to be given.
|
continu.init ();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
random_move_generator(move);
|
||||||
|
|
||||||
\param __move_rand a move generator (generally randomly).
|
incremental_fitness = incremental_evaluation (move, _solution);
|
||||||
\param __incr_eval a (generaly) efficient evaluation function
|
|
||||||
\param __cont a stopping criterion.
|
|
||||||
\param __init_temp the initial temperature.
|
|
||||||
\param __cool_sched a cooling schedule, describes how the temperature is modified.
|
|
||||||
\param __full_eval a full evaluation function.
|
|
||||||
*/
|
|
||||||
moSA (moRandMove < M > &__move_rand,
|
|
||||||
moMoveIncrEval < M > &__incr_eval,
|
|
||||||
moSolContinue < EOT > &__cont,
|
|
||||||
double __init_temp,
|
|
||||||
moCoolingSchedule & __cool_sched, eoEvalFunc < EOT > &__full_eval):
|
|
||||||
move_rand (__move_rand),
|
|
||||||
incr_eval (__incr_eval),
|
|
||||||
cont (__cont),
|
|
||||||
init_temp (__init_temp),
|
|
||||||
cool_sched (__cool_sched),
|
|
||||||
full_eval (__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! function that launches the SA algorithm.
|
delta_fit = incremental_fitness - _solution.fitness ();
|
||||||
/*!
|
|
||||||
As a moTS or a moHC, the SA can be used for HYBRIDATION in an evolutionary algorithm.
|
if( (_solution.fitness() > incremental_fitness ) && (exp (delta_fit / temperature) > 1.0) )
|
||||||
|
{
|
||||||
|
delta_fit = -delta_fit;
|
||||||
|
}
|
||||||
|
|
||||||
\param __sol a solution to improve.
|
if ( (incremental_fitness > _solution.fitness()) || (rng.uniform () < exp (delta_fit / temperature)) )
|
||||||
\return TRUE.
|
{
|
||||||
*/
|
move(_solution);
|
||||||
bool operator ()(EOT & __sol)
|
_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) );
|
||||||
|
|
||||||
if (__sol.invalid ())
|
_solution = best_solution;
|
||||||
{
|
|
||||||
full_eval (__sol);
|
|
||||||
}
|
|
||||||
|
|
||||||
double temp = init_temp;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
M move;
|
private:
|
||||||
|
|
||||||
EOT best_sol = __sol;
|
//! A move generator (generally randomly)
|
||||||
|
moRandMove < M > & random_move_generator;
|
||||||
|
|
||||||
do
|
//! A (generally) efficient evaluation function.
|
||||||
{
|
moMoveIncrEval < M > & incremental_evaluation;
|
||||||
|
|
||||||
cont.init ();
|
//! Stopping criterion before temperature update
|
||||||
do
|
moSolContinue < EOT > & continu;
|
||||||
{
|
|
||||||
|
|
||||||
move_rand (move);
|
//! Initial temperature
|
||||||
|
double initial_temperature;
|
||||||
Fitness incremental_fitness = incr_eval (move, __sol);
|
|
||||||
|
//! The cooling schedule
|
||||||
Fitness delta_fit = incremental_fitness - __sol.fitness ();
|
moCoolingSchedule & cooling_schedule;
|
||||||
|
|
||||||
if((__sol.fitness() > incremental_fitness ) && (exp (delta_fit / temp) > 1.0))
|
//! A full evaluation function.
|
||||||
{
|
eoEvalFunc < EOT > & full_evaluation;
|
||||||
delta_fit = -delta_fit;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
if (incremental_fitness > __sol.fitness() || rng.uniform () < exp (delta_fit / temp))
|
|
||||||
{
|
|
||||||
__sol.fitness (incremental_fitness);
|
|
||||||
move (__sol);
|
|
||||||
|
|
||||||
/* Updating the best solution found
|
|
||||||
until now ? */
|
|
||||||
if (__sol.fitness () > best_sol.fitness ())
|
|
||||||
{
|
|
||||||
best_sol = __sol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
while (cont (__sol));
|
|
||||||
|
|
||||||
}
|
|
||||||
while (cool_sched (temp));
|
|
||||||
|
|
||||||
__sol = best_sol;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! A move generator (generally randomly)
|
|
||||||
moRandMove < M > &move_rand;
|
|
||||||
|
|
||||||
//! A (generally) efficient evaluation function.
|
|
||||||
moMoveIncrEval < M > &incr_eval;
|
|
||||||
|
|
||||||
//! Stopping criterion before temperature update
|
|
||||||
moSolContinue < EOT > &cont;
|
|
||||||
|
|
||||||
//! Initial temperature
|
|
||||||
double init_temp;
|
|
||||||
|
|
||||||
//! The cooling schedule
|
|
||||||
moCoolingSchedule & cool_sched;
|
|
||||||
|
|
||||||
//! A full evaluation function.
|
|
||||||
eoEvalFunc < EOT > &full_eval; // Full evaluator.
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,151 +1,154 @@
|
||||||
/*
|
/*
|
||||||
* <moSimpleMoveTabuList.h>
|
<moSimpleMoveTabuList.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSimpleMoveTabuList_h
|
#ifndef _moSimpleMoveTabuList_h
|
||||||
#define __moSimpleMoveTabuList_h
|
#define _moSimpleMoveTabuList_h
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include "moTabuList.h"
|
#include <moTabuList.h>
|
||||||
|
|
||||||
//! Class describing a move tabu list with a limited memory.
|
//! Class describing a move tabu list with a limited memory.
|
||||||
template <class M>
|
template <class M>
|
||||||
class moSimpleMoveTabuList: public moTabuList < 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;
|
||||||
public:
|
//code only used to avoid warning because _solution is not used in this function.
|
||||||
|
EOT solution=(EOT)_solution;
|
||||||
//! Alias for the type
|
|
||||||
typedef typename M::EOType EOT;
|
it=tabuList.begin();
|
||||||
|
// The code is !(*it)==_move instead of (*it)!=_move because people designing their specific move representation
|
||||||
//! Constructor
|
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||||
/*
|
while ( it!=tabuList.end() && !((*it)==_move) )
|
||||||
\param __size The maximum size of the move tabu list.
|
|
||||||
*/
|
|
||||||
moSimpleMoveTabuList(unsigned int __size): maxSize(__size)
|
|
||||||
{
|
|
||||||
currentSize=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
|
||||||
/*!
|
|
||||||
\param __move A given moMove.
|
|
||||||
\param __sol A solution.
|
|
||||||
\return true or false.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
operator () (const M & __move, const EOT & __sol)
|
|
||||||
{
|
|
||||||
typename std::list<M>::iterator it;
|
|
||||||
|
|
||||||
it=tabuList.begin();
|
|
||||||
while (it!=tabuList.end()&&(!((*it)==__move)))
|
|
||||||
{
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return it!=tabuList.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
add (const M & __move, const EOT & __sol)
|
|
||||||
{
|
{
|
||||||
if (currentSize!=0)
|
it++;
|
||||||
{
|
|
||||||
// Useful in the case of a move has been kept thanks to the moAspirCrit.
|
|
||||||
// In this case, the move can already be in the tabuList.
|
|
||||||
removeMove(__move);
|
|
||||||
}
|
|
||||||
|
|
||||||
tabuList.push_back(__move);
|
|
||||||
|
|
||||||
if (currentSize==maxSize)
|
|
||||||
{
|
|
||||||
tabuList.erase(tabuList.begin());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSize++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
return it!=tabuList.end();
|
||||||
update ()
|
}
|
||||||
{
|
|
||||||
//nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void add(const M & _move, const EOT & _solution)
|
||||||
init ()
|
{
|
||||||
{
|
//code only used to avoid warning because _solution is not used in this function.
|
||||||
//nothing to do
|
EOT solution=(EOT)_solution;
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
//! Procedure that removes a given move from the tabu list (if it is into, else do nothing).
|
tabuList.push_back(_move);
|
||||||
/*!
|
|
||||||
\param __move A given moMove.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
removeMove(const M & __move)
|
|
||||||
{
|
|
||||||
typename std::list<M>::iterator it;
|
|
||||||
|
|
||||||
it=tabuList.begin();
|
if (memory_size == memory_maximum_size)
|
||||||
while (it!=tabuList.end()&&(!((*it)==__move)))
|
{
|
||||||
{
|
tabuList.erase(tabuList.begin());
|
||||||
it++;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
memory_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (it!=tabuList.end())
|
void update ()
|
||||||
{
|
{
|
||||||
tabuList.erase(it);
|
//nothing to do
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
void init ()
|
||||||
|
{
|
||||||
|
//nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
//! The maximum size of the tabu list.
|
private:
|
||||||
unsigned int maxSize;
|
|
||||||
|
|
||||||
//! The current size of the tabu list.
|
//! Procedure that removes a given move from the tabu list (if it is into, else do nothing).
|
||||||
unsigned int currentSize;
|
/*!
|
||||||
|
\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 move tabu list.
|
//! The maximum size of the tabu list.
|
||||||
std::list<M> tabuList;
|
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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,160 +1,159 @@
|
||||||
/*
|
/*
|
||||||
* <moSimpleSolutionTabuList.h>
|
<moSimpleSolutionTabuList.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSimpleSolutionTabuList_h
|
#ifndef _moSimpleSolutionTabuList_h
|
||||||
#define __moSimpleSolutionTabuList_h
|
#define _moSimpleSolutionTabuList_h
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include "moTabuList.h"
|
#include <moTabuList.h>
|
||||||
|
|
||||||
//! Class describing a solution tabu list with limited length.
|
//! Class describing a solution tabu list with limited length.
|
||||||
template <class M>
|
template <class M>
|
||||||
class moSimpleSolutionTabuList: public moTabuList < 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)
|
||||||
{
|
{
|
||||||
|
solutionIterator it;
|
||||||
|
|
||||||
public:
|
M move=(M)_move;
|
||||||
|
EOT solution=(EOT) _solution;
|
||||||
|
|
||||||
//! Alias for the type
|
move(solution);
|
||||||
typedef typename M::EOType EOT;
|
|
||||||
|
|
||||||
//! Constructor
|
it=tabuList.begin();
|
||||||
/*!
|
// The code is !(*it)==_solution instead of (*it)!=_solution because people designing their specific solution representation
|
||||||
\param __size The maximum size of the solution tabu list.
|
// will write the "==" operator (I hope) but not necessary the "!=" operator.
|
||||||
*/
|
while (it!=tabuList.end()&&(!((*it)==solution)))
|
||||||
moSimpleSolutionTabuList(unsigned int __size): maxSize(__size)
|
|
||||||
{
|
|
||||||
currentSize=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Function that indicates if, in a given state, the _move is tabu or not.
|
|
||||||
/*!
|
|
||||||
\param __move A given moMove.
|
|
||||||
\param __sol A solution.
|
|
||||||
\return true or false.
|
|
||||||
*/
|
|
||||||
bool operator () (const M & __move, const EOT & __sol)
|
|
||||||
{
|
|
||||||
typename std::list<EOT>::iterator it;
|
|
||||||
|
|
||||||
M _move=(M)__move;
|
|
||||||
EOT _sol=(EOT) __sol;
|
|
||||||
|
|
||||||
_move(_sol);
|
|
||||||
|
|
||||||
it=tabuList.begin();
|
|
||||||
while (it!=tabuList.end()&&(!((*it)==_sol)))
|
|
||||||
{
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return it!=tabuList.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
add (const M & __move, const EOT & __sol)
|
|
||||||
{
|
{
|
||||||
M _move=(M)__move;
|
it++;
|
||||||
EOT _sol=(EOT) __sol;
|
|
||||||
|
|
||||||
_move(_sol);
|
|
||||||
|
|
||||||
if (currentSize!=0)
|
|
||||||
{
|
|
||||||
// Useful in the case of a solution has been kept thanks to the moAspirCrit.
|
|
||||||
// In this case, the solution can already be in the tabuList.
|
|
||||||
removeSolution(_sol);
|
|
||||||
}
|
|
||||||
|
|
||||||
tabuList.push_back(_sol);
|
|
||||||
|
|
||||||
if (currentSize==maxSize)
|
|
||||||
{
|
|
||||||
tabuList.erase(tabuList.begin());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentSize++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
return it!=tabuList.end();
|
||||||
update ()
|
}
|
||||||
{
|
|
||||||
//nothing to do
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void add (const M & _move, const EOT & _solution)
|
||||||
init ()
|
{
|
||||||
{
|
M move=(M)_move;
|
||||||
//nothing to do
|
EOT solution=(EOT) _solution;
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
_move(_solution);
|
||||||
|
|
||||||
//! Procedure that removes a given solution from the tabu list (if it is into, else does nothing).
|
if (memory_size!=0)
|
||||||
/*!
|
{
|
||||||
\param __sol A given solution.
|
// 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.
|
||||||
void
|
removeSolution(_solution);
|
||||||
removeSolution(const EOT & __sol)
|
}
|
||||||
{
|
|
||||||
typename std::list<EOT>::iterator it;
|
|
||||||
|
|
||||||
it=tabuList.begin();
|
tabuList.push_back(_solution);
|
||||||
while (it!=tabuList.end()&&(!((*it)==__sol)))
|
|
||||||
{
|
|
||||||
it++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it!=tabuList.end())
|
if (memory_size == memory_maximum_size)
|
||||||
{
|
{
|
||||||
tabuList.erase(it);
|
tabuList.erase(tabuList.begin());
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
memory_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//! The maximum size of the tabu list.
|
void update ()
|
||||||
unsigned int maxSize;
|
{
|
||||||
|
//nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
//! The current size of the tabu list.
|
void init ()
|
||||||
unsigned int currentSize;
|
{
|
||||||
|
//nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
//! The solution tabu list.
|
private:
|
||||||
std::list<EOT> tabuList;
|
|
||||||
};
|
//! 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! 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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,58 @@
|
||||||
/*
|
/*
|
||||||
* <moSolContinue.h>
|
<moSolContinue.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSolContinue_h
|
#ifndef _moSolContinue_h
|
||||||
#define __moSolContinue_h
|
#define _moSolContinue_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
//! Class that describes a stop criterion for a solution-based heuristic
|
//! 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).
|
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 >
|
template < class EOT >
|
||||||
{
|
class moSolContinue:public eoUF < const EOT &, bool >
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
//! Procedure which initialises all that the stop criterion needs
|
//! Procedure which initialises all that the stop criterion needs
|
||||||
/*!
|
/*!
|
||||||
Generally, it allocates some data structures or initialises some counters.
|
Generally, it allocates some data structures or initialises some counters.
|
||||||
*/
|
*/
|
||||||
virtual void init () = 0;
|
virtual void init () = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,143 +1,142 @@
|
||||||
/*
|
/*
|
||||||
* <moSteadyFitSolContinue.h>
|
<moSteadyFitSolContinue.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moSteadyFitSolContinue_h
|
#ifndef _moSteadyFitSolContinue_h
|
||||||
#define __moSteadyFitSolContinue_h
|
#define _moSteadyFitSolContinue_h
|
||||||
|
|
||||||
#include "moSolContinue.h"
|
#include <moSolContinue.h>
|
||||||
|
|
||||||
//! One possible stopping criterion for a solution-based heuristic.
|
//! 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).
|
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 >
|
template < class EOT >
|
||||||
{
|
class moSteadyFitSolContinue:public moSolContinue < EOT >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
public:
|
//! Alias for the fitness.
|
||||||
|
typedef typename EOT::Fitness Fitness;
|
||||||
//! Alias for the fitness.
|
|
||||||
typedef typename EOT::Fitness Fitness;
|
//! Basic constructor.
|
||||||
|
/*!
|
||||||
//! 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.
|
||||||
\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),
|
||||||
moSteadyFitSolContinue (unsigned int __maxNumberOfIterations, unsigned int __maxNumberOfIterationWithoutImprovement)
|
maxNumberOfIterationsReached(false), firstFitnessSaved(true), counter(0)
|
||||||
: maxNumberOfIterations (__maxNumberOfIterations), maxNumberOfIterationsWithoutImprovement(__maxNumberOfIterationWithoutImprovement),
|
|
||||||
maxNumberOfIterationsReached(false), firstFitnessSaved(true), counter(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//! Function that activates the stopping criterion.
|
//! Function that activates the stopping criterion.
|
||||||
/*!
|
/*!
|
||||||
Indicates if the fitness has not been improved since a number of iterations (after a minimum of iterations).
|
Indicates if the fitness has not been improved since a number of iterations (after a minimum of iterations).
|
||||||
|
|
||||||
\param __sol the current solution.
|
\param _solution the current solution.
|
||||||
\return true or false.
|
\return true or false.
|
||||||
*/
|
*/
|
||||||
bool operator () (const EOT & __sol)
|
bool operator () (const EOT & _solution)
|
||||||
{
|
{
|
||||||
if (!maxNumberOfIterationsReached)
|
if (!maxNumberOfIterationsReached)
|
||||||
{
|
{
|
||||||
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
maxNumberOfIterationsReached=((++counter)==maxNumberOfIterations);
|
||||||
if (maxNumberOfIterationsReached)
|
if (maxNumberOfIterationsReached)
|
||||||
{
|
{
|
||||||
std::cout << "moSteadyFitSolContinue: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
std::cout << "[moSteadyFitSolContinue.h]: Done the minimum number of iterations [" << counter << "]." << std::endl;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_solution.invalid())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstFitnessSaved)
|
||||||
|
{
|
||||||
|
fitness=_solution.fitness();
|
||||||
|
counter=0;
|
||||||
|
firstFitnessSaved=false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (__sol.invalid())
|
counter++;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (firstFitnessSaved)
|
if ( _solution.fitness() > fitness )
|
||||||
{
|
{
|
||||||
fitness=__sol.fitness();
|
fitness=_solution.fitness();
|
||||||
counter=0;
|
counter=0;
|
||||||
firstFitnessSaved=false;
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
counter++;
|
if (counter==maxNumberOfIterationsWithoutImprovement)
|
||||||
|
{
|
||||||
|
std::cout << "[moSteadyFitSolContinue.h]: Done [" << counter << "] iterations without improvement." << std::endl;
|
||||||
|
}
|
||||||
|
return counter!=maxNumberOfIterationsWithoutImprovement;
|
||||||
|
}
|
||||||
|
|
||||||
if ( __sol.fitness() > fitness )
|
//! Procedure which allows to initialise the stuff needed.
|
||||||
{
|
/*!
|
||||||
fitness=__sol.fitness();
|
It can be also used to reinitialize the counter all the needed things.
|
||||||
counter=0;
|
*/
|
||||||
}
|
void init ()
|
||||||
|
{
|
||||||
|
maxNumberOfIterationsReached=false;
|
||||||
|
counter=0;
|
||||||
|
firstFitnessSaved=true;
|
||||||
|
}
|
||||||
|
|
||||||
if (counter==maxNumberOfIterationsWithoutImprovement)
|
private:
|
||||||
{
|
|
||||||
std::cout << "moSteadyFitSolContinue: Done [" << counter << "] iterations without improvement." << std::endl;
|
|
||||||
}
|
|
||||||
return counter!=maxNumberOfIterationsWithoutImprovement;
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Procedure which allows to initialise the stuff needed.
|
//! Maximum number of iterations before considering the fitness.
|
||||||
/*!
|
unsigned int maxNumberOfIterations;
|
||||||
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 without improvement allowed.
|
||||||
|
unsigned int maxNumberOfIterationsWithoutImprovement;
|
||||||
|
|
||||||
//! Maximum number of iterations before considering the fitness.
|
//! Flag that indicates that the maxNumberIteration have been reached.
|
||||||
unsigned int maxNumberOfIterations;
|
bool maxNumberOfIterationsReached;
|
||||||
|
|
||||||
//! Maximum number of iterations without improvement allowed.
|
//! Flag that this is the first time that the fitness is used.
|
||||||
unsigned int maxNumberOfIterationsWithoutImprovement;
|
bool firstFitnessSaved;
|
||||||
|
|
||||||
//! Flag that indicates that the maxNumberIteration have been reached.
|
//! Current Fitness.
|
||||||
bool maxNumberOfIterationsReached;
|
Fitness fitness;
|
||||||
|
|
||||||
//! Flag that this is the first time that the fitness is used.
|
//! The iteration couter.
|
||||||
bool firstFitnessSaved;
|
unsigned int counter;
|
||||||
|
};
|
||||||
//! Current Fitness.
|
|
||||||
Fitness fitness;
|
|
||||||
|
|
||||||
//! The iteration couter.
|
|
||||||
unsigned int counter;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,169 +1,151 @@
|
||||||
/*
|
/*
|
||||||
* <moTS.h>
|
<moTS.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moTS_h
|
#ifndef _moTS_h
|
||||||
#define __moTS_h
|
#define _moTS_h
|
||||||
|
|
||||||
#include <eoOp.h>
|
|
||||||
#include <eoEvalFunc.h>
|
#include <eoEvalFunc.h>
|
||||||
|
|
||||||
#include "moAlgo.h"
|
#include <moAlgo.h>
|
||||||
#include "moSolContinue.h"
|
#include <moSolContinue.h>
|
||||||
|
#include <moTSMoveLoopExpl.h>
|
||||||
#include "moMoveExpl.h"
|
|
||||||
#include "moTSMoveLoopExpl.h"
|
|
||||||
|
|
||||||
|
|
||||||
//! Tabu Search (TS)
|
//! Tabu Search (TS)
|
||||||
/*!
|
/*!
|
||||||
Generic algorithm that describes a tabu search.
|
Generic algorithm that describes a tabu search.
|
||||||
*/
|
*/
|
||||||
template < class M > class moTS:public moAlgo < typename M::EOType >
|
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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! 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;
|
||||||
|
|
||||||
//!Alias for the type
|
if ( _solution.invalid () )
|
||||||
typedef
|
{
|
||||||
typename
|
full_evaluation (_solution);
|
||||||
M::EOType
|
}
|
||||||
EOT;
|
|
||||||
|
best_solution=_solution;
|
||||||
|
|
||||||
//!Alias for the fitness
|
// code used for avoiding warning because new_solution is indirectly initialized by move_expl.
|
||||||
typedef
|
new_solution=_solution;
|
||||||
typename
|
|
||||||
EOT::Fitness
|
continu.init ();
|
||||||
Fitness;
|
|
||||||
|
|
||||||
public:
|
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) );
|
||||||
|
|
||||||
//!Constructor of a moTS specifying all the boxes
|
_solution = best_solution;
|
||||||
/*!
|
|
||||||
In this constructor, a moTSMoveLoopExpl is instanciated.
|
|
||||||
|
|
||||||
\param __move_init move initialisation
|
return true;
|
||||||
\param __next_move neighborhood explorer
|
}
|
||||||
\param __incr_eval efficient evaluation
|
|
||||||
\param __tabu_list tabu list
|
|
||||||
\param __aspir_crit aspiration criterion
|
|
||||||
\param __cont stop criterion
|
|
||||||
\param __full_eval full evaluation function
|
|
||||||
*/
|
|
||||||
moTS (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (*new moTSMoveLoopExpl < M >
|
|
||||||
(__move_init, __next_move, __incr_eval, __tabu_list,
|
|
||||||
__aspir_crit)), cont (__cont), full_eval (__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Constructor with less parameters
|
private:
|
||||||
/*!
|
|
||||||
The explorer is given in the parameters.
|
|
||||||
|
|
||||||
\param __move_expl the explorer (generally different that a moTSMoveLoopExpl)
|
//! Neighborhood explorer
|
||||||
\param __cont stop criterion
|
moMoveExpl < M > & move_explorer;
|
||||||
\param __full_eval full evaluation function
|
|
||||||
*/
|
|
||||||
moTS (moMoveExpl < M > &__move_expl, moSolContinue < EOT > &__cont, eoEvalFunc < EOT > &__full_eval):move_expl (__move_expl),
|
|
||||||
cont (__cont),
|
|
||||||
full_eval (__full_eval)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//! Function which launchs the Tabu Search
|
//! Stop criterion
|
||||||
/*!
|
moSolContinue < EOT > & continu;
|
||||||
Algorithm of the tabu search.
|
|
||||||
As a moSA or a moHC, it can be used for HYBRIDATION in an evolutionary algorithm.
|
|
||||||
For security a lock (pthread_mutex_t) is closed during the algorithm.
|
|
||||||
|
|
||||||
\param __sol a solution to improve.
|
//! Full evaluation function
|
||||||
\return TRUE.
|
eoEvalFunc < EOT > & full_evaluation;
|
||||||
*/
|
};
|
||||||
bool operator ()(EOT & __sol)
|
|
||||||
{
|
|
||||||
if (__sol.invalid ())
|
|
||||||
{
|
|
||||||
full_eval (__sol);
|
|
||||||
}
|
|
||||||
|
|
||||||
M move;
|
|
||||||
|
|
||||||
EOT best_sol = __sol, new_sol;
|
|
||||||
|
|
||||||
cont.init ();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
|
|
||||||
new_sol = __sol;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
move_expl (__sol, new_sol);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (EmptySelection & __ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Updating the best solution
|
|
||||||
found until now ? */
|
|
||||||
if (new_sol.fitness () > __sol.fitness ())
|
|
||||||
{
|
|
||||||
best_sol = new_sol;
|
|
||||||
}
|
|
||||||
|
|
||||||
__sol = new_sol;
|
|
||||||
|
|
||||||
}
|
|
||||||
while (cont (__sol));
|
|
||||||
|
|
||||||
__sol = best_sol;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//! Neighborhood explorer
|
|
||||||
moMoveExpl < M > &move_expl;
|
|
||||||
|
|
||||||
//! Stop criterion
|
|
||||||
moSolContinue < EOT > &cont;
|
|
||||||
|
|
||||||
//! Full evaluation function
|
|
||||||
eoEvalFunc < EOT > &full_eval;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,157 +1,158 @@
|
||||||
/*
|
/*
|
||||||
* <moTSMoveLoopExpl.h>
|
<moTSMoveLoopExpl.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moTSMoveLoopExpl_h
|
#ifndef _moTSMoveLoopExpl_h
|
||||||
#define __moTSMoveLoopExpl_h
|
#define _moTSMoveLoopExpl_h
|
||||||
|
|
||||||
#include "moMoveLoopExpl.h"
|
#include <moMoveLoopExpl.h>
|
||||||
|
#include <moMoveInit.h>
|
||||||
#include "moMoveInit.h"
|
#include <moNextMove.h>
|
||||||
#include "moNextMove.h"
|
#include <moMoveIncrEval.h>
|
||||||
#include "moMoveIncrEval.h"
|
#include <moMoveSelect.h>
|
||||||
#include "moMoveSelect.h"
|
#include <moTabuList.h>
|
||||||
|
#include <moAspirCrit.h>
|
||||||
#include "moTabuList.h"
|
#include <moBestImprSelect.h>
|
||||||
#include "moAspirCrit.h"
|
|
||||||
#include "moBestImprSelect.h"
|
|
||||||
|
|
||||||
//! Explorer for a Tabu Search algorithm
|
//! Explorer for a Tabu Search algorithm
|
||||||
/*!
|
/*!
|
||||||
It is used by a moTS.
|
It is used by a moTS.
|
||||||
*/
|
*/
|
||||||
template < class M > class moTSMoveLoopExpl:public moMoveLoopExpl < M >
|
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.
|
||||||
|
|
||||||
//!Alias for the type
|
\param _old_solution the initial solution
|
||||||
typedef typename M::EOType EOT;
|
\param _new_solution the new solution
|
||||||
|
*/
|
||||||
|
void operator () (const EOT & _old_solution, EOT & _new_solution)
|
||||||
|
{
|
||||||
|
M move, best_move;
|
||||||
|
Fitness fitness, best_move_fitness;
|
||||||
|
|
||||||
//!Alias for the fitness
|
bool move_is_tabu, aspiration_criterion_is_verified, selection_update_is_ok, has_next_move;
|
||||||
typedef typename M::EOType::Fitness Fitness;
|
|
||||||
|
//At the begining, the new solution is equivalent to the old one.
|
||||||
|
_new_solution=(EOT)_old_solution;
|
||||||
|
|
||||||
public:
|
// Restarting the exploration of of the neighborhood !
|
||||||
|
move_initializer (move, _old_solution);
|
||||||
|
|
||||||
//!Constructor
|
move_selection.init( _old_solution.fitness() );
|
||||||
/*!
|
|
||||||
\param __move_init move initialisation
|
|
||||||
\param __next_move neighborhood explorer
|
|
||||||
\param __incr_eval efficient evaluation
|
|
||||||
\param __tabu_list tabu list
|
|
||||||
\param __aspir_crit aspiration criterion
|
|
||||||
*/
|
|
||||||
moTSMoveLoopExpl (moMoveInit < M > &__move_init, moNextMove < M > &__next_move, moMoveIncrEval < M > &__incr_eval, moTabuList < M > &__tabu_list, moAspirCrit < M > &__aspir_crit):
|
|
||||||
move_init (__move_init),
|
|
||||||
next_move (__next_move),
|
|
||||||
incr_eval (__incr_eval),
|
|
||||||
tabu_list (__tabu_list), aspir_crit (__aspir_crit)
|
|
||||||
{
|
|
||||||
|
|
||||||
tabu_list.init ();
|
do
|
||||||
aspir_crit.init ();
|
{
|
||||||
}
|
fitness = incremental_evaluation(move, _old_solution);
|
||||||
|
|
||||||
//!Procedure which lauches the exploration
|
move_is_tabu = tabu_list(move, _old_solution);
|
||||||
/*!
|
|
||||||
The exploration continues while the chosen move is not in the tabu list
|
|
||||||
or the aspiration criterion is true. If these 2 conditions are not true, the
|
|
||||||
exploration stops if the move selector update function returns false.
|
|
||||||
|
|
||||||
\param __old_sol the initial solution
|
aspiration_criterion_is_verified = aspiration_criterion(move, fitness);
|
||||||
\param __new_sol the new solution
|
|
||||||
*/
|
|
||||||
void operator () (const EOT & __old_sol, EOT & __new_sol)
|
|
||||||
{
|
|
||||||
|
|
||||||
M move;
|
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_init (move, __old_sol); /* Restarting the exploration of
|
move_selection(best_move, best_move_fitness);
|
||||||
of the neighborhood ! */
|
|
||||||
|
|
||||||
move_select.init (__old_sol.fitness ());
|
// Apply the best move.
|
||||||
|
best_move(_new_solution);
|
||||||
do
|
|
||||||
{
|
// The fitness is set to avoid an additionnal fitness computation.
|
||||||
|
_new_solution.fitness(best_move_fitness);
|
||||||
Fitness fit = incr_eval (move, __old_sol);
|
|
||||||
|
|
||||||
if (!tabu_list (move, __old_sol) || aspir_crit (move, fit))
|
|
||||||
{
|
|
||||||
if (!move_select.update (move, fit))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
while (next_move (move, __old_sol));
|
|
||||||
|
|
||||||
M best_move;
|
|
||||||
|
|
||||||
Fitness best_move_fit;
|
|
||||||
|
|
||||||
move_select (best_move, best_move_fit);
|
|
||||||
|
|
||||||
best_move (__new_sol);
|
|
||||||
__new_sol.fitness (best_move_fit);
|
|
||||||
|
|
||||||
/* Removing moves that are
|
// Removing moves that are no more tabu.
|
||||||
no more tabu */
|
tabu_list.update ();
|
||||||
tabu_list.update ();
|
|
||||||
|
// Updating the tabu list
|
||||||
|
tabu_list.add(best_move, _new_solution);
|
||||||
|
}
|
||||||
|
|
||||||
// Updating the tabu list
|
private:
|
||||||
tabu_list.add (best_move, __new_sol);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
//! Move initialisation
|
||||||
|
moMoveInit < M > & move_initializer;
|
||||||
|
|
||||||
//!Move initialisation
|
//! Neighborhood explorer
|
||||||
moMoveInit < M > &move_init;
|
moNextMove < M > & next_move_generator;
|
||||||
|
|
||||||
//!Neighborhood explorer
|
//! Efficient evaluation
|
||||||
moNextMove < M > &next_move;
|
moMoveIncrEval < M > & incremental_evaluation;
|
||||||
|
|
||||||
//!Efficient evaluation
|
//! Move selector
|
||||||
moMoveIncrEval < M > &incr_eval;
|
moBestImprSelect < M > move_selection;
|
||||||
|
|
||||||
//!Move selector
|
//! Tabu list
|
||||||
moBestImprSelect < M > move_select;
|
moTabuList < M > & tabu_list;
|
||||||
|
|
||||||
//!Tabu list
|
//! Aspiration criterion
|
||||||
moTabuList < M > &tabu_list;
|
moAspirCrit < M > & aspiration_criterion;
|
||||||
|
};
|
||||||
//!Aspiration criterion
|
|
||||||
moAspirCrit < M > &aspir_crit;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,40 @@
|
||||||
/*
|
/*
|
||||||
* <moTabuList.h>
|
<moTabuList.h>
|
||||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||||
* (C) OPAC Team, LIFL, 2002-2007
|
(C) OPAC Team, LIFL, 2002-2008
|
||||||
*
|
|
||||||
* Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
Sébastien Cahon, Jean-Charles Boisson (Jean-Charles.Boisson@lifl.fr)
|
||||||
*
|
|
||||||
* This software is governed by the CeCILL license under French law and
|
This software is governed by the CeCILL license under French law and
|
||||||
* abiding by the rules of distribution of free software. You can use,
|
abiding by the rules of distribution of free software. You can use,
|
||||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
modify and/ or redistribute the software under the terms of the CeCILL
|
||||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
license as circulated by CEA, CNRS and INRIA at the following URL
|
||||||
* "http://www.cecill.info".
|
"http://www.cecill.info".
|
||||||
*
|
|
||||||
* As a counterpart to the access to the source code and rights to copy,
|
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
|
modify and redistribute granted by the license, users are provided only
|
||||||
* with a limited warranty and the software's author, the holder of the
|
with a limited warranty and the software's author, the holder of the
|
||||||
* economic rights, and the successive licensors have only limited liability.
|
economic rights, and the successive licensors have only limited liability.
|
||||||
*
|
|
||||||
* In this respect, the user's attention is drawn to the risks associated
|
In this respect, the user's attention is drawn to the risks associated
|
||||||
* with loading, using, modifying and/or developing or reproducing the
|
with loading, using, modifying and/or developing or reproducing the
|
||||||
* software by the user in light of its specific status of free software,
|
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
|
that may mean that it is complicated to manipulate, and that also
|
||||||
* therefore means that it is reserved for developers and experienced
|
therefore means that it is reserved for developers and experienced
|
||||||
* professionals having in-depth computer knowledge. Users are therefore
|
professionals having in-depth computer knowledge. Users are therefore
|
||||||
* encouraged to load and test the software's suitability as regards their
|
encouraged to load and test the software's suitability as regards their
|
||||||
* requirements in conditions enabling the security of their systems and/or
|
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
|
data to be ensured and, more generally, to use and operate it in the
|
||||||
* same conditions as regards security.
|
same conditions as regards security.
|
||||||
* The fact that you are presently reading this means that you have had
|
The fact that you are presently reading this means that you have had
|
||||||
* knowledge of the CeCILL license and that you accept its terms.
|
knowledge of the CeCILL license and that you accept its terms.
|
||||||
*
|
|
||||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __moTabuList_h
|
#ifndef _moTabuList_h
|
||||||
#define __moTabuList_h
|
#define _moTabuList_h
|
||||||
|
|
||||||
#include <eoFunctor.h>
|
#include <eoFunctor.h>
|
||||||
|
|
||||||
|
|
@ -43,39 +42,34 @@
|
||||||
/*!
|
/*!
|
||||||
It is only a description, does nothing... A new object that herits from this class has to be defined in order
|
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.
|
to be used in a moTS.
|
||||||
*/
|
*/
|
||||||
template < class M > class moTabuList:public eoBF < const M &, const typename
|
template < class M > class moTabuList: public eoBF < const M &, const typename M::EOType &, bool >
|
||||||
M::EOType &,
|
{
|
||||||
bool >
|
public:
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
//! Alias for the type
|
||||||
//! Alias for the type
|
typedef typename M::EOType EOT;
|
||||||
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 to add a move in the tabu list
|
//! Procedure that updates the tabu list content.
|
||||||
/*!
|
/*!
|
||||||
The two parameters have not to be modified so they are constant parameters.
|
Generally, a counter associated to each saved move is decreased by one.
|
||||||
|
*/
|
||||||
\param __move a new tabu move.
|
virtual void update () = 0;
|
||||||
\param __sol the origianl solution associated to this move.
|
|
||||||
*/
|
//! Procedure which initialises the tabu list.
|
||||||
virtual void
|
/*!
|
||||||
add (const M & __move, const EOT & __sol) = 0;
|
Can be useful if the data structure needs to be allocated before being used.
|
||||||
|
*/
|
||||||
//! Procedure that updates the tabu list content.
|
virtual void init () = 0;
|
||||||
/*!
|
};
|
||||||
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
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue