46 #define MAXDIST_ID "MaximumDistance"
59 "Maximum cartesian distance to closest point",
60 "Maximum cartesian distance to closest point",
81 "Probability is inversely proportional to the cartesian\
82 distance in environmental space to the nearest presence point.",
85 "Normalizes the environmental variables values and the\
86 parameter (according to the number of environmental variables).\
87 Calculates the distance between the given environmental conditions\
88 to each occurrence point and selects the closest distance.\n\
89 If distance 'dist' is within [0, MaxDist] then probability will\
90 be in [0,1]. If 'dist' > MaxDist then probability will be zero.",
97 "mauro [at] cria.org.br",
135 _hasCategorical( false ),
164 int dim =
_samp->numIndependent();
166 _dist *= sqrt( (
double) dim );
168 if (
_samp->numPresence() == 0 ) {
180 while ( p_iterator != p_end ) {
182 Sample point = (*p_iterator)->environment();
194 if (
_samp->isCategorical( i ) ) {
234 for(
unsigned int i=0; i<
_envPoints.size(); i++) {
238 if ( (dist >= 0) && (dist < min || min < 0) )
243 if ( min < 0 || min >
_dist )
246 return 1.0 - (min /
_dist);
270 if ( x[i] != pnt[i] ) {
294 config->addSubsection( model_config );
296 model_config->addNameValue(
"IsCategoricalLayer",
_isCategorical );
297 model_config->addNameValue(
"Distance",
_dist );
300 model_config->addSubsection( envpoints_config );
302 for(
unsigned int i=0; i<
_envPoints.size(); i++) {
305 envpoints_config->addSubsection( point_config );
307 point_config->addNameValue(
"Value",
_envPoints[i] );
320 _isCategorical = model_config->getAttributeAsSample(
"IsCategoricalLayer" );
333 _dist = model_config->getAttributeAsDouble(
"Distance", 0.0 );
336 ConstConfigurationPtr envpoints_config = model_config->getSubsection(
"EnvironmentalReferences",
false );
340 Configuration::subsection_list::iterator begin = subs.begin();
341 Configuration::subsection_list::iterator end = subs.end();
342 for ( ; begin != end; ++begin ) {
344 if ( (*begin)->getName() !=
"Reference" )
347 Sample point = (*begin)->getAttributeAsSample(
"Value" );
Scalar getValue(const Sample &x) const
static AlgMetadata metadata
void warn(const char *format,...)
'Warn' level.
std::vector< ConfigurationPtr > subsection_list
double Scalar
Type of map values.
std::vector< Sample > _envPoints
Scalar _dist
Parameter for MaxDistance.
static Log * instance()
Returns the instance pointer, creating the object on the first call.
virtual void _setConfiguration(const ConstConfigurationPtr &)
OM_ALG_DLL_EXPORT AlgorithmImpl * algorithmFactory()
OM_ALG_DLL_EXPORT AlgMetadata const * algorithmMetadata()
void error(const char *format,...)
'Error' level.
int getParameter(std::string const &name, std::string *value)
void resize(std::size_t size)
static AlgParamMetadata parameters[NUM_PARAM]
int getConvergence(Scalar *val)
virtual void _getConfiguration(ConfigurationPtr &) const
Scalar findDist(const Sample &x, const Sample &pnt) const
std::vector< OccurrencePtr >::const_iterator const_iterator
Normalizer * _normalizerPtr
virtual ~MinimumDistance()