int main() { std::cout << "____________________________________" << std::endl << " Testing transformations from cdf to pdf and inversely" <<std::endl; int zval[5] = {1,2,3,4,5}; double prob[5] = {0.2, 0.3, 0.6, 0.8, 1}; typedef Non_param_pdf<int> Pdf; typedef Categ_non_param_cdf<int> Cdf; Cdf categ_cdf( 5, prob); Pdf pdf(zval, zval+5); cdf_to_pdf(pdf, categ_cdf); for(int i=0; i<=4; i++) std::cout << pdf.prob(i) << " " ; std::cout << std::endl; Cdf back(5); pdf_to_cdf(back,pdf); for(int i=0; i<=4; i++) std::cout << back.prob(i) << " " ; std::cout << std::endl; cdf_to_pdf(pdf, back); for(int i=0; i<=4; i++) std::cout << pdf.prob(i) << " " ; std::cout << std::endl; Pdf new_pdf(categ_cdf); for(int i=0; i<=4; i++) std::cout << new_pdf.prob(i) << " " ; std::cout << std::endl; std::cout << std::endl << "____________________________________" << std::endl << " Testing transformations from cdf to pdf and inversely "<<std::endl; Gaussian_cdf normal(0,1); std::vector<double> range(1000); for(std::vector<double>::iterator it=range.begin(); it!=range.end(); it++) *it = drand48()*100; std::ofstream out1( "uniform.dbg" ); std::copy( range.begin(), range.end(), std::ostream_iterator<double>( out1, "\n" ) ); cdf_transform(range.begin(), range.end(), normal); std::ofstream out2( "nscore.dbg" ); std::copy( range.begin(), range.end(), std::ostream_iterator<double>( out2, "\n" ) ); std::cout << std::endl << "____________________________________" << std::endl << " Testing cdf correction "<<std::endl; double order_relation[5] = {0.2, 0.3, -0.2, 0.1, 1.2}; Cdf bad_cdf(5, order_relation); std::cout << "Is bad cdf ok? " << is_valid_cdf(bad_cdf) << std::endl; make_cdf_valid(bad_cdf); std::cout << "Corrected cdf: " << std::endl; for(int i=0; i<bad_cdf.size(); i++) std::cout << bad_cdf.prob(i) << " " ; std::cout << std::endl; std::cout << std::endl << "____________________________________" << std::endl << " Testing cdf construction "<<std::endl; double val_range[9] = {1,1,1,4,7,12,31,55,60}; double z_values[7] = {1,4,7,12,31,55,60}; Non_param_cdf<> new_cdf( z_values, z_values+7); build_cdf( val_range, val_range+9, new_cdf.z_begin(), new_cdf.z_end(), new_cdf.p_begin() ); Non_param_cdf<>::z_iterator z_it = new_cdf.z_begin(); for( ; z_it != new_cdf.z_end(); z_it++ ) { std::cout << "P( " << *z_it << " ) = " << new_cdf.prob( *z_it ) << std::endl; } std::cout << std::endl; build_cdf( val_range, val_range+9, new_cdf, true ); z_it = new_cdf.z_begin(); for( ; z_it != new_cdf.z_end(); z_it++ ) { std::cout << "P( " << *z_it << " ) = " << new_cdf.prob( *z_it ) << std::endl; } }
bool Cosisim::initialize( const Parameters_handler* parameters, Error_messages_handler* errors ) { OPEN_DEBUG_STREAM( "cosisim.dbg" ); // Extract the parameters input by the user from the parameter handler //------------- // The "simulation" grid parameters std::string simul_grid_name = parameters->value( "Grid_Name.value" ); errors->report( simul_grid_name.empty(), "Grid_Name", "No grid selected" ); std::string property_name = parameters->value( "Property_Name.value" ); errors->report( property_name.empty(), "Property_Name", "No property name specified" ); // Get the simulation grid from the grid manager if( simul_grid_name.empty() ) return false; bool ok = geostat_utils::create( simul_grid_, simul_grid_name, "Grid_Name", errors ); if( !ok ) return false; // create a multi-realization property multireal_property_ = simul_grid_->add_multi_realization_property( property_name ); int nb_indicators = String_Op::to_number<int>( parameters->value( "Nb_Indicators.value" ) ); //------------- // The cdf parameters (# of thresholds, marginal, ...) bool categorical = String_Op::to_number<bool>( parameters->value( "Categorical_Variable_Flag.value" ) ); std::string marginal_probabilities_string = parameters->value( "Marginal_Probabilities.value" ); std::vector<double> marginal_probs = String_Op::to_numbers<double>( marginal_probabilities_string ); errors->report( marginal_probs.size() != nb_indicators, "Marginal_Probabilities", "Enter one probability value per indicator" ); if( categorical ) { // we ignore the input threshold values. The categories are numbered // from 0 to k (if there are k+1 categories). ccdf_ = new Categ_non_param_cdf<float>( marginal_probs.size() ); marginal_ = new Categ_non_param_cdf<float>( marginal_probs.size(), marginal_probs.begin() ); errors->report( !is_valid_cdf( marginal_probs.begin(), marginal_probs.end(), GsTL::discrete_variable_tag() ), "Marginal_Probabilities", "Values must be between 0 and 1 and sum up to 1" ); } else { std::vector<float> thresholds = String_Op::to_numbers<float>( parameters->value( "Thresholds.value" ) ); errors->report( !GsTL::is_sorted( thresholds.begin(), thresholds.end() ), "Thresholds", "Threshold values must be sorted in ascending order" ); ccdf_ = new Non_param_cdf<>( thresholds.begin(), thresholds.end() ); marginal_ = new Non_param_cdf<>( thresholds.begin(), thresholds.end(), marginal_probs.begin() ); errors->report( !is_valid_cdf( marginal_probs.begin(), marginal_probs.end(), GsTL::continuous_variable_tag() ), "Marginal_Probabilities", "The values entered do not define a valid cdf" ); // Set up the extrapolation tails geostat_utils::set_cdf_extrapolation_tail(parameters,errors, *((Non_param_cdf<>*) ccdf_), "lowerTailCdf", "upperTailCdf"); geostat_utils::set_cdf_extrapolation_tail(parameters,errors, *((Non_param_cdf<>*) marginal_), "lowerTailCdf", "upperTailCdf"); } //------------- // The hard data parameters std::string prim_harddata_grid_name = parameters->value( "Primary_Harddata_Grid.value" ); Geostat_grid* prim_harddata_grid = 0; Geostat_grid* sec_harddata_grid = 0; if( !prim_harddata_grid_name.empty() ) { // Get the harddata grid from the grid manager bool ok = geostat_utils::create( prim_harddata_grid, prim_harddata_grid_name, "Primary_Harddata_Grid", errors ); if( !ok ) return false; if( !dynamic_cast<Point_set*>(prim_harddata_grid) && prim_harddata_grid != simul_grid_ ) { std::ostringstream error_message; error_message << "the grid should either be the same as the simulation grid " << "or be a set of points"; errors->report( std::string( "Primary_Harddata_Grid" ), error_message.str() ); } // get the properties std::string primary_indicators_str = parameters->value( "Primary_Indicators.value" ); std::vector<std::string> primary_indicators_names = String_Op::decompose_string( primary_indicators_str, ";", false ); for( unsigned int i= 0; i < primary_indicators_names.size() ; i++ ) { primary_indicators_.push_back( prim_harddata_grid->property( primary_indicators_names[i] ) ); } if( nb_indicators != primary_indicators_names.size() ) { std::ostringstream message; message << "Specify exactly " << nb_indicators << " properties"; errors->report( std::string("Primary_Indicators"), message.str() ); } } std::string sec_harddata_grid_name = parameters->value( "Secondary_Harddata_Grid.value" ); if( !sec_harddata_grid_name.empty() ) { // Get the harddata grid from the grid manager bool ok2 = geostat_utils::create( sec_harddata_grid, sec_harddata_grid_name, "Secondary_Harddata_Grid", errors ); if( !ok2 ) return false; if( !dynamic_cast<Point_set*>( sec_harddata_grid ) && sec_harddata_grid != simul_grid_ ) { std::ostringstream error_message; error_message << "the grid should either be the same as the simulation grid " << "or be a set of points"; errors->report( std::string( "Secondary_Harddata_Grid" ), error_message.str() ); } std::string secondary_indicators_str = parameters->value( "Secondary_Indicators.value" ); errors->report( secondary_indicators_str.empty(), "Secondary_Indicators", "No property names specified" ); std::vector<std::string> secondary_indicators_names = String_Op::decompose_string( secondary_indicators_str, ";", false ); for( unsigned int i= 0; i < secondary_indicators_names.size() ; i++ ) { secondary_indicators_.push_back( sec_harddata_grid->property( secondary_indicators_names[i] ) ); } if( nb_indicators != secondary_indicators_names.size() ) { std::ostringstream message; message << "Specify exactly " << nb_indicators << " properties"; errors->report( std::string("Secondary_Indicators"), message.str() ); } } // check if errors were reported so far if( !errors->empty() ) return false; //-------------------- // Create K new properties on the simulation grid. Those are the properties // the simulation algorithm will be working on for each realization for( unsigned int j = 0 ; j < nb_indicators ; j++ ) { std::ostringstream prop_name; prop_name << "__tmp_indicator_" << j; GsTLGridProperty* prop = geostat_utils::add_property_to_grid( simul_grid_, prop_name.str() ); indicators_.push_back( prop ); } //-------------------- // Currently, we always assign the hard data to the simulation grid if( prim_harddata_grid ) { property_copier_ = Property_copier_factory::get_copier( prim_harddata_grid, simul_grid_ ); if( !property_copier_ ) { std::ostringstream message; message << "It is currently not possible to copy a property from a " << prim_harddata_grid->classname() << " to a " << simul_grid_->classname() ; errors->report( !property_copier_, "Assign_Hard_Data", message.str() ); return false; } //initializer_ = new Grid_initializer( simul_grid_, false ); for( unsigned int i = 0 ; i < primary_indicators_.size() ; i++ ) { property_copier_->copy( prim_harddata_grid, primary_indicators_[i], simul_grid_, indicators_[i] ); } } //------------- // Number of realizations and random number seed nb_of_realizations_ = String_Op::to_number<int>( parameters->value( "Nb_Realizations.value" ) ); seed_ = String_Op::to_number<int>( parameters->value( "Seed.value" ) ); //------------- // Set-up the indicator coding function if( categorical ) indicator_coder_ = Indicator<float>( new Class_indicator_function<float> ); else indicator_coder_ = Indicator<float>( new Indicator_function<float> ); //------------- // The Ik parameter (median or full) do_median_ik_ = String_Op::to_number<bool>( parameters->value( "Median_Ik_Flag.value" ) ); //------------- // The search neighborhood parameters int prim_max_neigh = String_Op::to_number<int>( parameters->value( "Max_Conditioning_Data_Primary.value" ) ); GsTLTriplet prim_ellips_ranges; GsTLTriplet prim_ellips_angles; bool prim_extract_ok = geostat_utils::extract_ellipsoid_definition( prim_ellips_ranges, prim_ellips_angles, "Search_Ellipsoid_Primary.value", parameters, errors ); if( !prim_extract_ok ) return false; GsTLTriplet sec_ellips_ranges; GsTLTriplet sec_ellips_angles; int sec_max_neigh = 0; if( sec_harddata_grid ) { sec_max_neigh = String_Op::to_number<int>( parameters->value( "Max_Conditioning_Data_Secondary.value" ) ); bool sec_extract_ok = geostat_utils::extract_ellipsoid_definition( sec_ellips_ranges, sec_ellips_angles, "Search_Ellipsoid_Secondary.value", parameters, errors ); if( !sec_extract_ok ) return false; } //------------- // Variogram (covariance) initialization // We distinguish two cases: // - median ik: there is only one covariance-set // - full ik : there are as many covariances as indicators std::vector< CovarianceType > covar_vector; std::vector<double> Bz_values; if( sec_harddata_grid ) { std::string Bz_string = parameters->value( "Bz_Values.value" ); Bz_values = String_Op::to_numbers<double>( Bz_string ); } else Bz_values.assign( nb_indicators, 0.0 ); if( do_median_ik_ ) { CovarianceType cov; bool init_cov_ok = geostat_utils::initialize_covariance( &cov, "Variogram_Median_Ik", parameters, errors ); if( !init_cov_ok ) return false; covar_vector.assign( nb_indicators, cov ); errors->report( Bz_values.empty(), "Bz_Values", "No values for Bz" ); covariances_.push_back( MarkovBayesCovariance(covar_vector[0], Bz_values[0]) ); } else { // We are doing full ik covar_vector.resize( nb_indicators ); if( Bz_values.size() != nb_indicators ) { errors->report( "Bz_Values", "Enter one Bz value per indicator" ); return false; } // initialize all the covariances bool init_cov_ok = geostat_utils::initialize_covariance( &covar_vector[0], "Variogram_Full_Ik", parameters, errors ); if( !init_cov_ok ) return false; covariances_.push_back( MarkovBayesCovariance(covar_vector[0], Bz_values[0]) ); for( int i=1; i < nb_indicators ; i++ ) { std::ostringstream tagname; tagname << "Variogram_Full_Ik_" << i+1 ; init_cov_ok = geostat_utils::initialize_covariance( &covar_vector[i], tagname.str(), parameters, errors ); if( !init_cov_ok ) return false; covariances_.push_back( MarkovBayesCovariance( covar_vector[i], Bz_values[i] ) ); } } Search_filter* prim_filter = geostat_utils:: set_advanced_search("AdvancedSearch_Primary", parameters, errors); Search_filter* soft_filter = NULL; if(sec_harddata_grid) soft_filter = geostat_utils:: set_advanced_search("AdvancedSearch_Secondary", parameters, errors); //-------------------- // neighborhoods initialization init_neighborhoods( simul_grid_, sec_harddata_grid, prim_ellips_ranges, prim_ellips_angles, sec_ellips_ranges, sec_ellips_angles, prim_max_neigh, sec_max_neigh, covar_vector, prim_filter, soft_filter ); delete prim_filter; delete soft_filter; //--------------------- // Kriging constraints and kriging combiner geostat_utils::Kriging_type ktype = geostat_utils::kriging_type( "Kriging_Type.value", parameters, errors ); if( ktype == geostat_utils::SK ) { for( int i = 0; i < nb_indicators ; i++ ) { typedef geostat_utils::WeightIterator Iter1; typedef geostat_utils::NeighIterator Iter2; typedef CoSK_combiner<Iter1,Iter2> CoSKCombiner; std::vector<double> means; // use the same mean for the primary and the secondary data: they are both // P(I(u)=1) means.assign( 2, *(marginal_->p_begin() + i) ); combiners_.push_back( geostat_utils::CoKrigingCombiner( new CoSKCombiner( means ) ) ); } Co_SKConstraints_impl< geostat_utils::NeighIterator, geostat_utils::Location > sk_constr; kconstraints_ = new geostat_utils::CoKrigingConstraints( &sk_constr ); } else { combiners_.resize( nb_indicators ); kconstraints_ = new geostat_utils::CoKrigingConstraints; } std::string region_name = parameters->value( "Grid_Name.region" ); if (!region_name.empty() && simul_grid_->region( region_name ) == NULL ) { errors->report("Grid_Name","Region "+region_name+" does not exist"); } else grid_region_.set_temporary_region( region_name, simul_grid_); if( simul_grid_ != sec_harddata_grid ) { std::string region_name = parameters->value( "Secondary_Harddata_Grid.region" ); if (!region_name.empty() && sec_harddata_grid->region( region_name ) == NULL ) { errors->report("Secondary_Harddata_Grid","Region "+region_name+" does not exist"); } else soft_grid_region_.set_temporary_region( region_name, sec_harddata_grid); } //------------------------------- // Done! if( !errors->empty() ) return false; return true; }
bool Sisim::initialize( const Parameters_handler* parameters, Error_messages_handler* errors ) { // Extract the parameters input by the user from the parameter handler //------------- // The "simulation" grid parameters std::string simul_grid_name = parameters->value( "Grid_Name.value" ); errors->report( simul_grid_name.empty(), "Grid_Name", "No grid selected" ); std::string property_name = parameters->value( "Property_Name.value" ); errors->report( property_name.empty(), "Property_Name", "No property name specified" ); // Get the simulation grid from the grid manager bool ok = geostat_utils::create( simul_grid_, simul_grid_name, "Grid_Name", errors ); if( !ok ) return false; // create a multi-realization property multireal_property_ = simul_grid_->add_multi_realization_property( property_name ); appli_assert( multireal_property_ ); //------------- // Miscellaneous simulation parameters nb_of_realizations_ = String_Op::to_number<int>( parameters->value( "Nb_Realizations.value" ) ); seed_ = String_Op::to_number<int>( parameters->value( "Seed.value" ) ); //------------- // The hard data parameters std::string harddata_grid_name = parameters->value( "Hard_Data_Grid.value" ); // Get the harddata grid from the grid manager and select the // hard data property if( !harddata_grid_name.empty() ) { geostat_utils::create( harddata_grid_, harddata_grid_name, "Hard_Data_Grid", errors ); std::string hdata_property_name = parameters->value( "Hard_Data_Property.value" ); errors->report( hdata_property_name.empty(), "Hard_Data_Property", "No properties specified" ); // Get the harddata property from the grid harddata_property_ = harddata_grid_->property( hdata_property_name ); } bool assign_harddata = String_Op::to_number<bool>( parameters->value( "Assign_Hard_Data.value" ) ); if( harddata_grid_ == NULL ) assign_harddata=false; else if( harddata_grid_ == simul_grid_ ) assign_harddata=true; if( assign_harddata ) { assign_harddata = true; // String_Op::to_number<bool>( parameters->value( "Assign_Hard_Data.value" ) ); // if( assign_harddata ) { property_copier_ = Property_copier_factory::get_copier( harddata_grid_, simul_grid_ ); if( !property_copier_ ) { std::ostringstream message; message << "It is currently not possible to copy a property from a " << harddata_grid_->classname() << " to a " << simul_grid_->classname() ; errors->report( !property_copier_, "Assign_Hard_Data", message.str() ); return false; } // initializer_ = new Grid_initializer( simul_grid_, false ); } is_data_coded_ = false; // Geostat_grid* coded_grid; std::string coded_grid_name = parameters->value( "coded_grid.value" ); if( !coded_grid_name.empty() ) { geostat_utils::create( coded_grid_, coded_grid_name, "coded_grid", errors ); } std::vector<GsTLGridProperty*> coded_props; std::string coded_prop_names = parameters->value( "coded_props.value" ); if(!coded_prop_names.empty() && coded_grid_ ) { is_data_coded_ = true; std::vector<std::string> coded_names = String_Op::decompose_string(coded_prop_names,";"); for(int i=0; i<coded_names.size() ; ++i ) { coded_props.push_back( coded_grid_->property( coded_names[i] ) ); errors->report(coded_props[i]==NULL,"coded_props","A property does not exist"); } } //------------- // The cdf parameters (# of thresholds, marginal, ...) int nb_indicators = String_Op::to_number<int>( parameters->value( "Nb_Indicators.value" ) ); if(is_data_coded_ && coded_props.size() != nb_indicators ) { std::ostringstream message; message << "enter exactly " << nb_indicators << " of soft data"; errors->report( "coded_props", message.str() ); return false; } bool categorical = String_Op::to_number<bool>( parameters->value( "Categorical_Variable_Flag.value" ) ); std::string marginal_probabilities_string = parameters->value( "Marginal_Probabilities.value" ); std::vector<double> marginal_probs = String_Op::to_numbers<double>( marginal_probabilities_string ); if( marginal_probs.size() != nb_indicators ) { std::ostringstream message; message << "enter exactly " << nb_indicators << " probabilities"; errors->report( "Marginal_Probabilities", message.str() ); return false; } if( categorical ) { // we ignore the input threshold values. The categories are numbered // from 0 to k (if there are k+1 categories). ccdf_ = new Categ_non_param_cdf<float>( marginal_probs.size() ); marginal_ = new Categ_non_param_cdf<float>( marginal_probs.size(), marginal_probs.begin() ); errors->report( !is_valid_cdf( marginal_probs.begin(), marginal_probs.end(), GsTL::discrete_variable_tag() ), "Marginal_Probabilities", "Values must be between 0 and 1 and sum up to 1" ); } else { std::vector<float> thresholds = String_Op::to_numbers<float>( parameters->value( "Thresholds.value" ) ); if( thresholds.size() != nb_indicators ) { std::ostringstream message; message << "enter exactly " << nb_indicators << " thresholds"; errors->report( "Thresholds", message.str() ); return false; } errors->report( !GsTL::is_sorted( thresholds.begin(), thresholds.end() ), "Thresholds", "Threshold values must be sorted in ascending order" ); ccdf_ = new Non_param_cdf<>( thresholds.begin(), thresholds.end() ); marginal_ = new Non_param_cdf<>( thresholds.begin(), thresholds.end(), marginal_probs.begin() ); errors->report( !is_valid_cdf( marginal_probs.begin(), marginal_probs.end(), GsTL::continuous_variable_tag() ), "Marginal_Probabilities", "The values entered do not define a valid cdf" ); geostat_utils::set_cdf_extrapolation_tail(parameters,errors, *((Non_param_cdf<>*) ccdf_), "lowerTailCdf", "upperTailCdf"); geostat_utils::set_cdf_extrapolation_tail(parameters,errors, *((Non_param_cdf<>*) marginal_), "lowerTailCdf", "upperTailCdf"); } // report errors found so far if( !errors->empty() ) return false; //------------- // The Ik parameter (median or full) do_median_ik_ = String_Op::to_number<bool>( parameters->value( "Median_Ik_Flag.value" ) ); //------------- // The search neighborhood parameters int max_neigh = String_Op::to_number<int>( parameters->value( "Max_Conditioning_Data.value" ) ); GsTLTriplet ranges; GsTLTriplet angles; bool extract_ok = geostat_utils::extract_ellipsoid_definition( ranges, angles, "Search_Ellipsoid.value", parameters, errors ); if( !extract_ok ) return false; extract_ok = geostat_utils::is_valid_range_triplet( ranges ); errors->report( !extract_ok, "Search_Ellipsoid", "Ranges must verify: major range >= " "medium range >= minor range >= 0" ); if( !extract_ok ) return false; //------------- // Variogram (covariance) and search ellipsoid initialization if( do_median_ik_ ) { // We're doing median ik: we only need one covariance and one // search neighborhood covar_vector_.resize( 1 ); bool init_cov_ok = geostat_utils::initialize_covariance( &covar_vector_[0], "Variogram_Median_Ik", parameters, errors ); if( !init_cov_ok ) return false; if( !harddata_grid_ || assign_harddata ) { neighborhood_ = SmartPtr<Neighborhood>( simul_grid_->neighborhood( ranges, angles, &covar_vector_[0] ) ); } else { Neighborhood* simul_neigh = simul_grid_->neighborhood( ranges, angles, &covar_vector_[0] ); Neighborhood* harddata_neigh = harddata_grid_->neighborhood( ranges, angles, &covar_vector_[0] ); harddata_neigh->max_size( max_neigh ); harddata_neigh->select_property( harddata_property_->name() ); neighborhood_ = SmartPtr<Neighborhood>( new Combined_neighborhood( harddata_neigh, simul_neigh, &covar_vector_[0]) ); } neighborhood_->max_size( max_neigh ); } else { // we're doing full ik: we need as many covariances and neighborhoods as // indicators covar_vector_.resize( ccdf_->size() ); neighborhoods_vector_.resize( ccdf_->size() ); // initialize all the covariances bool init_cov_ok = geostat_utils::initialize_covariance( &covar_vector_[0], "Variogram_Full_Ik", parameters, errors ); if( !init_cov_ok ) return false; for( int i=1; i < ccdf_->size(); i++ ) { std::string tagname = "Variogram_Full_Ik_" + String_Op::to_string( i+1 ); init_cov_ok = geostat_utils::initialize_covariance( &covar_vector_[i], tagname, parameters, errors ); if( !init_cov_ok ) return false; } // initialize all the neighborhoods. for( int j=0; j < ccdf_->size(); j++ ) { SmartPtr<Neighborhood> coded_neigh; if( is_data_coded_ ) { coded_neigh = SmartPtr<Neighborhood>( coded_grid_->neighborhood(ranges, angles, &covar_vector_[j] )); coded_neigh->select_property( coded_props[j]->name() ); coded_neigh->max_size( max_neigh ); } else { coded_neigh = SmartPtr<Neighborhood>( new DummyNeighborhood() ); } if( !harddata_grid_ || assign_harddata ) { SmartPtr<Neighborhood> simul_neigh = SmartPtr<Neighborhood>( simul_grid_->neighborhood( ranges, angles, &covar_vector_[j] )); SmartPtr<Neighborhood> neighborhood = SmartPtr<Neighborhood>( new Combined_neighborhood_dedup( coded_neigh, simul_neigh, &covar_vector_[j],true) ); neighborhood->max_size( max_neigh ); neighborhoods_vector_[j] = NeighborhoodHandle( neighborhood ); } else { Neighborhood* simul_neigh = simul_grid_->neighborhood( ranges, angles, &covar_vector_[j] ); simul_neigh->max_size( max_neigh ); Neighborhood* harddata_neigh = harddata_grid_->neighborhood( ranges, angles, &covar_vector_[j] ); harddata_neigh->max_size( max_neigh ); harddata_neigh->select_property( harddata_property_->name() ); SmartPtr<Neighborhood> hard_soft_data_neigh = SmartPtr<Neighborhood>( new Combined_neighborhood( harddata_neigh, coded_neigh, &covar_vector_[j] ) ); hard_soft_data_neigh->max_size( max_neigh ); SmartPtr<Neighborhood> neighborhood = SmartPtr<Neighborhood>( new Combined_neighborhood_dedup( hard_soft_data_neigh, simul_neigh, &covar_vector_[j],false ) ); neighborhood->max_size( max_neigh ); neighborhoods_vector_[j] = NeighborhoodHandle( neighborhood ); } } } //------------- // Set-up the cdf estimator if( categorical ) { Indicator<double> indicator( new Class_indicator_function<double> ); /* cdf_estimator_ = new CdfEstimator( covar_vector_.begin(), covar_vector_.end(), marginal_->p_begin(), marginal_->p_end(), indicator );*/ cdf_estimator_ = new CdfSoftEstimator( covar_vector_.begin(), covar_vector_.end(), marginal_->p_begin(), marginal_->p_end(), indicator,harddata_property_ ); } else { // The user has no pre-coded data; /* if( !is_data_coded_ ) { Indicator<double> indicator( new Indicator_function<double> ); cdf_estimator_ = new CdfEstimator( covar_vector_.begin(), covar_vector_.end(), marginal_->p_begin(), marginal_->p_end(), indicator ); } // There is some pre-coded data else {*/ Indicator<double> indicator( new Indicator_function<double> ); //cdf_soft_estimator_ = cdf_estimator_ = new CdfSoftEstimator( covar_vector_.begin(), covar_vector_.end(), marginal_->p_begin(), marginal_->p_end(), indicator,harddata_property_ ); // } } //------------------------------- // Done! if( !errors->empty() ) return false; return true; }