From 458a5fbbfdfe546ce87c84b39117c72f65a95175 Mon Sep 17 00:00:00 2001 From: Arthur Bit-Monnot Date: Tue, 16 Jan 2024 15:17:48 +0100 Subject: [PATCH 1/4] fix: only write explicit initial values in protobuf --- unified_planning/grpc/proto_writer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified_planning/grpc/proto_writer.py b/unified_planning/grpc/proto_writer.py index c64294e07..49f7479ef 100644 --- a/unified_planning/grpc/proto_writer.py +++ b/unified_planning/grpc/proto_writer.py @@ -603,7 +603,7 @@ def _convert_problem(self, problem: model.Problem) -> proto.Problem: actions=[self.convert(a) for a in problem.actions], initial_state=[ proto.Assignment(fluent=self.convert(x), value=self.convert(v)) - for (x, v) in problem.initial_values.items() + for (x, v) in problem.explicit_initial_values.items() ], timed_effects=timed_effects, goals=goals, From 33dbb77d77e19f138183b66b22b89e571709189c Mon Sep 17 00:00:00 2001 From: Arthur Bit-Monnot Date: Tue, 16 Jan 2024 22:43:02 +0100 Subject: [PATCH 2/4] test: add test case with important default values --- unified_planning/test/examples/minimals.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/unified_planning/test/examples/minimals.py b/unified_planning/test/examples/minimals.py index a18f921a9..ec0722c82 100644 --- a/unified_planning/test/examples/minimals.py +++ b/unified_planning/test/examples/minimals.py @@ -363,6 +363,31 @@ def get_example_problems(): ) problems["basic_with_costs"] = basic_with_costs + # basic with defaults + problem = Problem("basic_with_default_values") + object = UserType("object") + objects = [problem.add_object(f"o{i}", object) for i in range(0, 5)] + available = Fluent("available", BoolType(), a=object) + + on = Fluent("on", object, a=object) + problem.add_fluent(available, default_initial_value=True) + problem.add_fluent(on, default_initial_value=objects[0]) + goal = problem.add_fluent("g", default_initial_value=False) + for i in [0, 1, 3, 4]: # override default for all but objects[2] + problem.set_initial_value(on(objects[i]), objects[4]) + act_a = InstantaneousAction("a", obj=object) + act_a.add_precondition(available(objects[0])) + act_a.add_precondition(Equals(on(act_a.obj), objects[0])) + act_a.add_effect(goal, True) + problem.add_action(act_a) + problem.add_goal(goal) + + problems["basic_with_default_values"] = TestCase( + problem=problem, + solvable=True, + valid_plans=[up.plans.SequentialPlan([act_a(objects[2])])], + ) + # counter counter_1 = Fluent("counter_1", IntType(0, 10)) counter_2 = Fluent("counter_2", IntType(0, 10)) From ce5107f5434cf2bad2a266d7a3d0d5c04434f059 Mon Sep 17 00:00:00 2001 From: Arthur Bit-Monnot Date: Thu, 25 Jan 2024 15:44:18 +0100 Subject: [PATCH 3/4] deps: bump up-aries requirement for correct default vaue handling --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 79290967c..109651dda 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ "fast-downward": ["up-fast-downward==0.4.1"], "lpg": ["up-lpg==0.0.10"], "fmap": ["up-fmap==0.0.13"], - "aries": ["up-aries>=0.3.2"], + "aries": ["up-aries>=0.3.3"], "symk": ["up-symk>=1.0.1"], "engines": [ "tarski[arithmetic]", From 51950aec45e7124639589eb7f812345f02574777 Mon Sep 17 00:00:00 2001 From: Arthur Bit-Monnot Date: Thu, 25 Jan 2024 20:43:24 +0100 Subject: [PATCH 4/4] doc: update comments regarding initial state in .proto defintions --- unified_planning/grpc/unified_planning.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unified_planning/grpc/unified_planning.proto b/unified_planning/grpc/unified_planning.proto index 99085ebb2..4d887ccfd 100644 --- a/unified_planning/grpc/unified_planning.proto +++ b/unified_planning/grpc/unified_planning.proto @@ -116,7 +116,6 @@ message Fluent { // If non-empty, then any state variable using this fluent that is not explicitly given a value in the initial state // will be assumed to have this default value. // This allows mimicking the closed world assumption by setting a "false" default value to predicates. - // Note that in the initial state of the problem message, it is assumed that all default values are set. Expression default_value = 4; } @@ -539,7 +538,8 @@ message Problem { // features: ACTION_BASED repeated Action actions = 6; - // Initial state, including default values of state variables. + // Explicit assignments to state variables in the initial state. + // State variables not assigned there and will take the default value of their fluent, if any. repeated Assignment initial_state = 7; // Facts and effects that are expected to occur strictly later than the initial state.