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::evocosm< OrganismType, LandscapeType > Class Template Reference

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

#include <evocosm.h>

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

Public Member Functions

 evocosm (listener &a_listener, size_t a_population_size, size_t a_number_of_populations, size_t a_number_of_unique_landscapes, size_t a_number_of_common_landscapes, mutator< OrganismType > &a_mutator, reproducer< OrganismType > &a_reproducer, scaler< OrganismType > &a_scaler, migrator< OrganismType > &a_migrator, selector< OrganismType > &a_selector, reporter< OrganismType, LandscapeType > &a_reporter, organism_factory< OrganismType > &a_organism_factory, landscape_factory< LandscapeType > &a_landscape_factory, bool a_minimizing=false)
 Creation constructor. More...
 
 evocosm (const evocosm< OrganismType, LandscapeType > &a_source)
 Copy constructor. More...
 
virtual ~evocosm ()
 Virtual destructor. More...
 
evocosmoperator= (const evocosm< OrganismType, LandscapeType > &a_source)
 Assignment operator. More...
 
virtual bool run_generation (bool a_finished, double &a_fitness)
 Compute next generation. More...
 
vector< OrganismType, LandscapeType > & population (size_t a_index=0)
 Directly view population. More...
 
void terminate ()
 Terminate this run. More...
 

Protected Attributes

listenerm_listener
 A listener for evocosm progress.
 
size_t m_population_size
 The initial evocosm size.
 
vector< vector< OrganismType > > m_populations
 The populations of organisms.
 
size_t m_number_of_populations
 The number of populations.
 
size_t m_number_of_unique_landscapes
 The number of fitness landscapes unique to individual populations.
 
size_t m_number_of_common_landscapes
 The number of fitness landscapes common to all populations.
 
vector< vector< LandscapeType > > m_unique_landscapes
 Fitness landscapes unique to individual populations.
 
vector< LandscapeType > m_common_landscapes
 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.
 
migrator< OrganismType > & m_migrator
 Handles emigration and immigration.
 
selector< OrganismType > & m_selector
 Selects organisms that survive from one generation to the next.
 
reporter< OrganismType, LandscapeType > & m_reporter
 Reports the a evocosm for analysis or display.
 
size_t m_iteration
 Count of iterations made.
 
bool m_minimizing
 Set true when minimizing; i.e., best fitness < worst fitness.
 
bool m_running
 termination flag
 

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

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
LandscapeType- The type of landscape

Constructor & Destructor Documentation

template<class OrganismType , class LandscapeType >
libevocosm::evocosm< OrganismType, LandscapeType >::evocosm ( listener a_listener,
size_t  a_population_size,
size_t  a_number_of_populations,
size_t  a_number_of_unique_landscapes,
size_t  a_number_of_common_landscapes,
mutator< OrganismType > &  a_mutator,
reproducer< OrganismType > &  a_reproducer,
scaler< OrganismType > &  a_scaler,
migrator< OrganismType > &  a_migrator,
selector< OrganismType > &  a_selector,
reporter< OrganismType, LandscapeType > &  a_reporter,
organism_factory< OrganismType > &  a_organism_factory,
landscape_factory< LandscapeType > &  a_landscape_factory,
bool  a_minimizing = false 
)

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

Parameters
a_listener- a listener for events
a_population_size- Initial population size
a_number_of_populations- Number of organisms in each population
a_number_of_unique_landscapes- Number of landscapes unique to each populations
a_number_of_common_landscapes- Number of landscapes common to all populations
a_mutator- A concrete implementation of mutator
a_reproducer- A concrete implementation of reproducer
a_scaler- A concrete implementation of scaler
a_migrator- A concrete implementation of migrator
a_selector- A concrete implementation of selector
a_reporter- A concrete implementation of reporter
a_organism_factory- A factory to create organisms
a_landscape_factory- A factory to create landscapes
a_minimizing- Set true when minimizing; i.e., best fitness < worst fitness

References libevocosm::organism_factory< OrganismType >::append(), libevocosm::enforce_lower_limit(), libevocosm::landscape_factory< LandscapeType >::generate(), libevocosm::evocosm< OrganismType, LandscapeType >::m_common_landscapes, libevocosm::evocosm< OrganismType, LandscapeType >::m_number_of_common_landscapes, libevocosm::evocosm< OrganismType, LandscapeType >::m_number_of_populations, libevocosm::evocosm< OrganismType, LandscapeType >::m_number_of_unique_landscapes, libevocosm::evocosm< OrganismType, LandscapeType >::m_population_size, libevocosm::evocosm< OrganismType, LandscapeType >::m_populations, and libevocosm::evocosm< OrganismType, LandscapeType >::m_unique_landscapes.

template<class OrganismType , class LandscapeType >
libevocosm::evocosm< OrganismType, LandscapeType >::evocosm ( const evocosm< OrganismType, LandscapeType > &  a_source)

Creates a new evocosm identical to an existing one.

Parameters
a_source- The source object
template<class OrganismType , class LandscapeType >
libevocosm::evocosm< OrganismType, LandscapeType >::~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 , class LandscapeType >
evocosm< OrganismType, LandscapeType > & libevocosm::evocosm< OrganismType, LandscapeType >::operator= ( const evocosm< OrganismType, LandscapeType > &  a_source)
template<class OrganismType, class LandscapeType>
vector<OrganismType, LandscapeType>& libevocosm::evocosm< OrganismType, LandscapeType >::population ( size_t  a_index = 0)
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.

Parameters
a_indexNumber of the population to return; defaults to 0 .
template<class OrganismType , class LandscapeType >
bool libevocosm::evocosm< OrganismType, LandscapeType >::run_generation ( bool  a_finished,
double &  a_fitness 
)
virtual

A generation represents a cycle in the life of an evocosm; this function performs one sequence of fitness testing & scaling, void append(vector<gccga_organism> a_population, size_t a_size);

reporting, migration, 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 false when the generation has reached a specific goal.
template<class OrganismType, class LandscapeType>
void libevocosm::evocosm< OrganismType, LandscapeType >::terminate ( )
inline

Calling this function sets a flag that tells the evocosm to stop running as soon as possible.


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.