<commit_before>/**
 * problem-params.h ---
 *
 * Copyright (C) 2013 <NAME>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License v3 as
 * published by the Free Software Foundation and including the exceptions
 * at http://opencog.org/wiki/Licenses
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, write to:
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef _OPENCOG_MOSES_PROBLEM_PARAMS_H
#define _OPENCOG_MOSES_PROBLEM_PARAMS_H

#include <string>
#include <vector>

#include <boost/program_options.hpp>

#include <opencog/comboreduct/combo/vertex.h>
#include <opencog/comboreduct/reduct/reduct.h>
#include <opencog/comboreduct/table/table.h>
#include <opencog/learning/moses/metapopulation/metapop_params.h>
#include <opencog/learning/moses/moses/moses_main.h>
#include <opencog/learning/moses/moses/moses_params.h>
#include <opencog/learning/moses/optimization/optimization.h>
#include <opencog/learning/moses/optimization/hill-climbing.h>


namespace opencog { namespace moses {

struct problem_params
{
    problem_params();
    void parse_options(int argc, char* argv[]);

    // program options, see options_description below for their meaning
    std::vector<std::string> jobs_str;
    unsigned min_pool;
    bool enable_mpi;

    unsigned long rand_seed;
    std::string problem;

    // default number of samples to describe a problem
    const unsigned int default_nsamples;
    int nsamples;
    double min_rand_input;
    double max_rand_input;
    unsigned long max_evals;
    time_t max_time;
    int max_gens;
    std::string log_level;
    std::string log_file;
    bool log_file_dep_opt;

    // output printing options (metapop_printer)
    long result_count;
    bool output_score;
    bool output_penalty;
    bool output_bscore;
    bool output_only_best;
    bool output_eval_number;
    bool output_with_labels;
    bool output_python;
    std::string output_file;

    // reduct options
    int reduct_candidate_effort;
    int reduct_knob_building_effort;
    std::vector<std::string> include_only_ops_str;
    std::vector<std::string> ignore_ops_str;
    vertex_set ignore_ops;
    std::vector<std::string> ignore_features_str;
    std::vector<std::string> exemplars_str;
    std::vector<combo_tree> exemplars;

    // metapop_param
    int max_candidates;
    bool reduce_all;
    int revisit;
    double noise;
    score_t complexity_temperature;
    score_t complexity_ratio;
    double cap_coef;
    unsigned cache_size;
    bool linear_regression;
    double perm_ratio;
    
    // diversity parameters
    bool include_dominated;
    score_t diversity_pressure;
    score_t diversity_exponent;
    bool diversity_normalize;
    std::string diversity_dst;
    score_t diversity_p_norm;
    std::string diversity_dst2dp;

    // optim_param
    std::string opt_algo; //optimization algorithm
    double pop_size_ratio;
    score_t max_score;
    size_t max_dist;

    // contin optimization
    bool weighted_accuracy;
    std::vector<contin_t> discretize_thresholds;

    // hardness of the activation range
    // constraint for problems pre, recall, prerec
    score_t hardness;

    // hc_param
    bool hc_widen_search;
    bool hc_single_step;
    bool hc_crossover;
    unsigned hc_crossover_pop_size;
    unsigned hc_crossover_min_neighbors;
    bool hc_allow_resize_deme;
    unsigned hc_max_nn;<commit_msg>minor notes<commit_after>/**
 * problem-params.h ---
 *
 * Copyright (C) 2013 <NAME>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License v3 as
 * published by the Free Software Foundation and including the exceptions
 * at http://opencog.org/wiki/Licenses
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program; if not, write to:
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef _OPENCOG_MOSES_PROBLEM_PARAMS_H
#define _OPENCOG_MOSES_PROBLEM_PARAMS_H

#include <string>
#include <vector>

#include <boost/program_options.hpp>

#include <opencog/comboreduct/combo/vertex.h>
#include <opencog/comboreduct/reduct/reduct.h>
#include <opencog/comboreduct/table/table.h>
#include <opencog/learning/moses/metapopulation/metapop_params.h>
#include <opencog/learning/moses/moses/moses_main.h>
#include <opencog/learning/moses/moses/moses_params.h>
#include <opencog/learning/moses/optimization/optimization.h>
#include <opencog/learning/moses/optimization/hill-climbing.h>


namespace opencog { namespace moses {

// XXX FIXME TODO The structure below should be split into multiple
// parts, with each sub-part resposnisble for picking out the argv's
// that it cares about. Unfortunately, this requires getting rid of 
// boost::program_options (because boost::program_options does not
// allow modulariztion in this way; it forces all program options to
// be treated in a global fashion.  I tried. It was a hell. See this
// commit, and thee ones leading up to it:
// dc77c2a8812b0be18d95fc8b916d16bb78a95b29
// Argh ...
struct problem_params
{
    problem_params();
    void parse_options(int argc, char* argv[]);

    // program options, see options_description below for their meaning
    std::vector<std::string> jobs_str;
    unsigned min_pool;
    bool enable_mpi;

    unsigned long rand_seed;
    std::string problem;

    // default number of samples to describe a problem
    const unsigned int default_nsamples;
    int nsamples;
    double min_rand_input;
    double max_rand_input;
    unsigned long max_evals;
    time_t max_time;
    int max_gens;
    std::string log_level;
    std::string log_file;
    bool log_file_dep_opt;

    // output printing options (metapop_printer)
    long result_count;
    bool output_score;
    bool output_penalty;
    bool output_bscore;
    bool output_only_best;
    bool output_eval_number;
    bool output_with_labels;
    bool output_python;
    std::string output_file;

    // reduct options
    int reduct_candidate_effort;
    int reduct_knob_building_effort;
    std::vector<std::string> include_only_ops_str;
    std::vector<std::string> ignore_ops_str;
    vertex_set ignore_ops;
    std::vector<std::string> ignore_features_str;
    std::vector<std::string> exemplars_str;
    std::vector<combo_tree> exemplars;

    // metapop_param
    int max_candidates;
    bool reduce_all;
    int revisit;
    double noise;
    score_t complexity_temperature;
    score_t complexity_ratio;
    double cap_coef;
    unsigned cache_size;
    bool linear_regression;
    double perm_ratio;
    
    // diversity parameters
    bool include_dominated;
    score_t diversity_pressure;
    score_t diversity_exponent;
    bool diversity_normalize;
    std::string diversity_dst;
    score_t diversity_p_norm;
    std::string diversity_dst2dp;

    // optim_param (applicable for all optimzation algos)
    std::string opt_algo; //optimization algorithm
    double pop_size_ratio;
    score_t max_score;
    size_t max_dist;

    // contin optimization
    bool weighted_accuracy;
    std::vector<contin_t> discretize_thresholds;

    // hardness of the activation range
    // constraint for problems pre, recall, prerec
    score_t hardness;

    // hc_param  (hill-climbing)
    bool hc_widen_search;
    bool hc_single_step;
    bool hc_crossover;
    unsigned hc_crossover_pop_size;
    unsigned hc_crossover_min_neighbors;
    bool hc_allow_resize_deme;
    unsigned hc_max_nn;
{'fraction_non_alphanumeric': 0.07766990291262135, 'fraction_numerical': 0.00703883495145631, 'mean_word_length': 3.839107457428068, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5315489', 'n_tokens_mistral': 2683, 'n_tokens_neox': 2575, 'n_words': 731}