Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in TimeTriggeredPlanValidator #619

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions unified_planning/engines/plan_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
25 changes: 25 additions & 0 deletions unified_planning/test/examples/minimals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
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(d_increase)
problem.add_action(d_decrease)
problem.set_initial_value(counter_f, 0)
problem.add_goal(Equals(counter_f, 1))
ttplan = up.plans.TimeTriggeredPlan(
[
(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=[ttplan])
problems["temporal_counter"] = t_counter

# basic with object constant
Location = UserType("Location")
is_at = Fluent("is_at", BoolType(), loc=Location)
Expand Down
1 change: 1 addition & 0 deletions unified_planning/test/test_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading