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

BitIntGene Class Reference

Integer gene that is implemented as a vector of BinaryGene genes. More...

#include <genes.h>

Inheritance diagram for BitIntGene:

AnyIntGene Gene Genstruct List of all members.

Public Methods

 BitIntGene ()
 BitIntGene (const GeneticID &id, int min, int max, int bits, const StringMap &params, double m=1.0)
virtual int getvalue () const
BitIntGene * setGrayCoding (bool gray=true)
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

Integer gene that is implemented as a vector of BinaryGene genes.

Because of the vector representation, the values are correlated, which would ne be case with IntGene.

The range of the gene values must be a power of two. For example range [0..1] is 2=2^1, and range [10..265] is 256=2^8.

Definition at line 675 of file genes.h.


Constructor & Destructor Documentation

BitIntGene   [inline]
 

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

Definition at line 679 of file genes.h.

Referenced by replicate().

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

Standard way to construct the gene.

Parameters:
id  Name of the gene.
min  Minimum value.
max  Maximum value.
bits  Number of bits in the genetic representation. This must equal sqrt(man-min).
params  Additional dynamic parameters.
params  ["grayCoding"] Should Gray coding be used for the value? [Default:0]
m  Mutation probability coefficient. [Default:1.0]

Definition at line 441 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 748 of file genes.h.

void check   const [virtual]
 

Standard check operator.

Implementation for Object.

Exceptions:
assertion_failed  check_failed

Reimplemented from AnyIntGene.

Definition at line 501 of file genes.cc.

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

void copy const Genstruct   other [virtual]
 

Standard copy operator.

Implementation for Genstruct.

Reimplemented from AnyIntGene.

Definition at line 458 of file genes.cc.

References AnyIntGene::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.

If the values of the bits do not have an equal significanse for the phenotype, this way of calculating may not be what you want.

Reimplemented from Genstruct.

Definition at line 727 of file genes.h.

References Gentainer::equality(), and mBits.

int getvalue   [virtual]
 

Returns the decoded phenotypic value of the gene.

Reimplemented from AnyIntGene.

Definition at line 469 of file genes.cc.

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

Referenced by check().

virtual void init   [inline, virtual]
 

Initializes the bits totally randomly.

Reimplemented from Genstruct.

Definition at line 715 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 720 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 489 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 494 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 729 of file genes.h.

References BitIntGene().

BitIntGene* setGrayCoding bool    gray = true [inline]
 

Sets the Gray coding mode on (true) or off (false).

The return value makes it possible to use the method as follows:

myGenome.add ((new BitIntGene ("myGene", 0, 7, 3, params))->setGrayCoding (true));

Returns:
Returns self.

Definition at line 710 of file genes.h.

References mGrayCoded.


Member Data Documentation

int mBitCount [protected]
 

Number of bits in the vector.

This can be calculated from the mBits Gentainer, but that would be slow, so we cache the value here.

Definition at line 743 of file genes.h.

Referenced by BitIntGene(), check(), and getvalue().

Gentainer mBits [protected]
 

Binary gene vector.

Definition at line 737 of file genes.h.

Referenced by BitIntGene(), check(), equality(), getvalue(), init(), pointMutate(), print(), and recombine().

bool mGrayCoded [protected]
 

Gray coding mode flag.

Definition at line 746 of file genes.h.

Referenced by BitIntGene(), and setGrayCoding().


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