diff --git a/mo/src/perturb/moMonOpPerturb.h b/mo/src/perturb/moMonOpPerturb.h index c056bbf6a..a4bcea574 100644 --- a/mo/src/perturb/moMonOpPerturb.h +++ b/mo/src/perturb/moMonOpPerturb.h @@ -48,8 +48,9 @@ public: * Constructor * @param _monOp an eoMonOp (pertubation operator) * @param _fullEval a full evaluation function + * @param _nbPerturbation number of operator executions for perturbation */ - moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval):monOp(_monOp), fullEval(_fullEval) {} + moMonOpPerturb(eoMonOp& _monOp, eoEvalFunc& _fullEval, unsigned int _nbPerturbation = 1):monOp(_monOp), fullEval(_fullEval), nbPerturbation(_nbPerturbation) {} /** * Apply monOp on the solution @@ -57,16 +58,22 @@ public: * @return value of monOp */ bool operator()(EOT& _solution) { - bool res = monOp(_solution); - _solution.invalidate(); - fullEval(_solution); - return res; + bool res = false; + + for(unsigned int i = 0; i < nbPerturbation; i++) + res = res || monOp(_solution); + + _solution.invalidate(); + fullEval(_solution); + + return res; } private: - /** monOp */ - eoMonOp& monOp; - eoEvalFunc& fullEval; + /** monOp */ + eoMonOp& monOp; + eoEvalFunc& fullEval; + unsigned int nbPerturbation; }; #endif diff --git a/mo/src/problems/eval/moQAPIncrEval.h b/mo/src/problems/eval/moQAPIncrEval.h index 3fd529a7f..5c47623d9 100644 --- a/mo/src/problems/eval/moQAPIncrEval.h +++ b/mo/src/problems/eval/moQAPIncrEval.h @@ -61,10 +61,10 @@ public: int d; int k; - unsigned i, j; - - _neighbor.getIndices(n, i, j); + unsigned i = _neighbor.first(); + unsigned j = _neighbor.second(); + // _neighbor.getIndices(n, i, j); d = (A[i][i]-A[j][j])*(B[_solution[j]][_solution[j]]-B[_solution[i]][_solution[i]]) + (A[i][j]-A[j][i])*(B[_solution[j]][_solution[i]]-B[_solution[i]][_solution[j]]); diff --git a/mo/src/problems/permutation/moIndexedSwapNeighbor.h b/mo/src/problems/permutation/moIndexedSwapNeighbor.h index 06491f134..d30305100 100644 --- a/mo/src/problems/permutation/moIndexedSwapNeighbor.h +++ b/mo/src/problems/permutation/moIndexedSwapNeighbor.h @@ -107,6 +107,22 @@ public: index( _first + n * (n - 1) / 2 ); } + /** + * Getter of the firt location + * @return first indice + */ + unsigned int first() { + return indices.first; + } + + /** + * Getter of the second location + * @return second indice + */ + unsigned int second() { + return indices.second; + } + private: std::pair indices;