Passage du code dans un pretty printer

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1813 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
jhumeau 2010-05-17 14:56:42 +00:00
commit 3d8057ac4d
88 changed files with 2726 additions and 2720 deletions

View file

@ -37,7 +37,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Abstract class for Acceptance criteria * Abstract class for Acceptance criteria
*/ */
template< class Neighbor > template< class Neighbor >
class moAcceptanceCriterion : public eoBF<typename Neighbor::EOT&, typename Neighbor::EOT&, bool>, virtual public moMemory<Neighbor>{ class moAcceptanceCriterion : public eoBF<typename Neighbor::EOT&, typename Neighbor::EOT&, bool>, virtual public moMemory<Neighbor> {
}; };

View file

@ -37,7 +37,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Acceptance Criterion for extreme diversification : always accept new solution * Acceptance Criterion for extreme diversification : always accept new solution
*/ */
template< class Neighbor > template< class Neighbor >
class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{ class moAlwaysAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
@ -48,7 +48,7 @@ public:
* @param _sol2 the new solution after local search * @param _sol2 the new solution after local search
* @return always true * @return always true
*/ */
bool operator()(EOT& _sol1, EOT& _sol2){ bool operator()(EOT& _sol1, EOT& _sol2) {
return true; return true;
} }

View file

@ -38,12 +38,12 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Acceptance Criterion for extreme intensification : accept if the new solution is better than previous one * Acceptance Criterion for extreme intensification : accept if the new solution is better than previous one
*/ */
template< class Neighbor > template< class Neighbor >
class moBetterAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor>{ class moBetterAcceptCrit : public moAcceptanceCriterion<Neighbor>, public moDummyMemory<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
moBetterAcceptCrit(moSolComparator<EOT>& _comparator):comparator(_comparator){} moBetterAcceptCrit(moSolComparator<EOT>& _comparator):comparator(_comparator) {}
/** /**
* Accept if the new solution is better than previous one * Accept if the new solution is better than previous one
@ -51,7 +51,7 @@ public:
* @param _sol2 the new solution after local search * @param _sol2 the new solution after local search
* @return true if the new solution is better than previous one * @return true if the new solution is better than previous one
*/ */
bool operator()(EOT& _sol1, EOT& _sol2){ bool operator()(EOT& _sol1, EOT& _sol2) {
return comparator(_sol1, _sol2); return comparator(_sol1, _sol2);
} }

View file

@ -97,9 +97,11 @@ public:
private: private:
class dummmyMonOp: public eoMonOp<EOT>{ class dummmyMonOp: public eoMonOp<EOT> {
public: public:
bool operator()(EOT&){return false;} bool operator()(EOT&) {
return false;
}
}dummyOp; }dummyOp;
moIterContinuator<moDummyNeighbor<EOT> > iterCont; moIterContinuator<moDummyNeighbor<EOT> > iterCont;
moMonOpPerturb<Neighbor> defaultPerturb; moMonOpPerturb<Neighbor> defaultPerturb;

View file

@ -65,7 +65,7 @@ public:
* @param _solution a solution * @param _solution a solution
*/ */
virtual void init(EOT & _solution) { virtual void init(EOT & _solution) {
for(unsigned int i = 0; i < continuators.size(); ++i) for (unsigned int i = 0; i < continuators.size(); ++i)
continuators[i]->init(_solution); continuators[i]->init(_solution);
} }
@ -78,7 +78,7 @@ public:
// some data may be update in each continuator. // some data may be update in each continuator.
// So, all continuators are tested // So, all continuators are tested
for(unsigned int i = 0; i < continuators.size(); ++i) for (unsigned int i = 0; i < continuators.size(); ++i)
if ( !(*continuators[i])(_solution) ) if ( !(*continuators[i])(_solution) )
bContinue = false; bContinue = false;

View file

@ -46,7 +46,7 @@ public:
/** /**
* @param _maxFit maximum fitness to reach * @param _maxFit maximum fitness to reach
*/ */
moFitContinuator(Fitness _maxFit): maxFit(_maxFit){} moFitContinuator(Fitness _maxFit): maxFit(_maxFit) {}
/** /**
*@param _solution a solution *@param _solution a solution

View file

@ -46,7 +46,7 @@ public:
* @param _maxIter number maximum of iterations * @param _maxIter number maximum of iterations
* @param _verbose true/false : verbose mode on/off * @param _verbose true/false : verbose mode on/off
*/ */
moIterContinuator(unsigned int _maxIter, bool _verbose=true): maxIter(_maxIter), verbose(_verbose){} moIterContinuator(unsigned int _maxIter, bool _verbose=true): maxIter(_maxIter), verbose(_verbose) {}
/** /**
*@param _solution a solution *@param _solution a solution
@ -56,7 +56,7 @@ public:
bool res; bool res;
cpt++; cpt++;
res = (cpt < maxIter); res = (cpt < maxIter);
if(!res && verbose) if (!res && verbose)
std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl; std::cout << "STOP in moIterContinuator: Reached maximum number of iterations [" << cpt << "/" << maxIter << "]" << std::endl;
return res; return res;
} }

View file

@ -51,7 +51,7 @@ public:
* @param _eval neighbor evaluation function to count * @param _eval neighbor evaluation function to count
* @param _maxNeighborEval number maximum of iterations * @param _maxNeighborEval number maximum of iterations
*/ */
moNeighborEvalContinuator(moEvalCounter<Neighbor> & _eval, unsigned int _maxNeighborEval): eval(_eval), maxNeighborEval(_maxNeighborEval){} moNeighborEvalContinuator(moEvalCounter<Neighbor> & _eval, unsigned int _maxNeighborEval): eval(_eval), maxNeighborEval(_maxNeighborEval) {}
/** /**
* Test if continue * Test if continue

View file

@ -54,7 +54,7 @@ public:
/** /**
* first call of a statistical operator * first call of a statistical operator
*/ */
virtual void init(EOT &){} virtual void init(EOT &) {}
}; };

