openModeller  Version 1.4.0
BestSubsets Class Reference

#include <best_subsets.hh>

Inheritance diagram for BestSubsets:
Collaboration diagram for BestSubsets:

List of all members.

Public Member Functions

 BestSubsets (AlgMetadata *metadata)
virtual ~BestSubsets ()
int initialize ()
int iterate ()
int done () const
float getProgress () const
Scalar getValue (const Sample &x) const
int getConvergence (Scalar *const val) const
void printListOfRuns (string msg, AlgorithmRun **runs, int numOfRuns)

Protected Member Functions

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

Protected Attributes

int _nparam
AlgParameter_alg_params

Private Member Functions

virtual AlgorithmImplgetBSAlgorithm ()=0
virtual int transferParametersToAlgorithm ()=0
int numActiveThreads ()
int earlyTerminationConditionMet ()
int calculateBestSubset ()
void sortRuns (AlgorithmRun **runList, int nelements, int errorType)

Private Attributes

double _trainProp
int _totalRuns
double _omissionThreshold
int _modelsUnderOmission
double _commissionThreshold
int _commissionSampleSize
int _maxThreads
bool _softOmissionThreshold
int _currentModelsUnderOmissionThreshold
AlgorithmRun ** _finishedRun
AlgorithmRun ** _activeRun
AlgorithmRun ** _bestRun
int _numFinishedRuns
int _numActiveRuns
int _numBestRuns
int _done
float _maxProgress

Detailed Description

Implements Best Subset Procedure (Anderson et al. 2003).

It runs "n" Garp models, filter the best ones based on the procedure defined by Anderson et al. 2003 and sum them to obtain a probability map for the species distribution.

Current implementation uses multi-threading to run multiple Garp runs in parallel. Takes advantage of multi-processor servers and workstations.

Definition at line 55 of file best_subsets.hh.


Constructor & Destructor Documentation

Definition at line 95 of file best_subsets.cpp.

References _activeRun, _alg_params, _bestRun, _finishedRun, and _numFinishedRuns.


Member Function Documentation

void BestSubsets::_getConfiguration ( ConfigurationPtr config) const [protected, virtual]

Reimplemented from AlgorithmImpl.

Definition at line 458 of file best_subsets.cpp.

References _bestRun, _done, _numBestRuns, and AlgorithmRun::getAlgorithm().

Here is the call graph for this function:

void BestSubsets::_setConfiguration ( const ConstConfigurationPtr config) [protected, virtual]

Reimplemented from AlgorithmImpl.

Definition at line 486 of file best_subsets.cpp.

References _bestRun, _done, _numBestRuns, and AlgorithmFactory::newAlgorithm().

Here is the call graph for this function:

Definition at line 313 of file best_subsets.cpp.

References _bestRun, _commissionThreshold, _finishedRun, _modelsUnderOmission, _numBestRuns, _numFinishedRuns, _totalRuns, Log::info(), Log::instance(), printListOfRuns(), and sortRuns().

Referenced by iterate().

Here is the call graph for this function:

int BestSubsets::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 390 of file best_subsets.cpp.

References _done.

Referenced by getProgress().

virtual AlgorithmImpl* BestSubsets::getBSAlgorithm ( ) [private, pure virtual]

Implements BSAlgorithmFactory.

Implemented in GarpBestSubsets, and DgGarpBestSubsets.

int BestSubsets::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 450 of file best_subsets.cpp.

float BestSubsets::getProgress ( ) const [virtual]

Return progress so far

Reimplemented from AlgorithmImpl.

Definition at line 398 of file best_subsets.cpp.

References _activeRun, _currentModelsUnderOmissionThreshold, _maxProgress, _modelsUnderOmission, _numActiveRuns, _numFinishedRuns, _softOmissionThreshold, _totalRuns, done(), and AlgorithmRun::getProgress().

Here is the call graph for this function:

Scalar BestSubsets::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:
xPointer 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 433 of file best_subsets.cpp.

References _bestRun, _done, _numBestRuns, and AlgorithmRun::getValue().

Here is the call graph for this function:

int BestSubsets::initialize ( ) [virtual]

Initialize data structures

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

Implements AlgorithmImpl.

Definition at line 120 of file best_subsets.cpp.

References _activeRun, _commissionSampleSize, _commissionThreshold, _finishedRun, _maxThreads, _modelsUnderOmission, _omissionThreshold, _softOmissionThreshold, _totalRuns, _trainProp, Log::error(), AlgorithmImpl::getParameter(), Log::instance(), transferParametersToAlgorithm(), and Log::warn().

Here is the call graph for this function:

int BestSubsets::iterate ( ) [virtual]

Start model execution (build the model). Consists of a single GARP run. It is also the control loop for the threads

Returns:
0 on error

Reimplemented from AlgorithmImpl.

Definition at line 198 of file best_subsets.cpp.

References _activeRun, _alg_params, _commissionSampleSize, _done, _maxThreads, _nparam, _numActiveRuns, _numFinishedRuns, AlgorithmImpl::_samp, _totalRuns, _trainProp, calculateBestSubset(), Log::debug(), earlyTerminationConditionMet(), AlgorithmRun::initialize(), Log::instance(), numActiveThreads(), AlgorithmRun::run(), SLEEP, and splitSampler().

Here is the call graph for this function:

void BestSubsets::printListOfRuns ( string  msg,
AlgorithmRun **  runs,
int  numOfRuns 
)

Definition at line 53 of file best_subsets.cpp.

References AlgorithmRun::getCommission(), and AlgorithmRun::getId().

Referenced by calculateBestSubset().

Here is the call graph for this function:

void BestSubsets::sortRuns ( AlgorithmRun **  runList,
int  nelements,
int  errorType 
) [private]

Definition at line 360 of file best_subsets.cpp.

References AlgorithmRun::getError(), Log::info(), and Log::instance().

Referenced by calculateBestSubset().

Here is the call graph for this function:

virtual int BestSubsets::transferParametersToAlgorithm ( ) [private, pure virtual]

Implemented in GarpBestSubsets, and DgGarpBestSubsets.

Referenced by initialize().


Member Data Documentation

Definition at line 137 of file best_subsets.hh.

Referenced by BestSubsets(), initialize(), and iterate().

Definition at line 136 of file best_subsets.hh.

Referenced by BestSubsets(), calculateBestSubset(), and initialize().

int BestSubsets::_done [private]
float BestSubsets::_maxProgress [mutable, private]

Definition at line 156 of file best_subsets.hh.

Referenced by BestSubsets(), and getProgress().

int BestSubsets::_maxThreads [private]

Definition at line 138 of file best_subsets.hh.

Referenced by initialize(), and iterate().

Definition at line 151 of file best_subsets.hh.

Referenced by BestSubsets(), getProgress(), iterate(), and numActiveThreads().

Definition at line 134 of file best_subsets.hh.

Referenced by BestSubsets(), initialize(), and numActiveThreads().

int BestSubsets::_totalRuns [private]

Definition at line 133 of file best_subsets.hh.

Referenced by BestSubsets(), calculateBestSubset(), getProgress(), initialize(), and iterate().

double BestSubsets::_trainProp [private]

Definition at line 132 of file best_subsets.hh.

Referenced by BestSubsets(), initialize(), and iterate().


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