git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@2262 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
boufaras 2011-05-25 21:45:10 +00:00
commit ef9eb7c173
6 changed files with 0 additions and 633 deletions

View file

@ -1,121 +0,0 @@
/*
<moCudaBitNeighbor.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Boufaras Karima, Thé Van LUONG
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 _moCudaBitNeighbor_h
#define _moCudaBitNeighbor_h
#include <neighborhood/moBackableNeighbor.h>
#include <neighborhood/moIndexNeighbor.h>
/**
* Neighbor related to a solution vector of EOT (type)
*/
template<class EOT, class Fitness = typename EOT::Fitness>
class moCudaBitNeighbor: public moBackableNeighbor<EOT, Fitness> ,
public moIndexNeighbor<EOT, Fitness> {
public:
using moBackableNeighbor<EOT, Fitness>::fitness;
using moIndexNeighbor<EOT, Fitness>::key;
/**
* move the solution
* @param
* _solution the solution to move
*/
virtual void move(EOT & _solution) {
_solution[key] = !_solution[key];
}
/**
* move back the solution (useful for the evaluation by modif)
* @param
* _solution the solution to move back
*/
virtual void moveBack(EOT & _solution) {
_solution[key] = !_solution[key];
}
/**
* Return the class name.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaBitNeighbor";
}
/**
* Read object.\
* Calls base class, just in case that one had something to do.
* The read and print methods should be compatible and have the same format.
* In principle, format is "plain": they just print a number
* @param _is a std::istream.
* @throw runtime_std::exception If a valid object can't be read.
*/
virtual void readFrom(std::istream& _is) {
std::string fitness_str;
int pos = _is.tellg();
_is >> fitness_str;
if (fitness_str == "INVALID") {
throw std::runtime_error("invalid fitness");
} else {
Fitness repFit;
_is.seekg(pos);
_is >> repFit;
_is >> key;
fitness(repFit);
}
}
/**
* Write object. Called printOn since it prints the object _on_ a stream.
* @param _os A std::ostream.
*/
virtual void printOn(std::ostream& _os) const {
_os << fitness() << ' ' << key << std::endl;
}
};
#endif

View file

