61 #if defined(DEBUG_MEMORY)
72 #if defined(DEBUG_MEMORY)
94 ParamSetType::const_iterator p =
_param.begin();
95 for( ; p !=
_param.end() ; ++p ) {
98 param_config->addSubsection( cfg );
99 cfg->addNameValue(
"Id", p->first );
100 cfg->addNameValue(
"Value", p->second );
103 config->addSubsection( param_config );
115 config->addSubsection( model_config );
138 Configuration::subsection_list::const_iterator nv;
140 for ( nv = params.begin(); nv != params.end(); ) {
142 string id = (*nv)->getAttribute(
"Id" );
143 string value = (*nv)->getAttribute(
"Value" );
156 bool found_normalization_section =
false;
160 norm_config = config->getSubsection(
"Normalization" );
162 found_normalization_section =
true;
171 if ( found_normalization_section ) {
175 std::string norm_class = norm_config->getAttribute(
"Class" );
177 if ( norm_class ==
"ScaleNormalizer" ) {
181 else if ( norm_class ==
"MeanVarianceNormalizer" ) {
187 string msg(
"Unknown normalizer class: " );
188 msg.append( norm_class );
236 while ( param < end ) {
258 std::string msg =
"Cannot produce copies of an algorithm without metadata.\n";
267 copy->setParameters(
_param );
277 ParamSetType::const_iterator pos =
_param.find(
id );
279 if ( pos ==
_param.end() ) {
284 *value = pos->second;
300 *value = atoi( str_value.c_str() );
315 *value = atof( str_value.c_str() );
330 *value = float( atof( str_value.c_str() ) );
366 std::string msg =
"Sampler not specified.\n";
373 if ( !samp->numPresence() && !samp->numAbsence() ) {
375 std::string msg =
"Cannot create model without any presence or absence point.\n";
386 if ( !
_samp->isNormalized() ) {
398 std::string msg =
"Normalizer not specified.\n";
408 if (
_samp->isNormalized() ) {
410 _samp->resetNormalization();
416 std::string msg =
"Algorithm could not be initialized.\n";
429 while ( resultFlag && ! doneFlag ) {
431 if ( callbackWrapper ) {
443 catch (
char * message ) {
445 string error(
"Exception in abort callback: " );
462 catch (
char * message ) {
464 string error(
"Exception in model iteration: " );
472 if ( callbackWrapper ) {
478 catch (
char * message ) {
480 string error(
"Exception in get progress: " );
491 std::string msg =
"Model creation aborted.\n";
500 std::string msg =
"Algorithm could not produce a model.\n";
509 std::string msg =
"Algorithm could not be finalized.\n";
516 if ( callbackWrapper ) {
522 catch (
char * message ) {
524 string error(
"Exception when finalizing progress: " );
Model createModel(const SamplerPtr &samp, CallbackWrapper *func=0)
Normalizer * getNormalizer() const
std::vector< ConfigurationPtr > subsection_list
AlgMetadata const * _metadata
static AlgorithmPtr newAlgorithm(std::string const id)
virtual int initialize()=0
AlgorithmImpl(AlgMetadata const *metadata)
virtual ConfigurationPtr getConfiguration() const =0
virtual Model getModel() const
ReferenceCountedPointer< ModelImpl > Model
static Log * instance()
Returns the instance pointer, creating the object on the first call.
AlgorithmPtr getFreshCopy()
void error(const char *format,...)
'Error' level.
int getParameter(std::string const &name, std::string *value)
ReferenceCountedPointer< const AlgorithmImpl > ConstAlgorithmPtr
void setNormalization(const SamplerPtr &samp) const
void setParameters(int nparam, AlgParameter const *param)
virtual void _setConfiguration(const ConstConfigurationPtr &)
std::map< icstring, std::string > ParamSetType
void notifyModelCreationProgress(float progress)
virtual void _getConfiguration(ConfigurationPtr &) const
void setConfiguration(const ConstConfigurationPtr &)
virtual int needNormalization()
std::string const value() const
ConfigurationPtr getConfiguration() const
std::string const id() const
void setSampler(const SamplerPtr &samp)
virtual void setConfiguration(const ConstConfigurationPtr &)=0
void info(const char *format,...)
'Info' level.
ParamSetType::value_type ParamSetValueType
virtual void computeNormalization(const ReferenceCountedPointer< const SamplerImpl > &samplerPtr)=0
void debug(const char *format,...)
'Debug' level.
virtual float getProgress() const
virtual Normalizer * getCopy()=0
Normalizer * _normalizerPtr