openModeller
Version 1.5.0
|
#include <garp.hh>
Public Member Functions | |
Garp () | |
virtual | ~Garp () |
int | initialize () |
int | iterate () |
int | done () const |
float | getProgress () const |
Scalar | getValue (const Sample &x) const |
int | getConvergence (Scalar *const val) const |
int | getGeneration () |
void | deleteTempDataMembers () |
Public Member Functions inherited from AlgorithmImpl | |
AlgorithmImpl (AlgMetadata const *metadata) | |
virtual | ~AlgorithmImpl () |
void | setParameters (int nparam, AlgParameter const *param) |
void | setParameters (const ParamSetType &) |
std::string const | getID () const |
AlgMetadata const * | getMetadata () const |
AlgorithmPtr | getFreshCopy () |
virtual int | supportsModelProjection () const |
Model | createModel (const SamplerPtr &samp, CallbackWrapper *func=0) |
void | setSampler (const SamplerPtr &samp) |
virtual int | finalize () |
virtual int | needNormalization () |
Normalizer * | getNormalizer () const |
void | setNormalization (const SamplerPtr &samp) const |
void | setNormalization (const EnvironmentPtr &env) const |
virtual Model | getModel () const |
ConfigurationPtr | getConfiguration () const |
void | setConfiguration (const ConstConfigurationPtr &) |
Public Member Functions inherited from Configurable | |
virtual | ~Configurable () |
Protected Member Functions | |
virtual void | _getConfiguration (ConfigurationPtr &) const |
virtual void | _setConfiguration (const ConstConfigurationPtr &) |
Protected Member Functions inherited from AlgorithmImpl | |
int | dimDomain () |
int | getParameter (std::string const &name, std::string *value) |
int | getParameter (std::string const &name, double *value) |
int | getParameter (std::string const &name, float *value) |
int | getParameter (std::string const &name, int *value) |
Private Member Functions | |
void | cacheSamples (const SamplerPtr &, OccurrencesPtr &, int resamples) |
void | colonize (GarpRuleSet *ruleset, int numRules) |
void | evaluate (GarpRuleSet *ruleset) |
void | keepFittest (GarpRuleSet *source, GarpRuleSet *target, PerfIndex perfIndex) |
void | select (GarpRuleSet *source, GarpRuleSet *target, double gapsize) |
void | mutate (GarpRuleSet *ruleset) |
void | crossover (GarpRuleSet *ruleset) |
Private Attributes | |
int | _max_gen |
int | _popsize |
int | _resamples |
double | _acc_limit |
double | _conv_limit |
double | _mortality |
double | _significance |
double | _crossover_rate |
double | _mutation_rate |
double | _gapsize |
GarpRuleSet * | _fittest |
GarpRuleSet * | _offspring |
BioclimHistogram | _bioclimHistogram |
Regression | _regression |
OccurrencesPtr | _cachedOccs |
double | _convergence |
int | _improvements |
int | _curr_heur_count [5] |
int | _prev_heur_count [5] |
int | _gen |
float | _maxProgress |
Additional Inherited Members | |
Public Types inherited from AlgorithmImpl | |
typedef std::map< icstring, std::string > | ParamSetType |
Protected Attributes inherited from AlgorithmImpl | |
SamplerPtr | _samp |
Normalizer * | _normalizerPtr |
ParamSetType | _param |
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.
|
virtual |
Definition at line 270 of file garp.cpp.
References _fittest, and _offspring.
|
protectedvirtual |
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().
|
protectedvirtual |
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().
|
private |
Definition at line 331 of file garp.cpp.
References GeoTransform::getDefaultCS(), and OccurrencesImpl::reserve().
Referenced by initialize().
|
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().
|
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.
|
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().
|
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().
|
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.
|
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().
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().
|
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().
|
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().
|
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().
|
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().
|
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().
|
private |
Minimum posterior probability of a rule
Definition at line 191 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), and Garp().
|
private |
BioclimHistogram to assist the creation of bioclim based rules
Definition at line 216 of file garp.hh.
Referenced by colonize(), and initialize().
|
private |
Definition at line 220 of file garp.hh.
Referenced by evaluate(), and initialize().
|
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().
|
private |
Definition at line 222 of file garp.hh.
Referenced by done(), Garp(), getConvergence(), getProgress(), and keepFittest().
|
private |
Definition at line 201 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), crossover(), and Garp().
|
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().
|
private |
Definition at line 203 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), Garp(), and iterate().
|
private |
Definition at line 228 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), done(), Garp(), getGeneration(), getProgress(), iterate(), and mutate().
|
private |
Definition at line 223 of file garp.hh.
Referenced by Garp(), and keepFittest().
|
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().
|
mutableprivate |
Definition at line 230 of file garp.hh.
Referenced by Garp(), and getProgress().
|
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().
|
private |
Definition at line 202 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), and Garp().
|
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().
|
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().
|
private |
Definition at line 218 of file garp.hh.
Referenced by colonize(), and initialize().
|
private |
Number of points to be considered after resampling (with replacement)
Definition at line 188 of file garp.hh.
Referenced by Garp(), and initialize().
|
private |
Definition at line 200 of file garp.hh.
Referenced by _getConfiguration(), _setConfiguration(), Garp(), and iterate().