diff options
author | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-16 22:48:32 +0000 |
---|---|---|
committer | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-16 22:48:32 +0000 |
commit | 98f1e33967fdfd790cc82cb57fd59c202742ff0c (patch) | |
tree | 091df8372aba111b2321b835369c774bc22c6ea9 | |
parent | 0098369ae77e17a73ee1476d7f848604a0c13bf0 (diff) | |
download | ATCD-98f1e33967fdfd790cc82cb57fd59c202742ff0c.tar.gz |
Sat Jan 16 22:46:36 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r-- | SA_POP/ChangeLog | 11 | ||||
-rw-r--r-- | SA_POP/SA_POP_Types.h | 2 | ||||
-rw-r--r-- | SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp | 111 | ||||
-rw-r--r-- | SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h | 23 | ||||
-rw-r--r-- | SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp | 18 |
5 files changed, 155 insertions, 10 deletions
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog index f8b2a9d40e1..329afa7fbf1 100644 --- a/SA_POP/ChangeLog +++ b/SA_POP/ChangeLog @@ -1,3 +1,14 @@ +Sat Jan 16 22:46:36 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> + + * SA_POP_Types.h: + * experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h: + * experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp: + * experiments/EU_Performance/SAPOP_Exp_EU.cpp: + + Experiment ignores (just SA, no planning) initial conditions/goal that result in invalid goal condition probabilities (or ones below the #define’d threshold). + Experiment ignores generated plans with the same EU (to within a #define’d threshold percentage) as the initial plan. + + Sat Jan 16 19:57:13 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> * experiments/EU_Performance/Exp_Core/Exp_EU_Planner.h: diff --git a/SA_POP/SA_POP_Types.h b/SA_POP/SA_POP_Types.h index cf834909e5a..5d61256ad5d 100644 --- a/SA_POP/SA_POP_Types.h +++ b/SA_POP/SA_POP_Types.h @@ -859,7 +859,7 @@ namespace SA_POP { namespace SA_POP { namespace Default { /// Threshold (>=) for probability of a condition to be considered satisfied. - const ::SA_POP::Probability COND_PROB_THRESH = 0.9; + const ::SA_POP::Probability COND_PROB_THRESH = 0.6; /// Environment variable for root path. const std::string ROOT_PATH_STR = "SAPOP_ROOT"; diff --git a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp index 398ceb58770..3fab1d73cf3 100644 --- a/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp +++ b/SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp @@ -47,7 +47,8 @@ Exp_EU_Planner::Exp_EU_Planner (void) :do_pause_ (false), input_ (0), ques_ (0), - do_stats_out_ (false) + do_stats_out_ (false), + trial_init_plan_eu (0.0) { this->reset_trial_stats (); this->reset_run_stats (); @@ -78,6 +79,7 @@ Exp_EU_Planner::~Exp_EU_Planner (void) // Reset all planning statistics for an individual trial. void Exp_EU_Planner::reset_trial_stats (void) { + this->trial_init_plan_eu = 0.0; this->trial_results_.num_plans = 0; this->trial_results_.pref_plan_eu = 0.0; this->trial_results_.max_plan_eu = 0.0; @@ -208,6 +210,69 @@ SA_POP::Exp_EU_Run_Results Exp_EU_Planner::exp_run (std::string log_trials_filen }; +// Run planning. +bool Exp_EU_Planner::plan (size_t sa_max_steps, SA_POP::Goal goal) +{ + // Add goal to working plan and task network. + this->working_plan_->set_goal (goal); + this->sanet_->update_goals (goal.goal_conds); + + // Reset network and run spreading activation. + this->sanet_->reset_sa (); + this->sanet_->update (sa_max_steps); + +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // Output goal probabilities + //std::ostringstream goal_str; + //goal_str << "Goals (probability true): "; + //for (SA_POP::GoalMap::iterator goal_iter = goal.goal_conds.begin (); goal_iter != goal.goal_conds.end (); goal_iter++) { + // goal_str << this->sanet_->get_cond_name (goal_iter->first) << "("; + // goal_str << this->sanet_->get_cond_future_val(goal_iter->first, true) << ") "; + //} + //SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, goal_str.str ()); +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + + // Check that goal conditions meet probability criteria. + // Skip planning and return false if any goal condition does not. + for (SA_POP::GoalMap::iterator goal_iter = goal.goal_conds.begin (); goal_iter != goal.goal_conds.end (); goal_iter++) { + if (goal_iter->second >= 0) { + if (this->sanet_->get_cond_future_val(goal_iter->first, true) > 1.0 || this->sanet_->get_cond_future_val(goal_iter->first, true) < SA_POP::Default::GOAL_PROB_THRESH) { + std::ostringstream invalid_goal_str; + invalid_goal_str << "Goal condition (" << this->sanet_->get_cond_name (goal_iter->first) << ") "; + invalid_goal_str << "with probability, " << this->sanet_->get_cond_future_val(goal_iter->first, true) << ", "; + invalid_goal_str << "does not meet goal probability criteria. Skipping planning."; + SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, invalid_goal_str.str ()); + + return false; + } + } else { + if (this->sanet_->get_cond_future_val(goal_iter->first, false) > 1.0 || this->sanet_->get_cond_future_val(goal_iter->first, false) < SA_POP::Default::GOAL_PROB_THRESH) { + std::ostringstream invalid_goal_str; + invalid_goal_str << "Goal condition (" << this->sanet_->get_cond_name (goal_iter->first) << ") "; + invalid_goal_str << "with probability, " << this->sanet_->get_cond_future_val(goal_iter->first, false) << ", "; + invalid_goal_str << "does not meet goal probability criteria. Skipping planning."; + SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, invalid_goal_str.str ()); + + return false; + } + } + } + + // Set planning strategy goals and satisfy open conditions. + this->plan_strat_->set_goals (goal.goal_conds); + + if (this->plan_strat_->satisfy_open_conds ()) { + this->plan_ = this->working_plan_->get_plan (); + + this->notify_plan_changed (); + return true; + } + + return false; +}; + + + // Satisfy scheduling constraints in fully instantiated plan (no // recursive call backs). bool Exp_EU_Planner::full_sched () @@ -242,20 +307,58 @@ void Exp_EU_Planner::track_stats (SA_POP::Plan plan) // Update number of plans generated. this->trial_results_.num_plans++; + // Get plan EU. + SA_POP::Utility plan_eu = this->calc_plan_eu (plan); + +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // Output plan EUs + //std::ostringstream plan_eu_str; + //plan_eu_str << "Plan (EU = " << plan_eu << ") "; + //SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, plan_eu_str.str ()); +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // Ignore first plan. if (this->trial_results_.num_plans <= 1) { // First plan. this->trial_results_.num_plans = 1; + // Save EU for comparison with following plans. + this->trial_init_plan_eu = plan_eu; + // Increment counter of trials with initial plan. this->run_results_.num_init_plans++; - // Nothing else to do for first plan. + // Ignore plan. return; } - // Get plan EU. - SA_POP::Utility plan_eu = this->calc_plan_eu (plan); + +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // If this plan has the same EU as first plan, ignore. + // WARNING: This assumes that all plans will have EUs + // that differ by at least a small percentage + // unless they are the same plan with unnecessary + // support for initially true conditions. + if (plan_eu >= ((1.0 - SA_POP::Default::PERCENT_DIFF_EU) * this->trial_init_plan_eu) && + plan_eu <= ((1.0 + SA_POP::Default::PERCENT_DIFF_EU) * this->trial_init_plan_eu)) + { + // Decrement plan counter, so this plan is not counted. + this->trial_results_.num_plans--; + +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // Output plan EUs + //std::ostringstream ignore_plan_str; + //ignore_plan_str << "Ignoring plan (EU = " << plan_eu << ") "; + //ignore_plan_str << "within ignore percentage/multiplier (" << SA_POP::Default::PERCENT_DIFF_EU << ") "; + //ignore_plan_str << "of initial plan (EU = " << this->trial_init_plan_eu << ")."; + //SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, ignore_plan_str.str ()); +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + + // Ignore plan. + return; + } +//*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP*****TEMP***** + // Second plan is SA-POP preferred plan. if (this->trial_results_.num_plans == 2) { 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 0694ab0bd1d..fbd72d337f4 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 @@ -40,6 +40,16 @@ namespace SA_POP { + // Default values for use in EU Experiment. + namespace Default { + /// Threshold (>=) for probability of a goal to be considered satisfied. + const ::SA_POP::Probability GOAL_PROB_THRESH = 0.6; + + /// Percentage/multiplier threshold for two plan EUs to be considered different. + /// (WARNING: This should be a very small value.) + const double PERCENT_DIFF_EU = 0.000001; + }; + /// Container for experimental trial parameters. struct Exp_EU_Trial_Params { /// Number of goal conditions to generate. @@ -204,6 +214,16 @@ namespace SA_POP { // Recursive planning/scheduling methods. // ************************************************************************ + /// Run planning. + /** + * @param sa_max_steps Maximum steps to run spreading activation. + * + * @param goal Goal for which to plan. + * + * @return True if planning succeeded, false otherwise. + */ + virtual bool plan (size_t sa_max_steps, SA_POP::Goal goal); + /// Satisfy scheduling constraints in fully instantiated plan (no /// recursive call backs). /** @@ -233,6 +253,9 @@ namespace SA_POP { /// Output file stream for logging trial statistics. std::ofstream log_runs_out_; + /// Trial EU value for initial (thrown out) plan. + SA_POP::Utility trial_init_plan_eu; + /// Results of current experimental trial. SA_POP::Exp_EU_Trial_Results trial_results_; diff --git a/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp b/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp index 1ad1ee92cfc..c365fa7072d 100644 --- a/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp +++ b/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp @@ -43,6 +43,11 @@ // Additional SA-POP DEFAULT values for use in demo. namespace SA_POP { namespace Default { + // Multiplier to determine max trial attempts from number of trials to achieve. + const size_t TrialAttemptsMult = 5; + + + // Default ranges for values from user. const SA_POP::CondID CondIDMin = 1; const SA_POP::CondID CondIDMax = 999999; const SA_POP::Utility GoalUtilMin = -1000; @@ -55,12 +60,10 @@ namespace SA_POP { const size_t NumKnownCondsMax = 100; const size_t NumTrialsMin = 1; const size_t NumTrialsMax = 1000; - + const size_t NumNetsMin = 1; + const size_t NumNetsMax = 100000; // Default percentage of initial conditions to set as true (valid values: [0, 100]). const size_t NumPercentCondsInit = 30; - - // Multiplier to determine max trial attempts from number of trials to achieve. - const size_t TrialAttemptsMult = 10; }; /* SA_POP::Default namespace */ }; /* SA_POP namespace */ @@ -269,7 +272,7 @@ int main (int argc, char* argv[]) } // Get number of networks to run. - UserInterface::QuestionInt num_runs_ques ("Number of networks:", SA_POP::Default::NumTrialsMin, SA_POP::Default::NumTrialsMax); + UserInterface::QuestionInt num_runs_ques ("Number of networks:", SA_POP::Default::NumNetsMin, SA_POP::Default::NumNetsMax); if (user_input.ask (num_runs_ques)) num_runs = num_runs_ques.get_answer_int (); @@ -443,6 +446,11 @@ int main (int argc, char* argv[]) planner->add_out_adapter (&graph_out); } + // Add file output adapter, if user requested it. + SA_POP::LogFileOut file_out (plan_out_filename.c_str ()); + if (do_plan_file) + planner->add_out_adapter (&file_out); + //****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP****TEMP std::cout << "Experimental parameters:" << std::endl; std::cout << " Number of goal conditions: " << trial_params.num_goal_conds << std::endl; |