openModeller  Version 1.4.0
AlgorithmImpl Class Reference

#include <Algorithm.hh>

Inheritance diagram for AlgorithmImpl:
Collaboration diagram for AlgorithmImpl:

List of all members.

Public Types

typedef std::map< icstring,
std::string > 
ParamSetType

Public Member Functions

 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 initialize ()=0
virtual int iterate ()
virtual int finalize ()
virtual int done () const
virtual int getConvergence (Scalar *const val) const
virtual float getProgress () const
virtual int needNormalization ()
NormalizergetNormalizer () const
void setNormalization (const SamplerPtr &samp) const
void setNormalization (const EnvironmentPtr &env) const
virtual Scalar getValue (const Sample &x) const =0
virtual Model getModel () const
ConfigurationPtr getConfiguration () const
void setConfiguration (const ConstConfigurationPtr &)

Protected Member Functions

virtual void _getConfiguration (ConfigurationPtr &) const
virtual void _setConfiguration (const ConstConfigurationPtr &)
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

SamplerPtr _samp
Normalizer_normalizerPtr
ParamSetType _param

Private Types

typedef ParamSetType::value_type ParamSetValueType

Private Attributes

AlgMetadata const * _metadata

Friends

class ReferenceCountedPointer< AlgorithmImpl >
class ReferenceCountedPointer< const AlgorithmImpl >

Detailed Description

Base class for all distribution modeling algorithms. Provide methods to all derived classes so that they can do data sampling and access the environmental layers to build the model.

Definition at line 76 of file Algorithm.hh.


Member Typedef Documentation

typedef std::map< icstring, std::string > AlgorithmImpl::ParamSetType

Definition at line 84 of file Algorithm.hh.

typedef ParamSetType::value_type AlgorithmImpl::ParamSetValueType [private]

Definition at line 257 of file Algorithm.hh.


Constructor & Destructor Documentation

AlgorithmImpl::AlgorithmImpl ( AlgMetadata const *  metadata) [explicit]

Definition at line 54 of file Algorithm.cpp.

References Log::debug(), and Log::instance().

Here is the call graph for this function:

Definition at line 70 of file Algorithm.cpp.

References _normalizerPtr, Log::debug(), and Log::instance().

Here is the call graph for this function:


Member Function Documentation

int AlgorithmImpl::dimDomain ( ) [inline, protected]

All protected methods should not be called before initialized(). This is because the sampler object _samp is not initialized in the constructor and the algorithm's parameters were not set yet. Dimension of problem domain: number of independent variables (climatic + soil) added to the number of dependent variables (occurrence prediction).

Definition at line 212 of file Algorithm.hh.

virtual int AlgorithmImpl::done ( ) const [inline, virtual]
virtual int AlgorithmImpl::finalize ( ) [inline, virtual]

Called after the training phase has finished, ie after done() returned not zero.

Definition at line 137 of file Algorithm.hh.

Referenced by createModel().

Implements Configurable.

Definition at line 86 of file Algorithm.cpp.

References _getConfiguration(), _metadata, _normalizerPtr, _param, Configurable::getConfiguration(), AlgMetadata::id, and AlgMetadata::version.

Here is the call graph for this function:

virtual int AlgorithmImpl::getConvergence ( Scalar *const  val) const [inline, virtual]

Returns the algorithm's convergence value at the moment

Reimplemented in Csm, AquaMaps, Garp, AbstractBestSubsets, BestSubsets, RfAlgorithm, EnvelopeScore, ConsensusAlgorithm, Bioclim, SvmAlgorithm, GarpAlgorithm, and VirtualNicheGenerator.

Definition at line 143 of file Algorithm.hh.

Returns a copy of this algorithm in the same state as it was before being initialized (ie., no model, same parameters).

Definition at line 254 of file Algorithm.cpp.

References _metadata, _param, Log::error(), AlgMetadata::id, Log::instance(), and AlgorithmFactory::newAlgorithm().

Here is the call graph for this function:

std::string const AlgorithmImpl::getID ( ) const [inline]

Definition at line 100 of file Algorithm.hh.

AlgMetadata const* AlgorithmImpl::getMetadata ( ) const [inline]

Definition at line 102 of file Algorithm.hh.

Model AlgorithmImpl::getModel ( ) const [virtual]

Definition at line 536 of file Algorithm.cpp.

Referenced by createModel().

Returns the normalizer used by the algorithm. This method was created for super algorithms like "best subsets", so that the super algorithm can retrieve and use the same normalizer needed by the sub algorithm.

Definition at line 338 of file Algorithm.cpp.

References _normalizerPtr, and Normalizer::getCopy().

Referenced by ConsensusAlgorithm::initialize().

Here is the call graph for this function:

int AlgorithmImpl::getParameter ( std::string const &  name,
double *  value 
) [protected]

Returns an algorithm parameter of floating point type.

Parameters:
nameParameters name.
valueFilled with parameter's value.
Returns:
Zero if the parameter does not exists or the parameters were not set yet.
int AlgorithmImpl::getParameter ( std::string const &  name,
float *  value 
) [protected]
int AlgorithmImpl::getParameter ( std::string const &  name,
int *  value 
) [protected]

Returns an algorithm parameter of int point type.

Parameters:
nameParameters name.
valueFilled with parameter's value.
Returns:
Zero if the parameter does not exists or the parameters were not set yet.
virtual float AlgorithmImpl::getProgress ( ) const [inline, virtual]

Returns progress so far (between 0.0 and 1.0)

Reimplemented in AquaMaps, Garp, AbstractBestSubsets, BestSubsets, NicheMosaic, NNAlgorithm, RfAlgorithm, ConsensusAlgorithm, and GarpAlgorithm.

Definition at line 146 of file Algorithm.hh.

Referenced by createModel().

virtual Scalar AlgorithmImpl::getValue ( const Sample x) const [pure virtual]

The algorithm must return the occurrence probability at the given environment conditions.

Parameters:
xEnvironmental conditions.
Returns:
The occurrence probability in the range [0,1].

Implemented in Csm, AquaMaps, Garp, AbstractBestSubsets, BestSubsets, NNAlgorithm, NicheMosaic, RfAlgorithm, EnvelopeScore, ConsensusAlgorithm, Bioclim, DistanceToAverage, MinimumDistance, SvmAlgorithm, GarpAlgorithm, VirtualNicheGenerator, and EnvironmentalDistance.

virtual int AlgorithmImpl::iterate ( ) [inline, virtual]

One step further on the training. Return 0 if something wrong happened.

Reimplemented in Csm, AquaMaps, Garp, AbstractBestSubsets, BestSubsets, NicheMosaic, NNAlgorithm, EnvelopeScore, RfAlgorithm, ConsensusAlgorithm, Bioclim, DistanceToAverage, MinimumDistance, SvmAlgorithm, GarpAlgorithm, and VirtualNicheGenerator.

Definition at line 132 of file Algorithm.hh.

Referenced by createModel().

virtual int AlgorithmImpl::needNormalization ( ) [inline, virtual]

The algorithm should return != 0 if it needs normalization of environmental variables (non categorical ones).

Reimplemented in AbstractBestSubsets, NNAlgorithm, RfAlgorithm, ConsensusAlgorithm, and SvmAlgorithm.

Definition at line 155 of file Algorithm.hh.

Referenced by createModel().

void AlgorithmImpl::setConfiguration ( const ConstConfigurationPtr config) [virtual]

Implements Configurable.

Definition at line 121 of file Algorithm.cpp.

References _normalizerPtr, _param, _setConfiguration(), Log::error(), Log::instance(), Configurable::setConfiguration(), and UNUSED.

Here is the call graph for this function:

void AlgorithmImpl::setNormalization ( const SamplerPtr samp) const

Normalize the given environment.

Parameters:
sampSampler to normalize.

Definition at line 350 of file Algorithm.cpp.

References _normalizerPtr.

Referenced by createModel(), SvmAlgorithm::initialize(), NNAlgorithm::initialize(), and AbstractBestSubsets::needNormalization().

void AlgorithmImpl::setNormalization ( const EnvironmentPtr env) const

Normalize the given environment.

Parameters:
envEnvironment to normalize.

Definition at line 356 of file Algorithm.cpp.

References _normalizerPtr.

void AlgorithmImpl::setParameters ( int  nparam,
AlgParameter const *  param 
)

Configure the algorithm's parameters.

Parameters:
nparamNumber of parameters.
paramVector with all parameters. The address 'param' points to must exists while this object is used.

Definition at line 229 of file Algorithm.cpp.

References _param, AlgParameter::id(), and AlgParameter::value().

Here is the call graph for this function:

void AlgorithmImpl::setParameters ( const ParamSetType params)

Definition at line 245 of file Algorithm.cpp.

References _param.

void AlgorithmImpl::setSampler ( const SamplerPtr samp)

Set the sampler object. Need to be called before start the algorithm initialization or iteration.

Definition at line 221 of file Algorithm.cpp.

References _samp.

Referenced by createModel().

virtual int AlgorithmImpl::supportsModelProjection ( ) const [inline, virtual]

If algorithm returns 0 then it does not support projection of models to other environmental data layers. By default all algorithms support that feature.

Definition at line 113 of file Algorithm.hh.


Friends And Related Function Documentation

friend class ReferenceCountedPointer< AlgorithmImpl > [friend]

Definition at line 79 of file Algorithm.hh.

friend class ReferenceCountedPointer< const AlgorithmImpl > [friend]

Definition at line 80 of file Algorithm.hh.


Member Data Documentation

Definition at line 253 of file Algorithm.hh.

Referenced by getConfiguration(), and getFreshCopy().


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