Created by Scott Robert Ladd at Coyote Gulch Productions.
00001 //--------------------------------------------------------------------- 00002 // Algorithmic Conjurings @ http://www.coyotegulch.com 00003 // Evocosm -- An Object-Oriented Framework for Evolutionary Algorithms 00004 // 00005 // landscape.h 00006 //--------------------------------------------------------------------- 00007 // 00008 // Copyright 1996, 1999, 2002, 2003, 2004, 2005, 2007 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_LANDSCAPE_H) 00036 #define LIBEVOCOSM_LANDSCAPE_H 00037 00038 // libevocosm 00039 #include "organism.h" 00040 00041 #include <iostream> 00042 #include <iomanip> 00043 00044 namespace libevocosm 00045 { 00047 00060 template <class OrganismType> 00061 class landscape : protected globals 00062 { 00063 public: 00065 00069 landscape(listener & a_listener) 00070 : m_listener(a_listener) 00071 { 00072 // nada 00073 } 00074 00076 landscape(const landscape & a_source) 00077 : m_listener(a_source.m_listener) 00078 { 00079 // nada 00080 } 00081 00083 landscape & operator = (const landscape & a_source) 00084 { 00085 m_listener = a_source.m_listener; 00086 return *this; 00087 } 00088 00090 00097 virtual ~landscape() 00098 { 00099 // nada 00100 } 00101 00103 00109 virtual double test(OrganismType & a_organism, bool a_verbose = false) const = 0; 00110 00112 00117 virtual double test_pop(vector<OrganismType> & a_population) const 00118 { 00119 double result = 0.0; 00120 int n = 0; 00121 int stop = (int)a_population.size(); 00122 00123 #ifdef _OPENMP 00124 #pragma omp parallel for schedule(static) reduction(+:result) private(n) 00125 #endif 00126 for (n = 0; n < stop; ++n) 00127 { 00128 a_population[n].fitness() = test(a_population[n]); 00129 result += a_population[n].fitness(); 00130 } 00131 00132 // algorithm doesn't use this return value, so return nothing. 00133 return result / (double)a_population.size(); 00134 } 00135 00136 protected: 00138 listener & m_listener; 00139 }; 00140 }; 00141 00142 #endif
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.