openModeller
Version 1.4.0
|
00001 00035 #ifndef _GARP_HH_ 00036 #define _GARP_HH_ 00037 00038 #include <openmodeller/om.hh> 00039 #include <openmodeller/Sample.hh> 00040 00041 // required include because of enum PerfIndex and class GarpRule 00042 #include "rules_base.hh" 00043 #include "bioclim_histogram.hh" 00044 #include "regression.hh" 00045 00046 00047 class GarpRuleSet; 00048 00049 class Random; 00050 00051 /****************************************************************/ 00052 /************************* GARP Algorithm ***********************/ 00053 00057 class Garp : public AlgorithmImpl 00058 { 00059 public: 00060 Garp(); 00061 virtual ~Garp(); 00062 00067 int initialize(); 00068 00078 int iterate(); 00079 00084 int done() const; 00085 00087 float getProgress() const; 00088 00089 // 00090 // Methods used to project the model 00091 // 00092 00101 Scalar getValue( const Sample& x ) const; 00102 00109 int getConvergence( Scalar * const val ) const; 00110 00111 int getGeneration() { return _gen; } 00112 00117 void deleteTempDataMembers(); 00118 00119 protected: 00120 virtual void _getConfiguration( ConfigurationPtr& ) const; 00121 virtual void _setConfiguration( const ConstConfigurationPtr & ); 00122 00123 private: 00124 00125 void cacheSamples(const SamplerPtr&, OccurrencesPtr&, int resamples); 00126 00131 void colonize(GarpRuleSet * ruleset, int numRules); 00132 00137 void evaluate(GarpRuleSet * ruleset); 00138 00153 void keepFittest(GarpRuleSet * source, GarpRuleSet * target, PerfIndex perfIndex); 00154 00155 00163 void select(GarpRuleSet * source, GarpRuleSet * target, double gapsize); 00164 00165 00169 void mutate(GarpRuleSet * ruleset); 00170 00171 00175 void crossover(GarpRuleSet * ruleset); 00176 00177 // 00178 // Algorithm parameters 00179 // 00180 00182 int _max_gen; 00183 00185 int _popsize; 00186 00188 int _resamples; 00189 00191 double _acc_limit; 00192 00194 double _conv_limit; 00195 00197 double _mortality; 00198 00200 double _significance; 00201 double _crossover_rate; 00202 double _mutation_rate; 00203 double _gapsize; 00204 00205 // 00206 // Internal variables 00207 // 00208 00210 GarpRuleSet * _fittest; 00211 00213 GarpRuleSet * _offspring; 00214 00216 BioclimHistogram _bioclimHistogram; 00217 00218 Regression _regression; 00219 00220 OccurrencesPtr _cachedOccs; 00221 00222 double _convergence; 00223 int _improvements; 00224 00225 int _curr_heur_count[5]; 00226 int _prev_heur_count[5]; 00227 00228 int _gen; 00229 00230 mutable float _maxProgress; 00231 }; 00232 00233 00234 #endif 00235