openModeller  Version 1.5.0
BestSubsets Class Referenceabstract

#include <best_subsets.hh>

Inheritance diagram for BestSubsets:
Inheritance graph
Collaboration diagram for BestSubsets:
Collaboration graph

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)
 
- Public Member Functions inherited from AlgorithmImpl
 AlgorithmImpl (AlgMetadata const *metadata)
 
virtual ~AlgorithmImpl ()
 
void setParameters (int nparam, AlgParameter const *param)
 
void setParameters (const ParamSetType &)
 
std::string const getID () const
 
AlgMetadata const * getMetadata () const
 
AlgorithmPtr getFreshCopy ()
 
virtual int supportsModelProjection () const
 
Model createModel (const SamplerPtr &samp, CallbackWrapper *func=0)
 
void setSampler (const SamplerPtr &samp)
 
virtual int finalize ()
 
virtual int needNormalization ()
 
NormalizergetNormalizer () const
 
void setNormalization (const SamplerPtr &samp) const
 
void setNormalization (const EnvironmentPtr &env) const
 
virtual Model getModel () const
 
ConfigurationPtr getConfiguration () const
 
void setConfiguration (const ConstConfigurationPtr &)
 
- Public Member Functions inherited from Configurable
virtual ~Configurable ()
 
- Public Member Functions inherited from BSAlgorithmFactory
virtual ~BSAlgorithmFactory ()
 

Protected Member Functions

void _getConfiguration (ConfigurationPtr &) const
 
void _setConfiguration (const ConstConfigurationPtr &)
 
- Protected Member Functions inherited from AlgorithmImpl
int dimDomain ()
 
int getParameter (std::string const &name, std::string *value)
 
int getParameter (std::string const &name, double *value)
 
int getParameter (std::string const &name, float *value)
 
int getParameter (std::string const &name, int *value)
 

Protected Attributes

int _nparam
 
AlgParameter_alg_params
 
- Protected Attributes inherited from AlgorithmImpl
SamplerPtr _samp
 
Normalizer_normalizerPtr
 
ParamSetType _param
 

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
 

Additional Inherited Members

- Public Types inherited from AlgorithmImpl
typedef std::map< icstring,
std::string > 
ParamSetType
 

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

BestSubsets::~BestSubsets ( )
virtual

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
protectedvirtual

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

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:

int BestSubsets::calculateBestSubset ( )
private

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

int BestSubsets::earlyTerminationConditionMet ( )
private
virtual AlgorithmImpl* BestSubsets::getBSAlgorithm ( )
privatepure 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:

int BestSubsets::numActiveThreads ( )
private
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 ( )
privatepure virtual

Implemented in GarpBestSubsets, and DgGarpBestSubsets.

Referenced by initialize().

Member Data Documentation

AlgorithmRun** BestSubsets::_activeRun
private
AlgorithmRun** BestSubsets::_bestRun
private
int BestSubsets::_commissionSampleSize
private

Definition at line 137 of file best_subsets.hh.

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

double BestSubsets::_commissionThreshold
private

Definition at line 136 of file best_subsets.hh.

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

int BestSubsets::_currentModelsUnderOmissionThreshold
private
int BestSubsets::_done
private
AlgorithmRun** BestSubsets::_finishedRun
private
float BestSubsets::_maxProgress
mutableprivate

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

int BestSubsets::_modelsUnderOmission
private
int BestSubsets::_nparam
protected
int BestSubsets::_numActiveRuns
private

Definition at line 151 of file best_subsets.hh.

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

int BestSubsets::_numBestRuns
private
int BestSubsets::_numFinishedRuns
private
double BestSubsets::_omissionThreshold
private

Definition at line 134 of file best_subsets.hh.

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

bool BestSubsets::_softOmissionThreshold
private
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: