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

Gentainer Class Reference

A genetic container. More...

#include <genetics.h>

Inheritance diagram for Gentainer:

Genstruct Genome DiploidGenome MonoploidGenome List of all members.

Public Methods

void add (Genstruct *newstruct)
const Genstructoperator[] (const GeneticID &name) const
Genstructoperator[] (const GeneticID &name)
const Genstructoperator[] (int i) const
Genstructoperator[] (int i)
int size () const
void selfadjust (bool val=true)
void recombRate (double rate)
virtual void init ()
virtual void addPrivateGenes (Gentainer &g, const StringMap &params)
virtual const GenstructgetGene (const GeneticID &name) const
virtual bool pointMutate (const MutationRate &k)
virtual void recombine (const Genstruct &a, const Genstruct &b)
virtual double equality (const Genstruct &other) const
virtual Genstructreplicate () const
virtual void copy (const Genstruct &other)
virtual void print (TextOStream &out) const
virtual bool execute (const GeneticMsg &msg) const
virtual DataOStream & operator>> (DataOStream &out) const
virtual void check () const

Protected Methods

virtual int calc_len () const

Protected Attributes

Array< Genstructsubstructs
bool self_adjust
double mRecombRate

Detailed Description

A genetic container.

It is a structurally middle-level Genstruct that contains atomic genes as well as other containers. Many genetic operations are implemented here.

Definition at line 430 of file genetics.h.


Member Function Documentation

void add Genstruct   newstruct
 

Appends a new substructure to the structure.

Definition at line 152 of file genetics.cc.

References substructs.

Referenced by MultiMinEAEnv::addFeaturesTo(), FloatTestEAEnv::addFeaturesTo(), BinaryTestEAEnv::addFeaturesTo(), Selector::addGenesTo(), MutationRate::addGenesTo(), addPrivateGenes(), BitFloatGene::BitFloatGene(), BitIntGene::BitIntGene(), and replicate().

void addPrivateGenes Gentainer &    parent,
const StringMap &    params
[virtual]
 

Adds internal genes to itself.

Additional parameters are passed in the String Map.

Parameters:
g  Owner Gentainer.
params  Dynamic parameters in a String Map.

Reimplemented from Genstruct.

Reimplemented in Genome, and DiploidGenome.

Definition at line 163 of file genetics.cc.

References add(), MutationRate::addGenesTo(), and substructs.

Referenced by Genome::addPrivateGenes(), BitFloatGene::BitFloatGene(), and BitIntGene::BitIntGene().

int calc_len   const [protected, virtual]
 

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

Reimplemented from Genstruct.

Reimplemented in DiploidGenome.

Definition at line 363 of file genetics.cc.

References substructs.

void check   [virtual]
 

Implementation for Object.

Reimplemented from Genstruct.

Reimplemented in Genome.

Definition at line 399 of file genetics.cc.

References Genstruct::check(), mRecombRate, and substructs.

Referenced by Genome::check(), BitIntGene::check(), and BitFloatGene::check().

void copy const Genstruct   o [virtual]
 

Copies another structure to self (recursively).

The other structure must be structurally EXACTLY equivalent to self (for example, replicated previously). This is cool.

Reimplemented from Genstruct.

Reimplemented in DiploidGenome.

Definition at line 318 of file genetics.cc.

References Genstruct::copyGenstr(), Genstruct::length(), self_adjust, and substructs.

double equality const Genstruct   o const [virtual]
 

Compares how genotypically similar the structure is to another.

The units of the distance are usually application-dependent. One might, for example, use same euclidean distance or Hamming distance measurement with all genes, but then some genes may really be irrelevant for some problem, and they may have to be weighted. Thus, implementing this method in a generic way may be rather difficult.

Returns:
The distance between the structures.

Reimplemented from Genstruct.

Reimplemented in DiploidGenome.

Definition at line 284 of file genetics.cc.

References Genstruct::getID(), Genstruct::length(), and substructs.

Referenced by Individual::equality(), BitIntGene::equality(), and BitFloatGene::equality().

bool execute const GeneticMsg   msg const [virtual]
 

Executes a genetic message in the gentainer.

Sends the message to every contained genstruct.

Implementation for Genstruct.

Reimplemented from Genstruct.

Definition at line 376 of file genetics.cc.

References GeneticMsg::receiver, and substructs.

Referenced by Individual::execute(), and Individual::incarnate().

const Genstruct * getGene const GeneticID &    cc_name const [virtual]
 

Fetches a gene from the structure by it's name.

To be logical, this really should be a method of Gentainer, but there are cases when some classes can't inherit Gentainer, and they still need this.

Reimplemented from Genstruct.

Definition at line 195 of file genetics.cc.

