Vita
|
A MEP (Multi Expression Programming) single member of a population
.
More...
#include <i_mep.h>
Inherits vita::individual< i_mep >.
Classes | |
class | basic_iterator |
Public Types | |
using | const_iterator = basic_iterator< true > |
enum | crossover_t { one_point , two_points , tree , uniform , NUM_CROSSOVERS } |
using | iterator = basic_iterator< false > |
using | value_type = gene |
Public Member Functions | |
unsigned | active_symbols () const |
Number of active symbols. More... | |
iterator | begin () |
const_iterator | begin () const |
locus | best () const |
std::set< locus > | blocks () const |
Calculates a set of loci referring to blocks contained in the individual. More... | |
category_t | categories () const |
category_t | category () const |
i_mep | cse () const |
A sort of "common subexpression elimination" optimization. More... | |
i_mep | destroy_block (index_t, const symbol_set &) const |
bool | empty () const |
iterator | end () |
const_iterator | end () const |
i_mep | get_block (const locus &) const |
i_mep (const problem &) | |
Generates the initial, random expressions that make up an individual. More... | |
i_mep (const std::vector< gene > &) | |
Creates a new individual containing genes from gv . More... | |
bool | is_valid () const |
unsigned | mutation (double, const problem &) |
A new individual is created mutating this . More... | |
bool | operator== (const i_mep &) const |
const gene & | operator[] (locus) const |
i_mep | replace (const gene &) const |
Creates a new individual obtained from this replacing the original symbol at locus best() with g . More... | |
i_mep | replace (const locus &, const gene &) const |
Create a new individual obtained from this replacing the original symbol at locus l with g . More... | |
hash_t | signature () const |
Signature maps syntactically distinct (but logically equivalent) individuals to the same value. More... | |
unsigned | size () const |
Public Member Functions inherited from vita::individual< i_mep > | |
unsigned | age () const |
void | inc_age () |
bool | load (std::istream &, const symbol_set &=symbol_set()) |
bool | save (std::ostream &) const |
Friends | |
template<bool > | |
class | basic_iterator |
i_mep | crossover (const i_mep &, const i_mep &) |
class | individual< i_mep > |
Related Functions | |
(Note that these are not member functions.) | |
i_mep | crossover (const i_mep &lhs, const i_mep &rhs) |
A Self-Adaptive Crossover operator. More... | |
unsigned | distance (const i_mep &lhs, const i_mep &rhs) |
std::ostream & | operator<< (std::ostream &s, const i_mep &ind) |
Additional Inherited Members | |
Protected Member Functions inherited from vita::individual< i_mep > | |
void | set_older_age (unsigned) |
Protected Attributes inherited from vita::individual< i_mep > | |
hash_t | signature_ |
A MEP (Multi Expression Programming) single member of a population
.
Each individual contains a genome which represents a possible solution to the task being tackled (i.e. a point in the search space).
using vita::i_mep::const_iterator = basic_iterator<true> |
using vita::i_mep::iterator = basic_iterator<false> |
using vita::i_mep::value_type = gene |
|
explicit |
|
explicit |
unsigned vita::i_mep::active_symbols | ( | ) | const |
Number of active symbols.
When category() > 1
, active_symbols() can be greater than size(). For instance consider the following individual:
[0, 1] FIFL 1 2 2 3 [1, 0] "car" [2, 0] "plane" [2, 1] 10 [3, 1] 20
size() == 4
(four slots / rows) and active_symbols() == 5
.
|
inline |
|
inline |
|
inline |
std::set< locus > vita::i_mep::blocks | ( | ) | const |
Calculates a set of loci referring to blocks contained in the individual.
A locus obtained with this function is usually an argument for the i_mep::get_block function.
|
inline |
category_t vita::i_mep::category | ( | ) | const |
i_mep vita::i_mep::cse | ( | ) | const |
A sort of "common subexpression elimination" optimization.
The function doesn't rely on the meaning of the symbols, just on the genome layout.
Some features of the cse-optimized individual are:
i_mep vita::i_mep::destroy_block | ( | index_t | index, |
const symbol_set & | sset | ||
) | const |
|
inline |
|
inline |
|
inline |
[in] | l | locus of the genome |
this
choosing the gene sequence starting at l
bool vita::i_mep::is_valid | ( | ) | const |
unsigned vita::i_mep::mutation | ( | double | pgm, |
const problem & | prb | ||
) |
bool vita::i_mep::operator== | ( | const i_mep & | x | ) | const |
hash_t vita::i_mep::signature | ( | ) | const |
Signature maps syntactically distinct (but logically equivalent) individuals to the same value.
In other words identical individuals at genotypic level have the same signature; different individuals at the genotipic level may be mapped to the same signature since the value of terminals is considered and not the index.
This is a very interesting property, useful for individual comparison, information retrieval, entropy calculation...
|
inline |
|
friend |
A Self-Adaptive Crossover operator.
[in] | lhs | first parent |
[in] | rhs | second parent |
Well known elementary crossover operators traverse the problem domain in different ways, exhibiting variable performances and specific problems. An attempt to make the algorithm more robust is combining various search strategies, encapsulated by the different elementary crossover operators available, via self adaptation.
We associate to each individual the type of crossover used to create it (initially this is set to a random type). This type is used afterwards to determine which crossover to apply and allows the algorithm to adjust the relative mixture of operators.
Here we briefly describe the elementary crossover operators that are utilised:
ONE POINT
We randomly select a parent (between from
and to
) and a single locus (common crossover point). The offspring is created with genes from the chosen parent up to the crossover point and genes from the other parent beyond that point. One-point crossover is the oldest homologous crossover in tree-based GP.
TREE
Inserts a complete tree from one parent into the other. The operation is less disruptive than other forms of crossover since an entire tree is copied (not just a part).
TWO POINTS
We randomly select two loci (common crossover points). The offspring is created with genes from the one parent before the first crossover point and after the second crossover point; genes between crossover points are taken from the other parent.
UNIFORM CROSSOVER
The i-th locus of the offspring has a 50% probability to be filled with the i-th gene of from
and 50% with i-th gene of to
.
Uniform crossover, as the name suggests, is a GP operator inspired by the GA operator of the same name (G. Syswerda. Uniform crossover in genetic algorithms - Proceedings of the Third International Conference on Genetic Algorithms. 1989). GA uniform crossover constructs offspring on a bitwise basis, copying each allele from each parent with a 50% probability. Thus the information at each gene location is equally likely to have come from either parent and on average each parent donates 50% of its genetic material. The whole operation, of course, relies on the fact that all the chromosomes in the population are of the same structure and the same length. GP uniform crossover begins with the observation that many parse trees are at least partially structurally similar.
[in] | lhs | first term of comparison |
[in] | rhs | second term of comparison |
lhs
and rhs
(the number of different genes between individuals)
|
friend |
|
related |