new implementation of the test
This commit is contained in:
parent
b2404c9daa
commit
4b844243ce
1 changed files with 14 additions and 13 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <eoInt.h>
|
#include <eoInt.h>
|
||||||
#include <eoShiftMutation.h>
|
#include <eoShiftMutation.h>
|
||||||
|
#include <set>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -23,18 +24,18 @@ double real_value(const Chrom & _chrom)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the given chromosome corresponds to a permutation
|
// Return true if the given chromosome corresponds to a permutation
|
||||||
// There must be an nicer way to do it (set?) ...
|
bool check_permutation(const Chrom& _chrom){
|
||||||
bool check_permutation(const Chrom & _chrom)
|
unsigned size= _chrom.size();
|
||||||
{
|
std::set<unsigned> verif;
|
||||||
for (unsigned i = 0; i < _chrom.size(); ++i)
|
for(unsigned i=0; i< size; i++){
|
||||||
for (unsigned j = 0; j < _chrom.size(); ++j)
|
if(verif.insert(_chrom[i]).second==false){
|
||||||
if(i!=j)
|
std::cout << " Error: Wrong permutation !" << std::endl;
|
||||||
if(_chrom[i]==_chrom[j]){
|
std::string s;
|
||||||
std::cout << " Error: Wrong permutation !" << std::endl;
|
s.append( " Wrong permutation in t-eoShiftMutation");
|
||||||
std::string s;
|
throw std::runtime_error( s );
|
||||||
s.append( " Wrong permutation in t-eoShiftMutation");
|
return false;
|
||||||
throw std::runtime_error( s );
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue