Skip to content

Commit

Permalink
Added a test for processes and events parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Enrico Scala committed Oct 16, 2024
1 parent f995acd commit 3d2d150
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions unified_planning/model/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions unified_planning/test/pddl/car_nl/d.pddl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
)
)



(:action decelerate
:parameters ()
Expand Down Expand Up @@ -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)
)
)


)
1 change: 0 additions & 1 deletion unified_planning/test/pddl/car_nl/p.pddl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
(= (max_acceleration) 1)
(= (min_acceleration) -1)
(= (drag_coefficient) 0.1)
(= (max_speed) 10.0)
)

(:goal
Expand Down
11 changes: 11 additions & 0 deletions unified_planning/test/test_pddl_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 3d2d150

Please sign in to comment.