From 3d2d15049438d89b17aa8a54dd83cb290494226b Mon Sep 17 00:00:00 2001 From: Enrico Scala Date: Wed, 16 Oct 2024 09:34:02 +0200 Subject: [PATCH] Added a test for processes and events parsing --- unified_planning/model/problem.py | 2 ++ unified_planning/test/pddl/car_nl/d.pddl | 11 +++++++++++ unified_planning/test/pddl/car_nl/p.pddl | 1 - unified_planning/test/test_pddl_io.py | 11 +++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/unified_planning/model/problem.py b/unified_planning/model/problem.py index f6df3b520..d6fcd6750 100644 --- a/unified_planning/model/problem.py +++ b/unified_planning/model/problem.py @@ -180,6 +180,8 @@ def __eq__(self, oth: object) -> bool: return False if set(self._actions) != set(oth._actions): return False + if set(self.processes) != set(oth.processes): + return False if set(self._trajectory_constraints) != set(oth._trajectory_constraints): return False diff --git a/unified_planning/test/pddl/car_nl/d.pddl b/unified_planning/test/pddl/car_nl/d.pddl index a262c7c37..256173351 100644 --- a/unified_planning/test/pddl/car_nl/d.pddl +++ b/unified_planning/test/pddl/car_nl/d.pddl @@ -42,6 +42,7 @@ ) ) + (:action decelerate :parameters () @@ -69,5 +70,15 @@ (decrease (v) (* #t (* (* (v) (v)) (drag_coefficient) ) ) ) ;; velocity changes because of the acceleration ) ) + (:event velocity_check + :parameters () + :precondition (and + (> (v) 100000 ) + ) + :effect (and + (engine_stopped) + ) + ) + ) diff --git a/unified_planning/test/pddl/car_nl/p.pddl b/unified_planning/test/pddl/car_nl/p.pddl index 17ee7dc92..452c4788d 100644 --- a/unified_planning/test/pddl/car_nl/p.pddl +++ b/unified_planning/test/pddl/car_nl/p.pddl @@ -11,7 +11,6 @@ (= (max_acceleration) 1) (= (min_acceleration) -1) (= (drag_coefficient) 0.1) - (= (max_speed) 10.0) ) (:goal diff --git a/unified_planning/test/test_pddl_io.py b/unified_planning/test/test_pddl_io.py index 6ee9fa2cb..48bdcff6c 100644 --- a/unified_planning/test/test_pddl_io.py +++ b/unified_planning/test/test_pddl_io.py @@ -425,7 +425,18 @@ def test_sailing_reader(self): problem_2 = reader.parse_problem_string(domain_str, problem_str) self.assertEqual(problem, problem_2) + def test_non_linear_car(self): + reader = PDDLReader() + + domain_filename = os.path.join(PDDL_DOMAINS_PATH, "car_nl", "d.pddl") + problem_filename = os.path.join(PDDL_DOMAINS_PATH, "car_nl", "p.pddl") + problem = reader.parse_problem(domain_filename, problem_filename) + self.assertTrue(problem is not None) + self.assertEqual(len(problem.fluents), 8) + self.assertEqual(len(list([ele for ele in problem.actions if isinstance(ele,Process)])), 3) + self.assertEqual(len(list([ele for ele in problem.actions if isinstance(ele,Event)])),1) + def test_matchcellar_reader(self): reader = PDDLReader()