View file

@ -47,7 +47,7 @@ public:
* @param _max maximum running time$ * @param _max maximum running time$
* @param _verbose verbose mode true/false -> on/off * @param _verbose verbose mode true/false -> on/off
*/ */
moTimeContinuator(time_t _max, bool _verbose=true): max(_max), verbose(_verbose){ moTimeContinuator(time_t _max, bool _verbose=true): max(_max), verbose(_verbose) {
start = time(NULL); start = time(NULL);
} }
@ -61,7 +61,7 @@ public:
bool res; bool res;
time_t elapsed = (time_t) difftime(time(NULL), start); time_t elapsed = (time_t) difftime(time(NULL), start);
res = (elapsed < max); res = (elapsed < max);
if(!res && verbose) if (!res && verbose)
std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl; std::cout << "STOP in moTimeContinuator: Reached maximum time [" << elapsed << "/" << max << "]" << std::endl;
return res; return res;
} }

View file

@ -179,7 +179,7 @@ public:
throw std::runtime_error(str); throw std::runtime_error(str);
} }
for(unsigned int i = 0; i < size(); i++) { for (unsigned int i = 0; i < size(); i++) {
os << getValue(i); os << getValue(i);
os << std::endl ; os << std::endl ;

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Dummy Evaluation function * Dummy Evaluation function
*/ */
template<class Neighbor> template<class Neighbor>
class moDummyEval : public moEval<Neighbor>{ class moDummyEval : public moEval<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
typedef typename EOT::Fitness Fitness; typedef typename EOT::Fitness Fitness;
@ -46,7 +46,7 @@ public:
* @param _sol a solution (unused) * @param _sol a solution (unused)
* @param _n a neighbor (unused) * @param _n a neighbor (unused)
*/ */
void operator()(EOT& _sol, Neighbor& _n){} void operator()(EOT& _sol, Neighbor& _n) {}
}; };

View file

@ -67,7 +67,9 @@ public:
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @return always false * @return always false
*/ */
bool isContinue(EOT& _solution) { return false; } ; bool isContinue(EOT& _solution) {
return false;
} ;
/** /**
* NOTHING TO DO * NOTHING TO DO
@ -80,7 +82,9 @@ public:
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @return always false * @return always false
*/ */
virtual bool accept(EOT& _solution) { return false; } ; virtual bool accept(EOT& _solution) {
return false;
} ;
/** /**
* NOTHING TO DO * NOTHING TO DO

View file

@ -62,14 +62,14 @@ public:
* @param _perturb a perturbation operator * @param _perturb a perturbation operator
* @param _acceptCrit a acceptance criteria * @param _acceptCrit a acceptance criteria
*/ */
moILSexplorer(moLocalSearch<Neighbor>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : moNeighborhoodExplorer<dummyNeighbor>(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit){ moILSexplorer(moLocalSearch<Neighbor>& _ls, moPerturbation<Neighbor>& _perturb, moAcceptanceCriterion<Neighbor>& _acceptCrit) : moNeighborhoodExplorer<dummyNeighbor>(), ls(_ls), perturb(_perturb), acceptCrit(_acceptCrit) {
firstIteration=true; firstIteration=true;
} }
/** /**
* Destructor * Destructor
*/ */
~moILSexplorer(){ ~moILSexplorer() {
} }
@ -77,7 +77,7 @@ public:
* Init perturbation and acceptance criteria * Init perturbation and acceptance criteria
* @param _solution the current solution * @param _solution the current solution
*/ */
virtual void initParam(EOT & _solution){ virtual void initParam(EOT & _solution) {
firstIteration=true; firstIteration=true;
perturb.init(_solution); perturb.init(_solution);
acceptCrit.init(_solution); acceptCrit.init(_solution);
@ -87,8 +87,8 @@ public:
* Update perturbation and acceptance criteria * Update perturbation and acceptance criteria
* @param _solution the current solution * @param _solution the current solution
*/ */
virtual void updateParam(EOT & _solution){ virtual void updateParam(EOT & _solution) {
if((*this).moveApplied()){ if ((*this).moveApplied()) {
perturb.add(_solution,emptyNeighbor); perturb.add(_solution,emptyNeighbor);
acceptCrit.add(_solution,emptyNeighbor); acceptCrit.add(_solution,emptyNeighbor);
} }
@ -100,18 +100,18 @@ public:
* terminate: NOTHING TO DO * terminate: NOTHING TO DO
* @param _solution a solution (unused) * @param _solution a solution (unused)
*/ */
virtual void terminate(EOT & _solution){}; virtual void terminate(EOT & _solution) {};
/** /**
* Perturb and apply local search on a solution * Perturb and apply local search on a solution
* @param _solution the solution * @param _solution the solution
*/ */
virtual void operator()(EOT & _solution){ virtual void operator()(EOT & _solution) {
//copy the solution to perform new local search //copy the solution to perform new local search
current=_solution; current=_solution;
//perturb solution exept at the first iteration //perturb solution exept at the first iteration
if(!firstIteration){ if (!firstIteration) {
perturb(current); perturb(current);
} }

View file

@ -171,7 +171,7 @@ public:
* Getter * Getter
* @return the temperature * @return the temperature
*/ */
double getTemperature(){ double getTemperature() {
return temperature; return temperature;
} }

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Count the number of move, noMove and the number of successive stagnation since the last Move * Count the number of move, noMove and the number of successive stagnation since the last Move
*/ */
template< class Neighbor > template< class Neighbor >
class moCountMoveMemory : virtual public moMemory<Neighbor>{ class moCountMoveMemory : virtual public moMemory<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
@ -82,7 +82,7 @@ public:
* Getter of the number of move * Getter of the number of move
* @return the counter * @return the counter
*/ */
unsigned int getNbMove(){ unsigned int getNbMove() {
return nbMove; return nbMove;
} }
@ -90,7 +90,7 @@ public:
* Getter of the number of no move * Getter of the number of no move
* @return the counter * @return the counter
*/ */
unsigned int getNbNoMove(){ unsigned int getNbNoMove() {
return nbNoMove; return nbNoMove;
} }
@ -98,14 +98,14 @@ public:
* Getter of the number of successive stagnation since the last Move * Getter of the number of successive stagnation since the last Move
* @return the counter * @return the counter
*/ */
unsigned int getCounter(){ unsigned int getCounter() {
return counter; return counter;
} }
/** /**
* Init counter * Init counter
*/ */
void initCounter(){ void initCounter() {
counter=0; counter=0;
} }

View file

@ -37,6 +37,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Abstract class for diversification strategy * Abstract class for diversification strategy
*/ */
template< class Neighbor > template< class Neighbor >
class moDiversification : virtual public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>{}; class moDiversification : virtual public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool> {};
#endif #endif

View file

@ -36,7 +36,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Dummy memory to make an empty memory * Dummy memory to make an empty memory
*/ */
template< class Neighbor > template< class Neighbor >
class moDummyMemory : virtual public moMemory<Neighbor>{ class moDummyMemory : virtual public moMemory<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;

View file

@ -37,6 +37,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Abstract class for intensification strategy * Abstract class for intensification strategy
*/ */
template< class Neighbor > template< class Neighbor >
class moIntensification : virtual public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool>{}; class moIntensification : virtual public moMemory<Neighbor>, public eoUF<typename Neighbor::EOT &,bool> {};
#endif #endif

View file

@ -50,14 +50,14 @@ public:
* @param _monOp an eoMonOp (diversification operator) * @param _monOp an eoMonOp (diversification operator)
* @param _fullEval a full evaluation function * @param _fullEval a full evaluation function
*/ */
moMonOpDiversification(eoMonOp<EOT>& _monOp, eoEvalFunc<EOT>& _fullEval):monOp(_monOp), fullEval(_fullEval){} moMonOpDiversification(eoMonOp<EOT>& _monOp, eoEvalFunc<EOT>& _fullEval):monOp(_monOp), fullEval(_fullEval) {}
/** /**
* Apply monOp on the solution * Apply monOp on the solution
* @param _solution to diversify * @param _solution to diversify
* @return value of monOp * @return value of monOp
*/ */
bool operator()(EOT& _solution){ bool operator()(EOT& _solution) {
bool res = monOp(_solution); bool res = monOp(_solution);
fullEval(_solution); fullEval(_solution);
return res; return res;

View file

@ -88,9 +88,9 @@ public:
* @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) {
if(howlong > 0) if (howlong > 0)
for (unsigned int i=0; i<tabuList.size(); i++) for (unsigned int i=0; i<tabuList.size(); i++)
if(tabuList[i].second > 0) if (tabuList[i].second > 0)
tabuList[i].second--; tabuList[i].second--;
} }

View file

@ -88,9 +88,9 @@ public:
* @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) {
if(howlong > 0) if (howlong > 0)
for (unsigned int i=0; i<tabuList.size(); i++) for (unsigned int i=0; i<tabuList.size(); i++)
if(tabuList[i].second > 0) if (tabuList[i].second > 0)
tabuList[i].second--; tabuList[i].second--;
} }

View file

@ -36,13 +36,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Dummy Neighborhood * Dummy Neighborhood
*/ */
template< class EOT > template< class EOT >
class moDummyNeighbor : public moNeighbor< EOT >{ class moDummyNeighbor : public moNeighbor< EOT > {
public: public:
/** /**
* NOTHING TO DO * NOTHING TO DO
* @param _solution the related solution * @param _solution the related solution
*/ */
virtual void move(EOT& _solution){} virtual void move(EOT& _solution) {}
}; };
#endif #endif

View file

@ -37,7 +37,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Dummy Neighborhood * Dummy Neighborhood
*/ */
template< class Neighbor > template< class Neighbor >
class moDummyNeighborhood : public moNeighborhood<Neighbor>{ class moDummyNeighborhood : public moNeighborhood<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
@ -46,7 +46,7 @@ public:
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @return always false * @return always false
*/ */
virtual bool hasNeighbor(EOT & _solution){ virtual bool hasNeighbor(EOT & _solution) {
return false; return false;
} }
@ -55,21 +55,21 @@ public:
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @param _current a neighbor (unused) * @param _current a neighbor (unused)
*/ */
virtual void init(EOT & _solution, Neighbor & _current){} virtual void init(EOT & _solution, Neighbor & _current) {}
/** /**
* NOTHING TO DO * NOTHING TO DO
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @param _current a neighbor (unused) * @param _current a neighbor (unused)
*/ */
virtual void next(EOT & _solution, Neighbor & _current){} virtual void next(EOT & _solution, Neighbor & _current) {}
/** /**
* NOTHING TO DO * NOTHING TO DO
* @param _solution a solution (unused) * @param _solution a solution (unused)
* @return always false * @return always false
*/ */
virtual bool cont(EOT & _solution){ virtual bool cont(EOT & _solution) {
return false; return false;
} }

View file

@ -98,7 +98,7 @@ public:
* @param _neighbor a neighbor * @param _neighbor a neighbor
* @return if _neighbor and this one are equals * @return if _neighbor and this one are equals
*/ */
virtual bool equals(moIndexNeighbor<EOT>& _neighbor){ virtual bool equals(moIndexNeighbor<EOT>& _neighbor) {
return (key==_neighbor.index()); return (key==_neighbor.index());
} }

View file

@ -107,7 +107,7 @@ public:
* @param _neighbor a neighbor * @param _neighbor a neighbor
* @return if _neighbor and this one are equals * @return if _neighbor and this one are equals
*/ */
virtual bool equals(moNeighbor<EOT>& _neighbor){ virtual bool equals(moNeighbor<EOT>& _neighbor) {
return false; return false;
} }

View file

@ -53,7 +53,7 @@ public:
* Apply the local search on the solution * Apply the local search on the solution
* @param _solution to perturb * @param _solution to perturb
*/ */
void operator()(EOT& _solution){ void operator()(EOT& _solution) {
init(_solution); init(_solution);
ls(_solution); ls(_solution);
} }

View file

@ -49,14 +49,14 @@ public:
* @param _monOp an eoMonOp (pertubation operator) * @param _monOp an eoMonOp (pertubation operator)
* @param _fullEval a full evaluation function * @param _fullEval a full evaluation function
*/ */
moMonOpPerturb(eoMonOp<EOT>& _monOp, eoEvalFunc<EOT>& _fullEval):monOp(_monOp), fullEval(_fullEval){} moMonOpPerturb(eoMonOp<EOT>& _monOp, eoEvalFunc<EOT>& _fullEval):monOp(_monOp), fullEval(_fullEval) {}
/** /**
* Apply monOp on the solution * Apply monOp on the solution
* @param _solution to perturb * @param _solution to perturb
* @return value of monOp * @return value of monOp
*/ */
bool operator()(EOT& _solution){ bool operator()(EOT& _solution) {
bool res = monOp(_solution); bool res = monOp(_solution);
fullEval(_solution); fullEval(_solution);
return res; return res;

View file

@ -38,7 +38,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
* Neighborhood Perturbation: explore the neighborhood to perturb the solution (the neighborhood could be different as the one used in the Local Search) * Neighborhood Perturbation: explore the neighborhood to perturb the solution (the neighborhood could be different as the one used in the Local Search)
*/ */
template< class Neighbor, class OtherNeighbor > template< class Neighbor, class OtherNeighbor >
class moNeighborhoodPerturb : public moPerturbation<Neighbor>{ class moNeighborhoodPerturb : public moPerturbation<Neighbor> {
public: public:
typedef typename Neighbor::EOT EOT; typedef typename Neighbor::EOT EOT;
@ -49,15 +49,15 @@ public:
* @param _otherNeighborhood a neighborhood * @param _otherNeighborhood a neighborhood
* @param _eval an Evaluation Function * @param _eval an Evaluation Function
*/ */
moNeighborhoodPerturb(OtherNH& _otherNeighborhood, moEval<OtherNeighbor>& _eval): otherNeighborhood(_otherNeighborhood), eval(_eval){} moNeighborhoodPerturb(OtherNH& _otherNeighborhood, moEval<OtherNeighbor>& _eval): otherNeighborhood(_otherNeighborhood), eval(_eval) {}
/** /**
* Apply move on the solution * Apply move on the solution
* @param _solution the current solution * @param _solution the current solution
* @return true * @return true
*/ */
virtual bool operator()(EOT& _solution){ virtual bool operator()(EOT& _solution) {
if(otherNeighborhood.hasNeighbor(_solution)){ if (otherNeighborhood.hasNeighbor(_solution)) {
eval(_solution, current); eval(_solution, current);
current.move(_solution); current.move(_solution);
_solution.fitness(current.fitness()); _solution.fitness(current.fitness());
@ -69,8 +69,8 @@ public:
* Init the neighborhood * Init the neighborhood
* @param _sol the current solution * @param _sol the current solution
*/ */
virtual void init(EOT & _sol){ virtual void init(EOT & _sol) {
if(otherNeighborhood.hasNeighbor(_sol)) if (otherNeighborhood.hasNeighbor(_sol))
otherNeighborhood.init(_sol, current); otherNeighborhood.init(_sol, current);
} }
@ -79,7 +79,7 @@ public:
* @param _sol the current solution * @param _sol the current solution
* @param _neighbor unused neighbor (always empty) * @param _neighbor unused neighbor (always empty)
*/ */
virtual void add(EOT & _sol, Neighbor & _neighbor){ virtual void add(EOT & _sol, Neighbor & _neighbor) {
(*this).init(_sol); (*this).init(_sol);
} }
@ -88,8 +88,8 @@ public:
* @param _sol the current solution * @param _sol the current solution
* @param _neighbor unused neighbor (always empty) * @param _neighbor unused neighbor (always empty)
*/ */
virtual void update(EOT & _sol, Neighbor & _neighbor){ virtual void update(EOT & _sol, Neighbor & _neighbor) {
if(otherNeighborhood.cont(_sol)) if (otherNeighborhood.cont(_sol))
otherNeighborhood.next(_sol, current); otherNeighborhood.next(_sol, current);
else else
(*this).init(_sol); (*this).init(_sol);
@ -98,7 +98,7 @@ public:
/** /**
* NOTHING TO DO * NOTHING TO DO
*/ */
virtual void clearMemory(){} virtual void clearMemory() {}
private: private:
OtherNH& otherNeighborhood; OtherNH& otherNeighborhood;

View file

@ -58,8 +58,8 @@ public:
* @param _solution to restart * @param _solution to restart
* @return true * @return true
*/ */
bool operator()(EOT& _solution){ bool operator()(EOT& _solution) {
if((*this).getCounter()>= threshold){ if ((*this).getCounter()>= threshold) {
initializer(_solution); initializer(_solution);
fullEval(_solution); fullEval(_solution);
(*this).initCounter(); (*this).initCounter();

View file

@ -49,7 +49,7 @@ public:
* Initialization on the externatl solution * Initialization on the externatl solution
* @param _solution to initialize * @param _solution to initialize
*/ */
void operator()(EOT& _solution){ void operator()(EOT& _solution) {
_solution = extSol; _solution = extSol;
} }

View file

@ -68,7 +68,7 @@ public :
int nc; int nc;
bool litt; bool litt;
for(unsigned int k = 0; k < size; k++) { for (unsigned int k = 0; k < size; k++) {
// number of the clause // number of the clause
nc = modifiedClauses[k]; nc = modifiedClauses[k];

View file

@ -46,20 +46,20 @@ public:
* Apply move on a solution regarding a key * Apply move on a solution regarding a key
* @param _sol the solution to move * @param _sol the solution to move
*/ */
virtual void move(EOT & _sol){ virtual void move(EOT & _sol) {
unsigned int tmp ; unsigned int tmp ;
size=_sol.size(); size=_sol.size();
translate(key+1); translate(key+1);
// keep the first component to change // keep the first component to change
tmp = _sol[first]; tmp = _sol[first];
// shift // shift
if (first < second){ if (first < second) {
for (unsigned int i=first; i<second-1; i++) for (unsigned int i=first; i<second-1; i++)
_sol[i] = _sol[i+1]; _sol[i] = _sol[i+1];
// shift the first component // shift the first component
_sol[second-1] = tmp; _sol[second-1] = tmp;
} }
else{ /* first > second*/ else { /* first > second*/
for (unsigned int i=first; i>second; i--) for (unsigned int i=first; i>second; i--)
_sol[i] = _sol[i-1]; _sol[i] = _sol[i-1];
// shift the first component // shift the first component
@ -72,15 +72,15 @@ public:
* fix two indexes regarding a key * fix two indexes regarding a key
* @param _key the key allowing to compute the two indexes for the shift * @param _key the key allowing to compute the two indexes for the shift
*/ */
void translate(unsigned int _key){ void translate(unsigned int _key) {
int step; int step;
int val = _key; int val = _key;
int tmpSize = size * (size-1) / 2; int tmpSize = size * (size-1) / 2;
// moves from left to right // moves from left to right
if (val <= tmpSize){ if (val <= tmpSize) {
step = size - 1; step = size - 1;
first = 0; first = 0;
while ((val - step) > 0){ while ((val - step) > 0) {
val = val - step; val = val - step;
step--; step--;
first++; first++;
@ -88,11 +88,11 @@ public:
second = first + val + 1; second = first + val + 1;
} }
// moves from right to left (equivalent moves are avoided) // moves from right to left (equivalent moves are avoided)
else{ /* val > tmpSize */ else { /* val > tmpSize */
val = val - tmpSize; val = val - tmpSize;
step = size - 2; step = size - 2;
second = 0; second = 0;
while ((val - step) > 0){ while ((val - step) > 0) {
val = val - step; val = val - step;
step--; step--;
second++; second++;
@ -101,7 +101,7 @@ public:
} }
} }
void print(){ void print() {
std::cout << key << ": [" << first << ", " << second << "] -> " << (*this).fitness() << std::endl; std::cout << key << ": [" << first << ", " << second << "] -> " << (*this).fitness() << std::endl;
} }

View file

@ -45,7 +45,7 @@ public:
* Apply the swap * Apply the swap
* @param _solution the solution to move * @param _solution the solution to move
*/ */
virtual void move(EOT& _solution){ virtual void move(EOT& _solution) {
unsigned int tmp; unsigned int tmp;
tmp=_solution[indices.first]; tmp=_solution[indices.first];
_solution[indices.first]=_solution[indices.second]; _solution[indices.first]=_solution[indices.second];
@ -57,7 +57,7 @@ public:
* apply the swap to restore the solution (use by moFullEvalByModif) * apply the swap to restore the solution (use by moFullEvalByModif)
* @param _solution the solution to move * @param _solution the solution to move
*/ */
virtual void moveBack(EOT& _solution){ virtual void moveBack(EOT& _solution) {
unsigned int tmp; unsigned int tmp;
tmp=_solution[indices.first]; tmp=_solution[indices.first];
_solution[indices.first]=_solution[indices.second]; _solution[indices.first]=_solution[indices.second];
@ -70,7 +70,7 @@ public:
* @param _first first index * @param _first first index
* @param _second second index * @param _second second index
*/ */
void setIndices(unsigned int _first, unsigned int _second){ void setIndices(unsigned int _first, unsigned int _second) {
indices.first = _first; indices.first = _first;
indices.second = _second; indices.second = _second;
} }
@ -78,7 +78,7 @@ public:
/** /**
* Print the Neighbor * Print the Neighbor
*/ */
void print(){ void print() {
std::cout << "[" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl; std::cout << "[" << indices.first << ", " << indices.second << "] -> " << (*this).fitness() << std::endl;
} }

View file

@ -45,7 +45,7 @@ public:
/** /**
* @return if there are available Neighbor * @return if there are available Neighbor
*/ */
virtual bool hasNeighbor(EOT& _solution){ virtual bool hasNeighbor(EOT& _solution) {
return (_solution.size() > 1); return (_solution.size() > 1);
}; };
@ -54,7 +54,7 @@ public:
* @param _solution the solution to explore * @param _solution the solution to explore
* @param _current the first neighbor * @param _current the first neighbor
*/ */
virtual void init(EOT& _solution, Neighbor& _current){ virtual void init(EOT& _solution, Neighbor& _current) {
indices.first=0; indices.first=0;
indices.second=1; indices.second=1;
size=_solution.size(); size=_solution.size();
@ -66,8 +66,8 @@ public:
* @param _solution the solution to explore * @param _solution the solution to explore
* @param _current the next neighbor * @param _current the next neighbor
*/ */
virtual void next(EOT& _solution, Neighbor& _current){ virtual void next(EOT& _solution, Neighbor& _current) {
if(indices.second==size-1){ if (indices.second==size-1) {
indices.first++; indices.first++;
indices.second=indices.first+1; indices.second=indices.first+1;
} }
@ -81,7 +81,7 @@ public:
* @param _solution the solution to explore * @param _solution the solution to explore
* @return if there is again a neighbor not explored * @return if there is again a neighbor not explored
*/ */
virtual bool cont(EOT& _solution){ virtual bool cont(EOT& _solution) {
return !((indices.first == (size-2)) && (indices.second == (size-1))); return !((indices.first == (size-2)) && (indices.second == (size-1)));
} }

View file

@ -70,7 +70,7 @@ public:
eoEvalFunc<EOT>& _fullEval, eoEvalFunc<EOT>& _fullEval,
moEval<Neighbor>& _eval, moEval<Neighbor>& _eval,
unsigned int _nbStep) : 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 * default destructor

View file

@ -64,7 +64,7 @@ public:
moDensityOfStatesSampling(eoInit<EOT> & _init, moDensityOfStatesSampling(eoInit<EOT> & _init,
eoEvalFunc<EOT>& _fullEval, eoEvalFunc<EOT>& _fullEval,
unsigned int _nbSol) : 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 * default destructor

View file

@ -79,7 +79,7 @@ public:
*/ */
~moSampling() { ~moSampling() {
// delete all monitors // delete all monitors
for(unsigned i = 0; i < monitorVec.size(); i++) for (unsigned i = 0; i < monitorVec.size(); i++)
delete monitorVec[i]; delete monitorVec[i];
// delete the checkpoint // delete the checkpoint
@ -108,7 +108,7 @@ public:
*/ */
void operator()(void) { void operator()(void) {
// clear all statistic vectors // clear all statistic vectors
for(unsigned i = 0; i < monitorVec.size(); i++) for (unsigned i = 0; i < monitorVec.size(); i++)
monitorVec[i]->clear(); monitorVec[i]->clear();
// change the checkpoint to compute the statistics // change the checkpoint to compute the statistics
@ -144,10 +144,10 @@ public:
// all vector have the same size // all vector have the same size
unsigned vecSize = monitorVec[0]->size(); unsigned vecSize = monitorVec[0]->size();
for(unsigned int i = 0; i < vecSize; i++) { for (unsigned int i = 0; i < vecSize; i++) {
os << monitorVec[0]->getValue(i); os << monitorVec[0]->getValue(i);
for(unsigned int j = 1; j < monitorVec.size(); j++) { for (unsigned int j = 1; j < monitorVec.size(); j++) {
os << _delim.c_str() << monitorVec[j]->getValue(i); os << _delim.c_str() << monitorVec[j]->getValue(i);
} }

View file

@ -79,7 +79,7 @@ public:
std = 0.0; std = 0.0;
double d; double d;
for(unsigned int i = 0; i < n; i++) { for (unsigned int i = 0; i < n; i++) {
d = data[i]; d = data[i];
if (d < min) if (d < min)
min = d; min = d;
@ -113,13 +113,13 @@ public:
unsigned int n = data.size(); unsigned int n = data.size();
matrix.resize(n); matrix.resize(n);
for(unsigned i = 0; i < n; i++) for (unsigned i = 0; i < n; i++)
matrix[i].resize(n); matrix[i].resize(n);
unsigned j; unsigned j;
for(unsigned i = 0; i < n; i++) { for (unsigned i = 0; i < n; i++) {
matrix[i][i] = 0.0; matrix[i][i] = 0.0;
for(j = 0; j < i; j++) { for (j = 0; j < i; j++) {
matrix[i][j] = distance(data[i], data[j]); matrix[i][j] = distance(data[i], data[j]);
matrix[j][i] = matrix[i][j]; matrix[j][i] = matrix[i][j];
} }
@ -154,7 +154,7 @@ public:
unsigned s, k; unsigned s, k;
for(s = 0; s <= nbS; s++) { for (s = 0; s <= nbS; s++) {
cov[s] = 0; cov[s] = 0;
m[s] = 0; m[s] = 0;
sig[s] = 0; sig[s] = 0;
@ -167,7 +167,7 @@ public:
s = nbS; s = nbS;
while (s > 0) { while (s > 0) {
while (k + s < n) { while (k + s < n) {
for(j = 0; j <= s; j++) { for (j = 0; j <= s; j++) {
m[j] += data[k+j]; m[j] += data[k+j];
sig[j] += data[k+j] * data[k+j]; sig[j] += data[k+j] * data[k+j];
cov[j] += data[k] * data[k+j]; cov[j] += data[k] * data[k+j];
@ -192,19 +192,19 @@ public:
double tmp1, tmp2; double tmp1, tmp2;
phi2[1][1] = rho[1]; phi2[1][1] = rho[1];
for(k = 2; k <= nbS; k++) { for (k = 2; k <= nbS; k++) {
tmp1 = 0; tmp1 = 0;
tmp2 = 0; tmp2 = 0;
for(j = 1; j < k; j++) { for (j = 1; j < k; j++) {
tmp1 += phi2[k-1][j] * rho[k-j]; tmp1 += phi2[k-1][j] * rho[k-j];
tmp2 += phi2[k-1][j] * rho[j]; tmp2 += phi2[k-1][j] * rho[j];
} }
phi2[k][k] = (rho[k] - tmp1) / (1 - tmp2); phi2[k][k] = (rho[k] - tmp1) / (1 - tmp2);
for(j = 1; j < k; j++) for (j = 1; j < k; j++)
phi2[k][j] = phi2[k-1][j] - phi2[k][k] * phi2[k-1][k-j]; phi2[k][j] = phi2[k-1][j] - phi2[k][k] * phi2[k-1][k-j];
} }
for(j = 1; j <= nbS; j++) for (j = 1; j <= nbS; j++)
phi[j] = phi2[j][j]; phi[j] = phi2[j][j];
} }