GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
Loading...
Searching...
No Matches
Public Member Functions | List of all members
galib::BestNeighborSelection< GeneType > Class Template Reference

Selects the fittest direct neighbour of a cell in a cellular grid. More...

#include <BestNeighborSelection.h>

Inheritance diagram for galib::BestNeighborSelection< GeneType >:
[legend]

Public Member Functions

const Individual< GeneType > & select (const Population< GeneType > &population, std::size_t row, std::size_t col, std::size_t rows, std::size_t cols) const override
 Returns the best direct neighbour of the specified cell.
 
- Public Member Functions inherited from galib::LocalSelection< GeneType >
virtual ~LocalSelection ()=default
 Virtual destructor for polymorphic use.
 

Detailed Description

template<typename GeneType>
class galib::BestNeighborSelection< GeneType >

Selects the fittest direct neighbour of a cell in a cellular grid.

The neighbourhood is the Von Neumann neighbourhood: up, down, left, and right. Grid boundaries wrap around, so border cells still have four neighbours.

Template Parameters
GeneTypeNumeric type of each gene.

Definition at line 20 of file BestNeighborSelection.h.

Member Function Documentation

◆ select()

template<typename GeneType >
const Individual< GeneType > & galib::BestNeighborSelection< GeneType >::select ( const Population< GeneType > &  population,
std::size_t  row,
std::size_t  col,
std::size_t  rows,
std::size_t  cols 
) const
inlineoverridevirtual

Returns the best direct neighbour of the specified cell.

Parameters
populationPopulation interpreted as a 2D grid in row-major order.
rowRow of the current cell.
colColumn of the current cell.
rowsTotal number of grid rows. Must be non-zero.
colsTotal number of grid columns. Must be non-zero.
Returns
Const reference to the neighbouring individual with the lowest fitness.
Exceptions
std::invalid_argumentif rows or cols is zero.

Implements galib::LocalSelection< GeneType >.

Definition at line 33 of file BestNeighborSelection.h.

References galib::Individual< GeneType >::getFitness().


The documentation for this class was generated from the following file: