diff options
Diffstat (limited to 'SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h')
-rw-r--r-- | SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h | 105 |
1 files changed, 97 insertions, 8 deletions
diff --git a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h index 3e6e3d5b06a..b935983b95d 100644 --- a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h +++ b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h @@ -21,11 +21,12 @@ #include <string> #include <set> #include <map> +#include <fstream> -#include "SA_POP_Types.h" +#include <boost/random.hpp> +#include "SA_POP_Types.h" #include "Planner.h" - #include "InputCL.h" //#include "PlanStrategy.h" @@ -70,18 +71,32 @@ namespace SA_POP { // Planning/re-planning methods. // ************************************************************************ - /// Run experiment planning. + /// Perform experimental trial(s). /** * @param sa_max_steps Maximum steps to run spreading activation. * - * @param goal Goal for which to plan. + * @param log_trials_filename Name of file to output trial statistics to. + * + * @param log_runs_filename Name of file to output cumulative statistics from run to. + * + * @param num_goal_conds Number of goal conditions to generate. * - * @param pause True to pause after next plan is generated or - * false to find all remaining plans. + * @param percent_init_true Percentage of conditions to set initial value to true. * - * @return True if plan generated, false otherwise. + * @param util_min Minimum goal utility (uniform random choice in range [util_min, util_max]). + * + * @param util_max Maximum goal utility (uniform random choice in range [util_min, util_max]). + * + * @param max_trial_attempts Maximum number of trial attempts to execute in order to reach assigned number of valid trials. + * + * @param num_trials Number of valid trials to attempt to achieve (each with randomly chosen initial conditions and goal). + * + * @param do_log_headers Flag to output header lines to log files (if true). */ -// virtual bool plan_exp (size_t sa_max_steps, SA_POP::Goal goal, bool pause = false); + virtual void exp_run (size_t sa_max_steps, std::string log_trials_filename, + std::string log_runs_filename, size_t num_goal_conds, double percent_init_true, + size_t util_min, size_t util_max, size_t max_trial_attempts, + size_t num_trials = 1, bool do_log_headers = false); // ************************************************************************ @@ -96,6 +111,9 @@ namespace SA_POP { virtual bool full_sched (); protected: + // Random number generator. + boost::mt19937 rand_gen_; + /// Flag for whether to pause for user input after each plan is generated. bool do_pause_; @@ -104,6 +122,77 @@ namespace SA_POP { /// Question to ask user whether to continue after each plan is generated. UserInterface::QuestionBool *ques_; + + /// Flag for whether to output statistics to files. + bool do_stats_out_; + + /// Output file stream for logging trial statistics. + std::ofstream log_trials_out_; + + /// Output file stream for logging trial statistics. + std::ofstream log_runs_out_; + + /// Trial counter for number of plans generated. + size_t trial_num_plans_; + + /// Run counter for number of trial attempts. + size_t run_num_trial_attempts_; + + /// Run counter for number of trials with initial plan generated. + size_t run_num_init_plans_; + + /// Run counter for number of trials with preferred plan generated. + size_t run_num_pref_plans_; + + /// Run counter for number of trials with at least one alternate plan generated. + size_t run_num_alt_plans_; + + /// Expected utility of SA-POP preferred plan. + SA_POP::Utility pref_plan_eu_; + + /// Highest expected utility of any (schedulable/valid) plan (including preferred plan). + SA_POP::Utility max_plan_eu_; + + + // ************************************************************************ + // Internal helper methods. + // ************************************************************************ + + /// Reset all planning statistics for an individual trial. + virtual void reset_trial_stats (void); + + /// Reset all planning statistics for an individual experimental run. + virtual void reset_run_stats (void); + + /// Add plan to tracking statistics. + virtual void track_stats (SA_POP::Plan plan); + + /// Output trial header to log. + virtual void log_trial_header (void); + + /// Output trial statistics to log. + virtual void log_trial_stats (void); + + /// Output run statistics to log. + virtual void log_run_stats (void); + + /// Output run header to log. + virtual void log_run_header (void); + + /// Initialize experiment (set values for initial conditions and + /// create goal). + /** + * @param num_goal_conds Number of goal conditions to generate. + * + * @param percent_init_true Percentage of conditions to set initial value to true. + * + * @param util_min Minimum goal utility (uniform random choice in range [util_min, util_max]). + * + * @param util_max Maximum goal utility (uniform random choice in range [util_min, util_max]). + * + * @return Goal to use in current experimental run. + */ + virtual SA_POP::Goal exp_init (size_t num_goal_conds, double percent_init_true, size_t util_min, size_t util_max); }; }; /* SA_POP namespace */ |