class BRKGA::HammingDistance
Overview
Hamming distance between two vectors. More…
#include <brkga_mp_ipr.hpp> class HammingDistance: public BRKGA::DistanceFunctionBase { public: // fields double threshold {0.5}; // construction HammingDistance(const double _threshold = 0.5); // methods virtual double distance( const Chromosome& vector1, const Chromosome& vector2 ); virtual bool affectSolution( const Chromosome::value_type key1, const Chromosome::value_type key2 ); virtual bool affectSolution( Chromosome::const_iterator v1_begin, Chromosome::const_iterator v2_begin, const std::size_t block_size ); };
Inherited Members
public: // methods virtual double distance( const Chromosome& v1, const Chromosome& v2 ) = 0; virtual bool affectSolution( const Chromosome::value_type key1, const Chromosome::value_type key2 ) = 0; virtual bool affectSolution( Chromosome::const_iterator v1_begin, Chromosome::const_iterator v2_begin, const std::size_t block_size ) = 0;
Detailed Documentation
Hamming distance between two vectors.
This class is a functor that computes the Hamming distance between two vectors. It takes a threshold parameter to “binarize” the vectors.
Fields
double threshold {0.5}
Threshold parameter used to rounding the values to 0 or 1.
Construction
HammingDistance(const double _threshold = 0.5)
Default constructor.
Parameters:
_threshold |
used to rounding the values to 0 or 1. |
Methods
virtual double distance( const Chromosome& vector1, const Chromosome& vector2 )
Computes the Hamming distance between two vectors.
Parameters:
vector1 |
first vector |
vector2 |
second vector |
virtual bool affectSolution( const Chromosome::value_type key1, const Chromosome::value_type key2 )
Returns true if the changing of key1
by key2
affects the solution.
Parameters:
key1 |
the first key |
key2 |
the second key |
virtual bool affectSolution( Chromosome::const_iterator v1_begin, Chromosome::const_iterator v2_begin, const std::size_t block_size )
Returns true if the changing of the blocks of keys v1
by the blocks of keys v2
affects the solution.
Parameters:
v1_begin |
begin of the first blocks of keys |
v2_begin |
begin of the first blocks of keys |
block_size |
number of keys to be considered. |