Skip to content

Commit

Permalink
feature(interpreted functions): added checks in test_plan_validator t…
Browse files Browse the repository at this point in the history
…o skip if no plan is available to test
  • Loading branch information
Samuel Gobbi committed Sep 25, 2024
1 parent 27bc2d8 commit 2a05346
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 2 additions & 5 deletions unified_planning/test/examples/minimals.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def i_f_simple_bool(inputone, inputtwo):
itwo = Fluent("itwo", IntType(0, 20))
instant_action_i_f_condition = InstantaneousAction("instant_action_i_f_condition")
increase_val = InstantaneousAction("increase_val")
increase_val.add_effect(ione, Plus(ione, 2))
increase_val.add_effect(itwo, Plus(itwo, 2))
instant_action_i_f_condition.add_precondition((funx(ione, itwo)))
instant_action_i_f_condition.add_effect(end_goal, True)
problem.add_fluent(end_goal)
Expand All @@ -619,11 +619,8 @@ def i_f_simple_bool(inputone, inputtwo):
problem.add_goal(end_goal)
ifproblem = TestCase(
problem=problem,
solvable=True,
solvable=False, # currently
valid_plans=[
up.plans.SequentialPlan([instant_action_i_f_condition()]),
],
invalid_plans=[
up.plans.SequentialPlan([increase_val(), instant_action_i_f_condition()]),
],
)
Expand Down
7 changes: 7 additions & 0 deletions unified_planning/test/test_plan_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def test_all_from_factory(self):
for p in self.problems.values():
if not pv.supports(p.problem.kind):
continue
if not p.valid_plans:
print(
p.problem
) # after adding an always impossible problem we have to make sure we skip it here
continue
problem, plan = p.problem, p.valid_plans[0]
validation_result = pv.validate(problem, plan)
self.assertEqual(validation_result.status, ValidationResultStatus.VALID)
Expand All @@ -72,6 +77,8 @@ def test_all_from_factory_with_problem_kind(self):
for p in self.problems.values():
problem, plans = p.problem, p.valid_plans
plan = plans[0] if plans else None
if not plan: # again skip the non existing plan
continue
pk = problem.kind
if SequentialPlanValidator.supports(pk):
environment = unified_planning.environment.Environment()
Expand Down

0 comments on commit 2a05346

Please sign in to comment.