64 "Maximum number of iterations run by the Genetic Algorithm.",
67 "Maximum number of iterations (generations) run by the Genetic\
83 "Defines the convergence value that makes the algorithm stop\
84 (before reaching MaxGenerations).",
101 "Maximum number of rules to be kept in solution.",
102 "Maximum number of rules to be kept in solution.",
117 "Number of points sampled (with replacement) used to test rules.",
120 "Number of points sampled (with replacement) used to test rules.",
137 "GARP (single run) - new openModeller implementation",
141 "GARP is a genetic algorithm that creates ecological niche \
142 models for species. The models describe environmental conditions \
143 under which the species should be able to maintain populations. \
144 For input, GARP uses a set of point localities where the species \
145 is known to occur and a set of geographic layers representing \
146 the environmental parameters that might limit the species' \
147 capabilities to survive. Please refer to algorithm description for \
148 more information about the differences between this new GARP \
149 implementation and the Desktop GARP implementation.",
152 "GARP is a genetic algorithm that creates ecological niche \
153 models for species. The models describe environmental conditions \
154 under which the species should be able to maintain populations. \
155 For input, GARP uses a set of point localities where the species \
156 is known to occur and a set of geographic layers representing \
157 the environmental parameters that might limit the species' \
158 capabilities to survive. This implementation is a complete rewrite \
159 of the DesktopGarp code, and it also contains the following \
160 changes/improvements: (1) Gene values changed from integers (between 1 \
161 and 253) to floating point numbers (between -1.0 and 1.0). This avoids \
162 precision problems in environment values during projection (for example, \
163 if an environment variable has the value 2.56 in some raster cell and \
164 2.76 in another one, DesktopGarp rounds them off to 3). (2) Atomic rules \
165 were removed since they seem to have little significance compared to the \
166 other rules. (3) Heuristic operator parameters (percentage of mutation \
167 and crossover per iteration) are now static since they used to converge \
168 to fixed values during the very first iterations. This implementation \
169 simply keeps the converged values. (4) A bug was fixed in the procedure \
170 responsible for ordering the rules. When a rule was only replacing \
171 another, it was being included in the wrong position.",
174 "Stockwell, D. R. B., modified by Ricardo Scachetti Pereira",
177 "Stockwell, D. R. B. 1999. Genetic algorithms II. \
178 Pages 123-144 in A. H. Fielding, editor. \
179 Machine learning methods for ecological applications. \
180 Kluwer Academic Publishers, Boston.\
182 Stockwell, D. R. B., and D. P. Peters. 1999. \
183 The GARP modelling system: Problems and solutions to automated \
184 spatial prediction. International Journal of Geographic \
185 Information Systems 13:143-158.\
187 Stockwell, D. R. B., and I. R. Noble. 1992. \
188 Induction of sets of rules from animal distribution data: \
189 A robust and informative method of analysis. Mathematics and \
190 Computers in Simulation 33:385-390.",
192 "Ricardo Scachetti Pereira",
193 "ricardo [at] tdwg . org",
206 #ifndef DONT_EXPORT_GARP_FACTORY
259 for (i = 0; i < 5; i++)
340 for (
int i = 0; i < resamples; ++i)
343 cachedOccs->insert(oc);
353 double perfBest, perfWorst, perfAvg;
369 &perfBest, &perfWorst, &perfAvg);
409 float progress = (byIterations > byConvergence) ? byIterations : byConvergence;
450 config->addSubsection( model_config );
452 model_config->addNameValue(
"Generations",
_gen );
453 model_config->addNameValue(
"AccuracyLimit",
_acc_limit );
454 model_config->addNameValue(
"Mortality",
_mortality );
457 model_config->addNameValue(
"FinalMutationRate",
_mutation_rate );
458 model_config->addNameValue(
"FinalGapSize",
_gapsize );
465 model_config->addSubsection( rules_config );
467 rules_config->addNameValue(
"Count", nrules );
469 for(
int i=0; i<nrules; i++ ) {
473 sprintf(type,
"%c", rule->
type() );
476 rules_config->addSubsection( rule_config );
478 rule_config->addNameValue(
"Type", type );
479 rule_config->addNameValue(
"Prediction", rule->
getPrediction() );
480 rule_config->addNameValue(
"Chromosome1", rule->
getChrom1());
481 rule_config->addNameValue(
"Chromosome2", rule->
getChrom2());
498 _gen = model_config->getAttributeAsInt(
"Generations", 0 );
499 _acc_limit = model_config->getAttributeAsDouble(
"AccuracyLimit", 0.0 );
500 _mortality = model_config->getAttributeAsDouble(
"Mortality", 0.0 );
501 _significance = model_config->getAttributeAsDouble(
"Significance", 0.0 );
502 _crossover_rate = model_config->getAttributeAsDouble(
"FinalCrossoverRate", 0.0 );
503 _mutation_rate = model_config->getAttributeAsDouble(
"FinalMutationRate", 0.0 );
504 _gapsize = model_config->getAttributeAsDouble(
"FinalGapSize", 0.0 );
509 Log::instance()->
error(
"Could not read parameter PopulationSize from serialized model.");
528 Configuration::subsection_list::const_iterator ss;
529 for( ss = rules_config->getAllSubsections().begin();
530 ss != rules_config->getAllSubsections().end();
536 string type = c->getAttribute(
"Type" );
538 Scalar pred = c->getAttributeAsDouble(
"Prediction", 0.0 );
540 Sample p_chrom1 = c->getAttributeAsSample(
"Chromosome1" );
542 Sample p_chrom2 = c->getAttributeAsSample(
"Chromosome2" );
546 c->getAttributeAsDoubleArray(
"Performance", &p_perf, &n_perf );
550 rule =
new RangeRule( pred, p_chrom1.
size(), p_chrom1, p_chrom2, p_perf );
554 rule =
new LogitRule( pred, p_chrom1.
size(), p_chrom1, p_chrom2, p_perf );
582 int i, n, converged, similarIndex;
583 GarpRule * candidateRule, * similarRule;
589 for (i = 0; i < n; i++)
591 candidateRule = source->
get(i);
596 if (similarIndex >= 0)
601 similarRule = target->
get(similarIndex);
606 candidateRule = candidateRule->
clone();
608 target->
remove(similarIndex);
609 target->
insert(perfIndex, candidateRule);
617 candidateRule = candidateRule->
clone();
618 target->
insert(perfIndex, candidateRule);
645 for (i = 0; i < n; i++)
662 dim =
_samp->numIndependent();
664 for (i = ruleset->
numRules(); i < numRules; i++)
685 Scalar pred = (rnd.
get(0.0, 1.0) > 0.5) ? 1.0 : 0.0;
704 int i, j, k, n, temp;
705 double perfBest, perfWorst, perfAvg;
706 double sum, ptr, factor, expected, rulePerf, size;
707 perfBest = perfWorst = perfAvg = 0.0;
715 if (perfAvg - perfWorst)
716 factor = 1.0 / (perfAvg - perfWorst);
729 for (i = 0; i < n; i++) {
731 expected = (rulePerf - perfWorst) * factor;
732 for (sum += expected; (sum > ptr) && (k <= _popsize); ptr++) {
734 Log::instance()->
error(
"Index out of bounds (#6). Limits are (0, %d), index is %d\n", _popsize, k);
751 j = rnd.
get (i , _popsize - 1);
753 sample[j] = sample[i];
761 size = ((double) _popsize) * gapsize;
763 for (i = 0; i < size; i++)
765 pRuleBeingInserted = source->
get(sample[i])->
clone();
767 if (!target->
add(pRuleBeingInserted)) {
769 std::string
error =
"Garp::reproduce(): Target rule set is full";
784 double temperature = 2.0 / (double)
_gen;
786 for (i = 0; i < n; i++)
796 int nrules, genes, xcount, last, mom, dad, xpt1, xpt2;
798 genes =
_samp->numIndependent();
802 for (xcount = 0; xcount < last; xcount += 2)
804 mom = rnd.
get(nrules);
805 dad = rnd.
get(nrules);
807 dad = (dad + 1) % nrules;
809 xpt1 = rnd.
get(genes);
810 xpt2 = rnd.
get(genes);
834 for (
int i = 1; i < ruleset->
numRules(); i++)
839 printf(
"\nError: rule set out of sort order (Index: %d)\n", index);
840 for (
int i = 0; i < ruleset->
numRules(); i++)
843 if ((i + 1) % 5 == 0)
virtual void crossover(GarpRule *rule, int xpt1, int xpt2)
double get(double min, double max)
virtual void _setConfiguration(const ConstConfigurationPtr &)
void evaluate(GarpRuleSet *ruleset)
void crossover(GarpRuleSet *ruleset)
virtual void _getConfiguration(ConfigurationPtr &) const
int findSimilar(GarpRule *rule)
OccurrencesPtr _cachedOccs
void keepFittest(GarpRuleSet *source, GarpRuleSet *target, PerfIndex perfIndex)
double Scalar
Type of map values.
void cacheSamples(const SamplerPtr &, OccurrencesPtr &, int resamples)
void reserve(int estimate)
static Log * instance()
Returns the instance pointer, creating the object on the first call.
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
Scalar getValue(const Sample &x) const
void filter(PerfIndex perfIndex, double threshold)
void error(const char *format,...)
'Error' level.
void performanceSummary(PerfIndex perfIndex, double *best, double *worst, double *average)
BioclimHistogram _bioclimHistogram
void printPerfs(char *msg, int index, GarpRuleSet *ruleset)
int getParameter(std::string const &name, std::string *value)
double evaluate(const OccurrencesPtr &occs)
void setPrediction(double pred)
const Sample & getChrom1() const
GarpRule * get(int index)
void calculateParameters(const OccurrencesPtr &occs)
const PerfIndex defaultPerfIndex
Scalar getValue(const Sample &x) const
virtual GarpRule * clone() const
float getProgress() const
virtual void mutate(double temperature)
int insert(PerfIndex perfIndex, GarpRule *rule)
Scalar getPrediction() const
virtual char type() const
const double * getPerformanceArray() const
AlgParamMetadata parameters[NUM_PARAM]
double getPerformance(PerfIndex perfIndex) const
void deleteTempDataMembers()
int getConvergence(Scalar *const val) const
const Sample & getChrom2() const
void mutate(GarpRuleSet *ruleset)
void colonize(GarpRuleSet *ruleset, int numRules)
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
void select(GarpRuleSet *source, GarpRuleSet *target, double gapsize)
void initialize(const OccurrencesPtr &occs)
Normalizer * _normalizerPtr