Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


Public Member Functions | Public Attributes | Protected Member Functions | List of all members
libevocosm::function_solution Class Reference

A potential solution to the problem at hand. More...

#include <function_optimizer.h>

Inheritance diagram for libevocosm::function_solution:
libevocosm::organism< vector< double > > libevocosm::fopt_global libevocosm::globals

Public Member Functions

 function_solution ()
 Default contructor. More...
 
 function_solution (int a_nargs, double a_minarg, double a_maxarg)
 Creation constructor. More...
 
 function_solution (const vector< double > &a_source)
 Construct from raw genes. More...
 
 function_solution (const organism< vector< double > > &a_source)
 Construct from base class. More...
 
 function_solution (const function_solution &a_source)
 Copy constructor. More...
 
virtual ~function_solution ()
 Virtual destructor. More...
 
function_solutionoperator= (const function_solution &a_source)
 Assignment operator. More...
 
virtual bool operator< (const organism< vector< double > > &a_right) const
 Comparison operator for algorithms. More...
 
- Public Member Functions inherited from libevocosm::organism< vector< double > >
 organism ()
 Creation constructor. More...
 
 organism (const vector< double > &a_genes)
 Value constructor. More...
 
 organism (const organism &a_source)
 Copy constructor. More...
 
virtual ~organism ()
 Virtual destructor. More...
 
organismoperator= (const organism &a_source)
 assignment operator More...
 
organismoperator= (const vector< double > &a_genes)
 assignment operator More...
 
virtual bool operator< (const organism &a_right) const
 Comparison operator for algorithms. More...
 
virtual void reset ()
 Resets an object to it's initial state. More...
 

Public Attributes

double value
 
- Public Attributes inherited from libevocosm::organism< vector< double > >
double fitness
 
vector< double > genes
 

Protected Member Functions

virtual void child_copy (const organism &a_source)
 

Additional Inherited Members

- Protected Types inherited from libevocosm::fopt_global
typedef vector< double > t_function(vector< double > a_args)
 Definition of a function type. More...
 
- 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.
 
- Static Protected Attributes inherited from libevocosm::fopt_global
static evoreal g_evoreal
 Provides mutation and crossover services for doubles.
 

Detailed Description

To support a wide variety of applications, I defined a function solution as a vector of doubles. This allows functions of any dimension to be optimized (within platform limits, of course). Note that the solution begins with an empty vector; this is because the number of elements and their initialization is application specific. Initialization of the genes takes place in the constructor for function_optimizer through a pointer to a user-supplied function.

Constructor & Destructor Documentation

libevocosm::function_solution::function_solution ( )
inline

Creates an empty solution.

libevocosm::function_solution::function_solution ( int  a_nargs,
double  a_minarg,
double  a_maxarg 
)
inline
libevocosm::function_solution::function_solution ( const vector< double > &  a_source)
inline

Constructs a new function solution from a set of genes

libevocosm::function_solution::function_solution ( const organism< vector< double > > &  a_source)
inline

Constructs a function solution from a base-class object.

Parameters
a_source- The source object
libevocosm::function_solution::function_solution ( const function_solution a_source)
inline

Duplicates an existing object.

Parameters
a_source- The source object
virtual libevocosm::function_solution::~function_solution ( )
inlinevirtual

Satisfies the requirements of the base class; does nothing

Member Function Documentation

virtual void libevocosm::function_solution::child_copy ( const organism a_source)
inlineprotectedvirtual

used to cast base class pointer to concrete class

virtual bool libevocosm::function_solution::operator< ( const organism< vector< double > > &  a_right) const
inlinevirtual

Returns true if the target object is greater than a_source. While the operator may be "less than", what it really meands for algorithms is "comes before" – and I want the highest fitness to come first.

Parameters
a_right- Right hand argument for less than operator
Returns
true if this organismsfitness if greater than a_right.fitness; false otherwise

References libevocosm::organism< vector< double > >::fitness.

function_solution& libevocosm::function_solution::operator= ( const function_solution a_source)
inline

Assigns the state of one solution to another.

Parameters
a_source- The source object
Returns
A reference to this

References value.

Member Data Documentation

double libevocosm::function_solution::value

Value is the actual computed value of this solution, which may or may not correspond directly to fitness. For example, when minimizing a function, the lowest value may correspond to the highest fitness. Generally, this is a display property.

Referenced by operator=(), and libevocosm::function_landscape::test().


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.