Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


libevocosm::fuzzy_machine< InSize, OutSize > Class Template Reference

A finite state machine. More...

#include <fuzzy_machine.h>

Inheritance diagram for libevocosm::fuzzy_machine< InSize, OutSize >:

libevocosm::globals libevocosm::fsm_tools

List of all members.

Public Member Functions

Static Public Member Functions

Protected Attributes

Static Protected Attributes

Classes


Detailed Description

template<size_t InSize, size_t OutSize>
class libevocosm::fuzzy_machine< InSize, OutSize >

The class defines an abstract fuzzy state machine that uses integer input and output types.

A fuzzy state machine differs from a finite state machine in the selection of state transitions and outputs. In a finite state machine, each input maps to specific output and state transitions for a given current state. The fuzzy state machine contains probability maps for outputs and inputs; for any given state an input, there is a probability that any valid output could be returned, for example.

Parameters:
InSize Number of input states
OutSize Number of output states

Constructor & Destructor Documentation

template<size_t InSize, size_t OutSize>
libevocosm::fuzzy_machine< InSize, OutSize >::fuzzy_machine ( size_t  a_size,
double  a_output_base,
double  a_output_range,
double  a_state_base,
double  a_state_range 
) [inline]

Creates a new finite state machine with a given number of states. The four weight values define the range of weights assigned to outputs and state transitions; the actual roulette tables are randomized in the range (base,base+range).

Parameters:
a_size - Initial number of states in this machine
a_output_base - Minimum (base) value for an output roulette wheel weight
a_output_range - Range for an output roulette wheel weight
a_state_base - Minimum (base) value for a new roulette wheel weight
a_state_range - Range for a new state roulette wheel weight

References libevocosm::globals::g_random, libevocosm::prng::get_real(), libevocosm::fuzzy_machine< InSize, OutSize >::m_current_state, libevocosm::fuzzy_machine< InSize, OutSize >::m_init_state, libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table, and libevocosm::globals::rand_index().

template<size_t InSize, size_t OutSize>
libevocosm::fuzzy_machine< InSize, OutSize >::fuzzy_machine ( size_t  a_size  )  [inline]

Creates a new finite state machine with a given number of states.

Parameters:
a_size - Initial number of states in this machine

References libevocosm::fuzzy_machine< InSize, OutSize >::m_current_state, libevocosm::fuzzy_machine< InSize, OutSize >::m_init_state, libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table, and libevocosm::globals::rand_index().

template<size_t InSize, size_t OutSize>
libevocosm::fuzzy_machine< InSize, OutSize >::fuzzy_machine ( const fuzzy_machine< InSize, OutSize > &  a_parent1,
const fuzzy_machine< InSize, OutSize > &  a_parent2 
) [inline]

template<size_t InSize, size_t OutSize>
libevocosm::fuzzy_machine< InSize, OutSize >::fuzzy_machine ( const fuzzy_machine< InSize, OutSize > &  a_source  )  [inline]

Creates a new fuzzy_machine identical to an existing one.

Parameters:
a_source - Object to be copied

template<size_t InSize, size_t OutSize>
libevocosm::fuzzy_machine< InSize, OutSize >::~fuzzy_machine (  )  [inline, virtual]

Does nothing in the base class; exists to allow destruction of derived class objects through base class (fuzzy_machine) pointers.


Member Function Documentation

template<size_t InSize, size_t OutSize>
fuzzy_machine< InSize, OutSize > & libevocosm::fuzzy_machine< InSize, OutSize >::operator= ( const fuzzy_machine< InSize, OutSize > &  a_source  )  [inline]

template<size_t InSize, size_t OutSize>
void libevocosm::fuzzy_machine< InSize, OutSize >::mutate ( double  a_rate  )  [inline]

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 fuzzy_machine. The same principle holds for the mutation selector.
    Parameters:
    a_rate - Chance that any given state will mutate

