passage du code dans astyle

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1713 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-03-24 10:25:33 +00:00
commit dd66b5e4bd
105 changed files with 3950 additions and 3924 deletions

View file

@ -62,7 +62,7 @@ public:
*/ */
virtual bool operator() (EOT & _solution) { virtual bool operator() (EOT & _solution) {
if(_solution.invalid()) if (_solution.invalid())
fullEval(_solution); fullEval(_solution);
// initialization of the parameter of the search (for example fill empty the tabu list) // initialization of the parameter of the search (for example fill empty the tabu list)
@ -77,7 +77,7 @@ public:
// explore the neighborhood of the solution // explore the neighborhood of the solution
searchExplorer(_solution); searchExplorer(_solution);
// if a solution in the neighborhood can be accepted // if a solution in the neighborhood can be accepted
if (searchExplorer.accept(_solution)){ if (searchExplorer.accept(_solution)) {
searchExplorer.move(_solution); searchExplorer.move(_solution);
searchExplorer.moveApplied(true); searchExplorer.moveApplied(true);
} }

View file

@ -55,7 +55,7 @@ public :
* @param _cont a continuator * @param _cont a continuator
* @param _interval frequency to compute statistical operators * @param _interval frequency to compute statistical operators
*/ */
moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0){ moCheckpoint(moContinuator<Neighborhood>& _cont, unsigned int _interval=1):interval(_interval), counter(0) {
continuators.push_back(&_cont); continuators.push_back(&_cont);
} }
@ -96,7 +96,7 @@ public :
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void init(EOT& _sol) { virtual void init(EOT& _sol) {
for(unsigned i = 0; i < continuators.size(); ++i) for (unsigned i = 0; i < continuators.size(); ++i)
continuators[i]->init(_sol); continuators[i]->init(_sol);
} }
@ -116,8 +116,8 @@ public :
unsigned i; unsigned i;
bool bContinue = true; bool bContinue = true;
for (i = 0; i < stats.size(); ++i){ for (i = 0; i < stats.size(); ++i) {
if(counter % interval == 0) if (counter % interval == 0)
(*stats[i])(_sol); (*stats[i])(_sol);
counter++; counter++;
} }
@ -139,7 +139,7 @@ public :
* last call of statistic operators, monitors and updaters * last call of statistic operators, monitors and updaters
* @param _sol reference of the solution * @param _sol reference of the solution
*/ */
void lastCall(EOT& _sol){ void lastCall(EOT& _sol) {
unsigned int i; unsigned int i;
for (i = 0; i < stats.size(); ++i) for (i = 0; i < stats.size(); ++i)
stats[i]->lastCall(_sol); stats[i]->lastCall(_sol);

View file

@ -51,13 +51,13 @@ public:
* Init Continuator parameters * Init Continuator parameters
* @param _solution the related solution * @param _solution the related solution
*/ */
virtual void init(EOT& _solution){}; virtual void init(EOT& _solution) {};
/** /**
* Last Call to terminate the checkpoint * Last Call to terminate the checkpoint
* @param _solution the related solution * @param _solution the related solution
*/ */
virtual void lastCall(EOT& _solution){}; virtual void lastCall(EOT& _solution) {};
}; };
#endif #endif

View file

@ -83,7 +83,9 @@ public :
/** /**
* @return name of the class * @return name of the class
*/ */
virtual std::string className(void) const { return "moCounterMonitorSaver"; } virtual std::string className(void) const {
return "moCounterMonitorSaver";
}
private : private :
/** interval and counter value */ /** interval and counter value */

View file

@ -54,20 +54,22 @@ public :
* @param _dist a distance * @param _dist a distance
* @param _ref the reference solution * @param _ref the reference solution
*/ */
moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref){} moDistanceStat(eoDistance<EOT> & _dist, EOT & _ref): moStat<EOT, T>(0, "distance"), dist(_dist), refSolution(_ref) {}
/** /**
* Compute distance between a solution and the reference solution * Compute distance between a solution and the reference solution
* @param _sol a solution * @param _sol a solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = dist(_sol, refSolution); value() = dist(_sol, refSolution);
} }
/** /**
* @return name of the class * @return name of the class
*/ */
virtual std::string className(void) const { return "moDistanceStat"; } virtual std::string className(void) const {
return "moDistanceStat";
}
private: private:
/** the distance */ /** the distance */

View file

@ -54,7 +54,7 @@ public :
* @param _description a description of the stat * @param _description a description of the stat
*/ */
moFitnessStat(std::string _description = "fitness"): moFitnessStat(std::string _description = "fitness"):
moStat<EOT, Fitness>(Fitness(), _description){} moStat<EOT, Fitness>(Fitness(), _description) {}
/** /**
* store fitness value * store fitness value
@ -68,7 +68,9 @@ public :
/** /**
* @return the name of the class * @return the name of the class
*/ */
virtual std::string className(void) const { return "moFitnessStat"; } virtual std::string className(void) const {
return "moFitnessStat";
}
}; };
#endif #endif

View file

@ -55,20 +55,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moMaxNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){} moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/** /**
* Set the max fitness in the neighborhood * Set the max fitness in the neighborhood
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getMax(); value() = nhStat.getMax();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moMaxNeighborStat"; } virtual std::string className(void) const {
return "moMaxNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -55,20 +55,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moMinNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat){} moStat<EOT, Fitness>(Fitness(), "min"), nhStat(_nhStat) {}
/** /**
* Set the worst fitness in the neighborhood * Set the worst fitness in the neighborhood
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getMin(); value() = nhStat.getMin();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moMinNeighborStat"; } virtual std::string className(void) const {
return "moMinNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -58,20 +58,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moNbInfNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat){} moStat<EOT, unsigned>(0, "nb inf"), nhStat(_nhStat) {}
/** /**
* Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution * Set the number of solutions in the neighborhood with (strictly) lower fitness than the current solution
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getNbInf(); value() = nhStat.getNbInf();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moNbInfNeighborStat"; } virtual std::string className(void) const {
return "moNbInfNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -58,20 +58,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moNbSupNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat){} moStat<EOT, unsigned>(0, "nb sup"), nhStat(_nhStat) {}
/** /**
* Set the number of solutions in the neighborhood with better fitness than the current solution * Set the number of solutions in the neighborhood with better fitness than the current solution
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getNbSup(); value() = nhStat.getNbSup();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moNbSupNeighborStat"; } virtual std::string className(void) const {
return "moNbSupNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -73,12 +73,12 @@ public :
* Compute classical statistics of a solution's neighborhood * Compute classical statistics of a solution's neighborhood
* @param _solution the corresponding solution * @param _solution the corresponding solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
Neighbor current ; Neighbor current ;
Neighbor best ; Neighbor best ;
Neighbor lowest ; Neighbor lowest ;
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, current); neighborhood.init(_solution, current);
@ -141,7 +141,7 @@ public :
else else
sd = 0.0; sd = 0.0;
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
value() = false; value() = false;
} }
@ -150,49 +150,49 @@ public :
/** /**
* @return the worst fitness value found in the neighborhood * @return the worst fitness value found in the neighborhood
*/ */
Fitness getMin(){ Fitness getMin() {
return min; return min;
} }
/** /**
* @return the best fitness value found in the neighborhood * @return the best fitness value found in the neighborhood
*/ */
Fitness getMax(){ Fitness getMax() {
return max; return max;
} }
/** /**
* @return the mean fitness value of the neighborhood * @return the mean fitness value of the neighborhood
*/ */
double getMean(){ double getMean() {
return mean; return mean;
} }
/** /**
* @return the standard deviation value of the neighborhood * @return the standard deviation value of the neighborhood
*/ */
double getSD(){ double getSD() {
return sd; return sd;
} }
/** /**
* @return the size of the neighborhood * @return the size of the neighborhood
*/ */
unsigned getSize(){ unsigned getSize() {
return nb; return nb;
} }
/** /**
* @return the number of neighbors having a better fitness than the current solution * @return the number of neighbors having a better fitness than the current solution
*/ */
unsigned getNbSup(){ unsigned getNbSup() {
return nbSup; return nbSup;
} }
/** /**
* @return the number of neighbors having the same fitness than the current solution * @return the number of neighbors having the same fitness than the current solution
*/ */
unsigned getNbEqual(){ unsigned getNbEqual() {
return nbEqual; return nbEqual;
} }

