openModeller
Version 1.4.0
|
#include <garp.hh>
Implementation of GARP: Genetic Algorithm for Rule-set Production
Garp::Garp | ( | ) |
Definition at line 231 of file garp.cpp.
References _acc_limit, _conv_limit, _convergence, _crossover_rate, _curr_heur_count, _fittest, _gapsize, _gen, _improvements, _max_gen, _maxProgress, _mortality, _mutation_rate, AlgorithmImpl::_normalizerPtr, _offspring, _popsize, _prev_heur_count, _resamples, and _significance.
Garp::~Garp | ( | ) | [virtual] |
Definition at line 270 of file garp.cpp.
References _fittest, and _offspring.
void Garp::_getConfiguration | ( | ConfigurationPtr & | config | ) | const [protected, virtual] |
Reimplemented from AlgorithmImpl.
Definition at line 444 of file garp.cpp.
References _acc_limit, _crossover_rate, _fittest, _gapsize, _gen, _mortality, _mutation_rate, _significance, done(), GarpRuleSet::get(), GarpRule::getChrom1(), GarpRule::getChrom2(), GarpRule::getPerformanceArray(), GarpRule::getPrediction(), GarpRuleSet::numRules(), and GarpRule::type().
void Garp::_setConfiguration | ( | const ConstConfigurationPtr & | config | ) | [protected, virtual] |
Reimplemented from AlgorithmImpl.
Definition at line 489 of file garp.cpp.
References _acc_limit, _crossover_rate, _fittest, _gapsize, _gen, _mortality, _mutation_rate, _offspring, _popsize, _significance, GarpRuleSet::add(), Log::error(), AlgorithmImpl::getParameter(), Log::instance(), and Sample::size().
void Garp::cacheSamples | ( | const SamplerPtr & | sampler, |
OccurrencesPtr & | cachedOccs, | ||
int | resamples | ||
) | [private] |
Definition at line 331 of file garp.cpp.
References GeoTransform::getDefaultCS(), and OccurrencesImpl::reserve().
Referenced by initialize().
void Garp::colonize | ( | GarpRuleSet * | ruleset, |
int | numRules | ||
) | [private] |
Fill a rule set with newly generated rules
ruleset,: | rule set where rules will be added to |
numRules | number of rules to be added to the rule set. |
Definition at line 656 of file garp.cpp.
References _bioclimHistogram, _regression, AlgorithmImpl::_samp, GarpRuleSet::add(), Random::get(), GarpRuleSet::numRules(), and GarpRule::setPrediction().
Referenced by initialize(), and iterate().
void Garp::crossover | ( | GarpRuleSet * | ruleset | ) | [private] |
Perform crossing over with rules in a rule set
ruleset | Rule set containing rules to be crossed over |
Definition at line 793 of file garp.cpp.
References _crossover_rate, AlgorithmImpl::_samp, GarpRule::crossover(), Random::get(), GarpRuleSet::get(), and GarpRuleSet::numRules().
Referenced by iterate().
void Garp::deleteTempDataMembers | ( | ) |
Deletes data structures that are not needed once the model is generated. Implemented to save some memory when clients have to store too many Garp objects.
Definition at line 818 of file garp.cpp.
References _offspring.
int Garp::done | ( | ) | const [virtual] |
Check if the model generation is completed (e.g. convergence point has been met.
Reimplemented from AlgorithmImpl.
Definition at line 419 of file garp.cpp.
References _conv_limit, _convergence, _gen, and _max_gen.
Referenced by _getConfiguration(), getProgress(), and iterate().
void Garp::evaluate | ( | GarpRuleSet * | ruleset | ) | [private] |
Evaluate rules from a rule set based on their performance to predict points provided by a sampler object.
ruleset,: | rule set to be tested. |
Definition at line 640 of file garp.cpp.
References _cachedOccs, GarpRule::evaluate(), GarpRuleSet::get(), and GarpRuleSet::numRules().
Referenced by iterate().
int Garp::getConvergence | ( | Scalar *const | val | ) | const [virtual] |
Returns a value that represents the convergence of the algorithm expressed as a number between 0 and 1 where 0 represents model completion.
val |
Reimplemented from AlgorithmImpl.
Definition at line 435 of file garp.cpp.
References _convergence.
int Garp::getGeneration | ( | ) | [inline] |
float Garp::getProgress | ( | ) | const [virtual] |
Return progress so far
Reimplemented from AlgorithmImpl.
Definition at line 401 of file garp.cpp.
References _conv_limit, _convergence, _gen, _max_gen, _maxProgress, and done().
Scalar Garp::getValue | ( | const Sample & | x | ) | const [virtual] |
This method is used when projecting the model.
x | a pointer to a vector of openModeller Scalar type (currently double). The vector should contain values looked up on the environmental variable layers into which the mode is being projected. |
Implements AlgorithmImpl.
Definition at line 427 of file garp.cpp.
References _fittest, and GarpRuleSet::getValue().
int Garp::initialize | ( | ) | [virtual] |
Initialize model by colonizing it with new rules.
Implements AlgorithmImpl.
Definition at line 290 of file garp.cpp.
References _bioclimHistogram, _cachedOccs, _conv_limit, _fittest, _max_gen, _offspring, _popsize, _regression, _resamples, AlgorithmImpl::_samp, cacheSamples(), Regression::calculateParameters(), colonize(), Log::error(), AlgorithmImpl::getParameter(), BioclimHistogram::initialize(), and Log::instance().
int Garp::iterate | ( | ) | [virtual] |
Start model execution (build the model). This method is the main body of the Genetic Algorithm. The steps during the algorithm are: 1) Evaluate current population testing the rules against data points 2) Select fittest individuals from population based on significance 3) If reached any stop condition (# of iterations or convergence limit) then output best result and stop 4) Else perform reproduction, generating a new offspring from current population 5) Repeat from step 1.
Reimplemented from AlgorithmImpl.
Definition at line 351 of file garp.cpp.
References _fittest, _gapsize, _gen, _offspring, _popsize, _significance, colonize(), crossover(), defaultPerfIndex, done(), evaluate(), GarpRuleSet::filter(), keepFittest(), mutate(), GarpRuleSet::performanceSummary(), select(), and GarpRuleSet::trim().
void Garp::keepFittest | ( | GarpRuleSet * | source, |
GarpRuleSet * | target, | ||
PerfIndex | perfIndex | ||
) | [private] |
Keep fittest individuals from source rule set storing them in target rule set in descending order of fitness.
source | Pointer to the source rule set where rules will be selected from (usually the previous generated population) |
target | Pointer to the target rule set where fittest rules will be transferred to (usually the fittest rule set) |
perfIndex | Index of value on performance array that will be used to select individuals. |
Definition at line 579 of file garp.cpp.
References _convergence, _improvements, GarpRule::clone(), GarpRuleSet::findSimilar(), GarpRuleSet::get(), GarpRule::getPerformance(), GarpRuleSet::insert(), GarpRuleSet::numRules(), and GarpRuleSet::remove().
Referenced by iterate().
void Garp::mutate | ( | GarpRuleSet * | ruleset | ) | [private] |
Mutate rules in a rule set
ruleset | Rule set containing rules to be mutated |
Definition at line 780 of file garp.cpp.
References _gen, GarpRuleSet::get(), GarpRule::mutate(), and GarpRuleSet::numRules().
Referenced by iterate().
void Garp::select | ( | GarpRuleSet * | source, |
GarpRuleSet * | target, | ||
double | gapsize | ||
) | [private] |
Select fittest individuals and store them into target ruleset
source | Pointer to the rule set containing parents (individuals that will provide genes to create new individuals). |
target | Pointer to the target rule set where offspring will be transferred to. |
gapsize | Proportion of contribution from the objBest archive set to the new population. |
Definition at line 699 of file garp.cpp.
References _popsize, GarpRuleSet::add(), GarpRuleSet::clear(), GarpRule::clone(), defaultPerfIndex, error, Log::error(), GarpRule::forceEvaluation(), Random::get(), GarpRuleSet::get(), GarpRule::getPerformance(), Log::instance(), GarpRuleSet::numRules(), and GarpRuleSet::performanceSummary().
Referenced by iterate().
double Garp::_acc_limit [private] |
Minimum posterior probability of a rule
Definition at line 191 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), and Garp().
BioclimHistogram Garp::_bioclimHistogram [private] |
BioclimHistogram to assist the creation of bioclim based rules
Definition at line 216 of file garp.hh.
Referenced by colonize(), and initialize().
OccurrencesPtr Garp::_cachedOccs [private] |
Definition at line 220 of file garp.hh.
Referenced by evaluate(), and initialize().
double Garp::_conv_limit [private] |
Minimum value for convergence that triggers termination of execution
Definition at line 194 of file garp.hh.
Referenced by done(), Garp(), getProgress(), and initialize().
double Garp::_convergence [private] |
Definition at line 222 of file garp.hh.
Referenced by done(), Garp(), getConvergence(), getProgress(), and keepFittest().
double Garp::_crossover_rate [private] |
Definition at line 201 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), crossover(), and Garp().
int Garp::_curr_heur_count[5] [private] |
GarpRuleSet* Garp::_fittest [private] |
Rule-set that stores the best rules found so far
Definition at line 210 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), Garp(), getValue(), initialize(), iterate(), and ~Garp().
double Garp::_gapsize [private] |
Definition at line 203 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), Garp(), and iterate().
int Garp::_gen [private] |
Definition at line 228 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), done(), Garp(), getGeneration(), getProgress(), iterate(), and mutate().
int Garp::_improvements [private] |
Definition at line 223 of file garp.hh.
Referenced by Garp(), and keepFittest().
int Garp::_max_gen [private] |
Maximum number of iterations to be executed (if convergence is not reached)
Definition at line 182 of file garp.hh.
Referenced by done(), Garp(), getProgress(), and initialize().
float Garp::_maxProgress [mutable, private] |
Definition at line 230 of file garp.hh.
Referenced by Garp(), and getProgress().
double Garp::_mortality [private] |
Percentage of rules that are killed at the end of a iteration
Definition at line 197 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), and Garp().
double Garp::_mutation_rate [private] |
Definition at line 202 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), and Garp().
GarpRuleSet* Garp::_offspring [private] |
Rule-set that stores the next generation of rules (offspring)
Definition at line 213 of file garp.hh.
Referenced by _setConfiguration(), deleteTempDataMembers(), Garp(), initialize(), iterate(), and ~Garp().
int Garp::_popsize [private] |
Number of points to be considered after resampling (with replacement)
Definition at line 185 of file garp.hh.
Referenced by _setConfiguration(), Garp(), initialize(), iterate(), and select().
int Garp::_prev_heur_count[5] [private] |
Regression Garp::_regression [private] |
Definition at line 218 of file garp.hh.
Referenced by colonize(), and initialize().
int Garp::_resamples [private] |
Number of points to be considered after resampling (with replacement)
Definition at line 188 of file garp.hh.
Referenced by Garp(), and initialize().
double Garp::_significance [private] |
Definition at line 200 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), Garp(), and iterate().