Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


fsm_tools.h
00001 //---------------------------------------------------------------------
00002 //  Algorithmic Conjurings @ http://www.coyotegulch.com
00003 //  Evocosm -- An Object-Oriented Framework for Evolutionary Algorithms
00004 //
00005 //  fsm_tools.h
00006 //---------------------------------------------------------------------
00007 //
00008 //  Copyright 1996, 1999, 2002, 2003, 2004, 2005 Scott Robert Ladd
00009 //
00010 //  This program is free software; you can redistribute it and/or modify
00011 //  it under the terms of the GNU General Public License as published by
00012 //  the Free Software Foundation; either version 2 of the License, or
00013 //  (at your option) any later version.
00014 //  
00015 //  This program is distributed in the hope that it will be useful,
00016 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //  
00020 //  You should have received a copy of the GNU General Public License
00021 //  along with this program; if not, write to the
00022 //      Free Software Foundation, Inc.
00023 //      59 Temple Place - Suite 330
00024 //      Boston, MA 02111-1307, USA.
00025 //
00026 //-----------------------------------------------------------------------
00027 //
00028 //  For more information on this software package, please visit
00029 //  Scott's web site, Coyote Gulch Productions, at:
00030 //
00031 //      http://www.coyotegulch.com
00032 //  
00033 //-----------------------------------------------------------------------
00034 
00035 #if !defined(LIBEVOCOSM_FSM_TOOLS_H)
00036 #define LIBEVOCOSM_FSM_TOOLS_H
00037 
00038 // libevocosm
00039 #include "roulette.h"
00040 
00041 namespace libevocosm
00042 {
00044 
00047     class fsm_tools
00048     {
00049     protected:
00051         enum mutation_id
00052         {
00053             MUTATE_OUTPUT_SYMBOL, 
00054             MUTATE_TRANSITION,    
00055             MUTATE_REPLACE_STATE, 
00056             MUTATE_SWAP_STATES,   
00057             MUTATE_INIT_STATE     
00058         };
00059 
00061 
00077         class mutation_selector
00078         {
00079         public:
00081 
00085             mutation_selector()
00086               : m_selector(NULL)
00087             {
00088                 static const double default_weights [] = { 20.0, 20.0, 20.0, 20.0, 20.0 };
00089 
00090                 m_selector = new roulette_wheel(default_weights,5);
00091             }
00092 
00094 
00098             mutation_selector(const mutation_selector & a_source)
00099               : m_selector(new roulette_wheel(*a_source.m_selector))
00100             {
00101                 // nada
00102             }
00103 
00105 
00108             ~mutation_selector()
00109             {
00110                 delete m_selector;
00111             }
00112 
00114 
00118             mutation_selector & operator = (const mutation_selector & a_source)
00119             {
00120                 m_selector = new roulette_wheel(*a_source.m_selector);
00121                 return *this;
00122             }
00123 
00125 
00130             void set_weight(mutation_id a_type, double & a_new_weight)
00131             {
00132                 m_selector->set_weight(a_type,a_new_weight);
00133             }
00134 
00136             /*
00137                 Returns an index, shosen by roulette wheel, corresponding to a
00138                 <i>mutation_id</i> value.
00139                 \return A mutation_id index
00140             */
00141             size_t get_index() const
00142             {
00143                 return m_selector->get_index();
00144             }
00145 
00146         private:
00147             // The actual roulette wheel
00148             roulette_wheel * m_selector;
00149         };
00150     };
00151 }
00152 
00153 #endif

© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.