Migration from SVN

This commit is contained in:
quemy 2012-08-30 11:30:11 +02:00
commit 8cd56f37db
29069 changed files with 0 additions and 4096888 deletions

View file

@ -0,0 +1,121 @@
/*
<moMaxSATincrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moMaxSATincrEval_h
#define _moMaxSATincrEval_h
#include <eval/moEval.h>
#include <eval/maxSATeval.h>
/**
* Incremental evaluation Function for the max SAT problem
*/
template <class Neighbor>
class moMaxSATincrEval : public moEval <Neighbor> {
public :
typedef typename Neighbor::EOT EOT;
moMaxSATincrEval(MaxSATeval<EOT> & _fulleval) : fulleval(_fulleval) {
nbClauses = _fulleval.nbClauses;
nbVar = _fulleval.nbVar;
clauses = _fulleval.clauses;
variables = _fulleval.variables;
}
/**
* incremental evaluation of the neighbor for the max SAT problem
* @param _solution the solution (of type bit string) to move
* @param _neighbor the neighbor (of type moBitNeigbor) to consider
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
// the difference of fitness
int delta = 0;
// the flipped bit
unsigned int bit = _neighbor.index();
// clauses which can be modified by the flipped bit
const std::vector<int> & modifiedClauses = variables[bit + 1] ; // remember that the variables start at index 1 and not 0
unsigned int size = modifiedClauses.size();
int nc;
bool litt;
for (unsigned int k = 0; k < size; k++) {
// number of the clause
nc = modifiedClauses[k];
// negative means that the not(variable) is in the clause
if (nc < 0) {
nc = - nc;
litt = !_solution[bit];
} else
litt = _solution[bit];
if (litt) {
// the litteral was true and becomes false
_solution[bit] = !_solution[bit];
if (!fulleval.clauseEval(nc, _solution))
// the clause was true and becomes false
delta--;
_solution[bit] = !_solution[bit];
} else {
// the litteral was false and becomes true
if (!fulleval.clauseEval(nc, _solution))
// the clause was false and becomes true
delta++;
}
}
_neighbor.fitness(_solution.fitness() + delta);
}
protected:
// number of variables
unsigned int nbVar;
// number of clauses
unsigned int nbClauses;
// list of clauses:
// each clause has the number of the variable (from 1 to nbVar)
// when the value, litteral = not(variable)
std::vector<int> * clauses;
// list of variables:
// for each variable, the list of clauses
std::vector<int> * variables;
//full eval of the max SAT
MaxSATeval<EOT> & fulleval;
};
#endif

View file

@ -0,0 +1,58 @@
/*
<moOneMaxIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moOneMaxIncrEval_H
#define _moOneMaxIncrEval_H
#include <eval/moEval.h>
/**
* Incremental evaluation Function for the OneMax problem
*/
template< class Neighbor >
class moOneMaxIncrEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
/*
* incremental evaluation of the neighbor for the oneMax problem
* @param _solution the solution to move (bit string)
* @param _neighbor the neighbor to consider (of type moBitNeigbor)
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
if (_solution[_neighbor.index()] == 0)
_neighbor.fitness(_solution.fitness() + 1);
else
_neighbor.fitness(_solution.fitness() - 1);
}
};
#endif

View file

@ -0,0 +1,92 @@
/*
<moQAPIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moQAPIncrEval_H
#define _moQAPIncrEval_H
#include <eval/moEval.h>
#include <eval/qapEval.h>
/**
* Incremental evaluation Function for the QAP problem
*/
template< class Neighbor >
class moQAPIncrEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
/*
* default constructor
* @param _qapEval full evaluation of the QAP problem
*/
moQAPIncrEval(QAPeval<EOT> & _qapEval) {
n = _qapEval.getNbVar();
A = _qapEval.getA();
B = _qapEval.getB();
}
/*
* incremental evaluation of the neighbor for the QAP problem
* @param _solution the solution to move (permutation)
* @param _neighbor the neighbor to consider (of type moSwapNeigbor)
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
int d;
int k;
unsigned i, j;
_neighbor.getIndices(n, i, j);
d = (A[i][i]-A[j][j])*(B[_solution[j]][_solution[j]]-B[_solution[i]][_solution[i]]) +
(A[i][j]-A[j][i])*(B[_solution[j]][_solution[i]]-B[_solution[i]][_solution[j]]);
for (k = 0; k < n; k++)
if (k != i && k != j)
d = d + (A[k][i]-A[k][j])*(B[_solution[k]][_solution[j]]-B[_solution[k]][_solution[i]]) +
(A[i][k]-A[j][k])*(B[_solution[j]][_solution[k]]-B[_solution[i]][_solution[k]]);
_neighbor.fitness(_solution.fitness() + d);
}
private:
// number of variables
int n;
// matrix A
int ** A;
// matrix B
int ** B;
};
#endif

View file

@ -0,0 +1,88 @@
/*
<moRoyalRoadIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moRoyalRoadIncrEval_H
#define _moRoyalRoadIncrEval_H
#include <eval/moEval.h>
#include <eval/royalRoadEval.h>
/**
* Incremental evaluation Function for the Royal Road problem
*/
template< class Neighbor >
class moRoyalRoadIncrEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
/**
* Constructor
* @param _rr full evaluation of the Royal Road (to have the same block size)
*/
moRoyalRoadIncrEval(RoyalRoadEval<EOT> & _rr) : k(_rr.blockSize()) {}
/**
* incremental evaluation of the neighbor for the Royal Road problem
* @param _solution the solution to move (bit string)
* @param _neighbor the neighbor to consider (of type moBitNeigbor)
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
// which block can be changed?
unsigned int n = _neighbor.index() / k;
// complete block?
unsigned int offset = n * k;
unsigned int j = 0;
while (j < k && _solution[offset + j]) j++;
if (j == k) // the block is complete, so the fitness decreases from one
_neighbor.fitness(_solution.fitness() - 1);
else {
if ((_solution[_neighbor.index()] == 0) && (offset + j == _neighbor.index())) { // can the block be filled?
j++; // next bit
while ( j < k && _solution[offset + j]) j++;
if (j == k) // the block can be filled, so the fitness increases from one
_neighbor.fitness(_solution.fitness() + 1);
else
_neighbor.fitness(_solution.fitness());
} else
_neighbor.fitness(_solution.fitness());
}
}
protected:
// size of the blocks
unsigned int k;
};
#endif

View file

@ -0,0 +1,124 @@
/*
<moUBQPBitsIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moUBQPBitsIncrEval_H
#define _moUBQPBitsIncrEval_H
#include <eval/moEval.h>
#include <eval/ubqpEval.h>
/**
* Incremental evaluation Function for the UBQPSimple problem
* when several bits are flipped (moBitsNeighbor)
*/
template< class Neighbor >
class moUBQPBitsIncrEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
/*
* default constructor
* @param _ubqpEval full evaluation of the UBQP problem
*/
moUBQPBitsIncrEval(UbqpEval<EOT> & _ubqpEval) {
n = _ubqpEval.getNbVar();
Q = _ubqpEval.getQ();
}
/*
* Incremental evaluation of the neighbor for the UBQP problem (complexity O(n * k) when k bits are flipped)
* @param _solution the solution to move (bit string)
* @param _neighbor the neighbor to consider of type moBitsNeighbor (several bits are flipped)
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
unsigned int b;
unsigned int j;
int d, delta;
delta = 0;
for(unsigned i = 0; i < _neighbor.nBits; i++) {
b = _neighbor.bits[i];
d = Q[b][b];
for(j = 0; j < b; j++)
if (_solution[j] == 1)
d += Q[b][j];
for(j = b+1; j < n; j++)
if (_solution[j] == 1)
d += Q[j][b];
if (_solution[b] == 0)
delta += d;
else
delta -= d;
// move the solution on this bit
_solution[b] = !_solution[b];
}
// move back the solution
for(unsigned i = 0; i < _neighbor.nBits; i++) {
b = _neighbor.bits[i];
_solution[b] = !_solution[b];
}
_neighbor.fitness(_solution.fitness() + delta);
}
/*
* to get the matrix Q
*
* @return matrix Q
*/
int** getQ() {
return Q;
}
/*
* to get the number of variable (bit string length)
*
* @return bit string length
*/
int getNbVar() {
return n;
}
private:
// number of variables
int n;
// matrix Q (supposed to be in lower triangular form)
int ** Q;
};
#endif