View file

@ -57,20 +57,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moNeutralDegreeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat){} moStat<EOT, unsigned>(0, "neutral degree"), nhStat(_nhStat) {}
/** /**
* Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness * Set the neutral degree of the solution which is the number of solutions in the neighborhood with equals fitness
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getNbEqual(); value() = nhStat.getNbEqual();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moNeutralDegreeNeighborStat"; } virtual std::string className(void) const {
return "moNeutralDegreeNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -55,13 +55,13 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moSecondMomentNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat){} moStat<EOT, std::pair<double, double> >(std::make_pair(0.0,0.0), "average and stdev"), nhStat(_nhStat) {}
/** /**
* Set the average and the standard deviation of fitness in the neighborhood * Set the average and the standard deviation of fitness in the neighborhood
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value().first = nhStat.getMean(); value().first = nhStat.getMean();
value().second = nhStat.getSD(); value().second = nhStat.getSD();
} }
@ -69,7 +69,9 @@ public :
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moSecondMomentNeighborStat"; } virtual std::string className(void) const {
return "moSecondMomentNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -56,20 +56,22 @@ public :
* @param _nhStat a neighborhoodStat * @param _nhStat a neighborhoodStat
*/ */
moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat): moSizeNeighborStat(moNeighborhoodStat<Neighborhood> & _nhStat):
moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat){} moStat<EOT, unsigned>(0, "size"), nhStat(_nhStat) {}
/** /**
* Set the number of solutions in the neighborhood * Set the number of solutions in the neighborhood
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = nhStat.getSize(); value() = nhStat.getSize();
} }
/** /**
* @return the class name * @return the class name
*/ */
virtual std::string className(void) const { return "moSizeNeighborStat"; } virtual std::string className(void) const {
return "moSizeNeighborStat";
}
private: private:
/** moNeighborhoodStat */ /** moNeighborhoodStat */

View file

@ -53,20 +53,20 @@ public :
* @param _description a description of the parameter * @param _description a description of the parameter
*/ */
moSolutionStat(std::string _description = "solution"): moSolutionStat(std::string _description = "solution"):
moStat<EOT, EOT>(EOT(), _description){} moStat<EOT, EOT>(EOT(), _description) {}
/** /**
* Set the solution by copy * Set the solution by copy
* @param _sol the corresponding solution * @param _sol the corresponding solution
*/ */
virtual void operator()(EOT & _sol){ virtual void operator()(EOT & _sol) {
value() = _sol; value() = _sol;
} }
/** /**
* @return name of the class * @return name of the class
*/ */
virtual std::string className(void) const{ virtual std::string className(void) const {
return "moSolutionStat"; return "moSolutionStat";
} }
}; };

View file

@ -53,12 +53,12 @@ public:
* @param _description a description of the parameter * @param _description a description of the parameter
*/ */
moStat(T _value, std::string _description): moStat(T _value, std::string _description):
eoValueParam<T>(_value, _description){} eoValueParam<T>(_value, _description) {}
/** /**
* @return name of the class * @return name of the class
*/ */
virtual std::string className(void) const{ virtual std::string className(void) const {
return "moStat"; return "moStat";
} }
}; };

View file

@ -57,7 +57,7 @@ public:
/** /**
* @return name of the class * @return name of the class
*/ */
virtual std::string className(void) const{ virtual std::string className(void) const {
return "moStatBase"; return "moStatBase";
} }
}; };

View file

@ -67,33 +67,33 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moFirstImprExplorer(){ ~moFirstImprExplorer() {
delete current; delete current;
} }
/** /**
* initParam: NOTHING TO DO * initParam: NOTHING TO DO
*/ */
virtual void initParam(EOT & solution){}; virtual void initParam(EOT & solution) {};
/** /**
* updateParam: NOTHING TO DO * updateParam: NOTHING TO DO
*/ */
virtual void updateParam(EOT & solution){}; virtual void updateParam(EOT & solution) {};
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & solution){}; virtual void terminate(EOT & solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
@ -108,7 +108,7 @@ public:
eval(_solution, (*current)); eval(_solution, (*current));
} }
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
isAccept=false; isAccept=false;
} }
@ -140,7 +140,7 @@ public:
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
isAccept = solNeighborComparator(_solution, (*current)) ; isAccept = solNeighborComparator(_solution, (*current)) ;
} }
return isAccept; return isAccept;

View file

@ -70,9 +70,9 @@ public:
moSolNeighborComparator<Neighbor>& _solNeighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator,
unsigned _nbStep) : unsigned _nbStep) :
moSimpleHCneutralExplorer<Neighborhood>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator), moSimpleHCneutralExplorer<Neighborhood>(_neighborhood, _eval, _neighborComparator, _solNeighborComparator),
nbStep(_nbStep){ nbStep(_nbStep) {
//Some cycle is possible with equals fitness solutions if the neighborhood is not random //Some cycle is possible with equals fitness solutions if the neighborhood is not random
if(!neighborhood.isRandom()){ if (!neighborhood.isRandom()) {
std::cout << "moHCneutralExplorer::Warning -> the neighborhood used is not random" << std::endl; std::cout << "moHCneutralExplorer::Warning -> the neighborhood used is not random" << std::endl;
} }
} }
@ -80,13 +80,13 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moHCneutralExplorer(){ ~moHCneutralExplorer() {
} }
/** /**
* initial number of step * initial number of step
*/ */
virtual void initParam(EOT & solution){ virtual void initParam(EOT & solution) {
moSimpleHCneutralExplorer<Neighborhood>::initParam(solution); moSimpleHCneutralExplorer<Neighborhood>::initParam(solution);
step = 0; step = 0;
@ -95,7 +95,7 @@ public:
/** /**
* one more step * one more step
*/ */
virtual void updateParam(EOT & solution){ virtual void updateParam(EOT & solution) {
moSimpleHCneutralExplorer<Neighborhood>::updateParam(solution); moSimpleHCneutralExplorer<Neighborhood>::updateParam(solution);
step++; step++;
@ -116,7 +116,7 @@ public:
* @return true if the best neighbor ameliorate the fitness or is equals * @return true if the best neighbor ameliorate the fitness or is equals
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)) if (neighborhood.hasNeighbor(_solution))
isAccept = solNeighborComparator(_solution, bestVector[0]) || solNeighborComparator.equals(_solution, bestVector[0]) ; isAccept = solNeighborComparator(_solution, bestVector[0]) || solNeighborComparator.equals(_solution, bestVector[0]) ;
return isAccept; return isAccept;
}; };

