Evocosm - A C++ Framework for Evolutionary Computing

Main Index

Created by Scott Robert Ladd at Coyote Gulch Productions.


landscape.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_LANDSCAPE_H)
54 #define LIBEVOCOSM_LANDSCAPE_H
55 
56 // libevocosm
57 #include "organism.h"
58 
59 #ifdef _OPENMP
60 #include "omp.h"
61 #endif
62 
63 namespace libevocosm
64 {
66 
79  template <class OrganismType>
80  class landscape : protected globals
81  {
82  public:
84 
89  : m_listener(a_listener)
90  {
91  // nada
92  }
93 
95  landscape(const landscape & a_source)
96  : m_listener(a_source.m_listener)
97  {
98  // nada
99  }
100 
102  landscape & operator = (const landscape & a_source)
103  {
104  m_listener = a_source.m_listener;
105  return *this;
106  }
107 
109 
116  virtual ~landscape()
117  {
118  // nada
119  }
120 
122 
128  virtual double test(OrganismType & a_organism, bool a_verbose = false) const = 0;
129 
131 
136  virtual double test(vector<OrganismType> & a_population) const
137  {
138  double result = 0.0;
139 
140  for (int n = 0; n < (int)a_population.size(); ++n)
141  {
142  a_population[n].fitness = test(a_population[n]);
143  result += a_population[n].fitness;
144  }
145 
146  // return average fitness
147  return 0.0; // result / (double)a_population.size();
148  }
149 
150  protected:
153  };
154 };
155 
156 #endif
virtual ~landscape()
Virtual destructor.
Definition: landscape.h:116
landscape(listener< OrganismType > &a_listener)
Constructor.
Definition: landscape.h:88
An abstract interface defining a fitness landscape.
Definition: landscape.h:80
A toolkit and framework for implementing evolutionary algorithms.
Definition: analyzer.h:60
landscape & operator=(const landscape &a_source)
Assignment operator.
Definition: landscape.h:102
Elements shared by all classes in Evocosm.
Definition: evocommon.h:117
An abstract interface defining a listener.
Definition: listener.h:80
virtual double test(vector< OrganismType > &a_population) const
Performs fitness testing.
Definition: landscape.h:136
landscape(const landscape &a_source)
Copy constructor.
Definition: landscape.h:95
virtual double test(OrganismType &a_organism, bool a_verbose=false) const =0
Performs fitness testing.
listener< OrganismType > & m_listener
The listener for landscape events.
Definition: landscape.h:152

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