Evocosm - A C++ Framework for Evolutionary Computing
Created by Scott Robert Ladd at
Coyote Gulch Productions.
libevocosm::simple_fsm< InSize, OutSize > Class Template Reference
A finite state machine.
More...
#include <simple_fsm.h>
Inheritance diagram for libevocosm::simple_fsm< InSize, OutSize >:
List of all members.Public Member Functions
Static Public Member Functions
Protected Attributes
Static Protected Attributes
-
static mutation_selector g_selector
- Global mutation selector.
Classes
Detailed Description
template<size_t InSize, size_t OutSize>
class libevocosm::simple_fsm< InSize, OutSize >
The class defines an abstract finite state machine that uses unsigned integer input and output types. This is much faster than the generic fsm class because the transition table can be represented as a simple two-dimensional array. - Parameters:
-
| InputSize | Number of input states |
| OutputSize | Number of output states |
Constructor & Destructor Documentation
|
Creates a new finite state machine with a given number of states. - Parameters:
-
| a_size | - Initial number of states in this machine |
|
|
Creates a new simple_fsm by combining the states of two parent machines. - Parameters:
-
| a_parent1 | - The first parent organism |
| a_parent2 | - The second parent organism |
|
|
Creates a new simple_fsm identical to an existing one. - Parameters:
-
| a_source | - Object to be copied |
|
|
Does nothing in the base class; exists to allow destruction of derived class objects through base class pointers. |
Member Function Documentation
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::current_state |
( |
|
) |
const [inline] |
|
|
Returns the current (active) state. - Returns:
- The current state
|
|
Get a transition from the internal state table. - Parameters:
-
| a_state | - Target state |
| a_input | - State information to return |
- Returns:
- A transition from the internal state table
|
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::init_state |
( |
|
) |
const [inline] |
|
|
Returns the initial (start up) state. - Returns:
- The initial state
|
template<size_t InSize, size_t OutSize> |
void libevocosm::simple_fsm< InSize, OutSize >::mutate |
( |
double |
a_rate |
) |
|
|
|
Mutates a finite state machine object. The four mutations supported are:
- Change a random output symbol
- Change a random state transition
- Swap two randomly-selected states
- Randomly change the initial state Why not store the input and output sets in the machine itself? That would duplicate information across every machine of a given type, greatly increasing the memory footprint of each simple_fsm. The same principle holds for the mutation selector.
- Parameters:
-
| a_rate | - Chance that any given state will mutate |
|
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::num_input_states |
( |
|
) |
const [inline] |
|
|
Returns the number of input states - Returns:
- The number of input states
|
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::num_output_states |
( |
|
) |
const [inline] |
|
|
Returns the number of output states - Returns:
- The number of output states
|
|
Copies the state of an existing simple_fsm. - Parameters:
-
| a_source | - Object to be copied |
- Returns:
- A reference to the target object
|
|
Prepares the FSM to start running from its initial state. |
|
Sets the weight value associated with a specific mutation; this changes the relative chance of this mutation happening. - Parameters:
-
| a_type | - ID of the weight to be changed |
| a_weight | - New weight to be assigned |
|
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::size |
( |
|
) |
const [inline] |
|
|
Returns the size of a simple_fsm. - Returns:
- The size, in number of states
|
template<size_t InSize, size_t OutSize> |
size_t libevocosm::simple_fsm< InSize, OutSize >::transition |
( |
size_t |
a_input |
) |
[inline] |
|
|
Based on an input symbol, this function changes the state of an simple_fsm and returns an output symbol. - Parameters:
-
- Returns:
- Output value resulting from transition
|
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.