class BRKGA::DistanceFunctionBase

Overview

Distance Function Base. More…

#include <brkga_mp_ipr.hpp>

class DistanceFunctionBase {
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;
};

// direct descendants

class HammingDistance;
class KendallTauDistance;

Detailed Documentation

Distance Function Base.

This class is a interface for functors that compute the distance between two chromosomes.

Methods

virtual double distance(
    const Chromosome& v1,
    const Chromosome& v2
) = 0

Computes the distance between two vectors.

Parameters:

v1

first chromosome.

v2

second chromosome.

virtual bool affectSolution(
    const Chromosome::value_type key1,
    const Chromosome::value_type key2
) = 0

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
) = 0

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.