From 162427f79ed3e530eea5b86cdb3c3b20520ae754 Mon Sep 17 00:00:00 2001 From: Samuel Gobbi Date: Tue, 3 Dec 2024 14:50:40 +0100 Subject: [PATCH] testing some functions --- unified_planning/model/problem.py | 4 ---- unified_planning/test/examples/processes.py | 6 ++++++ unified_planning/test/test_problem.py | 13 +++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/unified_planning/model/problem.py b/unified_planning/model/problem.py index 1205a4aa1..592ebb0fc 100644 --- a/unified_planning/model/problem.py +++ b/unified_planning/model/problem.py @@ -1030,10 +1030,6 @@ def update_problem_kind_action( if len(action.simulated_effects) > 0: self.kind.set_simulated_entities("SIMULATED_EFFECTS") self.kind.set_time("CONTINUOUS_TIME") - elif isinstance(action, up.model.natural_transition.Process): - pass # TODO add Process kind - elif isinstance(action, up.model.natural_transition.Event): - pass # TODO add Event kind else: raise NotImplementedError diff --git a/unified_planning/test/examples/processes.py b/unified_planning/test/examples/processes.py index 70e95fbf4..f4faec940 100644 --- a/unified_planning/test/examples/processes.py +++ b/unified_planning/test/examples/processes.py @@ -17,10 +17,16 @@ def get_example_problems(): evt.add_precondition(GE(d, 200)) evt.add_effect(on, False) + evt.clear_effects() + evt.add_effect(on, False) + b = Process("moving") b.add_precondition(on) b.add_derivative(d, 1) + b.clear_effects() + b.add_derivative(d, 1) + problem = Problem("1d_Movement") problem.add_fluent(on) problem.add_fluent(d) diff --git a/unified_planning/test/test_problem.py b/unified_planning/test/test_problem.py index 2189f311c..b59cf1bfb 100644 --- a/unified_planning/test/test_problem.py +++ b/unified_planning/test/test_problem.py @@ -606,6 +606,19 @@ def test_undefined_initial_state(self): pb_name, ) + def test_natural_transitions(self): + p = self.problems["1d_movement"].problem + print(p) + self.assertTrue(p.has_process("moving")) + self.assertTrue(p.has_event("turn_off_automatically")) + proc = p.process("moving") + evt = p.event("turn_off_automatically") + print(proc) + print(evt) + p.clear_events() + p.clear_processes() + self.assertEqual(len(p.natural_transitions), 0) + if __name__ == "__main__": main()