diff options
author | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-19 19:06:34 +0000 |
---|---|---|
committer | jkinnebrew <jkinnebrew@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-01-19 19:06:34 +0000 |
commit | 33922c463cabab17f9056642610322130500edc0 (patch) | |
tree | 4a1a9788a482708756b4d6eb2fd7801c0b802d7b | |
parent | a4cc54d436a15a92fff3c482d5900f942f4fa60a (diff) | |
download | ATCD-33922c463cabab17f9056642610322130500edc0.tar.gz |
Tue Jan 19 19:01:00 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu>
-rw-r--r-- | SA_POP/ChangeLog | 41 | ||||
-rw-r--r-- | SA_POP/Planner.cpp | 12 | ||||
-rw-r--r-- | SA_POP/experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp | 59 | ||||
-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 | 6 |
5 files changed, 84 insertions, 57 deletions
diff --git a/SA_POP/ChangeLog b/SA_POP/ChangeLog index 329afa7fbf1..6e86624ada9 100644 --- a/SA_POP/ChangeLog +++ b/SA_POP/ChangeLog @@ -1,3 +1,36 @@ +Tue Jan 19 19:01:00 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> + + * Planner.cpp: + + Clean-up on Planner::calc_plan_eu() + + * 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: + + Clean-up on EU experiment code, including throwing out plans with + invalid expected utilities (due to inability of SA to catch certain + double loops). + + +Tue Jan 19 07:03:24 UTC 2010 Ben Podgursky <bpodgursky@gmail.com> + + * Planner.cpp: + * experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp: + * experiments/EU_Performance/SAPOP_Exp_EU.cpp: + + Additional debug output (checking for > 1 probabilities) + +Tue Jan 19 02:07:16 UTC 2010 Ben Podgursky <bpodgursky@gmail.com> + + * experiments/EU_Performance/Exp_Core/Exp_EU_Planner.cpp: + * experiments/EU_Performance/SAPOP_Exp_EU.cpp: + + Turned off memory leak checking (took ages to output the leaks after long runs) + + Check for invalid plan EU values. + + Sat Jan 16 22:46:36 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.edu> * SA_POP_Types.h: @@ -5,8 +38,12 @@ Sat Jan 16 22:46:36 UTC 2010 John S. Kinnebrew <john.s.kinnebrew@vanderbilt.ed * 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. + Experiment ignores (just SA, no planning) initial conditions/goal that + result in invalid goal condition probabilities (and 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> diff --git a/SA_POP/Planner.cpp b/SA_POP/Planner.cpp index 77096b87fcb..70b7aa3af0b 100644 --- a/SA_POP/Planner.cpp +++ b/SA_POP/Planner.cpp @@ -515,6 +515,9 @@ Utility Planner::calc_plan_eu(Plan plan) // Clone current SANet. SANet::Network sanet (*(this->sanet_)); + // Reset network. + sanet.reset_sa (); + // Deactivate all nodes, before activating relevant ones. sanet.set_nodes_state (false); @@ -529,7 +532,7 @@ Utility Planner::calc_plan_eu(Plan plan) sanet.set_cond_state (goal_iter->first, true); } -// SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, goal_str.str ()); +// SA_POP_DEBUG_STR(SA_POP_DEBUG_VERBOSE, goal_str.str ()); // Activate tasks in plan and their preconditions. for (PlanInstSet::iterator inst_iter = plan.task_insts.begin (); inst_iter != plan.task_insts.end (); inst_iter++) { @@ -554,11 +557,10 @@ Utility Planner::calc_plan_eu(Plan plan) } // temp_str << ")"; -// SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, temp_str.str ()); +// SA_POP_DEBUG_STR(SA_POP_DEBUG_VERBOSE, temp_str.str ()); } - // Reset network and run spreading activation. - sanet.reset_sa (); + // Run spreading activation. sanet.update(sa_max_steps); // std::ostringstream eu_str; @@ -591,7 +593,7 @@ Utility Planner::calc_plan_eu(Plan plan) // eu_str << prob << ", " << eu << ") " ; } -// SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, eu_str.str ()); +// SA_POP_DEBUG_STR(SA_POP_DEBUG_VERBOSE, eu_str.str ()); return eu_total; }; 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 591aa325766..e6512f00567 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 @@ -17,7 +17,7 @@ #include <string> #include <set> #include <map> -#include <stdlib.h> +//#include <stdlib.h> #include <fstream> #include <sstream> #include <algorithm> @@ -231,17 +231,12 @@ bool Exp_EU_Planner::plan (size_t sa_max_steps, SA_POP::Goal goal) //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. + // Check that goal conditions meet probability and utility 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; + 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."; @@ -260,11 +255,6 @@ bool Exp_EU_Planner::plan (size_t sa_max_steps, SA_POP::Goal goal) return false; } } - - //Very Temp--this is only for debugging, limit goal utility to 10 for now - //if(goal_iter->second){ - // return false; - //} } // Set planning strategy goals and satisfy open conditions. @@ -319,19 +309,30 @@ void Exp_EU_Planner::track_stats (SA_POP::Plan plan) // Get plan EU. SA_POP::Utility plan_eu = this->calc_plan_eu (plan); - GoalMap goals = this->sanet_->get_goals(); - - double max_eu = 0; - for(GoalMap::iterator it = goals.begin(); it != goals.end(); it++){ - max_eu+=it->second; + // Calculate maximum goal utility as sum of absolute value of goal condition utilities. + SA_POP::Utility max_util_total = 0.0; + for (SA_POP::GoalMap::iterator goal_iter = plan.goal.goal_conds.begin (); goal_iter != plan.goal.goal_conds.end (); goal_iter++) { + // Add absolute value of utility of this goal to total. + if (goal_iter->second > 0) { + max_util_total += goal_iter->second; + } + else { + max_util_total += -1 * goal_iter->second; + } } - if(max_eu < plan_eu){ - std::ostringstream invalid_plan_str; - invalid_plan_str << "Invalid plan EU, returning"; - SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, invalid_plan_str.str ()); - - return; + + // Throw out plans with invalid utilities. + if (plan_eu > max_util_total) { + // Decrement plan counter, so this plan is not counted. + this->trial_results_.num_plans--; + + std::ostringstream invalid_plan_str; + invalid_plan_str << "Invalid plan EU of " << plan_eu << ". Ignoring plan."; + SA_POP_DEBUG_STR(SA_POP_DEBUG_TEMP, invalid_plan_str.str ()); + + // 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***** @@ -382,7 +383,11 @@ void Exp_EU_Planner::track_stats (SA_POP::Plan plan) return; } - std::cout<<"EU of plan: "<<plan_eu<<" init plan EU: "<<this->trial_init_plan_eu<<std::endl; + // Output other plan EUs compared to initial plan EU. + //std::ostringstream plan_eu_str; + //plan_eu_str << "Current (valid) Plan EU = " << plan_eu << ", and "; + //plan_eu_str << "Initial Plan EU = " << this->trial_init_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***** 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 fbd72d337f4..58aa084e71c 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 @@ -43,7 +43,7 @@ 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; + const ::SA_POP::Probability GOAL_PROB_THRESH = 0.3; /// Percentage/multiplier threshold for two plan EUs to be considered different. /// (WARNING: This should be a very small value.) @@ -262,27 +262,6 @@ namespace SA_POP { /// Results of current experimental run (multiple trials). SA_POP::Exp_EU_Run_Results run_results_; - /// 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. diff --git a/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp b/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp index e0f542d58e2..3d124d2a1c5 100644 --- a/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp +++ b/SA_POP/experiments/EU_Performance/SAPOP_Exp_EU.cpp @@ -13,8 +13,10 @@ */ //============================================================================= +// Dumping memory leaks at end of a long experimental run can take an +// inordinate amount of time, so removing this for now. //#define _CRTDBG_MAP_ALLOC -#include <stdlib.h> +//#include <stdlib.h> //#include <crtdbg.h> #include <iostream> @@ -577,6 +579,8 @@ int main (int argc, char* argv[]) // UserInterface::Question end_ques ("Enter any character to end program:"); // user_input.ask (end_ques); +// Dumping memory leaks at end of a long experimental run can take an +// inordinate amount of time, so removing this for now. //_CrtDumpMemoryLeaks(); return 0; |