From 4bc2b5f80460085f9a4ba9b77af984703627cf9f Mon Sep 17 00:00:00 2001 From: Tom Silver Date: Tue, 5 Dec 2023 12:35:23 -0500 Subject: [PATCH 1/2] save and load online learning cycle in active sampler learning (#1594) --- predicators/approaches/active_sampler_learning_approach.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/predicators/approaches/active_sampler_learning_approach.py b/predicators/approaches/active_sampler_learning_approach.py index 5819a546ac..4de4eb8511 100644 --- a/predicators/approaches/active_sampler_learning_approach.py +++ b/predicators/approaches/active_sampler_learning_approach.py @@ -136,7 +136,8 @@ def load(self, online_learning_cycle: Optional[int]) -> None: self._nsrt_to_explorer_sampler = save_dict["nsrt_to_explorer_sampler"] self._seen_train_task_idxs = save_dict["seen_train_task_idxs"] self._train_tasks = save_dict["train_tasks"] - self._online_learning_cycle = CFG.skip_until_cycle + 1 + self._online_learning_cycle = 0 if online_learning_cycle is None \ + else online_learning_cycle + 1 def _learn_nsrts(self, trajectories: List[LowLevelTrajectory], online_learning_cycle: Optional[int], From 4cd25c8cfdb015950e60100b896409580de250c9 Mon Sep 17 00:00:00 2001 From: Nishanth Kumar Date: Tue, 5 Dec 2023 16:13:21 -0500 Subject: [PATCH 2/2] should be good! (#1596) --- predicators/approaches/active_sampler_learning_approach.py | 6 +++++- predicators/settings.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/predicators/approaches/active_sampler_learning_approach.py b/predicators/approaches/active_sampler_learning_approach.py index 4de4eb8511..3ada097f1e 100644 --- a/predicators/approaches/active_sampler_learning_approach.py +++ b/predicators/approaches/active_sampler_learning_approach.py @@ -104,7 +104,11 @@ def _create_explorer(self) -> BaseExplorer: preds = self._get_current_predicates() # Pursue the task goal during exploration periodically. n = CFG.active_sampler_learning_explore_pursue_goal_interval - pursue_task_goal_first = (self._online_learning_cycle % n == 0) + pursue_task_goal_first = False + if self._online_learning_cycle < \ + CFG.active_sampler_learning_init_cycles_to_pursue_goal or ( + self._online_learning_cycle % n == 0): + pursue_task_goal_first = True explorer = create_explorer( CFG.explorer, preds, diff --git a/predicators/settings.py b/predicators/settings.py index b3fe92e663..f91edc4bfe 100644 --- a/predicators/settings.py +++ b/predicators/settings.py @@ -602,6 +602,7 @@ class GlobalSettings: active_sampler_explorer_replan_frequency = 100 active_sampler_explorer_planning_progress_max_tasks = 10 active_sampler_explorer_planning_progress_max_replan_tasks = 5 + active_sampler_learning_init_cycles_to_pursue_goal = 1 # grammar search invention parameters grammar_search_grammar_includes_givens = True