View file

@ -69,7 +69,7 @@ public:
moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) { moMetropolisHastingExplorer(Neighborhood& _neighborhood, moEval<Neighbor>& _eval, moNeighborComparator<Neighbor>& _neighborComparator, moSolNeighborComparator<Neighbor>& _solNeighborComparator, unsigned int _nbStep) : moNeighborhoodExplorer<Neighborhood>(_neighborhood, _eval), neighborComparator(_neighborComparator), solNeighborComparator(_solNeighborComparator), nbStep(_nbStep) {
isAccept = false; isAccept = false;
current=new Neighbor(); current=new Neighbor();
if(!neighborhood.isRandom()){ if (!neighborhood.isRandom()) {
std::cout << "moMetropolisHastingExplorer::Warning -> the neighborhood used is not random" << std::endl; std::cout << "moMetropolisHastingExplorer::Warning -> the neighborhood used is not random" << std::endl;
} }
} }
@ -77,7 +77,7 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moMetropolisHastingExplorer(){ ~moMetropolisHastingExplorer() {
delete current; delete current;
} }
@ -85,7 +85,7 @@ public:
* initialization of the number of step to be done * initialization of the number of step to be done
* @param _solution the solution (unused here) * @param _solution the solution (unused here)
*/ */
virtual void initParam(EOT & _solution){ virtual void initParam(EOT & _solution) {
step = 0; step = 0;
isAccept = true; isAccept = true;
}; };
@ -94,7 +94,7 @@ public:
* increase the number of step * increase the number of step
* @param _solution the solution (unused here) * @param _solution the solution (unused here)
*/ */
virtual void updateParam(EOT & _solution){ virtual void updateParam(EOT & _solution) {
step++; step++;
}; };
@ -102,22 +102,22 @@ public:
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
* @param _solution the solution (unused here) * @param _solution the solution (unused here)
*/ */
virtual void terminate(EOT & _solution){}; virtual void terminate(EOT & _solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
//eval the _solution moved with the neighbor and stock the result in the neighbor //eval the _solution moved with the neighbor and stock the result in the neighbor
eval(_solution, (*current)); eval(_solution, (*current));
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
isAccept=false; isAccept=false;
} }
@ -150,19 +150,19 @@ public:
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
double alpha=0.0; double alpha=0.0;
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
if (solNeighborComparator(_solution, *current)) if (solNeighborComparator(_solution, *current))
isAccept = true; isAccept = true;
else{ else {
if(_solution.fitness() != 0){ if (_solution.fitness() != 0) {
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing if ( (double)current->fitness() < (double)_solution.fitness()) // maximizing
alpha = (double) current->fitness() / (double) _solution.fitness(); alpha = (double) current->fitness() / (double) _solution.fitness();
else //minimizing else //minimizing
alpha = (double) _solution.fitness() / (double) current->fitness(); alpha = (double) _solution.fitness() / (double) current->fitness();
isAccept = (rng.uniform() < alpha) ; isAccept = (rng.uniform() < alpha) ;
} }
else{ else {
if( (double)current->fitness() < (double)_solution.fitness()) // maximizing if ( (double)current->fitness() < (double)_solution.fitness()) // maximizing
isAccept = true; isAccept = true;
else else
isAccept = false; isAccept = false;

View file

@ -102,7 +102,7 @@ public:
* Getter for variable "isMoved" * Getter for variable "isMoved"
* @return true if move is applied * @return true if move is applied
*/ */
bool moveApplied(){ bool moveApplied() {
return isMoved; return isMoved;
} }
@ -110,7 +110,7 @@ public:
* Setter for variable "isMoved" * Setter for variable "isMoved"
* @param _isMoved * @param _isMoved
*/ */
void moveApplied(bool _isMoved){ void moveApplied(bool _isMoved) {
isMoved=_isMoved; isMoved=_isMoved;
} }

View file

@ -69,7 +69,7 @@ public:
nbStep(_nbStep) { nbStep(_nbStep) {
isAccept = false; isAccept = false;
current=new Neighbor(); current=new Neighbor();
if(!neighborhood.isRandom()){ if (!neighborhood.isRandom()) {
std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random" << std::endl; std::cout << "moRandomNeutralWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
} }
} }
@ -77,14 +77,14 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moRandomNeutralWalkExplorer(){ ~moRandomNeutralWalkExplorer() {
delete current; delete current;
} }
/** /**
* initialization of the number of step to be done * initialization of the number of step to be done
*/ */
virtual void initParam(EOT & solution){ virtual void initParam(EOT & solution) {
step = 0; step = 0;
isAccept = true; isAccept = true;
}; };
@ -92,22 +92,22 @@ public:
/** /**
* increase the number of step * increase the number of step
*/ */
virtual void updateParam(EOT & solution){ virtual void updateParam(EOT & solution) {
step++; step++;
}; };
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & solution){}; virtual void terminate(EOT & solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
@ -122,7 +122,7 @@ public:
eval(_solution, (*current)); eval(_solution, (*current));
} }
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
isAccept=false; isAccept=false;
} }
@ -154,7 +154,7 @@ public:
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)) if (neighborhood.hasNeighbor(_solution))
isAccept = solNeighborComparator.equals(_solution, (*current)) ; isAccept = solNeighborComparator.equals(_solution, (*current)) ;
return isAccept; return isAccept;
}; };

View file

