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 // roulette.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_ROULETTE_H) 00036 #define LIBEVOCOSM_ROULETTE_H 00037 00038 // standard C++ Library 00039 #include <cmath> 00040 #include <vector> 00041 #include <limits> 00042 00043 // libevocosm 00044 #include "evocommon.h" 00045 00046 namespace libevocosm 00047 { 00048 using std::vector; 00049 00051 00071 class roulette_wheel : protected globals 00072 { 00073 public: 00075 00081 roulette_wheel(const vector<double> & a_weights, 00082 double a_min_weight = std::numeric_limits<double>::epsilon(), 00083 double a_max_weight = std::numeric_limits<double>::max()); 00084 00086 00093 roulette_wheel(const double * a_weights, 00094 size_t a_length, 00095 double a_min_weight = std::numeric_limits<double>::epsilon(), 00096 double a_max_weight = std::numeric_limits<double>::max()); 00097 00099 00103 roulette_wheel(const roulette_wheel & a_source); 00104 00106 00110 roulette_wheel & operator = (const roulette_wheel & a_source); 00111 00113 00116 ~roulette_wheel(); 00117 00119 00123 size_t get_size() const 00124 { 00125 return m_size; 00126 } 00127 00129 00135 double set_weight(size_t a_index, double a_weight); 00136 00138 00143 double get_weight(size_t a_index) const; 00144 00146 00152 size_t get_index() const; 00153 00154 protected: 00156 size_t m_size; 00157 00159 double * m_weights; 00160 00162 double m_total_weight; 00163 00165 double m_min_weight; 00166 00168 double m_max_weight; 00169 00170 private: 00171 // internal copy function 00172 void copy(const roulette_wheel & a_source); 00173 }; 00174 }; 00175 00176 #endif
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.