Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

BitFloatGene Class Reference

Floating point value encoded genetically as a binary vector. More...

#include <genes.h>

Inheritance diagram for BitFloatGene:

AnyFloatGene Gene Genstruct List of all members.

Public Methods

 BitFloatGene ()
 BitFloatGene (const GeneticID &id, double min, double max, int bits, const StringMap &params, 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 Genstructreplicate () 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

Detailed Description

Floating point value encoded genetically as a binary vector.

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.


Constructor & Destructor Documentation

BitFloatGene   [inline]
 

Default constructor, FORBIDDEN! Exists only because of RTTI system.

Definition at line 443 of file genes.h.

Referenced by replicate().

BitFloatGene const GeneticID &    id,
double    min,
double    max,
int    bits,
const StringMap &    params,
double    m = 1.0
 

Standard constructor.

Usually used for example:

myGenome.add (new BitFloatGene ("myGene", 0.2, 0.8, 10, params, 1.0));

Parameters:
id  Name of the gene.
min  Lower limit for the floating-point value range.
max  Upper limit for the floating-point value range.
bits  Number of bits for encoding the value.
params  Additional dynamic parameters.
params  ["grayCoding"] Should Gray coding be used. [Default:0]
m  Mutation coefficient. [Default:1.0]

Definition at line 262 of file genes.cc.

References Gentainer::add(), Gentainer::addPrivateGenes(), Genstruct::id, mBitCount, mBits, mGrayCoded, and Gentainer::selfadjust().


Member Function Documentation

virtual int calc_len   const [inline, protected, virtual]
 

Actually calculates the true length of the genome (recursively).

Reimplemented from Gene.

Definition at line 504 of file genes.h.

void check   [virtual]
 

Standard check operator.

Implementation for Object.

Exceptions:
assertion_failed  check_failed

Reimplemented from AnyFloatGene.

Definition at line 321 of file genes.cc.

References Gentainer::check(), AnyFloatGene::check(), getvalue(), mBitCount, mBits, AnyFloatGene::mMax, and AnyFloatGene::mMin.

void copy const Genstruct   other [virtual]
 

Standard copy operator.

Implementation for Genstruct.

Reimplemented from AnyFloatGene.

Definition at line 277 of file genes.cc.

References AnyFloatGene::copy().

virtual double equality const Genstruct   o const [inline, virtual]
 

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.

double getvalue   const [virtual]
 

Returns the decoded, phenotypic value of the gene.

The inheritor MUST overload this method.

Exceptions:
must_overload 

Reimplemented from AnyFloatGene.

Definition at line 288 of file genes.cc.

References Gentainer::getGene(), mBitCount, mBits, AnyFloatGene::mMax, and AnyFloatGene::mMin.

Referenced by check().

virtual void init   [inline, virtual]
 

Initializes the bits totally randomly.

Reimplemented from Genstruct.

Definition at line 469 of file genes.h.

References Gentainer::init(), and mBits.

virtual bool pointMutate const MutationRate   k [inline, virtual]
 

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().

void print TextOStream &    out const [virtual]
 

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().

void recombine const Genstruct   ar,
const Genstruct   br
[virtual]
 

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().

virtual Genstruct* replicate   const [inline, virtual]
 

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().


Member Data Documentation

int mBitCount [protected]
 

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().

Gentainer mBits [protected]
 

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().

bool mGrayCoded [protected]
 

Gray coding mode flag.

Definition at line 502 of file genes.h.

Referenced by BitFloatGene().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 20:12:01 2005 for NeHeP by doxygen1.2.18