@ -63,7 +63,7 @@ public:
current=new Neighbor(); current=new Neighbor();
// number of step done // number of step done
step = 0; step = 0;
if(!neighborhood.isRandom()){ if (!neighborhood.isRandom()) {
std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl; std::cout << "moRandomWalkExplorer::Warning -> the neighborhood used is not random" << std::endl;
} }
} }
@ -71,14 +71,14 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moRandomWalkExplorer(){ ~moRandomWalkExplorer() {
delete current; delete current;
} }
/** /**
* initialization of the number of step to be done * initialization of the number of step to be done
*/ */
virtual void initParam(EOT & solution){ virtual void initParam(EOT & solution) {
step = 0; step = 0;
isAccept = true; isAccept = true;
}; };
@ -86,23 +86,23 @@ public:
/** /**
* increase the number of step * increase the number of step
*/ */
virtual void updateParam(EOT & solution){ virtual void updateParam(EOT & solution) {
step++; step++;
}; };
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & solution){}; virtual void terminate(EOT & solution) {};
/** /**
* Explore the neighborhood with only one random solution * Explore the neighborhood with only one random solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
@ -111,7 +111,7 @@ public:
isAccept = true; isAccept = true;
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
isAccept=false; isAccept=false;
} }
@ -143,7 +143,7 @@ public:
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)) if (neighborhood.hasNeighbor(_solution))
isAccept = true ; isAccept = true ;
return isAccept; return isAccept;
}; };

View file

@ -68,7 +68,7 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moSimpleHCexplorer(){ ~moSimpleHCexplorer() {
delete current; delete current;
delete best; delete best;
} }
@ -76,27 +76,27 @@ public:
/** /**
* initParam: NOTHING TO DO * initParam: NOTHING TO DO
*/ */
virtual void initParam(EOT & solution){}; virtual void initParam(EOT & solution) {};
/** /**
* updateParam: NOTHING TO DO * updateParam: NOTHING TO DO
*/ */
virtual void updateParam(EOT & solution){}; virtual void updateParam(EOT & solution) {};
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & solution){}; virtual void terminate(EOT & solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//est qu'on peut initializer //est qu'on peut initializer
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
@ -119,7 +119,7 @@ public:
} }
} }
else{ else {
//if _solution hasn't neighbor, //if _solution hasn't neighbor,
isAccept=false; isAccept=false;
} }
@ -151,7 +151,7 @@ public:
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
isAccept = solNeighborComparator(_solution, (*best)) ; isAccept = solNeighborComparator(_solution, (*best)) ;
} }
return isAccept; return isAccept;

View file

@ -75,14 +75,14 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moSimpleHCneutralExplorer(){ ~moSimpleHCneutralExplorer() {
delete current; delete current;
} }
/** /**
* empty the vector of best solutions * empty the vector of best solutions
*/ */
virtual void initParam(EOT & solution){ virtual void initParam(EOT & solution) {
// delete all the best solutions // delete all the best solutions
bestVector.clear(); bestVector.clear();
}; };
@ -90,7 +90,7 @@ public:
/** /**
* empty the vector of best solutions * empty the vector of best solutions
*/ */
virtual void updateParam(EOT & solution){ virtual void updateParam(EOT & solution) {
// delete all the best solutions // delete all the best solutions
bestVector.clear(); bestVector.clear();
}; };
@ -98,16 +98,16 @@ public:
/** /**
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
*/ */
virtual void terminate(EOT & solution){}; virtual void terminate(EOT & solution) {};
/** /**
* Explore the neighborhood of a solution * Explore the neighborhood of a solution
* @param _solution * @param _solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//Test if _solution has a Neighbor //Test if _solution has a Neighbor
if(neighborhood.hasNeighbor(_solution)){ if (neighborhood.hasNeighbor(_solution)) {
//init the first neighbor //init the first neighbor
neighborhood.init(_solution, (*current)); neighborhood.init(_solution, (*current));
@ -170,7 +170,7 @@ public:
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution) { virtual bool accept(EOT & _solution) {
if(neighborhood.hasNeighbor(_solution)) if (neighborhood.hasNeighbor(_solution))
isAccept = solNeighborComparator(_solution, bestVector[0]) ; isAccept = solNeighborComparator(_solution, bestVector[0]) ;
return isAccept; return isAccept;
}; };

View file

@ -85,7 +85,7 @@ public:
/** /**
* Destructor * Destructor
*/ */
~moTSExplorer(){ ~moTSExplorer() {
delete current; delete current;
delete best; delete best;
} }
@ -110,11 +110,11 @@ public:
*/ */
virtual void updateParam(EOT& _solution) virtual void updateParam(EOT& _solution)
{ {
if ((*this).moveApplied()){ if ((*this).moveApplied()) {
tabuList.add(_solution, *best); tabuList.add(_solution, *best);
intensification.add(_solution, *best); intensification.add(_solution, *best);
diversification.add(_solution, *best); diversification.add(_solution, *best);
if(_solution.fitness() > bestSoFar.fitness()) if (_solution.fitness() > bestSoFar.fitness())
bestSoFar = _solution; bestSoFar = _solution;
} }
tabuList.update(_solution, *best); tabuList.update(_solution, *best);
@ -127,7 +127,7 @@ public:
/** /**
* terminate : _solution becomes the best so far * terminate : _solution becomes the best so far
*/ */
virtual void terminate(EOT & _solution){ virtual void terminate(EOT & _solution) {
_solution= bestSoFar; _solution= bestSoFar;
}; };
@ -141,7 +141,7 @@ public:
bool found=false; bool found=false;
intensification(_solution); intensification(_solution);
diversification(_solution); diversification(_solution);
if(neighborhood.hasNeighbor(_solution)) if (neighborhood.hasNeighbor(_solution))
{ {
//init the current neighbor //init the current neighbor
neighborhood.init(_solution, *current); neighborhood.init(_solution, *current);
@ -149,43 +149,43 @@ public:
eval(_solution, *current); eval(_solution, *current);
//Find the first non-tabu element //Find the first non-tabu element
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ){ if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ) {
// set best // set best
(*best)= (*current); (*best)= (*current);
found=true; found=true;
} }
while(neighborhood.cont(_solution) && !found){ while (neighborhood.cont(_solution) && !found) {
//next neighbor //next neighbor
neighborhood.next(_solution, (*current)); neighborhood.next(_solution, (*current));
//eval //eval
eval(_solution, (*current)); eval(_solution, (*current));
if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ){ if ( (!tabuList.check(_solution, *current)) || aspiration(_solution, *current) ) {
// set best // set best
(*best)=(*current); (*best)=(*current);
found=true; found=true;
} }
} }
//Explore the neighborhood //Explore the neighborhood
if(found){ if (found) {
isAccept=true; isAccept=true;
while(neighborhood.cont(_solution)){ while (neighborhood.cont(_solution)) {
//next neighbor //next neighbor
neighborhood.next(_solution, (*current)); neighborhood.next(_solution, (*current));
//eval //eval
eval(_solution, (*current)); eval(_solution, (*current));
//check if the current is better than the best and is not tabu or if it is aspirat (by the aspiration criteria of course) //check if the current is better than the best and is not tabu or if it is aspirat (by the aspiration criteria of course)
if ( (!tabuList.check(_solution, *current) || aspiration(_solution, (*current))) && neighborComparator((*best),(*current))){ if ( (!tabuList.check(_solution, *current) || aspiration(_solution, (*current))) && neighborComparator((*best),(*current))) {
// set best // set best
(*best)=(*current); (*best)=(*current);
} }
} }
} }
else{ else {
isAccept=false; isAccept=false;
} }
} }
else{ else {
isAccept=false; isAccept=false;
} }
}; };
@ -196,7 +196,7 @@ public:
* @param _solution the solution * @param _solution the solution
* @return true * @return true
*/ */
virtual bool isContinue(EOT & _solution){ virtual bool isContinue(EOT & _solution) {
return true; return true;
}; };
@ -218,7 +218,7 @@ public:
* @param _solution the solution * @param _solution the solution
* @return true if the best neighbor ameliorate the fitness * @return true if the best neighbor ameliorate the fitness
*/ */
virtual bool accept(EOT & _solution){ virtual bool accept(EOT & _solution) {
return isAccept; return isAccept;
}; };

View file