View file

@ -0,0 +1,108 @@
/*
<moUBQPSimpleIncrEval.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef _moUBQPSimpleIncrEval_H
#define _moUBQPSimpleIncrEval_H
#include <eval/moEval.h>
#include <eval/ubqpEval.h>
/**
* Incremental evaluation Function for the UBQPSimple problem
*/
template< class Neighbor >
class moUBQPSimpleIncrEval : public moEval<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
/*
* default constructor
* @param _ubqpEval full evaluation of the UBQP problem
*/
moUBQPSimpleIncrEval(UbqpEval<EOT> & _ubqpEval) {
n = _ubqpEval.getNbVar();
Q = _ubqpEval.getQ();
}
/*
* Incremental evaluation of the neighbor for the UBQP problem (linear time complexity)
* @param _solution the solution to move (bit string)
* @param _neighbor the neighbor to consider (of type moBitNeighbor)
*/
virtual void operator()(EOT & _solution, Neighbor & _neighbor) {
unsigned int i = _neighbor.index();
unsigned int j;
int d = Q[i][i];
for(j = 0; j < i; j++)
if (_solution[j] == 1)
d += Q[i][j];
for(j = i+1; j < n; j++)
if (_solution[j] == 1)
d += Q[j][i];
if (_solution[i] == 0)
_neighbor.fitness(_solution.fitness() + d);
else
_neighbor.fitness(_solution.fitness() - d);
}
/*
* to get the matrix Q
*
* @return matrix Q
*/
int** getQ() {
return Q;
}
/*
* to get the number of variable (bit string length)
*
* @return bit string length
*/
int getNbVar() {
return n;
}
private:
// number of variables
int n;
// matrix Q (supposed to be in lower triangular form)
int ** Q;
};
#endif