References libevocosm::globals::g_random, libevocosm::fuzzy_machine< InSize, OutSize >::g_selector, libevocosm::fsm_tools::mutation_selector::get_index(), libevocosm::prng::get_real(), libevocosm::fuzzy_machine< InSize, OutSize >::m_current_state, libevocosm::fuzzy_machine< InSize, OutSize >::m_init_state, libevocosm::fuzzy_machine< InSize, OutSize >::tranout_t::m_new_state, libevocosm::fuzzy_machine< InSize, OutSize >::tranout_t::m_output, libevocosm::fuzzy_machine< InSize, OutSize >::m_output_base, libevocosm::fuzzy_machine< InSize, OutSize >::m_output_range, libevocosm::fuzzy_machine< InSize, OutSize >::m_state_base, libevocosm::fuzzy_machine< InSize, OutSize >::m_state_range, libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table, libevocosm::fsm_tools::MUTATE_INIT_STATE, libevocosm::fsm_tools::MUTATE_OUTPUT_SYMBOL, libevocosm::fsm_tools::MUTATE_REPLACE_STATE, libevocosm::fsm_tools::MUTATE_SWAP_STATES, libevocosm::fsm_tools::MUTATE_TRANSITION, libevocosm::globals::rand_index(), and libevocosm::roulette_wheel::set_weight().

template<size_t InSize, size_t OutSize>
void libevocosm::fuzzy_machine< InSize, OutSize >::set_mutation_weight ( mutation_id  a_type,
double  a_weight 
) [inline, static]

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

References libevocosm::fuzzy_machine< InSize, OutSize >::g_selector, and libevocosm::fsm_tools::mutation_selector::set_weight().

template<size_t InSize, size_t OutSize>
size_t libevocosm::fuzzy_machine< InSize, OutSize >::transition ( size_t  a_input  )  [inline]

Based on an input symbol, this function changes the state of an fuzzy_machine and returns an output symbol.

Parameters:
a_input - An input symbol
Returns:
Output value resulting from transition

References libevocosm::roulette_wheel::get_index(), libevocosm::fuzzy_machine< InSize, OutSize >::m_current_state, libevocosm::fuzzy_machine< InSize, OutSize >::tranout_t::m_new_state, libevocosm::fuzzy_machine< InSize, OutSize >::tranout_t::m_output, and libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table.

template<size_t InSize, size_t OutSize>
void libevocosm::fuzzy_machine< InSize, OutSize >::reset (  )  [inline]

template<size_t InSize, size_t OutSize>
size_t libevocosm::fuzzy_machine< InSize, OutSize >::size (  )  const [inline]

Returns the size of a fuzzy_machine.

Returns:
The size, in number of states

template<size_t InSize, size_t OutSize>
const fuzzy_machine< InSize, OutSize >::tranout_t & libevocosm::fuzzy_machine< InSize, OutSize >::get_transition ( size_t  a_state,
size_t  a_input 
) const [inline]

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.

References libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table.

template<size_t InSize, size_t OutSize>
size_t libevocosm::fuzzy_machine< 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::fuzzy_machine< InSize, OutSize >::num_output_states (  )  const [inline]

Returns the number of output states

Returns:
The number of output states

template<size_t InSize, size_t OutSize>
size_t libevocosm::fuzzy_machine< InSize, OutSize >::init_state (  )  const [inline]

Returns the initial (start up) state.

Returns:
The initial state

References libevocosm::fuzzy_machine< InSize, OutSize >::m_init_state.

template<size_t InSize, size_t OutSize>
size_t libevocosm::fuzzy_machine< InSize, OutSize >::current_state (  )  const [inline]

Returns the current (active) state.

Returns:
The current state

References libevocosm::fuzzy_machine< InSize, OutSize >::m_current_state.

template<size_t InSize, size_t OutSize>
tranout_t*** libevocosm::fuzzy_machine< InSize, OutSize >::state_table (  )  [inline]

Returns the state transition table pointer.

This is a very dangerous function, as it gives unrestricted access to the transition table that defines a machine. Given the complexity of fuzzy state machines, I implemented this function for debugging purposes; it is not intended as a tool for directly altering the transition table. /return Pointer to the transition table for the target machine

References libevocosm::fuzzy_machine< InSize, OutSize >::m_state_table.


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.