@ -17,7 +17,7 @@ public:
* init the best solution * init the best solution
* @param _sol the best solution found * @param _sol the best solution found
*/ */
void init(EOT & _sol){ void init(EOT & _sol) {
bestFoundSoFar = _sol; bestFoundSoFar = _sol;
} }
@ -26,7 +26,7 @@ public:
* @param _sol a solution * @param _sol a solution
* @param _neighbor a neighbor * @param _neighbor a neighbor
*/ */
void update(EOT & _sol, Neighbor & _neighbor){ void update(EOT & _sol, Neighbor & _neighbor) {
if (bestFoundSoFar.fitness() < _sol.fitness()) if (bestFoundSoFar.fitness() < _sol.fitness())
bestFoundSoFar = _sol; bestFoundSoFar = _sol;
} }
@ -38,7 +38,7 @@ public:
* @param _neighbor a neighbor * @param _neighbor a neighbor
* @return true if _neighbor fitness is better than the "bestFoundSoFar" * @return true if _neighbor fitness is better than the "bestFoundSoFar"
*/ */
bool operator()(EOT & _sol, Neighbor & _neighbor){ bool operator()(EOT & _sol, Neighbor & _neighbor) {
return (bestFoundSoFar.fitness() < _neighbor.fitness()); return (bestFoundSoFar.fitness() < _neighbor.fitness());
} }
@ -46,7 +46,7 @@ public:
* Getter * Getter
* @return a reference on the best found so far solution * @return a reference on the best found so far solution
*/ */
EOT& getBest(){ EOT& getBest() {
return bestFoundSoFar; return bestFoundSoFar;
} }

View file

@ -9,6 +9,6 @@
*/ */
template< class Neighbor > template< class Neighbor >
class moDiversification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool> class moDiversification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
{}; {};
#endif #endif

View file

@ -35,7 +35,7 @@ public:
/** /**
* @return always false * @return always false
*/ */
bool operator()(EOT &){ bool operator()(EOT &) {
return false; return false;
} }
}; };

View file

@ -35,7 +35,7 @@ public:
/** /**
* @return always false * @return always false
*/ */
bool operator()(EOT &){ bool operator()(EOT &) {
return false; return false;
} }
}; };

View file

@ -9,6 +9,6 @@
*/ */
template< class Neighbor > template< class Neighbor >
class moIntensification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool> class moIntensification : public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>
{}; {};
#endif #endif

View file

@ -19,7 +19,7 @@ public:
* @param _maxSize maximum size of the tabu list * @param _maxSize maximum size of the tabu list
* @param _howlong how many iteration a move is tabu * @param _howlong how many iteration a move is tabu
*/ */
moSolVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong){ moSolVectorTabuList(unsigned int _maxSize, unsigned int _howlong) : maxSize(_maxSize), howlong(_howlong) {
tabuList.reserve(_maxSize); tabuList.reserve(_maxSize);
tabuList.resize(0); tabuList.resize(0);
} }
@ -28,7 +28,7 @@ public:
* init the tabuList by clearing the memory * init the tabuList by clearing the memory
* @param _sol the current solution * @param _sol the current solution
*/ */
virtual void init(EOT & _sol){ virtual void init(EOT & _sol) {
clearMemory(); clearMemory();
} }
@ -38,15 +38,15 @@ public:
* @param _sol the current solution * @param _sol the current solution
* @param _neighbor the current neighbor (unused) * @param _neighbor the current neighbor (unused)
*/ */
virtual void add(EOT & _sol, Neighbor & _neighbor){ virtual void add(EOT & _sol, Neighbor & _neighbor) {
if(tabuList.size() < maxSize){ if (tabuList.size() < maxSize) {
std::pair<EOT, unsigned int> tmp; std::pair<EOT, unsigned int> tmp;
tmp.first=_sol; tmp.first=_sol;
tmp.second=howlong; tmp.second=howlong;
tabuList.push_back(tmp); tabuList.push_back(tmp);
} }
else{ else {
tabuList[index%maxSize].first = _sol; tabuList[index%maxSize].first = _sol;
tabuList[index%maxSize].second = howlong; tabuList[index%maxSize].second = howlong;
index++; index++;
@ -58,8 +58,8 @@ public:
* @param _sol the current solution * @param _sol the current solution
* @param _neighbor the current neighbor (unused) * @param _neighbor the current neighbor (unused)
*/ */
virtual void update(EOT & _sol, Neighbor & _neighbor){ virtual void update(EOT & _sol, Neighbor & _neighbor) {
for(unsigned int i=0; i<tabuList.size(); i++) for (unsigned int i=0; i<tabuList.size(); i++)
tabuList[i].second--; tabuList[i].second--;
} }
@ -69,10 +69,10 @@ public:
* @param _neighbor the current neighbor (unused) * @param _neighbor the current neighbor (unused)
* @return true if tabuList contains _sol * @return true if tabuList contains _sol
*/ */
virtual bool check(EOT & _sol, Neighbor & _neighbor){ virtual bool check(EOT & _sol, Neighbor & _neighbor) {
EOT tmp=_sol; EOT tmp=_sol;
_neighbor.move(tmp); _neighbor.move(tmp);
for(unsigned int i=0; i<tabuList.size(); i++){ for (unsigned int i=0; i<tabuList.size(); i++) {
if ((howlong > 0 && tabuList[i].second > 0 && tabuList[i].first == tmp) || (howlong==0 && tabuList[i].first==tmp)) if ((howlong > 0 && tabuList[i].second > 0 && tabuList[i].first == tmp) || (howlong==0 && tabuList[i].first==tmp))
return true; return true;
} }
@ -82,7 +82,7 @@ public:
/** /**
* clearMemory: remove all solution of the tabuList * clearMemory: remove all solution of the tabuList
*/ */
virtual void clearMemory(){ virtual void clearMemory() {
tabuList.resize(0); tabuList.resize(0);
index = 0; index = 0;
} }

View file

@ -87,10 +87,10 @@ public:
std::string fitness_str; std::string fitness_str;
int pos = _is.tellg(); int pos = _is.tellg();
_is >> fitness_str; _is >> fitness_str;
if (fitness_str == "INVALID"){ if (fitness_str == "INVALID") {
throw std::runtime_error("invalid fitness"); throw std::runtime_error("invalid fitness");
} }
else{ else {
Fitness repFit ; Fitness repFit ;
_is.seekg(pos); // rewind _is.seekg(pos); // rewind
_is >> repFit; _is >> repFit;

View file

@ -50,7 +50,7 @@ public:
/** /**
* Default Constructor * Default Constructor
*/ */
moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0){} moIndexNeighbor() : moNeighbor<EOT, Fitness>(), key(0) {}
/** /**
* Copy Constructor * Copy Constructor
@ -80,7 +80,7 @@ public:
* Getter * Getter
* @return index of the IndexNeighbor * @return index of the IndexNeighbor
*/ */
unsigned int index(){ unsigned int index() {
return key; return key;
} }
@ -88,7 +88,7 @@ public:
* Setter * Setter
* @param _key index of the IndexNeighbor * @param _key index of the IndexNeighbor
*/ */
void index(unsigned int _key){ void index(unsigned int _key) {
key=_key; key=_key;
} }

View file

@ -53,7 +53,7 @@ public:
* Constructor * Constructor
* @param _neighborhoodSize the size of the neighborhood * @param _neighborhoodSize the size of the neighborhood
*/ */
moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize){} moIndexNeighborhood(unsigned int _neighborhoodSize):neighborhoodSize(_neighborhoodSize) {}
/** /**
* Return the class id. * Return the class id.

View file

@ -51,7 +51,7 @@ public:
/** /**
* Default Constructor * Default Constructor
*/ */
moNeighbor(){} moNeighbor() {}
/** /**
* Copy Constructor * Copy Constructor
@ -98,7 +98,7 @@ public:
* Set fitness. At the same time, validates it. * Set fitness. At the same time, validates it.
* @param _fitness new fitness value. * @param _fitness new fitness value.
*/ */
void fitness(const Fitness& _fitness){ void fitness(const Fitness& _fitness) {
repFitness = _fitness; repFitness = _fitness;
} }
@ -106,7 +106,9 @@ public:
* Return the class id. * Return the class id.
* @return the class name as a std::string * @return the class name as a std::string
*/ */
virtual std::string className() const { return "moNeighbor"; } virtual std::string className() const {
return "moNeighbor";
}
/** /**
* Read object. * Read object.

View file

@ -52,12 +52,12 @@ public:
/** /**
* Default Constructor * Default Constructor
*/ */
moNeighborhood(){} moNeighborhood() {}
/** /**
* @return if the neighborhood is random * @return if the neighborhood is random
*/ */
virtual bool isRandom(){ virtual bool isRandom() {
return false; return false;
} }

View file

@ -59,7 +59,7 @@ public:
* Constructor * Constructor
* @param _neighborhoodSize the size of the neighborhood * @param _neighborhoodSize the size of the neighborhood
*/ */
moOrderNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), currentIndex(0){} moOrderNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), currentIndex(0) {}
/** /**
* Test if it exist a neighbor * Test if it exist a neighbor
@ -105,7 +105,7 @@ public:
* Getter * Getter
* @return the position in the Neighborhood * @return the position in the Neighborhood
*/ */
unsigned int position(){ unsigned int position() {
return currentIndex; return currentIndex;
} }

View file

@ -33,11 +33,11 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <neighborhood/moNeighborhood.h> #include <neighborhood/moNeighborhood.h>
template< class Neighbor > template< class Neighbor >
class moRndNeighborhood : virtual public moNeighborhood<Neighbor>{ class moRndNeighborhood : virtual public moNeighborhood<Neighbor> {
public: public:
bool isRandom(){ bool isRandom() {
return true; return true;
} }
}; };

View file

@ -60,7 +60,7 @@ public:
* Constructor * Constructor
* @param _neighborhoodSize the size of the neighborhood * @param _neighborhoodSize the size of the neighborhood
*/ */
moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize){} moRndWithReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize) {}
/** /**
* Test if it exist a neighbor * Test if it exist a neighbor

View file

@ -60,8 +60,8 @@ public:
* Constructor * Constructor
* @param _neighborhoodSize the size of the neighborhood * @param _neighborhoodSize the size of the neighborhood
*/ */
moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0){ moRndWithoutReplNeighborhood(unsigned int _neighborhoodSize): moIndexNeighborhood<Neighbor>(_neighborhoodSize), maxIndex(0) {
for(unsigned int i=0; i < neighborhoodSize; i++) for (unsigned int i=0; i < neighborhoodSize; i++)
indexVector.push_back(i); indexVector.push_back(i);
} }
@ -119,7 +119,7 @@ public:
* Getter * Getter
* @return the position in the Neighborhood * @return the position in the Neighborhood
*/ */
unsigned int position(){ unsigned int position() {
return indexVector[maxIndex]; return indexVector[maxIndex];
} }

View file

@ -15,13 +15,13 @@ public:
using moEval<BackableNeighbor>::EOT EOT; using moEval<BackableNeighbor>::EOT EOT;
using moEval<BackableNeighbor>::Fitness Fitness; using moEval<BackableNeighbor>::Fitness Fitness;
moIncrEvalWrapper(moIncrEval<M>& _incr):incr(_incr){} moIncrEvalWrapper(moIncrEval<M>& _incr):incr(_incr) {}
/* /*
* make the evaluation of the current neighbor and update the information on this neighbor * make the evaluation of the current neighbor and update the information on this neighbor
* the evaluation could be incremental * the evaluation could be incremental
*/ */
virtual void eval(MoveNeighbor& _neighbor,EOT & _solution){ virtual void eval(MoveNeighbor& _neighbor,EOT & _solution) {
_neighbor.fitness(incrEval(*(_neighbor.getMove()), _solution)); _neighbor.fitness(incrEval(*(_neighbor.getMove()), _solution));
} }

View file

@ -48,7 +48,7 @@
template < class EOT > template < class EOT >
class moMove:public eoUF < EOT &, void > class moMove:public eoUF < EOT &, void >
{ {
public: public:
// Alias for the type // Alias for the type
typedef EOT EOType; typedef EOT EOType;

View file

@ -47,6 +47,6 @@
*/ */
template < class M, class Objective = typename M::EOType::Fitness> template < class M, class Objective = typename M::EOType::Fitness>
class moMoveIncrEval:public eoBF < const M &, const typename M::EOType &, Objective > class moMoveIncrEval:public eoBF < const M &, const typename M::EOType &, Objective >
{}; {};
#endif #endif

View file

@ -45,6 +45,6 @@
*/ */
template < class M > template < class M >
class moMoveInit:public eoBF < M &, const typename M::EOType &, void > class moMoveInit:public eoBF < M &, const typename M::EOType &, void >
{}; {};
#endif #endif

View file

@ -12,7 +12,7 @@
contener of the neighbor informations contener of the neighbor informations
*/ */
template< class M , class Fitness > template< class M , class Fitness >
class moMoveNeighbor : public moNeighbor <typename M::EOType, Fitness> class moMoveNeighbor : public moNeighbor <typename M::EOType, Fitness>
{ {
public: public:
@ -43,20 +43,22 @@ public:
/* /*
* move the solution * move the solution
*/ */
virtual void move(EOT & _solution){ virtual void move(EOT & _solution) {
(*move)(_solution); (*move)(_solution);
} }
/** Return the class id. /** Return the class id.
* @return the class name as a std::string * @return the class name as a std::string
*/ */
virtual std::string className() const { return "moMoveNeighbor"; } virtual std::string className() const {
return "moMoveNeighbor";
}
void setMove(M* _move){ void setMove(M* _move) {
move=_move; move=_move;
} }
M* getMove(){ M* getMove() {
return move; return move;
} }

View file

@ -8,7 +8,7 @@
#include <move/moNextMove.h> #include <move/moNextMove.h>
template< class M, class Fitness > template< class M, class Fitness >
class moMoveNeighborhood : public moNeighborhood <moMoveNeighbor<M, Fitness> > class moMoveNeighborhood : public moNeighborhood <moMoveNeighbor<M, Fitness> >
{ {
public: public:
@ -17,14 +17,14 @@ public:
moMoveNeighborhood(moMoveInit<M>& i, moNextMove<M>& n):_init(i), _next(n), isContinue(true) {} moMoveNeighborhood(moMoveInit<M>& i, moNextMove<M>& n):_init(i), _next(n), isContinue(true) {}
virtual bool hasNeighbor(EOT & solution){ virtual bool hasNeighbor(EOT & solution) {
return true; return true;
} }
/* /*
initialisation of the neighborhood initialisation of the neighborhood
*/ */
virtual void init(EOT & solution, Neighbor & current){ virtual void init(EOT & solution, Neighbor & current) {
_init(*(current._move), solution); _init(*(current._move), solution);
isContinue=true; isContinue=true;
} }
@ -32,23 +32,25 @@ public:
/* /*
Give the next neighbor Give the next neighbor
*/ */
virtual void next(EOT & solution, Neighbor & current){ virtual void next(EOT & solution, Neighbor & current) {
isContinue=_next(*(current._move), solution); isContinue=_next(*(current._move), solution);
} }
/* /*
if false, there is no neighbor left to explore if false, there is no neighbor left to explore
*/ */
virtual bool cont(EOT & solution){ virtual bool cont(EOT & solution) {
return isContinue; return isContinue;
} }
/** Return the class id. /** Return the class id.
* @return the class name as a std::string * @return the class name as a std::string
*/ */
virtual std::string className() const { return "moMoveNeighborhood"; } virtual std::string className() const {
return "moMoveNeighborhood";
}
private: private:
moMoveInit<M>& _init; moMoveInit<M>& _init;
moNextMove<M>& _next; moNextMove<M>& _next;
bool isContinue; bool isContinue;

View file

@ -45,6 +45,6 @@
*/ */
template < class M > template < class M >
class moNextMove:public eoBF < M &, const typename M::EOType &, bool > class moNextMove:public eoBF < M &, const typename M::EOType &, bool >
{}; {};
#endif #endif

View file

@ -54,44 +54,44 @@
typedef eoBit<eoMinimizingFitness> bitVector; typedef eoBit<eoMinimizingFitness> bitVector;
typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ; typedef moBitNeighbor<eoMinimizingFitness> bitNeighbor ;
class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/{ class moDummyRndNeighborhood: public moOrderNeighborhood<bitNeighbor>/*, public moRndNeighborhood<bitNeighbor>*/ {
public: public:
moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a){} moDummyRndNeighborhood(unsigned int a): moOrderNeighborhood<bitNeighbor>(a) {}
}; };
typedef moDummyRndNeighborhood bitNeighborhood ; typedef moDummyRndNeighborhood bitNeighborhood ;
typedef EO<int> Solution; typedef EO<int> Solution;
class moDummyNeighbor : public moNeighbor<Solution,int>{ class moDummyNeighbor : public moNeighbor<Solution,int> {
public: public:
virtual void move(Solution & _solution){} virtual void move(Solution & _solution) {}
}; };
class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int>{ class moDummyBackableNeighbor : public moBackableNeighbor<Solution,int> {
public: public:
virtual void move(Solution & _solution){} virtual void move(Solution & _solution) {}
virtual void moveBack(Solution & _solution){} virtual void moveBack(Solution & _solution) {}
}; };
class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor>{ class moDummyNeighborhood : public moNeighborhood<moDummyNeighbor> {
public: public:
typedef moDummyNeighbor Neighbor; typedef moDummyNeighbor Neighbor;
moDummyNeighborhood():i(0),j(0){} moDummyNeighborhood():i(0),j(0) {}
virtual bool hasNeighbor(EOT & _solution){ virtual bool hasNeighbor(EOT & _solution) {
bool res; bool res;
if(i%3==0) if (i%3==0)
res=false; res=false;
else else
res=true; res=true;
i++; i++;
return res; return res;
} }
virtual void init(EOT & _solution, Neighbor & _current){} virtual void init(EOT & _solution, Neighbor & _current) {}
virtual void next(EOT & _solution, Neighbor & _current){} virtual void next(EOT & _solution, Neighbor & _current) {}
virtual bool cont(EOT & _solution){ virtual bool cont(EOT & _solution) {
j++; j++;
return (j%10!=0); return (j%10!=0);
} }
@ -100,10 +100,10 @@ private:
int i,j; int i,j;
}; };
class moDummyEval: public eoEvalFunc<Solution>{ class moDummyEval: public eoEvalFunc<Solution> {
public: public:
void operator()(Solution& _sol){ void operator()(Solution& _sol) {
if(_sol.invalid()) if (_sol.invalid())
_sol.fitness(100); _sol.fitness(100);
else else
_sol.fitness(_sol.fitness()+50); _sol.fitness(_sol.fitness()+50);
@ -122,7 +122,7 @@ public:
void operator() (bitVector& _sol, bitNeighbor& _n) { void operator() (bitVector& _sol, bitNeighbor& _n) {
unsigned int fit = _sol.fitness(); unsigned int fit = _sol.fitness();
if(_sol[_n.index()]) if (_sol[_n.index()])
fit--; fit--;
else else
fit++; fit++;
@ -150,14 +150,14 @@ class monitor1 : public eoMonitor
{ {
public: public:
monitor1(unsigned int& _a): a(_a){} monitor1(unsigned int& _a): a(_a) {}
eoMonitor& operator()(){ eoMonitor& operator()() {
a++; a++;
return *this; return *this;
} }
void lastCall(){ void lastCall() {
a++; a++;
} }
@ -169,14 +169,14 @@ class monitor2 : public eoMonitor
{ {
public: public:
monitor2(unsigned int& _a): a(_a){} monitor2(unsigned int& _a): a(_a) {}
eoMonitor& operator()(){ eoMonitor& operator()() {
a++; a++;
return *this; return *this;
} }
void lastCall(){ void lastCall() {
a++; a++;
} }
@ -187,13 +187,13 @@ private:
class updater1: public eoUpdater class updater1: public eoUpdater
{ {
public: public:
updater1(unsigned int& _a): a(_a){} updater1(unsigned int& _a): a(_a) {}
void operator()(){ void operator()() {
a++; a++;
} }
void lastCall(){ void lastCall() {
a++; a++;
} }

View file

@ -33,7 +33,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moBestImprAspiration] => START" << std::endl; std::cout << "[t-moBestImprAspiration] => START" << std::endl;

View file

@ -37,7 +37,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moBitNeighbor] => START" << std::endl; std::cout << "[t-moBitNeighbor] => START" << std::endl;

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moCheckpoint] => START" << std::endl; std::cout << "[t-moCheckpoint] => START" << std::endl;

View file

@ -35,7 +35,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moCounterMonitorSaver] => START" << std::endl; std::cout << "[t-moCounterMonitorSaver] => START" << std::endl;

View file

@ -35,7 +35,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moDistanceStat] => START" << std::endl; std::cout << "[t-moDistanceStat] => START" << std::endl;

View file

@ -35,7 +35,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moDummyMemory] => START" << std::endl; std::cout << "[t-moDummyMemory] => START" << std::endl;

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moFirstImprExplorer] => START" << std::endl; std::cout << "[t-moFirstImprExplorer] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moFitnessStat] => START" << std::endl; std::cout << "[t-moFitnessStat] => START" << std::endl;

View file

@ -38,7 +38,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval //Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval

View file

@ -38,7 +38,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval //Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moHCneutralExplorer] => START" << std::endl; std::cout << "[t-moHCneutralExplorer] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moMetropolisHastingExplorer] => START" << std::endl; std::cout << "[t-moMetropolisHastingExplorer] => START" << std::endl;
@ -60,9 +60,9 @@ int main(){
unsigned int oui=0, non=0; unsigned int oui=0, non=0;
//test de l'acceptation d'un voisin non améliorant //test de l'acceptation d'un voisin non améliorant
for(unsigned int i=0; i<1000; i++){ for (unsigned int i=0; i<1000; i++) {
test(sol); test(sol);
if(test.accept(sol)) if (test.accept(sol))
oui++; oui++;
else else
non++; non++;

View file

@ -37,7 +37,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moNeighbor] => START" << std::endl; std::cout << "[t-moNeighbor] => START" << std::endl;

View file

@ -40,7 +40,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moNeighborComparator] => START" << std::endl; std::cout << "[t-moNeighborComparator] => START" << std::endl;

View file

@ -46,7 +46,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
/* /*
* Tests all classes depending of moNeighborhoodStat.h * Tests all classes depending of moNeighborhoodStat.h
*/ */
int main(){ int main() {
//test de moNeighborhoodStat.h //test de moNeighborhoodStat.h
std::cout << "[t-moNeighborhoodStat] => START" << std::endl; std::cout << "[t-moNeighborhoodStat] => START" << std::endl;
@ -81,7 +81,7 @@ int main(){
assert(test.getMax()==6); assert(test.getMax()==6);
assert(test.getMean()==6.6); assert(test.getMean()==6.6);
double sd=test.getSD(); double sd=test.getSD();
assert(test.getSD()>0.966 && test.getSD()<0.967); assert(sd>0.966 && sd<0.967);
assert(test.getSize()==10); assert(test.getSize()==10);
assert(test.getNbSup()==7); assert(test.getNbSup()==7);
assert(test.getNbInf()==3); assert(test.getNbInf()==3);

View file

@ -39,7 +39,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moOrderNeighborhood] => START" << std::endl; std::cout << "[t-moOrderNeighborhood] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moRandomNeutralWalkExplorer] => START" << std::endl; std::cout << "[t-moRandomNeutralWalkExplorer] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moRandomWalkExplorer] => START" << std::endl; std::cout << "[t-moRandomWalkExplorer] => START" << std::endl;

View file

@ -35,7 +35,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl; std::cout << "[t-moRndWithReplNeighborhood] => START" << std::endl;
@ -52,7 +52,7 @@ int main(){
test.init(sol,n); test.init(sol,n);
//on s'assure qu'on a bien toujours bien l'index 0, 1 ou 2 qui est renvoyé //on s'assure qu'on a bien toujours bien l'index 0, 1 ou 2 qui est renvoyé
for(unsigned int i=0; i<100; i++){ for (unsigned int i=0; i<100; i++) {
a=n.index(); a=n.index();
test.next(sol,n); test.next(sol,n);

View file

@ -35,7 +35,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl; std::cout << "[t-moRndWithoutReplNeighborhood] => START" << std::endl;

View file

@ -41,7 +41,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
//Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval //Pas grand chose à faire: le gros du travail est fait par le voisin et l'eval

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moSimpleHCneutralExplorer] => START" << std::endl; std::cout << "[t-moSimpleHCneutralExplorer] => START" << std::endl;

View file

@ -40,7 +40,7 @@
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moSolNeighborComparator] => START" << std::endl; std::cout << "[t-moSolNeighborComparator] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moSolVectorTabuList] => START" << std::endl; std::cout << "[t-moSolVectorTabuList] => START" << std::endl;

View file

@ -34,7 +34,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moSolutionStat] => START" << std::endl; std::cout << "[t-moSolutionStat] => START" << std::endl;

View file

@ -38,7 +38,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <cstdlib> #include <cstdlib>
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moTSExplorer] => START" << std::endl; std::cout << "[t-moTSExplorer] => START" << std::endl;

View file

@ -39,7 +39,7 @@
#include <cassert> #include <cassert>
int main(){ int main() {
std::cout << "[t-moTrueContinuator] => START" << std::endl; std::cout << "[t-moTrueContinuator] => START" << std::endl;

View file

@ -72,11 +72,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -187,10 +187,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -76,11 +76,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -191,10 +191,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -76,11 +76,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -191,10 +191,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -94,11 +94,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -268,10 +268,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -82,11 +82,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -233,10 +233,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -72,11 +72,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -187,10 +187,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -72,11 +72,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -187,10 +187,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -74,11 +74,11 @@ void main_function(int argc, char **argv)
// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED // do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED
// i.e. in case you need parameters somewhere else, postpone these // i.e. in case you need parameters somewhere else, postpone these
if (parser.userNeedsHelp()){ if (parser.userNeedsHelp()) {
parser.printHelp(cout); parser.printHelp(cout);
exit(1); exit(1);
} }
if (statusParam.value() != ""){ if (statusParam.value() != "") {
ofstream os(statusParam.value().c_str()); ofstream os(statusParam.value().c_str());
os << parser;// and you can use that file as parameter file os << parser;// and you can use that file as parameter file
} }
@ -193,10 +193,10 @@ void main_function(int argc, char **argv)
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
try{ try {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e){ catch (exception& e) {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }
return 1; return 1;

View file

@ -205,7 +205,7 @@ int main(int argc, char **argv)
{ {
main_function(argc, argv); main_function(argc, argv);
} }
catch(exception& e) catch (exception& e)
{ {
cout << "Exception: " << e.what() << '\n'; cout << "Exception: " << e.what() << '\n';
} }

View file

@ -13,7 +13,7 @@ class BitMove : public moMove <EOT> {
public : public :
typedef EOT EOType; typedef EOT EOType;
unsigned bit; unsigned bit;

View file

@ -12,16 +12,16 @@ template <class EOT>
class OneMaxIncrEval : public moMoveIncrEval < BitMove<EOT> > { class OneMaxIncrEval : public moMoveIncrEval < BitMove<EOT> > {
public : public :
OneMaxIncrEval(){ }; OneMaxIncrEval() { };
typename EOT::Fitness operator () (const BitMove<EOT> & move, const EOT & chrom) { typename EOT::Fitness operator () (const BitMove<EOT> & move, const EOT & chrom) {
if(chrom[move.bit]==0){ if (chrom[move.bit]==0) {
return chrom.fitness()+1; return chrom.fitness()+1;
} }
else{ else {
return chrom.fitness()-1; return chrom.fitness()-1;
} }
}; };
}; };
#endif #endif

View file

@ -18,9 +18,9 @@ public:
bool operator () (BitMove<EOT> & __move, const EOT & genome) { bool operator () (BitMove<EOT> & __move, const EOT & genome) {
if (__move.bit >= (genome.size() - 1)){ if (__move.bit >= (genome.size() - 1)) {
return false ; return false ;
} }
else { else {
__move.bit++; __move.bit++;
return true ; return true ;