Vita
Public Types | Public Member Functions | Friends | Related Functions | List of all members
vita::i_de Class Reference

An individual optimized for differential evolution. More...

#include <i_de.h>

Inherits vita::individual< i_de >.

Public Types

using const_iterator = genome_t::const_iterator
 
using genome_t = std::vector< double >
 
using iterator = genome_t::iterator
 
using value_type = genome_t::value_type
 

Public Member Functions

iterator begin ()
 
const_iterator begin () const
 
i_de crossover (double, const range_t< double > &, const i_de &, const i_de &, const i_de &) const
 Differential evolution crossover. More...
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
void graphviz (std::ostream &) const
 Inserts into the output stream the graph representation of the individual. More...
 
 i_de (const problem &)
 Constructs a new, random DE individual. More...
 
bool is_valid () const
 
 operator std::vector< value_type > () const
 
i_deoperator= (const std::vector< value_type > &)
 Sets up the individual with values from a vector. More...
 
value_type & operator[] (std::size_t i)
 
value_type operator[] (std::size_t i) const
 
std::size_t parameters () const
 
hash_t signature () const
 
- Public Member Functions inherited from vita::individual< i_de >
unsigned age () const
 
void inc_age ()
 
bool load (std::istream &, const symbol_set &=symbol_set())
 
bool save (std::ostream &) const
 

Friends

class individual< i_de >
 

Related Functions

(Note that these are not member functions.)

std::ostream & in_line (const i_de &de, std::ostream &s)
 Prints the genes of the individual. More...
 
std::ostream & operator<< (std::ostream &s, const i_de &ind)
 

Additional Inherited Members

- Protected Member Functions inherited from vita::individual< i_de >
void set_older_age (unsigned)
 
- Protected Attributes inherited from vita::individual< i_de >
hash_t signature_
 

Detailed Description

An individual optimized for differential evolution.

See also
https://github.com/morinim/vita/wiki/bibliography#10

Definition at line 26 of file i_de.h.

Member Typedef Documentation

◆ const_iterator

using vita::i_de::const_iterator = genome_t::const_iterator

Definition at line 34 of file i_de.h.

◆ genome_t

using vita::i_de::genome_t = std::vector<double>

Definition at line 33 of file i_de.h.

◆ iterator

using vita::i_de::iterator = genome_t::iterator

Definition at line 35 of file i_de.h.

◆ value_type

using vita::i_de::value_type = genome_t::value_type

Definition at line 36 of file i_de.h.

Constructor & Destructor Documentation

◆ i_de()

vita::i_de::i_de ( const problem p)
explicit

Constructs a new, random DE individual.

Parameters
[in]pcurrent problem

The process that generates the initial, random expressions has to be implemented so as to ensure that they don't violate the type system's constraints.

Definition at line 29 of file i_de.cc.

Member Function Documentation

◆ begin() [1/2]

i_de::iterator vita::i_de::begin ( )
inline
Returns
an iterator pointing to the first gene

Definition at line 119 of file i_de.h.

◆ begin() [2/2]

i_de::const_iterator vita::i_de::begin ( ) const
inline
Returns
a const iterator pointing to the first gene

Definition at line 103 of file i_de.h.

◆ crossover()

i_de vita::i_de::crossover ( double  p,
const range_t< double > &  f,
const i_de a,
const i_de b,
const i_de c 
) const

Differential evolution crossover.

Parameters
[in]pcrossover probability
[in]fscaling factor range (environment.de.weight)
[in]afirst parent
[in]bsecond parent
[in]cthird parent (base vector)
Returns
the offspring (trial vector)

The offspring, also called trial vector, is generated as follows:

offspring = crossover(this, c + F * (a - b))

first the search direction is defined by calculating a difference vector between the pair of vectors a and b (usually choosen at random from the population). This difference vector is scaled by using the scale factor f. This scaled difference vector is then added to a third vector c, called the base vector. As a result a new vector is obtained, known as the mutant vector. The mutant vector is recombined, based on a used defined parameter, called crossover probability, with the target vector this (also called parent vector).

This way no separate probability distribution has to be used which makes the scheme completely self-organizing.

a and b are used for mutation, this and c for crossover.

Definition at line 104 of file i_de.cc.

◆ empty()

bool vita::i_de::empty ( ) const
inline
Returns
true if the individual is empty, false otherwise

Definition at line 64 of file i_de.h.

◆ end() [1/2]

i_de::iterator vita::i_de::end ( )
inline
Returns
an iterator pointing to (one) past the last gene

Definition at line 127 of file i_de.h.

◆ end() [2/2]

i_de::const_iterator vita::i_de::end ( ) const
inline
Returns
a const iterator pointing to (one) past the last gene

Definition at line 111 of file i_de.h.

◆ graphviz()

void vita::i_de::graphviz ( std::ostream &  s) const

Inserts into the output stream the graph representation of the individual.

Parameters
[out]soutput stream
Note
The format used to describe the graph is the dot language (http://www.graphviz.org/).

Definition at line 51 of file i_de.cc.

◆ is_valid()

bool vita::i_de::is_valid ( ) const
Returns
true if the individual passes the internal consistency check

Definition at line 200 of file i_de.cc.

◆ operator=()

i_de & vita::i_de::operator= ( const std::vector< value_type > &  v)

Sets up the individual with values from a vector.

Parameters
[in]vinput vector (a point in a multidimensional space)
Returns
a reference to *this

Definition at line 188 of file i_de.cc.

◆ operator[]() [1/2]

value_type & vita::i_de::operator[] ( std::size_t  i)
inline

Definition at line 50 of file i_de.h.

◆ operator[]() [2/2]

value_type vita::i_de::operator[] ( std::size_t  i) const
inline

Definition at line 44 of file i_de.h.

◆ parameters()

std::size_t vita::i_de::parameters ( ) const
inline
Returns
the number of parameters stored in the individual

Definition at line 67 of file i_de.h.

◆ signature()

hash_t vita::i_de::signature ( ) const
Returns
the signature of this individual

Identical individuals, at genotypic level, have the same signature

Definition at line 140 of file i_de.cc.

Friends And Related Function Documentation

◆ in_line()

std::ostream & in_line ( const i_de de,
std::ostream &  s 
)
related

Prints the genes of the individual.

Parameters
[in]dedata to be printed
[out]soutput stream
Returns
a reference to the output stream

Definition at line 70 of file i_de.cc.

◆ individual< i_de >

friend class individual< i_de >
friend

Definition at line 74 of file i_de.h.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  s,
const i_de ind 
)
related
Parameters
[out]soutput stream
[in]indindividual to print
Returns
output stream including ind

Definition at line 275 of file i_de.cc.


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