openModeller  Version 1.5.0
OpenModeller.hh
Go to the documentation of this file.
1 
28 #ifndef _OM_CONTROLHH_
29 #define _OM_CONTROLHH_
30 
31 #include <openmodeller/om_defs.hh>
33 #include <openmodeller/Log.hh>
36 #include <openmodeller/Sampler.hh>
39 #include <openmodeller/RocCurve.hh>
40 
41 class AlgParameter;
42 
45 
46 // Since MapCommand's defn/decl have been moved to om_projector.hh,
47 // we need to actually include the entire header.
49 
51 
53 
54 class MapFormat;
55 class ConfusionMatrix;
56 class RocCurve;
57 class AreaStats;
58 
59 #include <string>
60 #include <vector>
61 
62 
63 /****************************************************************/
64 /************************* Open Modeller ************************/
65 
71 class dllexp OpenModeller
72 {
73 public:
74 
75  OpenModeller();
76  ~OpenModeller();
77 
83  void setLogLevel(Log::Level level);
84 
85 
89  std::string getVersion();
90 
91  /*****************************************************************************
92  *
93  * Algorithms related methods
94  *
95  ****************************************************************************/
96 
106  AlgMetadata const **availableAlgorithms();
107 
113  AlgMetadata const *algorithmMetadata( char const *algorithm_id );
114 
121  int numAvailableAlgorithms();
122 
123  /*****************************************************************************
124  *
125  * Accessor methods
126  *
127  ****************************************************************************/
128 
133  EnvironmentPtr getEnvironment() { return _env; }
134 
139  AlgorithmPtr getAlgorithm() { return _alg; }
140 
145  Model getModel() const { return _alg->getModel(); }
146 
151  const SamplerPtr& getSampler() const { return _samp; }
152 
153  /*****************************************************************************
154  *
155  * Parameters setting methods
156  *
157  ****************************************************************************/
158 
167  int setOccurrences( const OccurrencesPtr& presence,
168  const OccurrencesPtr& absence=OccurrencesPtr() );
169 
179  int setAlgorithm( std::string const id, int nparam, AlgParameter const *param );
180 
189  void setEnvironment( std::vector<std::string> categ_map,
190  std::vector<std::string> continuous_map,
191  const std::string& mask );
192 
196  void setSampler(const SamplerPtr& sampler);
197 
203  void setAbortionCallback( AbortionCallback func, void *param=0 );
204 
205  /*****************************************************************************
206  *
207  * Projection / Map Generation Methods
208  *
209  ****************************************************************************/
210 
217  void setMapCallback( ModelProjectionCallback func, void *param=0 );
218 
228  int createMap( const EnvironmentPtr & env, char const *output_file, MapFormat& format );
229 
237  int createMap( const EnvironmentPtr & env, char const *output_file );
238 
248  int createMap( char const *output_file, MapFormat& format );
249 
257  int createMap( char const *output_file );
258 
259  /*****************************************************************************
260  *
261  * Model generation procedures
262  *
263  ****************************************************************************/
264 
271  void setModelCallback( ModelCreationCallback func, void *param=0 );
272 
273  //
274  // Model and distribution map related methods.
275  //
276 
279  int createModel();
280 
283  int run() { return createModel(); }
284 
294  Scalar getValue(const ConstEnvironmentPtr& env, Coord x, Coord y);
295 
302  Scalar getValue( Scalar const *environment_values );
303 
304  char *error() { return _error; }
305 
306  /*****************************************************************************
307  *
308  * Statistics
309  *
310  ****************************************************************************/
311 
318  AreaStats * getActualAreaStats();
319 
330  AreaStats * getEstimatedAreaStats(double proportionAreaToSample = 0.01);
331  AreaStats * getEstimatedAreaStats(const ConstEnvironmentPtr& env,
332  double proportionAreaToSample = 0.01);
333 
339  const ConfusionMatrix * const getConfusionMatrix();
340 
346  RocCurve * const getRocCurve();
347 
348  /*****************************************************************************
349  *
350  * Serialization & Deserialization
351  *
352  ****************************************************************************/
353 
354  ConfigurationPtr getModelConfiguration() const;
355 
356  void setModelConfiguration( const ConstConfigurationPtr & );
357 
358  void setProjectionConfiguration( const ConstConfigurationPtr & );
359 
360  void calculateModelStatistics( const ConstConfigurationPtr & );
361 
362 private:
363 
364  bool hasEnvironment();
365 
366  // Sampler object
368 
369  // Algorithm object
371 
372  // Presence occurrences points
374 
375  // Absence occurrences points
377 
378  // Original environmental layers
380 
381  // Wrapper object for callbacks
383 
384  // Output format
386 
387  // Environmental layers for projection
389 
390  // Model statistics: helper objects
393 
394  // Confusion matrix
396 
397  // ROC Curve
399 
400  char _error[256];
401 };
402 
403 
404 #endif
ReferenceCountedPointer< OccurrencesImpl > OccurrencesPtr
Definition: Occurrences.hh:47
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
Definition: aquamaps.cpp:223
ConfusionMatrix _confusion_matrix
double Scalar
Type of map values.
Definition: om_defs.hh:39
void(* ModelCreationCallback)(float progress, void *extra_param)
Definition: om_defs.hh:49
char * error()
Model getModel() const
Level
Definition: Log.hh:54
OccurrencesPtr _absence
AreaStats * _actualAreaStats
AlgorithmPtr _alg
EnvironmentPtr getEnvironment()
AreaStats * _estimatedAreaStats
AlgorithmPtr getAlgorithm()
RocCurve _roc_curve
EnvironmentPtr _env
EnvironmentPtr _projEnv
SamplerPtr _samp
bool(* AbortionCallback)(void *extra_param)
Definition: om_defs.hh:64
OccurrencesPtr _presence
const SamplerPtr & getSampler() const
double Coord
Type of map coordinates.
Definition: om_defs.hh:38
MapFormat _format
void(* ModelProjectionCallback)(float progress, void *extra_param)
Definition: om_defs.hh:58
CallbackWrapper _callback_wrapper