Ejemplo n.º 1
0
void PluginLoader::execute(const Configuration & cfg) {
    Setting files = cfg.setting["plugin_files"];
    size_t n = files.size();
    for (size_t i = 0; i < n; i++) {
        std::string filename = utils::replace_theta_dir(files[i]);
        load(filename);
    }
}
Ejemplo n.º 2
0
void SettingUsageRecorder::get_unused(std::vector<std::string> & unused, const Setting & aggregate_setting) const{
    size_t n = aggregate_setting.size();
    for(size_t i=0; i<n; ++i){
        std::string path = aggregate_setting[i].get_path();
        bool a_unused = false;
        if(used_paths.find(path) == used_paths.end()){
            unused.push_back(path);
            a_unused = true;
        }
        //don't descend if already aggregate was reported as unused ...
        if((aggregate_setting[i].get_type() == Setting::TypeList || aggregate_setting[i].get_type() == Setting::TypeGroup) && !a_unused){
            get_unused(unused, aggregate_setting[i]);
        }
    }
}
cubiclinear_histomorph::cubiclinear_histomorph(const Configuration & ctx): normalize_to_nominal(false) {
    boost::shared_ptr<VarIdManager> vm = ctx.pm->get<VarIdManager>();
    //build nominal histogram:
    h0_wu = get_constant_histogram(Configuration(ctx, ctx.setting["nominal-histogram"]));
    h0 = h0_wu.get_values_histogram();
    if(ctx.setting.exists("normalize_to_nominal")){
        normalize_to_nominal = ctx.setting["normalize_to_nominal"];
    }
    Setting psetting = ctx.setting["parameters"];
    size_t n = psetting.size();
    parameter_factors.resize(n, 1.0);
    bool have_parameter_factors = ctx.setting.exists("parameter_factors");
    for(size_t i=0; i<n; i++){
        string par_name = psetting[i];
        ParId pid = vm->get_par_id(par_name);
        par_ids.insert(pid);
        vid.push_back(pid);
        string setting_name;
        //plus:
        setting_name = par_name + "-plus-histogram";
        hplus_diff.push_back(get_constant_histogram(Configuration(ctx, ctx.setting[setting_name])).get_values_histogram());
        hplus_diff.back().check_compatibility(h0);
        hplus_diff.back().add_with_coeff(-1.0, h0);
        //minus:
        setting_name = par_name + "-minus-histogram";
        hminus_diff.push_back(get_constant_histogram(Configuration(ctx, ctx.setting[setting_name])).get_values_histogram());
        hminus_diff.back().check_compatibility(h0);
        hminus_diff.back().add_with_coeff(-1.0, h0);
        
        sum.push_back(hplus_diff.back());
        sum.back() += hminus_diff.back();
        diff.push_back(hplus_diff.back());
        diff.back().add_with_coeff(-1, hminus_diff.back());
        
        if(have_parameter_factors){
            parameter_factors[i] = ctx.setting["parameter_factors"][i];
        }
    }
    h0_sum = 0;
    for(size_t i=0; i < h0.get_nbins(); ++i){
        h0_sum += h0.get(i);
    }
}