#include <genes.h>
Inheritance diagram for BitFloatGene:
Public Methods | |
BitFloatGene () | |
BitFloatGene (const GeneticID &id, double min, double max, int bits, const StringMap ¶ms, double m=1.0) | |
virtual double | getvalue () const |
virtual void | init () |
virtual bool | pointMutate (const MutationRate &k) |
virtual double | equality (const Genstruct &o) const |
virtual void | copy (const Genstruct &other) |
virtual Genstruct * | replicate () const |
virtual void | print (TextOStream &out) const |
virtual void | recombine (const Genstruct &a, const Genstruct &b) |
virtual void | check () const |
Protected Methods | |
virtual int | calc_len () const |
Protected Attributes | |
Gentainer | mBits |
int | mBitCount |
bool | mGrayCoded |
This is the way to encode "real" values in canonical Genetic Algorithms.
The encoding has two modes: linear and Gray-encoded. In linear mode the value is simply a sum of bits: SUM(i=0..n-1) b(i)*2^i, where b(i) is the i:th bit in the genetic sequence b.
Definition at line 438 of file genes.h.
|
Default constructor, FORBIDDEN! Exists only because of RTTI system.
Definition at line 443 of file genes.h. Referenced by replicate(). |
|
Standard constructor. Usually used for example: myGenome.add (new BitFloatGene ("myGene", 0.2, 0.8, 10, params, 1.0));
Definition at line 262 of file genes.cc. References Gentainer::add(), Gentainer::addPrivateGenes(), Genstruct::id, mBitCount, mBits, mGrayCoded, and Gentainer::selfadjust(). |
|
Actually calculates the true length of the genome (recursively).
Reimplemented from Gene. |
|
Standard check operator. Implementation for Object.
Reimplemented from AnyFloatGene. Definition at line 321 of file genes.cc. References Gentainer::check(), AnyFloatGene::check(), getvalue(), mBitCount, mBits, AnyFloatGene::mMax, and AnyFloatGene::mMin. |
|
Standard copy operator. Implementation for Genstruct. Reimplemented from AnyFloatGene. Definition at line 277 of file genes.cc. References AnyFloatGene::copy(). |
|
The genetic distance is calculated as the Hamming distance between the bits that encode the integer value. This might really not be what you usually want, as some bits are usually more important than others. It might be more appropriate to use the difference between getvalue() decoded values. Reimplemented from Genstruct. Definition at line 482 of file genes.h. References Gentainer::equality(), and mBits. |
|
Returns the decoded, phenotypic value of the gene. The inheritor MUST overload this method.
Reimplemented from AnyFloatGene. Definition at line 288 of file genes.cc. References Gentainer::getGene(), mBitCount, mBits, AnyFloatGene::mMax, and AnyFloatGene::mMin. Referenced by check(). |
|
Initializes the bits totally randomly.
Reimplemented from Genstruct. Definition at line 469 of file genes.h. References Gentainer::init(), and mBits. |
|
The point mutation forwards the mutation to the Gentainer holding the BinaryGene bits that encode the integer value.
Reimplemented from Genstruct. Definition at line 474 of file genes.h. References mBits, and Gentainer::pointMutate(). |
|
Recursively prints the genome to the given stream. This is most cool. Reimplemented from Genstruct. Definition at line 309 of file genes.cc. References Genstruct::id, mBits, and Gentainer::print(). |
|
Makes this structure a recombination of given parent structures. If no internal recombination actualizes within the structure, the parent 'a' must always be copied. Reimplemented from Genstruct. Definition at line 314 of file genes.cc. References mBits, and Gentainer::recombine(). |
|
Clones a copy of self, RECURSIVELY. It's funny how simple reproduction is nowadays. Reimplemented from Genstruct. Definition at line 484 of file genes.h. References BitFloatGene(). |
|
Number of bits in the genetic representation of the floating-point value. This could be calculated from the mBits Gentainer, but that would be slow, so we cache the value here. Definition at line 499 of file genes.h. Referenced by BitFloatGene(), check(), and getvalue(). |
|
Actual BinaryGene sequence encoding the floating-point value.
Definition at line 492 of file genes.h. Referenced by BitFloatGene(), check(), equality(), getvalue(), init(), pointMutate(), print(), and recombine(). |
|
Gray coding mode flag.
Definition at line 502 of file genes.h. Referenced by BitFloatGene(). |