Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


machine_tools.h
1 /*
2  Evocosm is a C++ framework for implementing evolutionary algorithms.
3 
4  Copyright 2011 Scott Robert Ladd. All rights reserved.
5 
6  Evocosm is user-supported open source software. Its continued development is dependent
7  on financial support from the community. You can provide funding by visiting the Evocosm
8  website at:
9 
10  http://www.coyotegulch.com
11 
12  You may license Evocosm in one of two fashions:
13 
14  1) Simplified BSD License (FreeBSD License)
15 
16  Redistribution and use in source and binary forms, with or without modification, are
17  permitted provided that the following conditions are met:
18 
19  1. Redistributions of source code must retain the above copyright notice, this list of
20  conditions and the following disclaimer.
21 
22  2. Redistributions in binary form must reproduce the above copyright notice, this list
23  of conditions and the following disclaimer in the documentation and/or other materials
24  provided with the distribution.
25 
26  THIS SOFTWARE IS PROVIDED BY SCOTT ROBERT LADD ``AS IS'' AND ANY EXPRESS OR IMPLIED
27  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
28  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SCOTT ROBERT LADD OR
29  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 
36  The views and conclusions contained in the software and documentation are those of the
37  authors and should not be interpreted as representing official policies, either expressed
38  or implied, of Scott Robert Ladd.
39 
40  2) Closed-Source Proprietary License
41 
42  If your project is a closed-source or proprietary project, the Simplified BSD License may
43  not be appropriate or desirable. In such cases, contact the Evocosm copyright holder to
44  arrange your purchase of an appropriate license.
45 
46  The author can be contacted at:
47 
48  scott.ladd@coyotegulch.com
49  scott.ladd@gmail.com
50  http:www.coyotegulch.com
51 */
52 
53 #if !defined(LIBEVOCOSM_FSM_TOOLS_H)
54 #define LIBEVOCOSM_FSM_TOOLS_H
55 
56 // libevocosm
57 #include "roulette.h"
58 
59 namespace libevocosm
60 {
62 
66  {
67  protected:
70  {
76  };
77 
79 
96  {
97  public:
99 
104  : m_selector(NULL)
105  {
106  static const double default_weights [] = { 20.0, 20.0, 20.0, 20.0, 20.0 };
107 
108  m_selector = new roulette_wheel(default_weights,5);
109  }
110 
112 
117  : m_selector(new roulette_wheel(*a_source.m_selector))
118  {
119  // nada
120  }
121 
123 
127  {
128  delete m_selector;
129  }
130 
132 
137  {
138  m_selector = new roulette_wheel(*a_source.m_selector);
139  return *this;
140  }
141 
143 
148  void set_weight(mutation_id a_type, double & a_new_weight)
149  {
150  m_selector->set_weight(a_type,a_new_weight);
151  }
152 
154  /*
155  Returns an index, shosen by roulette wheel, corresponding to a
156  <i>mutation_id</i> value.
157  \return A mutation_id index
158  */
159  size_t get_index() const
160  {
161  return m_selector->get_index();
162  }
163 
164  private:
165  // The actual roulette wheel
166  roulette_wheel * m_selector;
167  };
168  };
169 }
170 
171 #endif
mutation_selector()
Creation constructor.
Definition: machine_tools.h:103
Wraps a roulette wheel for selecting mutations.
Definition: machine_tools.h:95
size_t get_index() const
Get a mutation index.
Definition: machine_tools.h:159
mutation_id
Types of mutation supported.
Definition: machine_tools.h:69
Mutate that initial state.
Definition: machine_tools.h:75
A set of common tools for finite state machines.
Definition: machine_tools.h:65
void set_weight(mutation_id a_type, double &a_new_weight)
Change a given weight.
Definition: machine_tools.h:148
A toolkit and framework for implementing evolutionary algorithms.
Definition: analyzer.h:60
Swap two states.
Definition: machine_tools.h:74
Mutate a state transition.
Definition: machine_tools.h:72
A simulated roulette wheel for weighted selection.
Definition: roulette.h:89
~mutation_selector()
Destructor.
Definition: machine_tools.h:126
Replace a new state with a randomly-generated one.
Definition: machine_tools.h:73
size_t get_index() const
Retrieve a random index.
mutation_selector & operator=(const mutation_selector &a_source)
Assignment operator.
Definition: machine_tools.h:136
mutation_selector(const mutation_selector &a_source)
Copy constructor.
Definition: machine_tools.h:116
double set_weight(size_t a_index, double a_weight)
Change the weight assigned to an entry.
Mutate an output symbol.
Definition: machine_tools.h:71

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