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

Genstruct Class Reference

The highest genetic abstraction: a genetic structure. More...

#include <genetics.h>

Inheritance diagram for Genstruct:

Gene Gentainer AnyFloatGene AnyIntGene BinaryGene InterGene Genome BitFloatGene FloatGene BitIntGene IntGene DiploidGenome MonoploidGenome List of all members.

Public Methods

 Genstruct (const GeneticID &name=NULL)
const Genstruct & operator[] (const GeneticID &name) const
Genstruct & operator[] (const GeneticID &name)
const GeneticID & getID () const
int length () const
virtual void init ()
virtual const Genstruct * getGene (const GeneticID &name) const
virtual bool execute (const GeneticMsg &msg) const
virtual void addPrivateGenes (Gentainer &g)
virtual void addPrivateGenes (Gentainer &g, const StringMap &params)
virtual bool pointMutate (const MutationRate &r)
virtual void recombine (const Genstruct &a, const Genstruct &b)
virtual double equality (const Genstruct &other) const
virtual Genstruct * replicate () const
virtual void copy (const Genstruct &other)
virtual void print (TextOStream &out) const
virtual DataOStream & operator>> (DataOStream &out) const
Genstruct & hide (bool h=true)
bool isHidden () const
virtual int calc_len () const
virtual void check () const

Protected Methods

void copyGenstr (const Genstruct &other)

Protected Attributes

GeneticID id

Friends

class Gentainer

Detailed Description

The highest genetic abstraction: a genetic structure.

These structures can be "genes" or "chromosomes" or "genomes", or whatever.

Definition at line 246 of file genetics.h.


Constructor & Destructor Documentation

Genstruct const GeneticID &    name = NULL
 

Creates the structure with the given name.

The name can be used to access the structure from Gentainer containers.

Definition at line 90 of file genetics.cc.

References id.


Member Function Documentation

