openModeller  Version 1.4.0
DgGarpBestSubsets.cpp
Go to the documentation of this file.
00001 
00029 #ifdef WIN32
00030 // avoid warnings caused by problems in VC headers
00031 #define _SCL_SECURE_NO_DEPRECATE
00032 #endif
00033 
00034 #include "DgGarpBestSubsets.hh"
00035 
00036 #include <openmodeller/om.hh>
00037 #include <openmodeller/Random.hh>
00038 #include <openmodeller/Sampler.hh>
00039 
00040 #include <stdlib.h>
00041 #include <stdio.h>
00042 #include <math.h>
00043 
00044 #define NUM_PARAM 11
00045 
00046 /************************************/
00047 /*** Algorithm parameter metadata ***/
00048 
00049 AlgParamMetadata parameters_bs[NUM_PARAM] = 
00050 {
00051   // Best Subsets Parameters
00052   {
00053     "TrainingProportion",          // Id.
00054     "Training Proportion",         // Name.
00055     Real,                          // Type.
00056 
00057     // Overview.
00058     "Percentage of occurrence data to be used to train models.",
00059 
00060     // Description.
00061     "Percentage of occurrence data to be used to train models.",
00062 
00063     1,      // Not zero if the parameter has lower limit.
00064     0,      // Parameter's lower limit.
00065     1,      // Not zero if the parameter has upper limit.
00066     100,    // Parameter's upper limit.
00067     "50"    // Parameter's typical (default) value.
00068   },
00069 
00070   {
00071     "TotalRuns",            // Id.
00072     "Total Runs",           // Name.
00073     Integer,                // Type.
00074 
00075     // Overview.
00076     "Maximum number of GARP runs to be performed.",
00077 
00078     // Description.
00079     "Maximum number of GARP runs to be performed.",
00080 
00081     1,      // Not zero if the parameter has lower limit.
00082     0,      // Parameter's lower limit.
00083     1,      // Not zero if the parameter has upper limit.
00084     10000,  // Parameter's upper limit.
00085     "20"    // Parameter's typical (default) value.
00086   },
00087 
00088   {
00089     "HardOmissionThreshold",          // Id.
00090     "Hard Omission Threshold",        // Name.
00091     Real,                             // Type.
00092 
00093     // Overview.
00094     "Maximum acceptable omission error. Set to 100% to use only soft omission.",
00095 
00096     // Description.
00097     "Maximum acceptable omission error. Set to 100% to use only soft omission.",
00098 
00099     1,      // Not zero if the parameter has lower limit.
00100     0,      // Parameter's lower limit.
00101     1,      // Not zero if the parameter has upper limit.
00102     100,    // Parameter's upper limit.
00103     "100"   // Parameter's typical (default) value.
00104   },
00105 
00106   {
00107     "ModelsUnderOmissionThreshold",                   // Id.
00108     "Models Under Omission Threshold",                // Name.
00109     Integer,                                          // Type.
00110 
00111     // Overview.
00112     "Minimum number of models below omission threshold.",
00113 
00114     // Description.
00115     "Minimum number of models below omission threshold.",
00116 
00117     1,      // Not zero if the parameter has lower limit.
00118     0,      // Parameter's lower limit.
00119     1,      // Not zero if the parameter has upper limit.
00120     10000,  // Parameter's upper limit.
00121     "20"    // Parameter's typical (default) value.
00122   },
00123 
00124   {
00125     "CommissionThreshold",          // Id.
00126     "Commission Threshold",         // Name.
00127     Real,                           // Type.
00128 
00129     // Overview.
00130     "Percentage of distribution models to be taken regarding commission error.",
00131 
00132     // Description.
00133     "Percentage of distribution models to be taken regarding commission error.",
00134 
00135     1,      // Not zero if the parameter has lower limit.
00136     0,      // Parameter's lower limit.
00137     1,      // Not zero if the parameter has upper limit.
00138     100,    // Parameter's upper limit.
00139     "50"    // Parameter's typical (default) value.
00140   },
00141 
00142   {
00143     "CommissionSampleSize",          // Id.
00144     "Commission Sample Size",        // Name.
00145     Real,                            // Type.
00146 
00147     // Overview.
00148     "Number of samples used to calculate commission error.",
00149 
00150     // Description.
00151     "Number of samples used to calculate commission error.",
00152 
00153     1,        // Not zero if the parameter has lower limit.
00154     1,        // Parameter's lower limit.
00155     0,        // Not zero if the parameter has upper limit.
00156     0,        // Parameter's upper limit.
00157     "10000"   // Parameter's typical (default) value.
00158   },
00159 
00160   {
00161     "MaxThreads",                       // Id.
00162     "Maximum Number of Threads",        // Name.
00163     Integer,                            // Type.
00164 
00165     // Overview.
00166     "Maximum number of threads of executions to run simultaneously.",
00167 
00168     // Description.
00169     "Maximum number of threads of executions to run simultaneously.",
00170 
00171     1,        // Not zero if the parameter has lower limit.
00172     1,        // Parameter's lower limit.
00173     1,        // Not zero if the parameter has upper limit.
00174     1024,     // Parameter's upper limit.
00175     "1"       // Parameter's typical (default) value.
00176   },
00177 
00178   // GARP parameters
00179   {
00180     "MaxGenerations",              // Id.
00181     "Max generations",             // Name.
00182     Integer,                       // Type.
00183 
00184     // Overview.
00185     "Maximum number of iterations run by the Genetic Algorithm.",
00186 
00187     // Description.
00188     "Maximum number of iterations (generations) run by the Genetic Algorithm.",
00189 
00190     1,      // Not zero if the parameter has lower limit.
00191     1,      // Parameter's lower limit.
00192     0,      // Not zero if the parameter has upper limit.
00193     0,      // Parameter's upper limit.
00194     "400"   // Parameter's typical (default) value.
00195   },
00196 
00197   {
00198     "ConvergenceLimit",        // Id.
00199     "Convergence limit",       // Name.
00200     Real,                      // Type.
00201 
00202     // Overview.
00203     "Defines the convergence value that makes the algorithm stop (before reaching MaxGenerations).",
00204 
00205     // Description.
00206     "Defines the convergence value that makes the algorithm stop (before reaching MaxGenerations).",
00207 
00208     1,     // Not zero if the parameter has lower limit.
00209     0.0,   // Parameter's lower limit.
00210     1,     // Not zero if the parameter has upper limit.
00211     1.0,   // Parameter's upper limit.
00212     "0.01"  // Parameter's typical (default) value.
00213   },
00214 
00215   {
00216     "PopulationSize",        // Id.
00217     "Population size",       // Name.
00218     Integer,                 // Type.
00219 
00220     "Maximum number of rules to be kept in solution.", // Overview.
00221     "Maximum number of rules to be kept in solution.", // Description
00222 
00223     1,     // Not zero if the parameter has lower limit.
00224     1,   // Parameter's lower limit.
00225     1,     // Not zero if the parameter has upper limit.
00226     500,   // Parameter's upper limit.
00227     "50"  // Parameter's typical (default) value.
00228   },
00229 
00230   {
00231     "Resamples",      // Id.
00232     "Resamples",      // Name.
00233     Integer,          // Type.
00234 
00235     // Overview.
00236     "Number of points sampled (with replacement) used to test rules.",
00237 
00238     // Description.
00239     "Number of points sampled (with replacement) used to test rules.",
00240 
00241     1,     // Not zero if the parameter has lower limit.
00242     1,   // Parameter's lower limit.
00243     1,     // Not zero if the parameter has upper limit.
00244     100000,   // Parameter's upper limit.
00245     "2500"  // Parameter's typical (default) value.
00246     }
00247 };
00248 
00249 /************************************/
00250 /*** Algorithm's general metadata ***/
00251 
00252 AlgMetadata metadata_bs = {
00253   
00254   "DG_GARP_BS", // Id.
00255   "GARP with best subsets - DesktopGARP implementation", // Name.
00256   "3.0.2", // Version.
00257 
00258   // Overview.
00259   "GARP is a genetic algorithm that creates ecological niche \
00260 models for species. The models describe environmental conditions \
00261 under which the species should be able to maintain populations. \
00262 For input, GARP uses a set of point localities where the species \
00263 is known to occur and a set of geographic layers representing \
00264 the environmental parameters that might limit the species' \
00265 capabilities to survive.",
00266 
00267   // Description.
00268   "GARP is a genetic algorithm that creates ecological niche \
00269 models for species. The models describe environmental conditions \
00270 under which the species should be able to maintain populations. \
00271 For input, GARP uses a set of point localities where the species \
00272 is known to occur and a set of geographic layers representing \
00273 the environmental parameters that might limit the species' \
00274 capabilities to survive.",
00275 
00276   // Author
00277   "Anderson, R. P., D. Lew, D. and A. T. Peterson.",  
00278 
00279   // Bibliography.
00280   "Anderson, R. P., D. Lew, and A. T. Peterson. 2003. \
00281 Evaluating predictive models of species' distributions: criteria \
00282 for selecting optimal models.Ecological Modelling, v. 162, p. 211 232.",
00283 
00284   "Ricardo Scachetti Pereira",  // Code author.
00285   "rpereira [at] ku.edu",       // Code author's contact.
00286 
00287   0,  // Does not accept categorical data.
00288   1,  // Does not need (pseudo)absence points.
00289 
00290   NUM_PARAM,   // Algorithm's parameters.
00291   parameters_bs
00292 };
00293 
00294 
00295 /****************************************************************/
00296 /****************** Algorithm's factory function ****************/
00297 
00298 OM_ALG_DLL_EXPORT 
00299 AlgorithmImpl * 
00300 algorithmFactory()
00301 {
00302   return new DgGarpBestSubsets();
00303 }
00304 
00305 OM_ALG_DLL_EXPORT
00306 AlgMetadata const *
00307 algorithmMetadata()
00308 {
00309   return &metadata_bs;
00310 }
00311 
00312 /****************************************************************/
00313 /****************** Garp class **********************************/
00314 
00315 DgGarpBestSubsets::DgGarpBestSubsets()
00316   : AbstractBestSubsets(& metadata_bs)
00317 {
00318   _subAlgorithm = "DG_GARP";
00319 }
00320 
00321 // ****************************************************************
00322 DgGarpBestSubsets::~DgGarpBestSubsets()
00323 {
00324 }
00325