View file

@ -0,0 +1,161 @@
/*
<moUBQPdoubleIncrEvaluation.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Sebastien Verel, Arnaud Liefooghe, Jeremie Humeau
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
As a counterpart to the access to the source code and rights to copy,
modify and redistribute granted by the license, users are provided only
with a limited warranty and the software's author, the holder of the
economic rights, and the successive licensors have only limited liability.
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef moUBQPdoubleIncrEvaluation_H
#define moUBQPdoubleIncrEvaluation_H
#include <eval/moDoubleIncrEvaluation.h>
#include <explorer/moNeighborhoodExplorer.h>
#include <eval/moEval.h>
/**
* The neighborhood evaluation for the UBQP
* The double incremental evaluation is used
*
* BECAREFULL: This object must be added to the moCheckpoint of the local search (init method)
*/
template<class Neighbor>
class moUBQPdoubleIncrEvaluation : public moDoubleIncrEvaluation<Neighbor>
{
public:
typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness;
using moDoubleIncrEvaluation<Neighbor>::deltaFitness;
using moDoubleIncrEvaluation<Neighbor>::firstEval;
/**
* Constructor
*
* @param _neighborhoodSize the size of the neighborhood
* @param _incrEval the incremental evaluation of the UBQP
*/
moUBQPdoubleIncrEvaluation(unsigned int _neighborhoodSize, moUBQPSimpleIncrEval<Neighbor> & _incrEval) : moDoubleIncrEvaluation<Neighbor>(_neighborhoodSize), searchExplorer(NULL)
{
n = _incrEval.getNbVar();
Q = _incrEval.getQ();
}
void neighborhoodExplorer(moNeighborhoodExplorer<Neighbor> & _searchExplorer) {
searchExplorer = & _searchExplorer;
}
/**
* Evaluation of the neighborhood
* Here nothing to do
*
* @param _solution the current solution
*/
virtual void operator()(EOT & _solution) {
if (firstEval) {
firstEval = false;
// compute the delta in the simple incremental way O(n)
unsigned int j;
int d;
for(unsigned i = 0; i < n; i++) {
d = Q[i][i];
for(j = 0; j < i; j++)
if (_solution[j])
d += Q[i][j];
for(j = i+1; j < n; j++)
if (_solution[j])
d += Q[j][i];
if (_solution[i])
d = - d;
deltaFitness[i] = d;
}
} else {
if (searchExplorer->moveApplied()) {
// compute the new fitness only when the solution has moved
// the selectedNeighbor is the neighbor which is selected in the neighborhood
// the movement is made on this neighbor
// we suppose that the neighborhood is bit string neighborhood (indexed neighbor)
unsigned iMove = searchExplorer->getSelectedNeighbor().index();
for(unsigned i = 0; i < n; i++) {
if (i == iMove)
deltaFitness[i] = - deltaFitness[i] ;
else {
if (_solution[i] != _solution[iMove])
if (i < iMove)
deltaFitness[i] += Q[iMove][i];
else
deltaFitness[i] += Q[i][iMove];
else
if (i < iMove)
deltaFitness[i] -= Q[iMove][i];
else
deltaFitness[i] -= Q[i][iMove];
}
}
}
}
}
/*
* to get the matrix Q
*
* @return matrix Q
*/
int** getQ() {
return Q;
}
/*
* to get the number of variable (bit string length)
*
* @return bit string length
*/
int getNbVar() {
return n;
}
private:
// number of variables
int n;
// matrix Q (supposed to be in lower triangular form)
int ** Q;
/** The search explorer of the local search */
moNeighborhoodExplorer<Neighbor> * searchExplorer;
};
#endif