virtual void addPrivateGenes Gentainer   g,
const StringMap &    params
[inline, 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 in Gene, Gentainer, Genome, and DiploidGenome.

Definition at line 313 of file genetics.h.

virtual void addPrivateGenes Gentainer   g [inline, virtual]
 

Adds internal genes to itself.

Parameters:
g  Owner Gentainer.

Definition at line 306 of file genetics.h.

virtual int calc_len   const [inline, virtual]
 

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

Reimplemented in Gene, BitFloatGene, BitIntGene, Gentainer, and DiploidGenome.

Definition at line 376 of file genetics.h.

Referenced by length().

void check   [virtual]
 

Implementation for Object.

Reimplemented in Gene, AnyFloatGene, FloatGene, BitFloatGene, AnyIntGene, IntGene, BitIntGene, Gentainer, and Genome.

Definition at line 121 of file genetics.cc.

Referenced by Gentainer::check(), and Gene::check().

virtual void copy const Genstruct &    other [inline, 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 in Gene, BinaryGene, AnyFloatGene, FloatGene, BitFloatGene, AnyIntGene, IntGene, BitIntGene, InterGene, Gentainer, and DiploidGenome.

Definition at line 351 of file genetics.h.

Referenced by recombine().

void copyGenstr const Genstruct &    other [inline, protected]
 

Inheritors should use this method to copy the contents.

Definition at line 387 of file genetics.h.

References id, mHidden, and size.

Referenced by Gentainer::copy(), InterGene::copy(), and Gene::copy().

virtual double equality const Genstruct &    other const [inline, 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 in BinaryGene, FloatGene, BitFloatGene, IntGene, BitIntGene, Gentainer, and DiploidGenome.

Definition at line 340 of file genetics.h.

virtual bool execute const GeneticMsg   msg const [inline, virtual]
 

Transmits a sad order to execute a gene.

The receiver of the message reads in the upper left corner of the message. It should then execute itself. It's good that objects don't have feelings. (Hmm, they don't?)

Reimplemented in InterGene, and Gentainer.

Definition at line 300 of file genetics.h.

virtual const Genstruct* getGene const GeneticID &    name const [inline, 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 in Gene, and Gentainer.

Definition at line 293 of file genetics.h.

Referenced by operator[]().

const GeneticID& getID   const [inline]
 

Retrieves the name (ID) of the structure.

Definition at line 273 of file genetics.h.

References id.

Referenced by Gentainer::equality(), and Gentainer::recombine().

Genstruct& hide bool    h = true [inline]
 

Sets the hide-flag of the structure, for example for printing methods, etc.

Definition at line 369 of file genetics.h.

Referenced by Selector::addGenesTo(), and MutationRate::addGenesTo().

virtual void init   [inline, virtual]
 

Generates an initial, random state for the structure.

Reimplemented in BinaryGene, FloatGene, BitFloatGene, IntGene, BitIntGene, InterGene, Gentainer, Genome, and DiploidGenome.

Definition at line 285 of file genetics.h.

bool isHidden   const [inline]
 

Is the genstruct hidden from printing?

Definition at line 372 of file genetics.h.

int length  
 

Calculates recursively the total number of genes within the genetic structure.

Reimplemented in DiploidGenome.

Definition at line 102 of file genetics.cc.

References calc_len().

Referenced by Gentainer::copy(), Gentainer::equality(), and Gentainer::recombine().

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

Another structural output operator, implementation from Object.

Reimplemented in BinaryGene, Gentainer, and Genome.

Definition at line 114 of file genetics.cc.

References id.

Referenced by Gentainer::operator>>().

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

Gene access operator, just like above, but for non-const objects.

Returns:
The gene with the given name within the structure.

Reimplemented in Gentainer.

Definition at line 268 of file genetics.h.

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

Gene access operator.

Returns:
The gene with the given name within the structure.
Exceptions:
invalid_gene_name  if the gene was not found within the structure.

Reimplemented in Gentainer.

Definition at line 261 of file genetics.h.

References getGene().

virtual bool pointMutate const MutationRate   r [inline, virtual]
 

Mutates the structure.

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

Reimplemented in BinaryGene, FloatGene, BitFloatGene, IntGene, BitIntGene, InterGene, Gentainer, and DiploidGenome.

Definition at line 322 of file genetics.h.

void print TextOStream &    out const [virtual]
 

Recursively prints the genome to the given stream.

This is most cool.

Reimplemented in BinaryGene, FloatGene, BitFloatGene, IntGene, BitIntGene, InterGene, Gentainer, Genome, and DiploidGenome.

Definition at line 109 of file genetics.cc.

References id.

virtual void recombine const Genstruct &    a,
const Genstruct &    b
[inline, 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 in BitFloatGene, BitIntGene, Gentainer, and DiploidGenome.

Definition at line 328 of file genetics.h.

References copy().

virtual Genstruct* replicate   const [inline, virtual]
 

Clones a copy of self, RECURSIVELY.

It's funny how simple reproduction is nowadays.

Reimplemented in BinaryGene, FloatGene, BitFloatGene, IntGene, BitIntGene, InterGene, Gentainer, and DiploidGenome.

Definition at line 345 of file genetics.h.


Friends And Related Function Documentation

friend class Gentainer [friend]
 

The Gentainer is your friend.

Love the Gentainer.

Definition at line 411 of file genetics.h.


Member Data Documentation

GeneticID id [protected]
 

The identification label of the structure.

It might be a string or it might be a number. But I am a genstruct, I am not a number.

Definition at line 396 of file genetics.h.

Referenced by BitFloatGene::BitFloatGene(), BitIntGene::BitIntGene(), copyGenstr(), Genstruct(), Gene::getGene(), getID(), operator>>(), BinaryGene::operator>>(), Gentainer::print(), print(), InterGene::print(), BitIntGene::print(), IntGene::print(), BitFloatGene::print(), and FloatGene::print().


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