Skip to content

Commit

Permalink
refactoring: correctly rewriting of _get_static_and_unused_fluents me…
Browse files Browse the repository at this point in the history
…thod in problem
  • Loading branch information
Samuel Gobbi committed Dec 3, 2024
1 parent 3e8b551 commit f7f6820
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions unified_planning/model/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,6 @@ def _get_static_and_unused_fluents(
unused_fluents.clear()
for f in a.simulated_effect.fluents:
static_fluents.discard(f.fluent())

elif isinstance(a, up.model.natural_transition.Event):
# NOTE copypaste of above, with mixin should become one single block
remove_used_fluents(*a.preconditions)
for e in a.effects:
remove_used_fluents(e.fluent, e.value, e.condition)
static_fluents.discard(e.fluent.fluent())
if a.simulated_effect is not None:
# empty the set because a simulated effect reads all the fluents
unused_fluents.clear()
for f in a.simulated_effect.fluents:
static_fluents.discard(f.fluent())
elif isinstance(a, up.model.action.DurativeAction):
for cl in a.conditions.values():
remove_used_fluents(*cl)
Expand All @@ -350,8 +338,21 @@ def _get_static_and_unused_fluents(
unused_fluents.clear()
for f in se.fluents:
static_fluents.discard(f.fluent())
elif isinstance(a, up.model.natural_transition.Process):
for e in a.effects:
else:
raise NotImplementedError

Check warning on line 342 in unified_planning/model/problem.py

View check run for this annotation

Codecov / codecov/patch

unified_planning/model/problem.py#L342

Added line #L342 was not covered by tests
for nt in self._natural_transitions:
if isinstance(nt, up.model.natural_transition.Event):
remove_used_fluents(*nt.preconditions)
for e in nt.effects:
remove_used_fluents(e.fluent, e.value, e.condition)
static_fluents.discard(e.fluent.fluent())
if nt.simulated_effect is not None:
# empty the set because a simulated effect reads all the fluents
unused_fluents.clear()
for f in nt.simulated_effect.fluents:
static_fluents.discard(f.fluent())

Check warning on line 353 in unified_planning/model/problem.py

View check run for this annotation

Codecov / codecov/patch

unified_planning/model/problem.py#L351-L353

Added lines #L351 - L353 were not covered by tests
elif isinstance(nt, up.model.natural_transition.Process):
for e in nt.effects:
remove_used_fluents(e.fluent, e.value, e.condition)
static_fluents.discard(e.fluent.fluent())
else:
Expand Down

0 comments on commit f7f6820

Please sign in to comment.