References substructs.

Referenced by Individual::getGene(), BitIntGene::getvalue(), BitFloatGene::getvalue(), MutationRate::MutationRate(), operator[](), Selector::read(), and recombine().

void init   [virtual]
 

Generates an initial, random state for the structure.

Reimplemented from Genstruct.

Reimplemented in Genome, and DiploidGenome.

Definition at line 157 of file genetics.cc.

References substructs.

Referenced by Genome::init(), BitIntGene::init(), and BitFloatGene::init().

DataOStream & operator>> DataOStream &    out const [virtual]
 

Another structural output operator, implementation from Object.

Reimplemented from Genstruct.

Reimplemented in Genome.

Definition at line 405 of file genetics.cc.

References Genstruct::operator>>(), and substructs.

Referenced by Genome::operator>>().

Genstruct& operator[] int    i [inline]
 

Fetches a substructure by it's index number.

Non-const version.

Definition at line 459 of file genetics.h.

References substructs.

const Genstruct& operator[] int    i const [inline]
 

Fetches a substructure by it's index number.

Definition at line 457 of file genetics.h.

References substructs.

Genstruct& operator[] const GeneticID &    name [inline]
 

Fetches the gene with the given ID within the structure.

This method is not recursive.

Non-const version of the above method.

Reimplemented from Genstruct.

Definition at line 452 of file genetics.h.

const Genstruct& operator[] const GeneticID &    name const [inline]
 

Fetches the gene with the given ID within the structure.

This method is not recursive.

Reimplemented from Genstruct.

Definition at line 444 of file genetics.h.

References getGene().

bool pointMutate const MutationRate   k [virtual]
 

Mutates the structure.

Parameters:
r  Mutation rate coefficients.
Returns:
TRUE if an actual mutation (change on genotype) has occurred.

Reimplemented from Genstruct.

Reimplemented in DiploidGenome.

Definition at line 219 of file genetics.cc.

References MutabilityRecord::addBoolMutability(), MutabilityRecord::addFloatMutability(), MutabilityRecord::addFloatVariance(), MutationRate::binaryRate(), MutationRate::doubleRate(), MutationRate::doubleVariance(), and substructs.

Referenced by Individual::pointMutate(), BitIntGene::pointMutate(), and BitFloatGene::pointMutate().

void print TextOStream &    out const [virtual]
 

Recursively prints the genome to the given stream.

This is most cool.

Reimplemented from Genstruct.

Reimplemented in Genome, and DiploidGenome.

Definition at line 342 of file genetics.cc.

References Genstruct::id, and substructs.

Referenced by Genome::print(), BitIntGene::print(), and BitFloatGene::print().

void recombine const Genstruct   as,
const Genstruct   bs
[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.

Reimplemented in DiploidGenome.

Definition at line 243 of file genetics.cc.

References getGene(), Genstruct::getID(), Genstruct::length(), and substructs.

Referenced by Individual::recombine(), BitIntGene::recombine(), and BitFloatGene::recombine().

void recombRate double    rate [inline]
 

Sets the local recombination rate coefficient.

Definition at line 471 of file genetics.h.

References mRecombRate.

Genstruct * replicate   const [virtual]
 

Clones a copy of self, RECURSIVELY.

It's funny how simple reproduction is nowadays.

Reimplemented from Genstruct.

Reimplemented in DiploidGenome.

Definition at line 303 of file genetics.cc.

References add(), replicate(), and substructs.

Referenced by replicate().

void selfadjust bool    val = true [inline]
 

Enable self-adjusting of mutation rates within the container.

When it is enabled, mutation-rate genes are inserted in the genome and used as coefficient for all mutation orders.

Definition at line 468 of file genetics.h.

References self_adjust.

Referenced by BitFloatGene::BitFloatGene(), BitIntGene::BitIntGene(), and SimplePopulation::SimplePopulation().

int size   const [inline]
 

Returns the number of immediate substructures contained.

Definition at line 462 of file genetics.h.

References substructs.


Member Data Documentation

double mRecombRate [protected]
 

Recombination rate coefficient.

Default: 1

Definition at line 499 of file genetics.h.

Referenced by check(), and recombRate().

bool self_adjust [protected]
 

Self-adjusting (autoadaptive) mutation rates.

Default: false.

Definition at line 496 of file genetics.h.

Referenced by copy(), and selfadjust().

Array<Genstruct> substructs [protected]
 

Substructures.

Definition at line 493 of file genetics.h.

Referenced by add(), addPrivateGenes(), calc_len(), check(), copy(), equality(), execute(), getGene(), init(), operator>>(), operator[](), pointMutate(), print(), recombine(), replicate(), and size().


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