Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


Public Member Functions | Protected Attributes | List of all members
libevocosm::organism< Genotype > Class Template Reference

An evolving organism. More...

#include <organism.h>

Inheritance diagram for libevocosm::organism< Genotype >:
libevocosm::globals

Public Member Functions

 organism ()
 Creation constructor. More...
 
 organism (const Genotype &a_value)
 Value constructor. More...
 
 organism (const organism &a_source)
 Copy constructor. More...
 
 organism (const organism &a_parent1, const organism &a_parent2)
 Crossover constructor. More...
 
virtual ~organism ()
 Virtual destructor. More...
 
organismoperator= (const organism &a_source)
 assignment operator More...
 
virtual bool operator< (const organism &a_right) const
 Comparison operator for algorithms. More...
 
virtual void reset_all ()
 Comparison operator for algorithms. More...
 
double & fitness ()
 Get fitness (read-write) More...
 
double fitness () const
 Get fitness (read-only) More...
 
Genotype & genes ()
 Get genes (read-write) More...
 
const Genotype & genes () const
 Get genes (read-only) More...
 

Protected Attributes

double m_fitness
 Fitness value.
 
Genotype m_genes
 Genetic material; could be almost anything.
 

Additional Inherited Members

- Static Protected Member Functions inherited from libevocosm::globals
static size_t rand_index (size_t n)
 Static function to allow use of g_random function pointer in random_shuffle.
 
static void set_random_seed (uint32_t a_seed)
 Set the seed for the random number generator.
 
static uint32_t get_seed ()
 Set the seed for the random number generator.
 
static std::string version ()
 Get version number.
 
- Static Protected Attributes inherited from libevocosm::globals
static prng g_random
 A shared random number generator.
 
static std::string g_version
 Version number.
 

Detailed Description

template<typename Genotype>
class libevocosm::organism< Genotype >

An organism is a solution to a problem posed by a fitness landscape; it has "genes" that define its behavior, and a fitness value assigned during fitness testing.

Evocosm provides the freedom to define organisms as anything: bit strings, floating-point numbers, finite state machines, LISP programs, or external robots controlled via radio waves.

Parameters
Genotype- The type of genes for this organism class

Constructor & Destructor Documentation

template<typename Genotype >
libevocosm::organism< Genotype >::organism ( )
inline

Creates a new organism, with default genes and zero fitness.

template<typename Genotype >
libevocosm::organism< Genotype >::organism ( const Genotype &  a_value)
inline

Creates a new organism with specific genes.

Parameters
a_value- Gene value for the new organism
template<typename Genotype >
libevocosm::organism< Genotype >::organism ( const organism< Genotype > &  a_source)
inline

Creates a new object identical to an existing one.

Parameters
a_source- The source object
template<typename Genotype >
libevocosm::organism< Genotype >::organism ( const organism< Genotype > &  a_parent1,
const organism< Genotype > &  a_parent2 
)
inline

Creates a new object identical to an existing one.

Parameters
a_parent1- First parent object
a_parent2- Second parent object
template<typename Genotype >
virtual libevocosm::organism< Genotype >::~organism ( )
inlinevirtual

A virtual destructor. By default, it does nothing; this is a placeholder that identifies this class as a potential base, ensuring that objects of a derived class will have their destructors called if they are destroyed through a base-class pointer.

Member Function Documentation

template<typename Genotype >
double& libevocosm::organism< Genotype >::fitness ( )
inline

Fitness is assigned by the landscape in which an organism is tested. A scaler object may alter fitness values after testing; a selector uses fitness to determine which organisms survive from one generation to the next, and a reproducer creates new organisms from parents selected by fitness.

Giving direct access to a member violates encapsulation, but it vastly simplifies the numerous functions that manipulate organisms.

Returns
Fitness for this organism
See also
landscape, scaler, selector, reproducer

References libevocosm::organism< Genotype >::m_fitness.

Referenced by libevocosm::scaler< OrganismType >::invert().

template<typename Genotype >
double libevocosm::organism< Genotype >::fitness ( ) const
inline

Fitness is assigned by the landscape in which an organism is tested. A scaler object may alter fitness values after testing; a selector uses fitness to determine which organisms survive from one generation to the next, and a reproducer creates new organisms from parents selected by fitness.

Giving direct access to a member violates encapsulation, but it vastly simplifies the numerous functions that manipulate organisms.

Returns
Fitness for this organism
See also
landscape, scaler, selector, reproducer

References libevocosm::organism< Genotype >::m_fitness.

template<typename Genotype >
Genotype& libevocosm::organism< Genotype >::genes ( )
inline

Genes define an organism's behavior in a fitness landscape. An initial population usually (but not always) contains organisms with random genes; a landscape tests the behavior defined by genes to calculate the fitness of an organism. A reproducer will create children from the genes of their parents, and a mutator may make random changes in those genes.

Returns
Genes encapsulated by this organism
See also
landscape, mutator, reproducer

References libevocosm::organism< Genotype >::m_genes.

template<typename Genotype >
const Genotype& libevocosm::organism< Genotype >::genes ( ) const
inline

Genes define an organism's behavior in a fitness landscape. An initial population usually (but not always) contains organisms with random genes; a landscape tests the behavior defined by genes to calculate the fitness of an organism. A reproducer will create children from the genes of their parents, and a mutator may make random changes in those genes.

Returns
Genes encapsulated by this organism
See also
landscape, mutator, reproducer

References libevocosm::organism< Genotype >::m_genes.

template<typename Genotype >
virtual bool libevocosm::organism< Genotype >::operator< ( const organism< Genotype > &  a_right) const
inlinevirtual

Many Standard C++ algorithms require a "less than" comparison operator for container elements.

Parameters
a_right- Right hand argument for less than operator

References libevocosm::organism< Genotype >::m_fitness.

template<typename Genotype >
organism& libevocosm::organism< Genotype >::operator= ( const organism< Genotype > &  a_source)
inline

Assigns an existing object the state of another.

Parameters
a_source- The source object
Returns
A reference to this

References libevocosm::organism< Genotype >::m_fitness, and libevocosm::organism< Genotype >::m_genes.

template<typename Genotype >
virtual void libevocosm::organism< Genotype >::reset_all ( )
inlinevirtual

Resets all data in an organisim to the initial (or startup) state, including setting the fitness to zero. Derived classes should override this method to "clear" any data.


The documentation for this class was generated from the following file:

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.