Vita
Public Types | Public Member Functions | List of all members
vita::basic_fitness_t< T > Class Template Reference

A value assigned to an individual which reflects how well the individual solves the task. More...

#include <fitness.h>

Public Types

using const_iterator = typename values_t::const_iterator
 
using iterator = typename values_t::iterator
 
using value_type = typename values_t::value_type
 
using values_t = small_vector< T, 1 >
 

Public Member Functions

 basic_fitness_t (std::initializer_list< T >)
 
 basic_fitness_t (values_t)
 
 basic_fitness_t (with_size, T=std::numeric_limits< T >::lowest())
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
bool load (std::istream &)
 
basic_fitness_toperator*= (const basic_fitness_t &)
 
basic_fitness_toperator+= (const basic_fitness_t &)
 
basic_fitness_toperator-= (const basic_fitness_t &)
 
T & operator[] (std::size_t)
 
operator[] (std::size_t) const
 
bool save (std::ostream &) const
 
std::size_t size () const
 

Detailed Description

template<class T>
class vita::basic_fitness_t< T >

A value assigned to an individual which reflects how well the individual solves the task.

Template Parameters
Ta numerical type used as a building block for the fitness (e.g. double)

This is NOT THE RAW FITNESS. Raw fitness is stated in the natural terminology of the problem: the better value may be either smaller (as when raw fitness is error) or larger (as when raw fitness is food eaten, benefit achieved...).

We use a STANDARDIZED FITNESS: a greater numerical value is always a better value (in many examples the optimal value is 0, but this isn't strictly necessary).

If, for a particular problem, a greater value of raw fitness is better, standardized fitness equals the raw fitness for that problem (otherwise standardized fitness must be computed from raw fitness).

Warning
The definition of standardized fitness given here is different from that used in Koza's "Genetic Programming: On the Programming of Computers by Means of Natural Selection". In the book a LOWER numerical value is always a better one. The main difference is that Vita attempts to maximize the fitness (while other applications try to minimize it). We chose this convention since it seemed more natural (a greater fitness is a better fitness; achieving a better fitness means to maximize the fitness). The downside is that sometimes we have to manage negative numbers, but for our purposes it's not so bad. Anyway maximization and minimization problems are basically the same: the solution of max(f(x)) is the same as -min(-f(x)). This is usually all you have to remember when dealing with examples/problems expressed in the other notation.

Definition at line 81 of file fitness.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
using vita::basic_fitness_t< T >::const_iterator = typename values_t::const_iterator

Definition at line 88 of file fitness.h.

◆ iterator

template<class T >
using vita::basic_fitness_t< T >::iterator = typename values_t::iterator

Definition at line 87 of file fitness.h.

◆ value_type

template<class T >
using vita::basic_fitness_t< T >::value_type = typename values_t::value_type

Definition at line 86 of file fitness.h.

◆ values_t

template<class T >
using vita::basic_fitness_t< T >::values_t = small_vector<T, 1>

Definition at line 85 of file fitness.h.


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