@ -1,119 +0,0 @@
/*
<moKswapNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
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 _moCudaKswapNeighborhood_h
#define _moCudaKswapNeighborhood_h
#include <neighborhood/moKswapNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* K-flip Neighborhood
*/
template<class N>
class moCudaKflipNeighborhood: public moKswapNeighborhood<N> {
public:
/**
* Define a Neighbor and type of a solution corresponding
*/
typedef N Neighbor;
typedef typename Neighbor::EOT EOT;
using moKswapNeighborhood<Neighbor>::neighborhoodSize;
using moKswapNeighborhood<Neighbor>::currentIndex;
using moKswapNeighborhood<Neighbor>::indices;
using moKswapNeighborhood<Neighbor>::mapping;
using moKswapNeighborhood<Neighbor>::Kswap;
using moKswapNeighborhood<Neighbor>::size;
using moKswapNeighborhood<Neighbor>::mutex;
/**
* Constructor
* @param _size the size of solution
* @param _size the solution size
* @param _Kflip the number of bit to flip
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaKflipNeighborhood(unsigned int _size, unsigned int _Kflip,
moCudaEval<Neighbor>& _eval) :
moKswapNeighborhood<Neighbor> (_size, _Kflip), eval(_eval) {
sendMapping = true;
cudaMalloc((void**) &device_Mapping, sizeof(unsigned int)
* neighborhoodSize * (_Kflip + 1));
}
;
/**
*Destructor
*/
~moCudaKflipNeighborhood() {
cudaFree(device_Mapping);
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _current the first neighbor
*/
virtual void init(EOT& _solution, Neighbor& _current) {
moKswapNeighborhood<Neighbor>::init(_solution, _current);
if (sendMapping) {
cudaMemcpy(device_Mapping, mapping, (Kswap + 1) * neighborhoodSize
* sizeof(unsigned int), cudaMemcpyHostToDevice);
sendMapping = false;
}
//Compute all neighbors fitness at one time
eval.neighborhoodKflipEval(_solution, device_Mapping, Kswap);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaKSwapNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
bool sendMapping;
unsigned int * device_Mapping;
};
#endif

View file

@ -1,119 +0,0 @@
/*
<moKswapNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Boufaras Karima, Thé Van Luong
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 _moCudaKswapNeighborhood_h
#define _moCudaKswapNeighborhood_h
#include <neighborhood/moKswapNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* K-Swap Neighborhood
*/
template<class N>
class moCudaKswapNeighborhood: public moKswapNeighborhood<N> {
public:
/**
* Define a Neighbor and type of a solution corresponding
*/
typedef N Neighbor;
typedef typename Neighbor::EOT EOT;
using moKswapNeighborhood<Neighbor>::neighborhoodSize;
using moKswapNeighborhood<Neighbor>::currentIndex;
using moKswapNeighborhood<Neighbor>::indices;
using moKswapNeighborhood<Neighbor>::mapping;
using moKswapNeighborhood<Neighbor>::Kswap;
using moKswapNeighborhood<Neighbor>::size;
using moKswapNeighborhood<Neighbor>::mutex;
/**
* Constructor
* @param _size the size of solution
* @param _Kswap the number of swap
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaKswapNeighborhood(unsigned int _size, unsigned int _Kswap,
moCudaEval<Neighbor>& _eval) :
moKswapNeighborhood<Neighbor> (_size, _Kswap), eval(_eval) {
sendMapping = true;
cudaMalloc((void**) &device_Mapping, sizeof(unsigned int)
* neighborhoodSize * (Kswap + 1));
}
;
/**
*Destructor
*/
~moCudaKswapNeighborhood() {
cudaFree(device_Mapping);
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _current the first neighbor
*/
virtual void init(EOT& _solution, Neighbor& _current) {
moKswapNeighborhood<Neighbor>::init(_solution, _current);
//Send Mapping for only the first time
if (sendMapping) {
cudaMemcpy(device_Mapping, mapping, (Kswap + 1) * neighborhoodSize
* sizeof(unsigned int), cudaMemcpyHostToDevice);
sendMapping = false;
}
//Compute all neighbors fitness at one time
eval.neighborhoodKswapEval(_solution, device_Mapping, Kswap);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaKSwapNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
bool sendMapping;
unsigned int * device_Mapping;
};
#endif

View file

@ -1,96 +0,0 @@
/*
<moCudaOrderNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Thé Van LUONG, Karima Boufaras
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 _moCudaOrderNeighborhood_h
#define _moCudaOrderNeighborhood_h
#include <neighborhood/moOrderNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* An ordered neighborhood with parallel evaluation
*/
template<class N>
class moCudaOrderNeighborhood: public moOrderNeighborhood<N> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef N Neighbor;
typedef typename Neighbor::EOT EOT;
using moOrderNeighborhood<Neighbor>::neighborhoodSize;
using moOrderNeighborhood<Neighbor>::currentIndex;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaOrderNeighborhood(unsigned int _neighborhoodSize,
moCudaEval<Neighbor>& _eval) :
moOrderNeighborhood<Neighbor> (_neighborhoodSize), eval(_eval) {
}
/**
* Initialization of the neighborhood
*@param _solution the solution to explore
*@param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moOrderNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class name.
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaOrderNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif

View file

@ -1,88 +0,0 @@
/*
<moCudaRndWithReplNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Karima Boufaras, Thé Van LUONG
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 _moCudaRndWithReplNeighborhood_h
#define _moCudaRndWithReplNeighborhood_h
#include <neighborhood/moRndWithReplNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* A Random With replacement Neighborhood with parallel evaluation
*/
template<class Neighbor>
class moCudaRndWithReplNeighborhood: public moRndWithReplNeighborhood<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
using moRndWithReplNeighborhood<Neighbor>::neighborhoodSize;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaRndWithReplNeighborhood(unsigned int _neighborhoodSize, moCudaEval<
Neighbor>& _eval) :
moRndWithReplNeighborhood<Neighbor> (_neighborhoodSize), eval(_eval) {
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moRndWithReplNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaRndWithReplNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif

View file

@ -1,90 +0,0 @@
/*
<moCudaRndWithoutReplNeighborhood.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2010
Jerémie Humeau, Boufaras Karima, Thé Van LUONG
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 _moCudaRndWithoutReplNeighborhood_h
#define _moCudaRndWithoutReplNeighborhood_h
#include <neighborhood/moRndWithoutReplNeighborhood.h>
#include <eval/moCudaEval.h>
/**
* A Random without replacement Neighborhood with parallel evaluation
*/
template<class Neighbor>
class moCudaRndWithoutReplNeighborhood: public moRndWithoutReplNeighborhood<Neighbor> {
public:
/**
* Define type of a solution corresponding to Neighbor
*/
typedef typename Neighbor::EOT EOT;
using moRndWithoutReplNeighborhood<Neighbor>::neighborhoodSize;
using moRndWithoutReplNeighborhood<Neighbor>::maxIndex;
using moRndWithoutReplNeighborhood<Neighbor>::indexVector;
/**
* Constructor
* @param _neighborhoodSize the size of the neighborhood
* @param _eval show how to evaluate neighborhood of a solution at one time
*/
moCudaRndWithoutReplNeighborhood(unsigned int _neighborhoodSize,moCudaEval<
Neighbor>& _eval) :
moRndWithoutReplNeighborhood<Neighbor> (_neighborhoodSize),eval(_eval) {
for (unsigned int i = 0; i < neighborhoodSize; i++)
indexVector.push_back(i);
}
/**
* Initialization of the neighborhood
* @param _solution the solution to explore
* @param _neighbor the first neighbor
*/
virtual void init(EOT & _solution, Neighbor & _neighbor) {
moRndWithoutReplNeighborhood<Neighbor>::init(_solution, _neighbor);
//Compute all neighbors fitness at one time
eval.neighborhoodEval(_solution);
}
/**
* Return the class Name
* @return the class name as a std::string
*/
virtual std::string className() const {
return "moCudaRndWithoutReplNeighborhood";
}
protected:
moCudaEval<Neighbor>& eval;
};
#endif