test added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1809 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
a2cf7f781d
commit
c60f80b480
28 changed files with 701 additions and 53 deletions
|
|
@ -60,13 +60,6 @@ class moComparator : public eoBF<const T1 & , const T2 & , bool>
|
|||
public:
|
||||
virtual bool equals(const T1&, const T2&) = 0;
|
||||
|
||||
/**
|
||||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moComparator";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public :
|
|||
* @param _eval an evaluation function
|
||||
* @param _neighborComparator a neighbor Comparator
|
||||
* @param _solNeighborComparator a comparator between a solution and a neighbor
|
||||
* @param _k number of neighbors visited
|
||||
*/
|
||||
moNeighborBestStat(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _k = 0):
|
||||
moStat<EOT, Fitness>(true, "neighborhood"),
|
||||
|
|
|
|||
|
|
@ -55,12 +55,12 @@ public:
|
|||
moStat(T _value, std::string _description):
|
||||
eoValueParam<T>(_value, _description) {}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moStat";
|
||||
}
|
||||
// /**
|
||||
// * @return name of the class
|
||||
// */
|
||||
// virtual std::string className(void) const {
|
||||
// return "moStat";
|
||||
// }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -56,12 +56,6 @@ public:
|
|||
*/
|
||||
virtual void init(EOT &){}
|
||||
|
||||
/**
|
||||
* @return name of the class
|
||||
*/
|
||||
virtual std::string className(void) const {
|
||||
return "moStatBase";
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
#ifndef moVectorMonitor_h
|
||||
#define moVectorMonitor_h
|
||||
|
||||
#include <fstream>
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <utils/eoParam.h>
|
||||
|
||||
|
|
@ -69,6 +70,14 @@ public:
|
|||
moVectorMonitor(eoValueParam<EOT> & _param) : doubleParam(NULL), intParam(NULL), eotParam(&_param)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _param the parameter of type EOT to save in the vector
|
||||
*/
|
||||
template <class ScalarType, class Compare>
|
||||
moVectorMonitor(eoValueParam<eoScalarFitness<ScalarType, Compare> > & _param) : doubleParam( & (eoValueParam<double>&)_param), intParam(NULL), eotParam(NULL)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param _param the parameter of type EOT to save in the vector
|
||||
|
|
@ -163,11 +172,11 @@ public:
|
|||
*/
|
||||
void fileExport(std::string _filename) {
|
||||
// create file
|
||||
ofstream os(_filename.c_str());
|
||||
std::ofstream os(_filename.c_str());
|
||||
|
||||
if (!os) {
|
||||
string str = "moVectorMonitor: Could not open " + _filename;
|
||||
throw runtime_error(str);
|
||||
std::string str = "moVectorMonitor: Could not open " + _filename;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < size(); i++) {
|
||||
|
|
|
|||
|
|
@ -123,9 +123,9 @@ public:
|
|||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moNeighborhoodExplorer";
|
||||
}
|
||||
// virtual std::string className() const {
|
||||
// return "moNeighborhoodExplorer";
|
||||
// }
|
||||
|
||||
protected:
|
||||
moDummyNeighborhood<Neighbor> dummyNeighborhood;
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ public:
|
|||
* Return the class id.
|
||||
* @return the class name as a std::string
|
||||
*/
|
||||
virtual std::string className() const {
|
||||
return "moIndexNeighborhood";
|
||||
}
|
||||
// virtual std::string className() const {
|
||||
// return "moIndexNeighborhood";
|
||||
// }
|
||||
|
||||
protected:
|
||||
unsigned int neighborhoodSize;
|
||||
|
|
|
|||
|
|
@ -67,11 +67,10 @@ public:
|
|||
*/
|
||||
moAutocorrelationSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbStep) :
|
||||
moSampling<Neighbor>(_init, * new moRandomWalk<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat)
|
||||
{
|
||||
}
|
||||
moSampling<Neighbor>(_init, * new moRandomWalk<Neighbor>(_neighborhood, _fullEval, _eval, _nbStep), fitnessStat){}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ public:
|
|||
moDensityOfStatesSampling(eoInit<EOT> & _init,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
unsigned int _nbSol) :
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat)
|
||||
{
|
||||
}
|
||||
moSampling<Neighbor>(_init, * new moRandomSearch<Neighbor>(_init, _fullEval, _nbSol), fitnessStat){}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
*/
|
||||
~moFDCsampling() {
|
||||
// delete the pointer on the local search which has been constructed in the constructor
|
||||
delete &localSearch;
|
||||
delete localSearch;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -77,9 +77,7 @@ public:
|
|||
fullEval(_fullEval),
|
||||
eval(_eval),
|
||||
nbSol(_nbSol)
|
||||
{
|
||||
// std::cout << "moFitnessCloudSampling: Warming to nothing will be sample." << std::endl;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* default destructor
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@ public:
|
|||
*/
|
||||
moHillClimberSampling(eoInit<EOT> & _init,
|
||||
moNeighborhood<Neighbor> & _neighborhood,
|
||||
eoEvalFunc<EOT>& _fullEval, moEval<Neighbor>& _eval,
|
||||
eoEvalFunc<EOT>& _fullEval,
|
||||
moEval<Neighbor>& _eval,
|
||||
unsigned int _nbAdaptWalk) :
|
||||
moSampling<Neighbor>(initHC, * new moRandomSearch<Neighbor>(initHC, _fullEval, _nbAdaptWalk), copyStat),
|
||||
copyStat(lengthStat),
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
#define moSampling_h
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <eoFunctor.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
#include <continuator/moStat.h>
|
||||
|
|
@ -44,6 +46,7 @@
|
|||
#include <algo/moLocalSearch.h>
|
||||
#include <eoInit.h>
|
||||
|
||||
|
||||
/**
|
||||
* To sample the search space:
|
||||
* A local search is used to sample the search space
|
||||
|
|
@ -97,7 +100,7 @@ public:
|
|||
monitorVec.push_back(monitor);
|
||||
checkpoint->add(*monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To sample the search and get the statistics
|
||||
|
|
@ -131,11 +134,11 @@ public:
|
|||
*/
|
||||
void fileExport(std::string _filename, std::string _delim = " ") {
|
||||
// create file
|
||||
ofstream os(_filename.c_str());
|
||||
std::ofstream os(_filename.c_str());
|
||||
|
||||
if (!os) {
|
||||
string str = "moSampling: Could not open " + _filename;
|
||||
throw runtime_error(str);
|
||||
std::string str = "moSampling: Could not open " + _filename;
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
// all vector have the same size
|
||||
|
|
@ -160,8 +163,8 @@ public:
|
|||
*/
|
||||
void fileExport(unsigned int _col, std::string _filename) {
|
||||
if (_col >= monitorVec.size()) {
|
||||
string str = "moSampling: Could not export into file the vector. The index does not exists (too large)";
|
||||
throw runtime_error(str);
|
||||
std::string str = "moSampling: Could not export into file the vector. The index does not exists (too large)";
|
||||
throw std::runtime_error(str);
|
||||
}
|
||||
|
||||
monitorVec[_col]->fileExport(_filename);
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#define moStatistics_h
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include <utils/eoDistance.h>
|
||||
|
||||
/**
|
||||
|
|
@ -61,7 +62,7 @@ public:
|
|||
* @param avg average to compute
|
||||
* @param std standard deviation to compute
|
||||
*/
|
||||
void basic(const vector<double> & data,
|
||||
void basic(const std::vector<double> & data,
|
||||
double & min, double & max, double & avg, double & std) {
|
||||
|
||||
if (data.size() == 0) {
|
||||
|
|
@ -104,8 +105,8 @@ public:
|
|||
* @param matrix matrix of distances between solutions
|
||||
*/
|
||||
template <class EOT>
|
||||
void distances(const vector<EOT> & data, eoDistance<EOT> & distance,
|
||||
vector< vector<double> > & matrix) {
|
||||
void distances(const std::vector<EOT> & data, eoDistance<EOT> & distance,
|
||||
std::vector< std::vector<double> > & matrix) {
|
||||
if (data.size() == 0) {
|
||||
matrix.resize(0);
|
||||
} else {
|
||||
|
|
@ -134,8 +135,8 @@ public:
|
|||
* @param rho autocorrelation coefficients
|
||||
* @param phi partial autocorrelation coefficients
|
||||
*/
|
||||
void autocorrelation(const vector<double> & data, unsigned int nbS,
|
||||
vector<double> & rho, vector<double> & phi) {
|
||||
void autocorrelation(const std::vector<double> & data, unsigned int nbS,
|
||||
std::vector<double> & rho, std::vector<double> & phi) {
|
||||
if (data.size() == 0) {
|
||||
rho.resize(0);
|
||||
phi.resize(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue