openModeller  Version 1.4.0
Garp Class Reference

#include <garp.hh>

Inheritance diagram for Garp:
Collaboration diagram for Garp:

List of all members.

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 ()

Protected Member Functions

virtual void _getConfiguration (ConfigurationPtr &) const
virtual void _setConfiguration (const ConstConfigurationPtr &)

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

Detailed Description

Implementation of GARP: Genetic Algorithm for Rule-set Production

Definition at line 57 of file garp.hh.


Constructor & Destructor Documentation

Garp::~Garp ( ) [virtual]

Definition at line 270 of file garp.cpp.

References _fittest, and _offspring.


Member Function Documentation

void Garp::_setConfiguration ( const ConstConfigurationPtr config) [protected, virtual]
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().

Here is the call graph for this function:

void Garp::colonize ( GarpRuleSet ruleset,
int  numRules 
) [private]

Fill a rule set with newly generated rules

Parameters:
ruleset,:rule set where rules will be added to
numRulesnumber 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().

Here is the call graph for this function:

void Garp::crossover ( GarpRuleSet ruleset) [private]

Perform crossing over with rules in a rule set

Parameters:
rulesetRule 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().

Here is the call graph for this function:

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.

Returns:
Implementation specific but usually 1 for completion.

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.

Parameters:
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().

Here is the call graph for this function:

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.

Returns:
Parameters:
val

Reimplemented from AlgorithmImpl.

Definition at line 435 of file garp.cpp.

References _convergence.

int Garp::getGeneration ( ) [inline]

Definition at line 111 of file garp.hh.

References _gen.

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().

Here is the call graph for this function:

Scalar Garp::getValue ( const Sample x) const [virtual]

This method is used when projecting the model.

Note:
This method is inherited from the Algorithm class
Returns:
Parameters:
xa 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().

Here is the call graph for this function:

int Garp::initialize ( ) [virtual]

Initialize model by colonizing it with new rules.

Note:
This method is inherited from the Algorithm class
Returns:
0 on error

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().

Here is the call graph for this function:

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.

Returns:
0 on error

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().

Here is the call graph for this function:

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.

Parameters:
sourcePointer to the source rule set where rules will be selected from (usually the previous generated population)
targetPointer to the target rule set where fittest rules will be transferred to (usually the fittest rule set)
perfIndexIndex of value on performance array that will be used to select individuals.
Note:
: This method produces a side effect that is to update the statistics about heuristic operators performance (that will be used to adjust probabilities of application of those operators on future generations) and overall rule performance that will be used to compute the changes to the convergence value.

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().

Here is the call graph for this function:

void Garp::mutate ( GarpRuleSet ruleset) [private]

Mutate rules in a rule set

Parameters:
rulesetRule 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().

Here is the call graph for this function:

void Garp::select ( GarpRuleSet source,
GarpRuleSet target,
double  gapsize 
) [private]

Select fittest individuals and store them into target ruleset

Parameters:
sourcePointer to the rule set containing parents (individuals that will provide genes to create new individuals).
targetPointer to the target rule set where offspring will be transferred to.
gapsizeProportion 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().

Here is the call graph for this function:


Member Data Documentation

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 to assist the creation of bioclim based rules

Definition at line 216 of file garp.hh.

Referenced by colonize(), and initialize().

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]

Definition at line 225 of file garp.hh.

Referenced by Garp().

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]
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().

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]

Definition at line 226 of file garp.hh.

Referenced by Garp().

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().


The documentation for this class was generated from the following files: