Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


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

Associates organisms with the components of an evolutionary system. More...

#include <evocosm.h>

Inheritance diagram for libevocosm::evocosm< OrganismType >:
libevocosm::globals

Public Member Functions

 evocosm (vector< OrganismType > &a_population, landscape< OrganismType > &a_landscape, mutator< OrganismType > &a_mutator, reproducer< OrganismType > &a_reproducer, scaler< OrganismType > &a_scaler, selector< OrganismType > &a_selector, analyzer< OrganismType > &a_analyzer, listener< OrganismType > &a_listener)
 Creation constructor. More...
 
 evocosm (const evocosm< OrganismType > &a_source)
 Copy constructor. More...
 
virtual ~evocosm ()
 Virtual destructor. More...
 
evocosmoperator= (const evocosm< OrganismType > &a_source)
 Assignment operator. More...
 
virtual bool run_generation ()
 Compute next generation. More...
 
vector< OrganismType > & get_population ()
 Directly view population. More...
 
unsigned int get_sleep_time ()
 Get the sleep time property value. More...
 
void set_sleep_time (unsigned int a_sleep_time)
 Set the sleep time property value. More...
 

Protected Member Functions

void yield ()
 Yield. More...
 

Protected Attributes

vector< OrganismType > & m_population
 The populations of organisms.
 
landscape< OrganismType > & m_landscape
 Fitness landscapes common to all populations.
 
mutator< OrganismType > & m_mutator
 A mutator to randomly influence genes.
 
reproducer< OrganismType > & m_reproducer
 Creates new organisms.
 
scaler< OrganismType > & m_scaler
 Scales the fitness of the evocosm.
 
selector< OrganismType > & m_selector
 Selects organisms that survive from one generation to the next.
 
analyzer< OrganismType > & m_analyzer
 Reports the a evocosm for analysis or display.
 
listener< OrganismType > & m_listener
 A listener for evocosm progress.
 
size_t m_iteration
 Count of iterations made.
 
unsigned int m_sleep_time
 Number microseconds for process to sleep on yield.
 

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_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<class OrganismType>
class libevocosm::evocosm< OrganismType >

This is where it all comes together: An evocosm binds a evocosm of organisms to a set of objects that define how those organisms evolve.

Parameters
OrganismType- The type of organism

Constructor & Destructor Documentation

template<class OrganismType>
libevocosm::evocosm< OrganismType >::evocosm ( vector< OrganismType > &  a_population,
landscape< OrganismType > &  a_landscape,
mutator< OrganismType > &  a_mutator,
reproducer< OrganismType > &  a_reproducer,
scaler< OrganismType > &  a_scaler,
selector< OrganismType > &  a_selector,
analyzer< OrganismType > &  a_analyzer,
listener< OrganismType > &  a_listener 
)

Creates a new evocosm. Think of an evocosm as a director, a tool for associating organisms with their landscape. Note that these arguments are modifiable references, and that the referenced objects must continue to exist during the lifetime of the evocosm.

Parameters
a_populationInitial population of organisms
a_landscapeInitial set of landscaoes for testing organism fitness
a_mutator- A concrete implementation of mutator
a_reproducer- A concrete implementation of reproducer
a_scaler- A concrete implementation of scaler
a_selector- A concrete implementation of selector
a_analyzer- A concrete implementation of analyzer
a_listener- a listener for events
template<class OrganismType>
libevocosm::evocosm< OrganismType >::evocosm ( const evocosm< OrganismType > &  a_source)

Creates a new evocosm identical to an existing one.

Parameters
a_source- The source object
template<class OrganismType >
libevocosm::evocosm< OrganismType >::~evocosm ( )
virtual

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<class OrganismType>
vector<OrganismType>& libevocosm::evocosm< OrganismType >::get_population ( )
inline

Use with caution! This function provides direct read-write access to an evocosm's population. This is necessary when the organisms need special manipulation, such as when they can not be randomized by a default constructor.

template<class OrganismType>
unsigned int libevocosm::evocosm< OrganismType >::get_sleep_time ( )
inline

Get the sleep time setting for this listerner. /return current value of sleep time (microseconds)

template<class OrganismType>
evocosm< OrganismType > & libevocosm::evocosm< OrganismType >::operator= ( const evocosm< OrganismType > &  a_source)
template<class OrganismType >
bool libevocosm::evocosm< OrganismType >::run_generation ( )
virtual

A generation represents a cycle in the life of an evocosm; this function performs one sequence of fitness testing & scaling, reporting, breeding, and mutation. This method can be replaced by in a derived class to define a different processing sequence; the default sequence defined here is good for most evolutionary algorithms I've created.

Returns
Returns true when the generation has reached a specific goal.
template<class OrganismType>
void libevocosm::evocosm< OrganismType >::set_sleep_time ( unsigned int  a_sleep_time)
inline

Set the sleep time property value. /param a_sleep_time new value of sleep time (microseconds)

template<class OrganismType>
void libevocosm::evocosm< OrganismType >::yield ( )
inlineprotected

Evocosm periodically invokes this function to allow other processes to run. In most cases, this will be some sort of platform-specific sleep function, such as usleep.


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.