Small modif in moIndexedSwapNeighbor

This commit is contained in:
verel 2014-06-25 17:02:38 +02:00
commit edefae4b28
17 changed files with 141 additions and 54 deletions

View file

@ -47,7 +47,7 @@ install(DIRECTORY do es ga gp other utils
add_subdirectory(es)
add_subdirectory(ga)
add_subdirectory(utils)
add_subdirectory(serial)
#add_subdirectory(serial)
if(ENABLE_PYEO)
add_subdirectory(pyeo)

View file

@ -62,13 +62,15 @@ public:
};
/**
SV: from eoHammingDistance, it is in fact the L1 distance
This is a generic class for L1 distance computation:
assumes the 2 things are std::vectors of something
that is double-castable
For bitstrings, this is the Hamming distance
*/
template< class EOT >
class eoHammingDistance : public eoDistance<EOT>
class eoL1Distance : public eoDistance<EOT>
{
public:
double operator()(const EOT & _v1, const EOT & _v2)
@ -83,6 +85,27 @@ public:
}
};
/**
SV: change to have the Hamming (number of differences)
For bitstrings, this is the Hamming distance
*/
template< class EOT >
class eoHammingDistance : public eoDistance<EOT>
{
public:
double operator()(const EOT & _v1, const EOT & _v2)
{
double sum=0.0;
for (unsigned i=0; i<_v1.size(); i++)
{
if (_v1[i] != _v2[i])
sum++;
}
return sum;
}
};
/* this distance measures the difference in fitness
* I am not sure it can be of any use, though ...
* except for some testing

View file

@ -69,6 +69,7 @@ set (TEST_LIST
#t-openmp # does not work anymore since functions used in this test were removed from EO
#t-eoDualFitness
t-eoParser
t-eoPartiallyMappedXover
)