From eb135ea43d2455643737c459861a9f66f9d4253a Mon Sep 17 00:00:00 2001 From: Alessandro Valentini Date: Mon, 15 Jul 2024 13:41:49 +0200 Subject: [PATCH 1/4] fix: fix a bug in the time triggered plan validator --- unified_planning/engines/plan_validator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/unified_planning/engines/plan_validator.py b/unified_planning/engines/plan_validator.py index fb35c6595..b24f78e72 100644 --- a/unified_planning/engines/plan_validator.py +++ b/unified_planning/engines/plan_validator.py @@ -311,6 +311,7 @@ def _apply_effect( updates: Dict[FNode, FNode], problem: Problem, ) -> Dict[FNode, FNode]: + em = problem.environment.expression_manager result = {} for instantiated_effect in effect.expand_effect(problem): if self._check_condition( @@ -326,9 +327,13 @@ def _apply_effect( if instantiated_effect.kind == EffectKind.ASSIGN: result[g_fluent] = se.evaluate(g_value, state=state) elif instantiated_effect.kind == EffectKind.DECREASE: - result[g_fluent] = f_value - se.evaluate(g_value, state=state) + result[g_fluent] = se.evaluate( + em.Minus(f_value, g_value), state=state + ) elif instantiated_effect.kind == EffectKind.INCREASE: - result[g_fluent] = f_value - se.evaluate(g_value, state=state) + result[g_fluent] = se.evaluate( + em.Plus(f_value, g_value), state=state + ) return result def _states_in_interval( From e73eb9f518e560686df6dcf3f6be834f4bb8a6d2 Mon Sep 17 00:00:00 2001 From: Alessandro Valentini Date: Wed, 24 Jul 2024 16:14:06 +0200 Subject: [PATCH 2/4] test: add example to test increase/decrease effects in the time triggered plan validator --- unified_planning/test/examples/minimals.py | 25 ++++++++++++++++++++++ unified_planning/test/test_problem.py | 1 + 2 files changed, 26 insertions(+) diff --git a/unified_planning/test/examples/minimals.py b/unified_planning/test/examples/minimals.py index 08d3cd194..63f0391d2 100644 --- a/unified_planning/test/examples/minimals.py +++ b/unified_planning/test/examples/minimals.py @@ -427,6 +427,31 @@ def get_example_problems(): counter_to_50 = TestCase(problem=problem, solvable=True, valid_plans=[plan]) problems["counter_to_50"] = counter_to_50 + # temporal counter + counter_f = Fluent("counter", IntType(0, 100)) + increase = DurativeAction("increase") + increase.set_fixed_duration(1) + increase.add_condition(StartTiming(), LT(counter_f, 99)) + increase.add_increase_effect(EndTiming(), counter_f, 2) + decrease = DurativeAction("decrease") + decrease.set_fixed_duration(1) + decrease.add_condition(StartTiming(), GT(counter_f, 0)) + decrease.add_decrease_effect(EndTiming(), counter_f, 1) + problem = Problem("temporal_counter") + problem.add_fluent(counter_f) + problem.add_action(increase) + problem.add_action(decrease) + problem.set_initial_value(counter_f, 0) + problem.add_goal(Equals(counter_f, 1)) + plan = up.plans.TimeTriggeredPlan( + [ + (Fraction(0, 1), up.plans.ActionInstance(increase), Fraction(1, 1)), + (Fraction(2, 1), up.plans.ActionInstance(decrease), Fraction(1, 1)), + ] + ) + t_counter = TestCase(problem=problem, solvable=True, valid_plans=[plan]) + problems["temporal_counter"] = t_counter + # basic with object constant Location = UserType("Location") is_at = Fluent("is_at", BoolType(), loc=Location) diff --git a/unified_planning/test/test_problem.py b/unified_planning/test/test_problem.py index 75b02a6c1..687ae4bd8 100644 --- a/unified_planning/test/test_problem.py +++ b/unified_planning/test/test_problem.py @@ -520,6 +520,7 @@ def test_simple_numeric_planning_kind(self): self.assertFalse(problem.kind.has_simple_numeric_planning()) names_of_SNP_problems = [ + "temporal_counter", "counter_to_50", "robot_decrease", "robot_locations_connected", From 7b43f3802e928a04b1d7587cd5564b819183b562 Mon Sep 17 00:00:00 2001 From: Alessandro Valentini Date: Wed, 24 Jul 2024 16:46:13 +0200 Subject: [PATCH 3/4] fix: fix mypy errors --- unified_planning/test/examples/minimals.py | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/unified_planning/test/examples/minimals.py b/unified_planning/test/examples/minimals.py index 63f0391d2..2b224e620 100644 --- a/unified_planning/test/examples/minimals.py +++ b/unified_planning/test/examples/minimals.py @@ -429,27 +429,27 @@ def get_example_problems(): # temporal counter counter_f = Fluent("counter", IntType(0, 100)) - increase = DurativeAction("increase") - increase.set_fixed_duration(1) - increase.add_condition(StartTiming(), LT(counter_f, 99)) - increase.add_increase_effect(EndTiming(), counter_f, 2) - decrease = DurativeAction("decrease") - decrease.set_fixed_duration(1) - decrease.add_condition(StartTiming(), GT(counter_f, 0)) - decrease.add_decrease_effect(EndTiming(), counter_f, 1) + d_increase = DurativeAction("increase") + d_increase.set_fixed_duration(1) + d_increase.add_condition(StartTiming(), LT(counter_f, 99)) + d_increase.add_increase_effect(EndTiming(), counter_f, 2) + d_decrease = DurativeAction("decrease") + d_decrease.set_fixed_duration(1) + d_decrease.add_condition(StartTiming(), GT(counter_f, 0)) + d_decrease.add_decrease_effect(EndTiming(), counter_f, 1) problem = Problem("temporal_counter") problem.add_fluent(counter_f) - problem.add_action(increase) - problem.add_action(decrease) + problem.add_action(d_increase) + problem.add_action(d_decrease) problem.set_initial_value(counter_f, 0) problem.add_goal(Equals(counter_f, 1)) - plan = up.plans.TimeTriggeredPlan( + ttplan = up.plans.TimeTriggeredPlan( [ - (Fraction(0, 1), up.plans.ActionInstance(increase), Fraction(1, 1)), - (Fraction(2, 1), up.plans.ActionInstance(decrease), Fraction(1, 1)), + (Fraction(0, 1), up.plans.ActionInstance(d_increase), Fraction(1, 1)), + (Fraction(2, 1), up.plans.ActionInstance(d_decrease), Fraction(1, 1)), ] ) - t_counter = TestCase(problem=problem, solvable=True, valid_plans=[plan]) + t_counter = TestCase(problem=problem, solvable=True, valid_plans=[ttplan]) problems["temporal_counter"] = t_counter # basic with object constant From a9c9d09c52ed098491dbffc07cb8448278753a1f Mon Sep 17 00:00:00 2001 From: Alessandro Valentini Date: Wed, 24 Jul 2024 18:03:32 +0200 Subject: [PATCH 4/4] CI: update planners ref --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bffa87e01..d6635599f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,10 +11,10 @@ on: required: true env: - up_tamer_commit: "631dfd43a56e7c2dda44fe273ec6f5492e99cfe1" + up_tamer_commit: "fba59b93ed7a85370f4bbf0dc5310bbeffce05b7" up_pyperplan_commit: "a24854213caf5038e1540e31613d24b93825fbb3" up_fast_downward_commit: "c60b6ab82cb8c3046cfd4782afe4d4c6071c4109" - up_enhsp_commit: "78cc3331beb1fcc36380a8f698f49b4312dc411a" + up_enhsp_commit: "f689d3b65bed921bed35c61b468ca771ae6f54a2" up_fmap_commit: "f29e66c8483abcb8f17ff1c46a0745ee9b1e95fa" jobs: