From 974e3bf9956a54df0b1e77aa5bccfb3e646b8f70 Mon Sep 17 00:00:00 2001 From: Enrico Scala Date: Sun, 6 Oct 2024 19:12:42 +0200 Subject: [PATCH] Done a pass with black --- docs/notebooks/01-basic-example.ipynb | 58 ++-- docs/notebooks/01-numeric-planning.ipynb | 56 ++-- docs/notebooks/02-optimal-planning.ipynb | 8 +- docs/notebooks/03-temporal-planning.ipynb | 55 ++-- docs/notebooks/04-simulated-effects.ipynb | 28 +- docs/notebooks/05-compilers.ipynb | 160 +++++----- .../06-oversubscription-with-metaengine.ipynb | 36 ++- docs/notebooks/07-hierarchical-planning.ipynb | 36 ++- docs/notebooks/08-sequential-simulator.ipynb | 259 +++++++++------- .../09-multiagent-planning-simple.ipynb | 28 +- docs/notebooks/10-multiagent-planning.ipynb | 30 +- docs/notebooks/11-plot.ipynb | 102 +++--- .../12-plan-parsing-conversion.ipynb | 40 ++- .../14-task-and-motion-planning.ipynb | 39 +-- docs/notebooks/io/01-pddl-usage-example.ipynb | 42 ++- .../io/02-mapddl-writer-example.ipynb | 30 +- docs/notebooks/tutorial/modeling.ipynb | 81 +++-- .../tutorial/planner-integration.ipynb | 106 ++++--- .../compilers/bounded_types_remover.py | 1 - .../grpc/generated/unified_planning_pb2.py | 292 +++++++++--------- .../generated/unified_planning_pb2_grpc.py | 237 ++++++++------ unified_planning/io/anml_grammar.py | 1 - unified_planning/model/action.py | 15 +- unified_planning/model/effect.py | 3 +- .../model/htn/hierarchical_problem.py | 3 +- unified_planning/model/mixins/metrics.py | 3 +- .../model/multi_agent/ma_environment.py | 3 +- unified_planning/model/problem.py | 11 +- unified_planning/model/timing.py | 3 +- unified_planning/model/walkers/generic.py | 1 + .../model/walkers/type_checker.py | 2 +- unified_planning/plans/time_triggered_plan.py | 1 - unified_planning/plot/plan_plot.py | 2 - unified_planning/test/__init__.py | 2 - unified_planning/test/test_model.py | 29 +- unified_planning/test/test_pddl_io.py | 1 - unified_planning/test/test_planner.py | 1 - unified_planning/test/test_problem.py | 1 - .../test/test_sequential_simulator.py | 1 - unified_planning/test/test_ttp_to_stn.py | 2 - up_test_cases/builtin/multiagent/depot.py | 1 - .../builtin/multiagent/procter_and_gamble.py | 1 - .../builtin/numeric/block_grouping.py | 1 - .../builtin/processes/constant_derivative.py | 12 +- .../builtin/tamp/construction/test_01.py | 1 - .../builtin/tamp/construction/test_02.py | 1 - .../builtin/tamp/construction/test_03.py | 1 - up_test_cases/builtin/tamp/office/test_01.py | 1 - up_test_cases/builtin/tamp/office/test_02.py | 1 - up_test_cases/builtin/tamp/office/test_03.py | 1 - .../performance/numeric/block_grouping.py | 1 - up_test_cases/report.py | 4 - up_test_cases/utils.py | 1 - 53 files changed, 1019 insertions(+), 817 deletions(-) diff --git a/docs/notebooks/01-basic-example.ipynb b/docs/notebooks/01-basic-example.ipynb index 6d7e1309d..219c76b5f 100644 --- a/docs/notebooks/01-basic-example.ipynb +++ b/docs/notebooks/01-basic-example.ipynb @@ -111,7 +111,7 @@ }, "outputs": [], "source": [ - "Location = UserType('Location')" + "Location = UserType(\"Location\")" ] }, { @@ -137,8 +137,10 @@ }, "outputs": [], "source": [ - "robot_at = unified_planning.model.Fluent('robot_at', BoolType(), l=Location)\n", - "connected = unified_planning.model.Fluent('connected', BoolType(), l_from=Location, l_to=Location)" + "robot_at = unified_planning.model.Fluent(\"robot_at\", BoolType(), l=Location)\n", + "connected = unified_planning.model.Fluent(\n", + " \"connected\", BoolType(), l_from=Location, l_to=Location\n", + ")" ] }, { @@ -185,9 +187,11 @@ } ], "source": [ - "move = unified_planning.model.InstantaneousAction('move', l_from=Location, l_to=Location)\n", - "l_from = move.parameter('l_from')\n", - "l_to = move.parameter('l_to')\n", + "move = unified_planning.model.InstantaneousAction(\n", + " \"move\", l_from=Location, l_to=Location\n", + ")\n", + "l_from = move.parameter(\"l_from\")\n", + "l_to = move.parameter(\"l_to\")\n", "move.add_precondition(connected(l_from, l_to))\n", "move.add_precondition(robot_at(l_from))\n", "move.add_effect(robot_at(l_from), False)\n", @@ -214,7 +218,7 @@ }, "outputs": [], "source": [ - "problem = unified_planning.model.Problem('robot')\n", + "problem = unified_planning.model.Problem(\"robot\")\n", "problem.add_fluent(robot_at, default_initial_value=False)\n", "problem.add_fluent(connected, default_initial_value=False)\n", "problem.add_action(move)" @@ -238,7 +242,7 @@ "outputs": [], "source": [ "NLOC = 10\n", - "locations = [unified_planning.model.Object('l%s' % i, Location) for i in range(NLOC)]\n", + "locations = [unified_planning.model.Object(\"l%s\" % i, Location) for i in range(NLOC)]\n", "problem.add_objects(locations)" ] }, @@ -263,7 +267,7 @@ "source": [ "problem.set_initial_value(robot_at(locations[0]), True)\n", "for i in range(NLOC - 1):\n", - " problem.set_initial_value(connected(locations[i], locations[i+1]), True)" + " problem.set_initial_value(connected(locations[i], locations[i + 1]), True)" ] }, { @@ -386,7 +390,7 @@ } ], "source": [ - "with OneshotPlanner(name='pyperplan') as planner:\n", + "with OneshotPlanner(name=\"pyperplan\") as planner:\n", " result = planner.solve(problem)\n", " if result.status == up.engines.PlanGenerationResultStatus.SOLVED_SATISFICING:\n", " print(\"Pyperplan returned: %s\" % result.plan)\n", @@ -511,9 +515,9 @@ "plan = result.plan\n", "with PlanValidator(problem_kind=problem.kind, plan_kind=plan.kind) as validator:\n", " if validator.validate(problem, plan):\n", - " print('The plan is valid')\n", + " print(\"The plan is valid\")\n", " else:\n", - " print('The plan is invalid')" + " print(\"The plan is invalid\")" ] }, { @@ -693,7 +697,9 @@ } ], "source": [ - "with Compiler(problem_kind=problem.kind, compilation_kind=CompilationKind.GROUNDING) as grounder:\n", + "with Compiler(\n", + " problem_kind=problem.kind, compilation_kind=CompilationKind.GROUNDING\n", + ") as grounder:\n", " grounding_result = grounder.compile(problem, CompilationKind.GROUNDING)\n", " ground_problem = grounding_result.problem\n", " print(ground_problem)\n", @@ -701,12 +707,16 @@ " # The grounding_result can be used to \"lift\" a ground plan back to the level of the original problem\n", " with OneshotPlanner(problem_kind=ground_problem.kind) as planner:\n", " ground_plan = planner.solve(ground_problem).plan\n", - " print('Ground plan: %s' % ground_plan)\n", + " print(\"Ground plan: %s\" % ground_plan)\n", " # Replace the action instances of the grounded plan with their correspoding lifted version\n", - " lifted_plan = ground_plan.replace_action_instances(grounding_result.map_back_action_instance)\n", - " print('Lifted plan: %s' % lifted_plan)\n", + " lifted_plan = ground_plan.replace_action_instances(\n", + " grounding_result.map_back_action_instance\n", + " )\n", + " print(\"Lifted plan: %s\" % lifted_plan)\n", " # Test the problem and plan validity\n", - " with PlanValidator(problem_kind=problem.kind, plan_kind=ground_plan.kind) as validator:\n", + " with PlanValidator(\n", + " problem_kind=problem.kind, plan_kind=ground_plan.kind\n", + " ) as validator:\n", " ground_validation = validator.validate(ground_problem, ground_plan)\n", " lift_validation = validator.validate(problem, lifted_plan)\n", " Valid = up.engines.ValidationResultStatus.VALID\n", @@ -771,8 +781,10 @@ } ], "source": [ - "with OneshotPlanner(names=['tamer', 'tamer', 'pyperplan'],\n", - " params=[{'heuristic': 'hadd'}, {'heuristic': 'hmax'}, {}]) as planner:\n", + "with OneshotPlanner(\n", + " names=[\"tamer\", \"tamer\", \"pyperplan\"],\n", + " params=[{\"heuristic\": \"hadd\"}, {\"heuristic\": \"hmax\"}, {}],\n", + ") as planner:\n", " plan = planner.solve(problem).plan\n", " print(\"%s returned: %s\" % (planner.name, plan))" ] @@ -810,18 +822,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", diff --git a/docs/notebooks/01-numeric-planning.ipynb b/docs/notebooks/01-numeric-planning.ipynb index 80e052b63..5378d820e 100644 --- a/docs/notebooks/01-numeric-planning.ipynb +++ b/docs/notebooks/01-numeric-planning.ipynb @@ -114,9 +114,9 @@ }, "outputs": [], "source": [ - "Counter = UserType('Counter')\n", + "Counter = UserType(\"Counter\")\n", "\n", - "value = Fluent('value', IntType(), m=Counter)" + "value = Fluent(\"value\", IntType(), m=Counter)" ] }, { @@ -136,15 +136,15 @@ }, "outputs": [], "source": [ - "inc = InstantaneousAction('increment',c=Counter)\n", - "c = inc.parameter('c')\n", + "inc = InstantaneousAction(\"increment\", c=Counter)\n", + "c = inc.parameter(\"c\")\n", "inc.add_precondition(LE(value(c), 10))\n", "inc.add_increase_effect(value(c), 1)\n", "\n", - "dec = InstantaneousAction('decrement',c=Counter)\n", - "c = dec.parameter('c')\n", + "dec = InstantaneousAction(\"decrement\", c=Counter)\n", + "c = dec.parameter(\"c\")\n", "dec.add_precondition(GT(value(c), 0))\n", - "dec.add_decrease_effect(value(c),1)\n" + "dec.add_decrease_effect(value(c), 1)" ] }, { @@ -219,19 +219,21 @@ } ], "source": [ - "problem = Problem('problem')\n", + "problem = Problem(\"problem\")\n", "\n", "problem.add_fluent(value, default_initial_value=0)\n", - "C0 = Object('c0', Counter)\n", - "C1 = Object('c1', Counter)\n", - "C2 = Object('c2', Counter)\n", + "C0 = Object(\"c0\", Counter)\n", + "C1 = Object(\"c1\", Counter)\n", + "C2 = Object(\"c2\", Counter)\n", "problem.add_object(C0)\n", "problem.add_object(C1)\n", "problem.add_object(C2)\n", "problem.add_action(inc)\n", "problem.add_action(dec)\n", - "problem.add_goal(And( GE(value(C2),Plus(value(C1),1)), GE(value(C1),Plus(value(C0),1))))\n", - "problem\n" + "problem.add_goal(\n", + " And(GE(value(C2), Plus(value(C1), 1)), GE(value(C1), Plus(value(C0), 1)))\n", + ")\n", + "problem" ] }, { @@ -315,17 +317,17 @@ } ], "source": [ - "N = 9 # This is the number of counters\n", + "N = 9 # This is the number of counters\n", "\n", - "p2 = Problem('Large_problems')\n", + "p2 = Problem(\"Large_problems\")\n", "\n", "p2.add_fluent(value, default_initial_value=0)\n", - "p2.add_objects([Object(f'c{i}',Counter) for i in range(N)])\n", + "p2.add_objects([Object(f\"c{i}\", Counter) for i in range(N)])\n", "p2.add_action(inc)\n", "p2.add_action(dec)\n", "\n", - "for i in range(N-1):\n", - " p2.add_goal(GE(value(p2.object(f'c{i+1}')),Plus(value(p2.object(f'c{i}')),1)))\n", + "for i in range(N - 1):\n", + " p2.add_goal(GE(value(p2.object(f\"c{i+1}\")), Plus(value(p2.object(f\"c{i}\")), 1)))\n", "\n", "p2" ] @@ -372,7 +374,7 @@ } ], "source": [ - "with OneshotPlanner(name='enhsp') as planner:\n", + "with OneshotPlanner(name=\"enhsp\") as planner:\n", " result = planner.solve(problem)\n", " plan = result.plan\n", " if plan is not None:\n", @@ -514,28 +516,30 @@ "source": [ "from unified_planning.model.metrics import MinimizeSequentialPlanLength\n", "\n", - "N = 7 #This is the number of counters\n", + "N = 7 # This is the number of counters\n", "\n", - "mediumSizeProblem = Problem('Medium_sized_problem')\n", + "mediumSizeProblem = Problem(\"Medium_sized_problem\")\n", "\n", "mediumSizeProblem.add_fluent(value, default_initial_value=0)\n", - "mediumSizeProblem.add_objects([Object(f'c{i}',Counter) for i in range(N)])\n", + "mediumSizeProblem.add_objects([Object(f\"c{i}\", Counter) for i in range(N)])\n", "mediumSizeProblem.add_action(inc)\n", "mediumSizeProblem.add_action(dec)\n", "metric = MinimizeSequentialPlanLength()\n", "mediumSizeProblem.add_quality_metric(metric)\n", "\n", - "for i in range(N-1):\n", - " mediumSizeProblem.add_goal(GE(value(p2.object(f'c{i+1}')),Plus(value(p2.object(f'c{i}')),1)))\n", + "for i in range(N - 1):\n", + " mediumSizeProblem.add_goal(\n", + " GE(value(p2.object(f\"c{i+1}\")), Plus(value(p2.object(f\"c{i}\")), 1))\n", + " )\n", "\n", - "with OneshotPlanner(problem_kind=problem.kind,optimality_guarantee=True) as planner:\n", + "with OneshotPlanner(problem_kind=problem.kind, optimality_guarantee=True) as planner:\n", " result = planner.solve(mediumSizeProblem)\n", " plan = result.plan\n", " if plan is not None:\n", " print(\"%s returned:\" % planner.name)\n", " print(plan)\n", " else:\n", - " print(\"No plan found.\")\n" + " print(\"No plan found.\")" ] } ], diff --git a/docs/notebooks/02-optimal-planning.ipynb b/docs/notebooks/02-optimal-planning.ipynb index 3a79c5320..53f15aa46 100644 --- a/docs/notebooks/02-optimal-planning.ipynb +++ b/docs/notebooks/02-optimal-planning.ipynb @@ -163,9 +163,7 @@ "metadata": {}, "outputs": [], "source": [ - "problem.add_quality_metric(\n", - " up.model.metrics.MinimizeActionCosts({a: 10, b: 1, c: 1})\n", - ")" + "problem.add_quality_metric(up.model.metrics.MinimizeActionCosts({a: 10, b: 1, c: 1}))" ] }, { @@ -328,9 +326,7 @@ }, "outputs": [], "source": [ - "expected_plan = up.plans.SequentialPlan(\n", - " [up.plans.ActionInstance(a)]\n", - ")\n", + "expected_plan = up.plans.SequentialPlan([up.plans.ActionInstance(a)])\n", "assert final_report.status == PlanGenerationResultStatus.SOLVED_OPTIMALLY\n", "assert plan == expected_plan" ] diff --git a/docs/notebooks/03-temporal-planning.ipynb b/docs/notebooks/03-temporal-planning.ipynb index 0ab6a9751..50a8a2a87 100644 --- a/docs/notebooks/03-temporal-planning.ipynb +++ b/docs/notebooks/03-temporal-planning.ipynb @@ -128,13 +128,13 @@ }, "outputs": [], "source": [ - "Match = UserType('Match')\n", - "Fuse = UserType('Fuse')\n", + "Match = UserType(\"Match\")\n", + "Fuse = UserType(\"Fuse\")\n", "\n", - "handfree = Fluent('handfree')\n", - "light = Fluent('light')\n", - "match_used = Fluent('match_used', BoolType(), m=Match)\n", - "fuse_mended = Fluent('fuse_mended', BoolType(), f=Fuse)" + "handfree = Fluent(\"handfree\")\n", + "light = Fluent(\"light\")\n", + "match_used = Fluent(\"match_used\", BoolType(), m=Match)\n", + "fuse_mended = Fluent(\"fuse_mended\", BoolType(), f=Fuse)" ] }, { @@ -154,7 +154,7 @@ }, "outputs": [], "source": [ - "problem = Problem('MatchCellar')\n", + "problem = Problem(\"MatchCellar\")\n", "\n", "problem.add_fluent(handfree)\n", "problem.add_fluent(light)\n", @@ -182,8 +182,8 @@ }, "outputs": [], "source": [ - "fuses = [Object(f'f{i}', Fuse) for i in range(3)]\n", - "matches = [Object(f'm{i}', Match) for i in range(3)]\n", + "fuses = [Object(f\"f{i}\", Fuse) for i in range(3)]\n", + "matches = [Object(f\"m{i}\", Match) for i in range(3)]\n", "\n", "problem.add_objects(fuses)\n", "problem.add_objects(matches)" @@ -235,8 +235,8 @@ } ], "source": [ - "light_match = DurativeAction('light_match', m=Match)\n", - "m = light_match.parameter('m')\n", + "light_match = DurativeAction(\"light_match\", m=Match)\n", + "m = light_match.parameter(\"m\")\n", "light_match.set_fixed_duration(6)\n", "light_match.add_condition(StartTiming(), Not(match_used(m)))\n", "light_match.add_effect(StartTiming(), match_used(m), True)\n", @@ -288,8 +288,8 @@ } ], "source": [ - "mend_fuse = DurativeAction('mend_fuse', f=Fuse)\n", - "f = mend_fuse.parameter('f')\n", + "mend_fuse = DurativeAction(\"mend_fuse\", f=Fuse)\n", + "f = mend_fuse.parameter(\"f\")\n", "mend_fuse.set_fixed_duration(5)\n", "mend_fuse.add_condition(StartTiming(), handfree)\n", "mend_fuse.add_condition(ClosedTimeInterval(StartTiming(), EndTiming()), light)\n", @@ -397,7 +397,7 @@ ], "source": [ "for f in fuses:\n", - " problem.add_timed_goal(EndTiming(), fuse_mended(f))\n", + " problem.add_timed_goal(EndTiming(), fuse_mended(f))\n", "\n", "print(problem)" ] @@ -424,15 +424,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001B[96m\u001B[1mNOTE: To disable printing of planning engine credits, add this line to your code: `up.shortcuts.get_environment().credits_stream = None`\n", - "\u001B[0m\u001B[96m *** Credits ***\n", - "\u001B[0m\u001B[96m * In operation mode `OneshotPlanner` at line 1 of `/tmp/ipykernel_153164/3087807287.py`, \u001B[0m\u001B[96myou are using the following planning engine:\n", - "\u001B[0m\u001B[96m * Engine name: Tamer\n", + "\u001b[96m\u001b[1mNOTE: To disable printing of planning engine credits, add this line to your code: `up.shortcuts.get_environment().credits_stream = None`\n", + "\u001b[0m\u001b[96m *** Credits ***\n", + "\u001b[0m\u001b[96m * In operation mode `OneshotPlanner` at line 1 of `/tmp/ipykernel_153164/3087807287.py`, \u001b[0m\u001b[96myou are using the following planning engine:\n", + "\u001b[0m\u001b[96m * Engine name: Tamer\n", " * Developers: FBK Tamer Development Team\n", - "\u001B[0m\u001B[96m * Description: \u001B[0m\u001B[96mTamer offers the capability to generate a plan for classical, numerical and temporal problems.\n", - " * For those kind of problems tamer also offers the possibility of validating a submitted plan.\u001B[0m\u001B[96m\n", - "\u001B[0m\u001B[96m\n", - "\u001B[0mTamer returned:\n", + "\u001b[0m\u001b[96m * Description: \u001b[0m\u001b[96mTamer offers the capability to generate a plan for classical, numerical and temporal problems.\n", + " * For those kind of problems tamer also offers the possibility of validating a submitted plan.\u001b[0m\u001b[96m\n", + "\u001b[0m\u001b[96m\n", + "\u001b[0mTamer returned:\n", "0.0: light_match(m1) [6.0]\n", "0.01: mend_fuse(f1) [5.0]\n", "6.01: light_match(m2) [6.0]\n", @@ -460,8 +460,7 @@ "metadata": {}, "outputs": [], "source": [ - "from unified_planning.plot import plot_plan\n", - "\n" + "from unified_planning.plot import plot_plan" ] }, { @@ -486,18 +485,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", diff --git a/docs/notebooks/04-simulated-effects.ipynb b/docs/notebooks/04-simulated-effects.ipynb index 06fedbf7d..5ad6e7a95 100644 --- a/docs/notebooks/04-simulated-effects.ipynb +++ b/docs/notebooks/04-simulated-effects.ipynb @@ -110,11 +110,11 @@ }, "outputs": [], "source": [ - "Location = UserType('Location')\n", - "Robot = UserType('Robot')\n", + "Location = UserType(\"Location\")\n", + "Robot = UserType(\"Robot\")\n", "\n", - "at = Fluent('at', Location, robot=Robot)\n", - "battery_charge = Fluent('battery_charge', IntType(0, 100), robot=Robot)" + "at = Fluent(\"at\", Location, robot=Robot)\n", + "battery_charge = Fluent(\"battery_charge\", IntType(0, 100), robot=Robot)" ] }, { @@ -137,17 +137,21 @@ }, "outputs": [], "source": [ - "move = InstantaneousAction('move', robot=Robot, l_from=Location, l_to=Location)\n", - "robot = move.parameter('robot')\n", - "l_from = move.parameter('l_from')\n", - "l_to = move.parameter('l_to')\n", + "move = InstantaneousAction(\"move\", robot=Robot, l_from=Location, l_to=Location)\n", + "robot = move.parameter(\"robot\")\n", + "l_from = move.parameter(\"l_from\")\n", + "l_to = move.parameter(\"l_to\")\n", "move.add_precondition(Equals(at(robot), l_from))\n", "move.add_precondition(GE(battery_charge(robot), 10))\n", "move.add_precondition(Not(Equals(l_from, l_to)))\n", "move.add_effect(at(robot), l_to)\n", + "\n", + "\n", "def fun(problem, state, actual_params):\n", " value = state.get_value(battery_charge(actual_params.get(robot))).constant_value()\n", " return [Int(value - 10)]\n", + "\n", + "\n", "move.set_simulated_effect(SimulatedEffect([battery_charge(robot)], fun))" ] }, @@ -168,11 +172,11 @@ }, "outputs": [], "source": [ - "l1 = Object('l1', Location)\n", - "l2 = Object('l2', Location)\n", - "r1 = Object('r1', Robot)\n", + "l1 = Object(\"l1\", Location)\n", + "l2 = Object(\"l2\", Location)\n", + "r1 = Object(\"r1\", Robot)\n", "\n", - "problem = Problem('robot_with_simulated_effects')\n", + "problem = Problem(\"robot_with_simulated_effects\")\n", "problem.add_fluent(at)\n", "problem.add_fluent(battery_charge)\n", "problem.add_action(move)\n", diff --git a/docs/notebooks/05-compilers.ipynb b/docs/notebooks/05-compilers.ipynb index e268876cb..84e60a2e3 100644 --- a/docs/notebooks/05-compilers.ipynb +++ b/docs/notebooks/05-compilers.ipynb @@ -65,39 +65,43 @@ "Work = UserType(\"Work\", Job)\n", "\n", "# Define fluents\n", - "is_cold = Fluent(\"is_cold\", BoolType()) # BoolType is the default, so it can be avoided\n", + "is_cold = Fluent(\"is_cold\", BoolType()) # BoolType is the default, so it can be avoided\n", "is_warm = Fluent(\"is_warm\")\n", "electrical_failure = Fluent(\"electrical_failure\")\n", - "job_done = Fluent(\"job_done\", BoolType(), job = Job)\n", - "is_on = Fluent(\"is_on\", BoolType(), heater = Heater)\n", - "used_heater = Fluent(\"used_heater\", BoolType(), heater = Heater)\n", + "job_done = Fluent(\"job_done\", BoolType(), job=Job)\n", + "is_on = Fluent(\"is_on\", BoolType(), heater=Heater)\n", + "used_heater = Fluent(\"used_heater\", BoolType(), heater=Heater)\n", "\n", "# Define actions\n", - "switch_heater_on = InstantaneousAction(\"switch_heater_on\", heater = Heater)\n", + "switch_heater_on = InstantaneousAction(\"switch_heater_on\", heater=Heater)\n", "heater = switch_heater_on.parameter(\"heater\")\n", - "switch_heater_on.add_precondition(Not(used_heater(heater))) # The heater must not have been already used \n", - "switch_heater_on.add_precondition(Not(is_on(heater))) # The heater must not be already on\n", - "switch_heater_on.add_effect(is_warm, True) # The temperature becomes warm\n", - "switch_heater_on.add_effect(is_on(heater), True) # The heater switches on\n", + "switch_heater_on.add_precondition(\n", + " Not(used_heater(heater))\n", + ") # The heater must not have been already used\n", + "switch_heater_on.add_precondition(\n", + " Not(is_on(heater))\n", + ") # The heater must not be already on\n", + "switch_heater_on.add_effect(is_warm, True) # The temperature becomes warm\n", + "switch_heater_on.add_effect(is_on(heater), True) # The heater switches on\n", "# Define a Variable of type \"Heater\", used for the existential condition\n", "h_var = Variable(\"h_var\", Heater)\n", "# If exists an heater that is already on, we have an electrical failure\n", - "switch_heater_on.add_effect(electrical_failure, True, Exists(is_on(h_var), h_var)) \n", + "switch_heater_on.add_effect(electrical_failure, True, Exists(is_on(h_var), h_var))\n", "\n", - "switch_heater_off = InstantaneousAction(\"switch_heater_off\", heater = Heater)\n", + "switch_heater_off = InstantaneousAction(\"switch_heater_off\", heater=Heater)\n", "heater = switch_heater_off.parameter(\"heater\")\n", - "switch_heater_off.add_precondition(is_on(heater)) # The heater must be on\n", - "switch_heater_off.add_effect(is_warm, False) # It is not warm anymore\n", - "switch_heater_off.add_effect(is_cold, True) # It becomes cold\n", - "switch_heater_off.add_effect(is_on(heater), False) # The heater turns off\n", - "switch_heater_off.add_effect(used_heater(heater), True) # The heater becomes used\n", + "switch_heater_off.add_precondition(is_on(heater)) # The heater must be on\n", + "switch_heater_off.add_effect(is_warm, False) # It is not warm anymore\n", + "switch_heater_off.add_effect(is_cold, True) # It becomes cold\n", + "switch_heater_off.add_effect(is_on(heater), False) # The heater turns off\n", + "switch_heater_off.add_effect(used_heater(heater), True) # The heater becomes used\n", "\n", - "perform_job = InstantaneousAction(\"perform_job\", job = Job)\n", + "perform_job = InstantaneousAction(\"perform_job\", job=Job)\n", "job = perform_job.parameter(\"job\")\n", - "perform_job.add_precondition(is_warm) # Must be warm to do the job\n", - "perform_job.add_effect(is_warm, False) # It is not warm anymore\n", - "perform_job.add_effect(is_cold, True) # It becomes cold again\n", - "perform_job.add_effect(job_done(job), True) # The job is done\n", + "perform_job.add_precondition(is_warm) # Must be warm to do the job\n", + "perform_job.add_effect(is_warm, False) # It is not warm anymore\n", + "perform_job.add_effect(is_cold, True) # It becomes cold again\n", + "perform_job.add_effect(job_done(job), True) # The job is done\n", "\n", "# define objects\n", "heater_1 = Object(\"heater_1\", Heater)\n", @@ -109,21 +113,23 @@ "# define the problem\n", "original_problem = Problem(\"heaters_and_jobs\")\n", "# add the fluents to the problem\n", - "original_problem.add_fluent(is_cold, default_initial_value = True)\n", - "original_problem.add_fluent(is_warm, default_initial_value = False)\n", - "original_problem.add_fluent(electrical_failure, default_initial_value = False)\n", - "original_problem.add_fluent(job_done, default_initial_value = False)\n", - "original_problem.add_fluent(is_on, default_initial_value = False)\n", - "original_problem.add_fluent(used_heater, default_initial_value = False)\n", + "original_problem.add_fluent(is_cold, default_initial_value=True)\n", + "original_problem.add_fluent(is_warm, default_initial_value=False)\n", + "original_problem.add_fluent(electrical_failure, default_initial_value=False)\n", + "original_problem.add_fluent(job_done, default_initial_value=False)\n", + "original_problem.add_fluent(is_on, default_initial_value=False)\n", + "original_problem.add_fluent(used_heater, default_initial_value=False)\n", "# add objects and actions\n", "original_problem.add_objects([heater_1, heater_2, clean, work])\n", "original_problem.add_actions([switch_heater_on, switch_heater_off, perform_job])\n", "\n", "# define the problem goals\n", - "original_problem.add_goal(Not(electrical_failure)) # No electrical failure\n", - "j_var = Variable(\"j_var\", Job) \n", - "original_problem.add_goal(Forall(job_done(j_var), j_var)) # All jobs are done\n", - "original_problem.add_goal(Forall(Not(is_on(h_var)), h_var)) # All heaters are switched off\n", + "original_problem.add_goal(Not(electrical_failure)) # No electrical failure\n", + "j_var = Variable(\"j_var\", Job)\n", + "original_problem.add_goal(Forall(job_done(j_var), j_var)) # All jobs are done\n", + "original_problem.add_goal(\n", + " Forall(Not(is_on(h_var)), h_var)\n", + ") # All heaters are switched off\n", "\n", "original_problem_kind = original_problem.kind" ] @@ -164,7 +170,7 @@ } ], "source": [ - "with OneshotPlanner(name = \"pyperplan\") as planner:\n", + "with OneshotPlanner(name=\"pyperplan\") as planner:\n", " assert not planner.supports(original_problem_kind)" ] }, @@ -201,26 +207,31 @@ "outputs": [], "source": [ "from unified_planning.engines import CompilationKind\n", + "\n", "# The CompilationKind class is defined in the unified_planning/engines/mixins/compiler.py file\n", "\n", "# To get the Compiler from the factory we can use the Compiler operation mode.\n", "# It takes a problem_kind and a compilation_kind, and returns a compiler with the capabilities we need\n", "with Compiler(\n", - " problem_kind = original_problem_kind, \n", - " compilation_kind = CompilationKind.QUANTIFIERS_REMOVING\n", - " ) as quantifiers_remover:\n", + " problem_kind=original_problem_kind,\n", + " compilation_kind=CompilationKind.QUANTIFIERS_REMOVING,\n", + ") as quantifiers_remover:\n", " # After we have the compiler, we get the compilation result\n", " qr_result = quantifiers_remover.compile(\n", - " original_problem, \n", - " CompilationKind.QUANTIFIERS_REMOVING\n", + " original_problem, CompilationKind.QUANTIFIERS_REMOVING\n", " )\n", " qr_problem = qr_result.problem\n", " qr_kind = qr_problem.kind\n", - " \n", + "\n", " # Check the result of the compilation\n", - " assert original_problem_kind.has_existential_conditions() and original_problem_kind.has_universal_conditions()\n", - " assert not qr_kind.has_existential_conditions() and not qr_kind.has_universal_conditions()\n", - " " + " assert (\n", + " original_problem_kind.has_existential_conditions()\n", + " and original_problem_kind.has_universal_conditions()\n", + " )\n", + " assert (\n", + " not qr_kind.has_existential_conditions()\n", + " and not qr_kind.has_universal_conditions()\n", + " )" ] }, { @@ -261,17 +272,15 @@ "source": [ "# Get the compiler from the factory\n", "with Compiler(\n", - " problem_kind = qr_kind, \n", - " compilation_kind = CompilationKind.CONDITIONAL_EFFECTS_REMOVING\n", - " ) as conditional_effects_remover:\n", + " problem_kind=qr_kind, compilation_kind=CompilationKind.CONDITIONAL_EFFECTS_REMOVING\n", + ") as conditional_effects_remover:\n", " # After we have the compiler, we get the compilation result\n", " cer_result = conditional_effects_remover.compile(\n", - " qr_problem, \n", - " CompilationKind.CONDITIONAL_EFFECTS_REMOVING\n", + " qr_problem, CompilationKind.CONDITIONAL_EFFECTS_REMOVING\n", " )\n", " cer_problem = cer_result.problem\n", " cer_kind = cer_problem.kind\n", - " \n", + "\n", " # Check the result of the compilation\n", " assert original_problem_kind.has_conditional_effects()\n", " assert qr_kind.has_conditional_effects()\n", @@ -312,17 +321,16 @@ "source": [ "# Get the compiler from the factory\n", "with Compiler(\n", - " problem_kind = cer_kind,\n", - " compilation_kind = CompilationKind.DISJUNCTIVE_CONDITIONS_REMOVING\n", - " ) as disjunctive_conditions_remover:\n", + " problem_kind=cer_kind,\n", + " compilation_kind=CompilationKind.DISJUNCTIVE_CONDITIONS_REMOVING,\n", + ") as disjunctive_conditions_remover:\n", " # After we have the compiler, we get the compilation result\n", " dcr_result = disjunctive_conditions_remover.compile(\n", - " cer_problem, \n", - " CompilationKind.DISJUNCTIVE_CONDITIONS_REMOVING\n", + " cer_problem, CompilationKind.DISJUNCTIVE_CONDITIONS_REMOVING\n", " )\n", " dcr_problem = dcr_result.problem\n", " dcr_kind = dcr_problem.kind\n", - " \n", + "\n", " # Check the result of the compilation\n", " assert qr_kind.has_disjunctive_conditions()\n", " assert cer_kind.has_disjunctive_conditions()\n", @@ -363,17 +371,15 @@ "source": [ "# Get the compiler from the factory\n", "with Compiler(\n", - " problem_kind = dcr_kind,\n", - " compilation_kind = CompilationKind.NEGATIVE_CONDITIONS_REMOVING\n", - " ) as negative_conditions_remover:\n", + " problem_kind=dcr_kind, compilation_kind=CompilationKind.NEGATIVE_CONDITIONS_REMOVING\n", + ") as negative_conditions_remover:\n", " # After we have the compiler, we get the compilation result\n", " ncr_result = negative_conditions_remover.compile(\n", - " dcr_problem, \n", - " CompilationKind.NEGATIVE_CONDITIONS_REMOVING\n", + " dcr_problem, CompilationKind.NEGATIVE_CONDITIONS_REMOVING\n", " )\n", " ncr_problem = ncr_result.problem\n", " ncr_kind = ncr_problem.kind\n", - " \n", + "\n", " # Check the result of the compilation\n", " assert original_problem_kind.has_negative_conditions()\n", " assert qr_kind.has_negative_conditions()\n", @@ -425,9 +431,13 @@ ], "source": [ "# Get the planner from the factory\n", - "with OneshotPlanner(name = \"pyperplan\") as planner:\n", - " assert planner.supports(ncr_kind) # Make sure the planner supports the compiled problem\n", - " ncr_plan = planner.solve(ncr_problem).plan # Solve the problem and get the plan for the compiled problem\n", + "with OneshotPlanner(name=\"pyperplan\") as planner:\n", + " assert planner.supports(\n", + " ncr_kind\n", + " ) # Make sure the planner supports the compiled problem\n", + " ncr_plan = planner.solve(\n", + " ncr_problem\n", + " ).plan # Solve the problem and get the plan for the compiled problem\n", " print(ncr_plan)\n", " assert len(ncr_plan.actions) == 6" ] @@ -466,6 +476,7 @@ ], "source": [ "from unified_planning.engines import ValidationResultStatus\n", + "\n", "# The ValidationResultStatus class is defined in the unified_planning/engines/results.py file\n", "\n", "# Create the equivalent plan for the dcr_problem (the one created by the disjunctive conditions remover)\n", @@ -473,8 +484,10 @@ "\n", "# Check to see if the plan is actually valid for the problem\n", "print(dcr_kind)\n", - "with PlanValidator(problem_kind = dcr_kind) as validator:\n", - " assert validator.validate(dcr_problem, dcr_plan).status == ValidationResultStatus.VALID" + "with PlanValidator(problem_kind=dcr_kind) as validator:\n", + " assert (\n", + " validator.validate(dcr_problem, dcr_plan).status == ValidationResultStatus.VALID\n", + " )" ] }, { @@ -518,8 +531,11 @@ "original_plan = qr_plan.replace_action_instances(qr_result.map_back_action_instance)\n", "\n", "# Check to see if the obtained plan is actually valid for the original problem\n", - "with PlanValidator(problem_kind = original_problem_kind) as validator:\n", - " assert validator.validate(original_problem, original_plan).status == ValidationResultStatus.VALID\n", + "with PlanValidator(problem_kind=original_problem_kind) as validator:\n", + " assert (\n", + " validator.validate(original_problem, original_plan).status\n", + " == ValidationResultStatus.VALID\n", + " )\n", "\n", "print(original_plan)" ] @@ -557,18 +573,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", @@ -581,7 +601,9 @@ "metadata": {}, "outputs": [], "source": [ - "plot_sequential_plan(original_plan, figsize=(8, 20), node_size=21000, font_size=10, top_bottom=True)" + "plot_sequential_plan(\n", + " original_plan, figsize=(8, 20), node_size=21000, font_size=10, top_bottom=True\n", + ")" ] } ], diff --git a/docs/notebooks/06-oversubscription-with-metaengine.ipynb b/docs/notebooks/06-oversubscription-with-metaengine.ipynb index 064759857..c5915b8af 100644 --- a/docs/notebooks/06-oversubscription-with-metaengine.ipynb +++ b/docs/notebooks/06-oversubscription-with-metaengine.ipynb @@ -86,12 +86,12 @@ }, "outputs": [], "source": [ - "Location = UserType('Location')\n", - "Robot = UserType('Robot')\n", + "Location = UserType(\"Location\")\n", + "Robot = UserType(\"Robot\")\n", "\n", - "at = Fluent('at', BoolType(), robot=Robot, location=Location)\n", - "visited = Fluent('visited', BoolType(), robot=Robot, location=Location)\n", - "connected = Fluent('connected', BoolType(), l_from=Location, l_to=Location)" + "at = Fluent(\"at\", BoolType(), robot=Robot, location=Location)\n", + "visited = Fluent(\"visited\", BoolType(), robot=Robot, location=Location)\n", + "connected = Fluent(\"connected\", BoolType(), l_from=Location, l_to=Location)" ] }, { @@ -111,10 +111,10 @@ }, "outputs": [], "source": [ - "move = InstantaneousAction('move', robot=Robot, l_from=Location, l_to=Location)\n", - "robot = move.parameter('robot')\n", - "l_from = move.parameter('l_from')\n", - "l_to = move.parameter('l_to')\n", + "move = InstantaneousAction(\"move\", robot=Robot, l_from=Location, l_to=Location)\n", + "robot = move.parameter(\"robot\")\n", + "l_from = move.parameter(\"l_from\")\n", + "l_to = move.parameter(\"l_to\")\n", "move.add_precondition(at(robot, l_from))\n", "move.add_precondition(connected(l_from, l_to))\n", "move.add_effect(at(robot, l_from), False)\n", @@ -139,11 +139,11 @@ }, "outputs": [], "source": [ - "r1 = Object('r1', Robot)\n", + "r1 = Object(\"r1\", Robot)\n", "NLOC = 10\n", - "locations = [Object('l%s' % i, Location) for i in range(NLOC)]\n", + "locations = [Object(\"l%s\" % i, Location) for i in range(NLOC)]\n", "\n", - "problem = Problem('robot_with_simulated_effects')\n", + "problem = Problem(\"robot_with_simulated_effects\")\n", "problem.add_fluent(at, default_initial_value=False)\n", "problem.add_fluent(visited, default_initial_value=False)\n", "problem.add_fluent(connected, default_initial_value=False)\n", @@ -155,7 +155,7 @@ "problem.set_initial_value(at(r1, locations[0]), True)\n", "problem.set_initial_value(visited(r1, locations[0]), True)\n", "for i in range(NLOC - 1):\n", - " problem.set_initial_value(connected(locations[i], locations[i+1]), True)\n", + " problem.set_initial_value(connected(locations[i], locations[i + 1]), True)\n", "problem.set_initial_value(connected(locations[4], locations[8]), True)" ] }, @@ -224,7 +224,7 @@ } ], "source": [ - "with OneshotPlanner(name='oversubscription[tamer]') as planner:\n", + "with OneshotPlanner(name=\"oversubscription[tamer]\") as planner:\n", " result = planner.solve(problem)\n", " print(\"%s returned: %s\" % (planner.name, result.plan))" ] @@ -329,18 +329,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", diff --git a/docs/notebooks/07-hierarchical-planning.ipynb b/docs/notebooks/07-hierarchical-planning.ipynb index 09e8a2bbf..58fe3be83 100644 --- a/docs/notebooks/07-hierarchical-planning.ipynb +++ b/docs/notebooks/07-hierarchical-planning.ipynb @@ -110,7 +110,7 @@ }, "outputs": [], "source": [ - "#pb = Problem() # for a non-hierarchical problem\n", + "# pb = Problem() # for a non-hierarchical problem\n", "pb = HierarchicalProblem() # make it hierarchical instead\n", "\n", "Package = UserType(\"Package\")\n", @@ -186,7 +186,7 @@ ], "source": [ "# city of location\n", - "city = pb.add_fluent(\"city\", City, of=Loc) \n", + "city = pb.add_fluent(\"city\", City, of=Loc)\n", "\n", "# current location of package / vehicle\n", "loc = pb.add_fluent(\"loc\", PackageLoc, package=Package)\n", @@ -380,7 +380,7 @@ "outputs": [], "source": [ "# helper function that just invokes a planner and prints the plan\n", - "def solve(pb: Problem, verbose=False): \n", + "def solve(pb: Problem, verbose=False):\n", " result = OneshotPlanner(problem_kind=pb.kind).solve(pb)\n", " if result.plan is not None:\n", " print(\"Plan:\", repr(result.plan) if verbose else str(result.plan))\n", @@ -528,7 +528,7 @@ "outputs": [], "source": [ "# declares that m achieves the `bring-truck(truck, dest)` task`\n", - "m.set_task(bring_truck, m.truck, m.dest) " + "m.set_task(bring_truck, m.truck, m.dest)" ] }, { @@ -548,7 +548,7 @@ "source": [ "# only usable if the truck is already at the right location\n", "# no subtasks, implying that if the method is usable, there is nothing left to do\n", - "m.add_precondition(Equals(at(m.truck), m.dest)) " + "m.add_precondition(Equals(at(m.truck), m.dest))" ] }, { @@ -600,7 +600,7 @@ "# Option 2: truck not at target location, move it\n", "m = Method(\"bring-truck-move\", truck=Truck, orig=Loc, dest=Loc)\n", "# declares that m achieves the `bring-truck(truck, to)` task`\n", - "m.set_task(bring_truck, m.truck, m.dest) " + "m.set_task(bring_truck, m.truck, m.dest)" ] }, { @@ -617,9 +617,11 @@ }, "outputs": [], "source": [ - "m.add_precondition(Equals(at(m.truck), m.orig)) # restrict applicability to cases where the truck is\n", - "m.add_precondition(Not(Equals(m.orig, m.dest))) # in a different location\n", - "m.add_precondition(Equals(city(m.orig), city(m.dest))) # of the same city" + "m.add_precondition(\n", + " Equals(at(m.truck), m.orig)\n", + ") # restrict applicability to cases where the truck is\n", + "m.add_precondition(Not(Equals(m.orig, m.dest))) # in a different location\n", + "m.add_precondition(Equals(city(m.orig), city(m.dest))) # of the same city" ] }, { @@ -633,7 +635,7 @@ "outputs": [], "source": [ "# accomplishing this method requires executing a `move` action\n", - "m.add_subtask(move, m.truck, m.orig, m.dest, ident=\"move-subtask\") \n", + "m.add_subtask(move, m.truck, m.orig, m.dest, ident=\"move-subtask\")\n", "\n", "pb.add_method(m)" ] @@ -942,7 +944,9 @@ "# Method 1: handling the case where the package is already at the destination\n", "m = Method(\"transport-in-city-noop\", package=Package, to=Loc)\n", "m.set_task(transport_in_city, m.package, m.to) # set the task that this method achieve\n", - "m.add_precondition(Equals(loc(m.package), m.to)) # only allow using this method if the package is already at the destination\n", + "m.add_precondition(\n", + " Equals(loc(m.package), m.to)\n", + ") # only allow using this method if the package is already at the destination\n", "# note: no subtasks are added => nothing to do in this method\n", "pb.add_method(m)" ] @@ -964,7 +968,7 @@ "source": [ "m = Method(\"transport-in-city-truck\", package=Package, orig=Loc, to=Loc, truck=Truck)\n", "m.set_task(transport_in_city, m.package, m.to)\n", - "m.add_precondition(Equals(loc(m.package), m.orig)) # package is at origin\n", + "m.add_precondition(Equals(loc(m.package), m.orig)) # package is at origin\n", "m.add_precondition(Not(Equals(m.orig, m.to)))\n", "m.add_precondition(Equals(city(m.orig), city(m.to))) # destination is the same city" ] @@ -988,7 +992,9 @@ "t1 = m.add_subtask(bring_truck, m.truck, m.orig) # bring truck to package location\n", "t2 = m.add_subtask(load, m.package, m.truck, m.orig) # load package in truck\n", "t3 = m.add_subtask(bring_truck, m.truck, m.to) # bring truck to target location\n", - "t4 = m.add_subtask(unload, m.package, m.truck, m.to) # unload package at target location\n", + "t4 = m.add_subtask(\n", + " unload, m.package, m.truck, m.to\n", + ") # unload package at target location\n", "m.set_ordered(t1, t2, t3, t4) # enforce all 4 subtasks to be done in this order\n", "pb.add_method(m)" ] @@ -1120,7 +1126,7 @@ "pb_clone = pb.clone()\n", "t1 = pb_clone.task_network.add_subtask(transport_in_city(package1, loc1))\n", "t2 = pb_clone.task_network.add_subtask(transport_in_city(package2, airport1))\n", - "pb_clone.task_network.set_ordered(t1, t2) # force t1 to be completed before starting t2\n", + "pb_clone.task_network.set_ordered(t1, t2) # force t1 to be completed before starting t2\n", "solve(pb_clone)" ] }, @@ -1166,7 +1172,7 @@ "pb_clone = pb.clone()\n", "t1 = pb_clone.task_network.add_subtask(transport_in_city(package1, loc1))\n", "t2 = pb_clone.task_network.add_subtask(transport_in_city(package1, airport1))\n", - "pb_clone.task_network.set_ordered(t1, t2) # force t1 to be completed before starting t2\n", + "pb_clone.task_network.set_ordered(t1, t2) # force t1 to be completed before starting t2\n", "solve(pb_clone)" ] }, diff --git a/docs/notebooks/08-sequential-simulator.ipynb b/docs/notebooks/08-sequential-simulator.ipynb index 1a8cf7c75..9da4b6ed4 100644 --- a/docs/notebooks/08-sequential-simulator.ipynb +++ b/docs/notebooks/08-sequential-simulator.ipynb @@ -115,11 +115,11 @@ }, "outputs": [], "source": [ - "Location = UserType('Location')\n", + "Location = UserType(\"Location\")\n", "\n", - "at = Fluent('at', Location)\n", - "distance = Fluent('distance', IntType(), l1=Location, l2=Location)\n", - "battery_charge = Fluent('battery_charge', IntType(0, 100))" + "at = Fluent(\"at\", Location)\n", + "distance = Fluent(\"distance\", IntType(), l1=Location, l2=Location)\n", + "battery_charge = Fluent(\"battery_charge\", IntType(0, 100))" ] }, { @@ -141,9 +141,9 @@ }, "outputs": [], "source": [ - "move = InstantaneousAction('move', l_from=Location, l_to=Location)\n", - "l_from = move.parameter('l_from')\n", - "l_to = move.parameter('l_to')\n", + "move = InstantaneousAction(\"move\", l_from=Location, l_to=Location)\n", + "l_from = move.parameter(\"l_from\")\n", + "l_to = move.parameter(\"l_to\")\n", "move.add_precondition(Equals(at, l_from))\n", "move.add_effect(at, l_to)\n", "move.add_decrease_effect(battery_charge, distance(l_from, l_to))" @@ -168,17 +168,17 @@ }, "outputs": [], "source": [ - "l1 = Object('l1', Location)\n", - "l2 = Object('l2', Location)\n", - "l3 = Object('l3', Location)\n", - "l4 = Object('l4', Location)\n", - "l5 = Object('l5', Location)\n", + "l1 = Object(\"l1\", Location)\n", + "l2 = Object(\"l2\", Location)\n", + "l3 = Object(\"l3\", Location)\n", + "l4 = Object(\"l4\", Location)\n", + "l5 = Object(\"l5\", Location)\n", "locations = [l5, l4, l3, l2, l1]\n", "\n", - "problem = Problem('moving_robot')\n", + "problem = Problem(\"moving_robot\")\n", "problem.add_fluent(at)\n", "problem.add_fluent(battery_charge)\n", - "problem.add_fluent(distance, default_initial_value = 101)\n", + "problem.add_fluent(distance, default_initial_value=101)\n", "problem.add_action(move)\n", "problem.add_objects(locations)\n", "\n", @@ -238,7 +238,7 @@ " initial_state = simulator.get_initial_state()\n", " for travel_location in locations:\n", " if simulator.is_applicable(initial_state, move, (l1, travel_location)):\n", - " print(f\"From l1 we can reach: {travel_location}\") " + " print(f\"From l1 we can reach: {travel_location}\")" ] }, { @@ -263,15 +263,15 @@ } ], "source": [ - " state_at_l3 = simulator.apply(initial_state, move, (l1, l3))\n", - " for travel_location in locations:\n", - " if simulator.is_applicable(state_at_l3, move, (l3, travel_location)):\n", - " print(f\"From l3 we can reach: {travel_location}\") \n", - " state_at_l4 = simulator.apply(state_at_l3, move, (l3, l4))\n", - " if simulator.is_applicable(state_at_l4, move, (l4, l5)):\n", - " print('Done!')\n", - " else:\n", - " print(f'Problem! Battery too low: {state_at_l4.get_value(battery_exp)}')" + "state_at_l3 = simulator.apply(initial_state, move, (l1, l3))\n", + "for travel_location in locations:\n", + " if simulator.is_applicable(state_at_l3, move, (l3, travel_location)):\n", + " print(f\"From l3 we can reach: {travel_location}\")\n", + "state_at_l4 = simulator.apply(state_at_l3, move, (l3, l4))\n", + "if simulator.is_applicable(state_at_l4, move, (l4, l5)):\n", + " print(\"Done!\")\n", + "else:\n", + " print(f\"Problem! Battery too low: {state_at_l4.get_value(battery_exp)}\")" ] }, { @@ -297,13 +297,15 @@ } ], "source": [ - " state_at_l2 = simulator.apply(initial_state, move, (l1, l2))\n", - " new_state_at_l3 = simulator.apply(state_at_l2, move, (l2, l3))\n", - " new_state_better = (new_state_at_l3.get_value(battery_exp) > state_at_l3.get_value(battery_exp)).simplify()\n", - " if new_state_better.bool_constant_value():\n", - " print(\"Reaching l3 passing through l2 saves battery!\")\n", - " else:\n", - " print(\"Can't save battery reaching l3, the problem has no solution!\")" + "state_at_l2 = simulator.apply(initial_state, move, (l1, l2))\n", + "new_state_at_l3 = simulator.apply(state_at_l2, move, (l2, l3))\n", + "new_state_better = (\n", + " new_state_at_l3.get_value(battery_exp) > state_at_l3.get_value(battery_exp)\n", + ").simplify()\n", + "if new_state_better.bool_constant_value():\n", + " print(\"Reaching l3 passing through l2 saves battery!\")\n", + "else:\n", + " print(\"Can't save battery reaching l3, the problem has no solution!\")" ] }, { @@ -327,13 +329,13 @@ } ], "source": [ - " state_at_l3 = new_state_at_l3\n", - " state_at_l4 = simulator.apply(state_at_l3, move, (l3, l4))\n", - " if simulator.is_applicable(state_at_l4, move, (l4, l5)):\n", - " print('Done!')\n", - " else:\n", - " print(f'Problem! Battery too low: {state_at_l4.get_value(battery_exp)}')\n", - " state_at_l5 = simulator.apply(state_at_l4, move, (l4, l5))" + "state_at_l3 = new_state_at_l3\n", + "state_at_l4 = simulator.apply(state_at_l3, move, (l3, l4))\n", + "if simulator.is_applicable(state_at_l4, move, (l4, l5)):\n", + " print(\"Done!\")\n", + "else:\n", + " print(f\"Problem! Battery too low: {state_at_l4.get_value(battery_exp)}\")\n", + "state_at_l5 = simulator.apply(state_at_l4, move, (l4, l5))" ] }, { @@ -365,27 +367,29 @@ } ], "source": [ - " from unified_planning.plans import SequentialPlan, ActionInstance\n", - " \n", - " plan = SequentialPlan([\n", - " ActionInstance(move, (l1, l2)), \n", + "from unified_planning.plans import SequentialPlan, ActionInstance\n", + "\n", + "plan = SequentialPlan(\n", + " [\n", + " ActionInstance(move, (l1, l2)),\n", " ActionInstance(move, (l2, l3)),\n", " ActionInstance(move, (l3, l4)),\n", - " ActionInstance(move, (l4, l5))\n", - " ])\n", - " print(f\"Initial battery value: {initial_state.get_value(battery_exp).constant_value()}\")\n", - " current_state = initial_state\n", - " # We also store the states to plot the metrics later\n", - " states = [current_state]\n", - " for action_instance in plan.actions:\n", - " current_state = simulator.apply(current_state, action_instance)\n", - " if current_state is None:\n", - " print(f'Error in applying: {action_instance}')\n", - " break\n", - " states.append(current_state)\n", - " current_battery_value = current_state.get_value(battery_exp).constant_value()\n", - " # in current_battery_value we inspect the State\n", - " print(f\"Battery value after {action_instance}: {current_battery_value}\")" + " ActionInstance(move, (l4, l5)),\n", + " ]\n", + ")\n", + "print(f\"Initial battery value: {initial_state.get_value(battery_exp).constant_value()}\")\n", + "current_state = initial_state\n", + "# We also store the states to plot the metrics later\n", + "states = [current_state]\n", + "for action_instance in plan.actions:\n", + " current_state = simulator.apply(current_state, action_instance)\n", + " if current_state is None:\n", + " print(f\"Error in applying: {action_instance}\")\n", + " break\n", + " states.append(current_state)\n", + " current_battery_value = current_state.get_value(battery_exp).constant_value()\n", + " # in current_battery_value we inspect the State\n", + " print(f\"Battery value after {action_instance}: {current_battery_value}\")" ] }, { @@ -401,7 +405,7 @@ "metadata": {}, "outputs": [], "source": [ - " from unified_planning.plot import plot_sequential_plan" + "from unified_planning.plot import plot_sequential_plan" ] }, { @@ -417,31 +421,35 @@ "metadata": {}, "outputs": [], "source": [ - " # Redefine the plot package methods imported above to print the plot to a temp file\n", - " # if the exception \"could not locate runnable browser\" is raised. This usually happens\n", - " # in the Continuous Integration.\n", + "# Redefine the plot package methods imported above to print the plot to a temp file\n", + "# if the exception \"could not locate runnable browser\" is raised. This usually happens\n", + "# in the Continuous Integration.\n", + "\n", + "from inspect import getmembers, isfunction\n", + "from unified_planning import plot\n", + "from functools import partial\n", + "import os, uuid, tempfile as tf\n", "\n", - " from inspect import getmembers, isfunction\n", - " from unified_planning import plot\n", - " from functools import partial\n", - " import os, uuid, tempfile as tf\n", "\n", - " # Define the function that will be executed instead\n", - " def _function(original_function, *args, **kwargs):\n", - " try:\n", - " original_function(*args, **kwargs)\n", - " except Exception as e:\n", - " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", - " )\n", - " else:\n", - " raise e\n", + "# Define the function that will be executed instead\n", + "def _function(original_function, *args, **kwargs):\n", + " try:\n", + " original_function(*args, **kwargs)\n", + " except Exception as e:\n", + " if \"could not locate runnable browser\" in str(e):\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", + " )\n", + " else:\n", + " raise e\n", + "\n", "\n", - " # Iterate over all the functions of the plot package\n", - " for function_name, function in getmembers(plot, isfunction):\n", - " # Override the original function with the new one\n", - " globals()[function_name] = partial(_function, function)" + "# Iterate over all the functions of the plot package\n", + "for function_name, function in getmembers(plot, isfunction):\n", + " # Override the original function with the new one\n", + " globals()[function_name] = partial(_function, function)" ] }, { @@ -450,7 +458,7 @@ "metadata": {}, "outputs": [], "source": [ - " plot_sequential_plan(plan, problem, battery_exp, figsize=(9, 3))" + "plot_sequential_plan(plan, problem, battery_exp, figsize=(9, 3))" ] }, { @@ -483,38 +491,45 @@ } ], "source": [ - " from unified_planning.engines.sequential_simulator import evaluate_quality_metric, evaluate_quality_metric_in_initial_state\n", + "from unified_planning.engines.sequential_simulator import (\n", + " evaluate_quality_metric,\n", + " evaluate_quality_metric_in_initial_state,\n", + ")\n", "\n", - " plan_length = MinimizeSequentialPlanLength()\n", - " maximize_battery = MaximizeExpressionOnFinalState(battery_exp)\n", + "plan_length = MinimizeSequentialPlanLength()\n", + "maximize_battery = MaximizeExpressionOnFinalState(battery_exp)\n", "\n", - " plan_length_value = evaluate_quality_metric_in_initial_state(simulator, plan_length)\n", - " maximize_battery_value = evaluate_quality_metric_in_initial_state(simulator, maximize_battery)\n", - " \n", - " current_state = states[0]\n", - " for next_state, action_instance in zip(states[1:], plan.actions):\n", - " plan_length_value = evaluate_quality_metric(\n", - " simulator, \n", - " plan_length, \n", - " plan_length_value,\n", - " current_state,\n", - " action_instance.action,\n", - " action_instance.actual_parameters,\n", - " next_state\n", - " )\n", - " maximize_battery_value = evaluate_quality_metric(\n", - " simulator, \n", - " maximize_battery, \n", - " maximize_battery_value,\n", - " current_state,\n", - " action_instance.action,\n", - " action_instance.actual_parameters,\n", - " next_state\n", - " )\n", - " current_state = next_state\n", - " \n", - " # Do something with the metric values\n", - " print(f'Plan length: {plan_length_value}\\nMaximized epression value: {maximize_battery_value}')" + "plan_length_value = evaluate_quality_metric_in_initial_state(simulator, plan_length)\n", + "maximize_battery_value = evaluate_quality_metric_in_initial_state(\n", + " simulator, maximize_battery\n", + ")\n", + "\n", + "current_state = states[0]\n", + "for next_state, action_instance in zip(states[1:], plan.actions):\n", + " plan_length_value = evaluate_quality_metric(\n", + " simulator,\n", + " plan_length,\n", + " plan_length_value,\n", + " current_state,\n", + " action_instance.action,\n", + " action_instance.actual_parameters,\n", + " next_state,\n", + " )\n", + " maximize_battery_value = evaluate_quality_metric(\n", + " simulator,\n", + " maximize_battery,\n", + " maximize_battery_value,\n", + " current_state,\n", + " action_instance.action,\n", + " action_instance.actual_parameters,\n", + " next_state,\n", + " )\n", + " current_state = next_state\n", + "\n", + " # Do something with the metric values\n", + " print(\n", + " f\"Plan length: {plan_length_value}\\nMaximized epression value: {maximize_battery_value}\"\n", + " )" ] }, { @@ -532,13 +547,21 @@ }, "outputs": [], "source": [ - " try:\n", - " plot_sequential_plan(plan, problem, metric_or_metrics=[plan_length, maximize_battery], figsize=(9, 3))\n", - " except Exception as e:\n", - " if \"could not locate runnable browser\" in str(e):\n", - " plot_sequential_plan(plan, problem, battery_exp, figsize=(9, 3), filename=\"sequential_simulator_2.png\")\n", - " else:\n", - " raise e" + "try:\n", + " plot_sequential_plan(\n", + " plan, problem, metric_or_metrics=[plan_length, maximize_battery], figsize=(9, 3)\n", + " )\n", + "except Exception as e:\n", + " if \"could not locate runnable browser\" in str(e):\n", + " plot_sequential_plan(\n", + " plan,\n", + " problem,\n", + " battery_exp,\n", + " figsize=(9, 3),\n", + " filename=\"sequential_simulator_2.png\",\n", + " )\n", + " else:\n", + " raise e" ] } ], diff --git a/docs/notebooks/09-multiagent-planning-simple.ipynb b/docs/notebooks/09-multiagent-planning-simple.ipynb index ae9092ead..6b387a150 100644 --- a/docs/notebooks/09-multiagent-planning-simple.ipynb +++ b/docs/notebooks/09-multiagent-planning-simple.ipynb @@ -124,7 +124,7 @@ "source": [ "problem = MultiAgentProblem(\"simple_MA\")\n", "\n", - "#AGENTs\n", + "# AGENTs\n", "robot_a = Agent(\"robot_a\", problem)\n", "scale_a = Agent(\"scale_a\", problem)" ] @@ -146,21 +146,21 @@ }, "outputs": [], "source": [ - "#USERTYPEs\n", + "# USERTYPEs\n", "Location = UserType(\"Location\")\n", "door = UserType(\"door\")\n", "\n", - "#FLUENTs\n", + "# FLUENTs\n", "open = Fluent(\"open\", door=door)\n", "pos = Fluent(\"pos\", loc=Location)\n", "\n", - "#OBJECTs\n", + "# OBJECTs\n", "home = Object(\"home\", Location)\n", "office = Object(\"office\", Location)\n", "open20 = Object(\"open20\", door)\n", "close20 = Object(\"close20\", door)\n", "\n", - "#ACTIONs\n", + "# ACTIONs\n", "movegripper = InstantaneousAction(\"movegripper\")\n", "movegripper.add_precondition(pos(office))\n", "movegripper.add_effect(pos(home), True)\n", @@ -267,17 +267,17 @@ }, "outputs": [], "source": [ - "#OBJECTs\n", + "# OBJECTs\n", "problem.add_object(home)\n", "problem.add_object(office)\n", "problem.add_object(open20)\n", "problem.add_object(close20)\n", "\n", - "#INITIAL VALUEs\n", + "# INITIAL VALUEs\n", "problem.set_initial_value(Dot(robot_a, pos(office)), True)\n", "problem.set_initial_value(Dot(scale_a, open(close20)), True)\n", "\n", - "#GOALs\n", + "# GOALs\n", "problem.add_goal(Dot(robot_a, pos(home)))\n", "problem.add_goal(Dot(scale_a, open(open20)))" ] @@ -378,11 +378,17 @@ } ], "source": [ - "with OneshotPlanner(name='fmap', params={'heuristic': '1'}) as planner:\n", + "with OneshotPlanner(name=\"fmap\", params={\"heuristic\": \"1\"}) as planner:\n", " result = planner.solve(problem)\n", " if result.status == up.engines.PlanGenerationResultStatus.SOLVED_SATISFICING:\n", - " print(\"%s Returned Sequential Plans object: %s\" % (planner.name, result.plan.all_sequential_plans()))\n", - " [print(f\"{idx} Sequential Plans: {seq_plan}\") for idx, seq_plan in enumerate(result.plan.all_sequential_plans())]\n", + " print(\n", + " \"%s Returned Sequential Plans object: %s\"\n", + " % (planner.name, result.plan.all_sequential_plans())\n", + " )\n", + " [\n", + " print(f\"{idx} Sequential Plans: {seq_plan}\")\n", + " for idx, seq_plan in enumerate(result.plan.all_sequential_plans())\n", + " ]\n", " print(\"Adjacency list:\", result.plan.get_adjacency_list)\n", " print(\"result:\", result)\n", " else:\n", diff --git a/docs/notebooks/10-multiagent-planning.ipynb b/docs/notebooks/10-multiagent-planning.ipynb index 73b05c3d5..292442ee6 100644 --- a/docs/notebooks/10-multiagent-planning.ipynb +++ b/docs/notebooks/10-multiagent-planning.ipynb @@ -119,7 +119,7 @@ }, "outputs": [], "source": [ - "#USERTYPEs\n", + "# USERTYPEs\n", "place = UserType(\"place\")\n", "locatable = UserType(\"locatable\")\n", "truck = UserType(\"truck\", locatable)\n", @@ -129,7 +129,7 @@ "crate = UserType(\"crate\", surface)\n", "pos = Fluent(\"pos\", place=place)\n", "\n", - "#FLUENTs\n", + "# FLUENTs\n", "at = Fluent(\"at\", BoolType(), locatable=locatable, place=place)\n", "on = Fluent(\"on\", BoolType(), crate=crate, surface=surface)\n", "In = Fluent(\"in\", BoolType(), crate=crate, truck=truck)\n", @@ -139,7 +139,7 @@ "lifting = Fluent(\"lifting\", hoist=hoist, crate=crate)\n", "driving = Fluent(\"driving\", truck=truck)\n", "\n", - "#OBJECTs\n", + "# OBJECTs\n", "truck0 = Object(\"truck0\", truck)\n", "truck1 = Object(\"truck1\", truck)\n", "depot0_place = Object(\"depot0_place\", place)\n", @@ -155,7 +155,7 @@ "hoist1 = Object(\"hoist1\", hoist)\n", "hoist2 = Object(\"hoist2\", hoist)\n", "\n", - "#ACTIONs\n", + "# ACTIONs\n", "drive = InstantaneousAction(\"drive\", x=truck, y=place, z=place)\n", "x = drive.parameter(\"x\")\n", "y = drive.parameter(\"y\")\n", @@ -435,7 +435,7 @@ }, "outputs": [], "source": [ - "#OBJECTs\n", + "# OBJECTs\n", "problem.add_object(crate0)\n", "problem.add_object(crate1)\n", "problem.add_object(truck0)\n", @@ -450,7 +450,7 @@ "problem.add_object(hoist1)\n", "problem.add_object(hoist2)\n", "\n", - "#INITIAL VALUEs\n", + "# INITIAL VALUEs\n", "problem.set_initial_value(at(pallet0, depot0_place), True)\n", "problem.set_initial_value(clear(crate1), True)\n", "problem.set_initial_value(at(pallet1, distributor0_place), True)\n", @@ -468,9 +468,7 @@ "problem.set_initial_value(at(crate1, depot0_place), True)\n", "problem.set_initial_value(on(crate1, pallet0), True)\n", "\n", - "problem.set_initial_value(\n", - " Dot(driver0_a, pos(distributor1_place)), True\n", - ") \n", + "problem.set_initial_value(Dot(driver0_a, pos(distributor1_place)), True)\n", "problem.set_initial_value(Dot(driver1_a, pos(depot0_place)), True)\n", "problem.set_initial_value(Dot(depot0_a, pos(depot0_place)), True)\n", "problem.set_initial_value(Dot(depot0_a, available(hoist0)), True)\n", @@ -483,7 +481,7 @@ "problem.set_initial_value(Dot(driver0_a, driving(truck0)), True)\n", "problem.set_initial_value(Dot(driver1_a, driving(truck1)), True)\n", "\n", - "#GOALs\n", + "# GOALs\n", "problem.add_goal(on(crate0, pallet2))\n", "problem.add_goal(on(crate1, pallet1))" ] @@ -729,18 +727,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", @@ -760,7 +762,9 @@ }, "outputs": [], "source": [ - "plot_partial_order_plan(result.plan, figsize=(20, 20), node_size=8000, font_size=10, top_bottom=True)" + "plot_partial_order_plan(\n", + " result.plan, figsize=(20, 20), node_size=8000, font_size=10, top_bottom=True\n", + ")" ] } ], diff --git a/docs/notebooks/11-plot.ipynb b/docs/notebooks/11-plot.ipynb index b37be01ee..5e8d5fabe 100644 --- a/docs/notebooks/11-plot.ipynb +++ b/docs/notebooks/11-plot.ipynb @@ -80,7 +80,7 @@ " STNPlan,\n", ")\n", "from unified_planning.plot import (\n", - " plot_plan, # plot_plan plots all the types of plans, but is not customizable, while specific methods\n", + " plot_plan, # plot_plan plots all the types of plans, but is not customizable, while specific methods\n", " plot_sequential_plan,\n", " plot_time_triggered_plan,\n", " plot_partial_order_plan,\n", @@ -90,7 +90,14 @@ ")\n", "\n", "\n", - "from unified_planning.model import InstantaneousAction, DurativeAction, TimepointKind, Fluent, Problem, Object\n", + "from unified_planning.model import (\n", + " InstantaneousAction,\n", + " DurativeAction,\n", + " TimepointKind,\n", + " Fluent,\n", + " Problem,\n", + " Object,\n", + ")\n", "from unified_planning.shortcuts import BoolType, UserType, IntType, RealType" ] }, @@ -116,18 +123,22 @@ "from functools import partial\n", "import os, uuid, tempfile as tf\n", "\n", + "\n", "# Define the function that will be executed instead\n", "def _function(original_function, *args, **kwargs):\n", " try:\n", " original_function(*args, **kwargs)\n", " except Exception as e:\n", " if \"could not locate runnable browser\" in str(e):\n", - " original_function(*args, **kwargs,\n", - " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\"\n", + " original_function(\n", + " *args,\n", + " **kwargs,\n", + " filename=f\"{os.path.join(tf.gettempdir(), str(uuid.uuid1()))}.png\",\n", " )\n", " else:\n", " raise e\n", "\n", + "\n", "# Iterate over all the functions of the plot package\n", "for function_name, function in getmembers(plot, isfunction):\n", " # Override the original function with the new one\n", @@ -206,7 +217,7 @@ "move.add_precondition(robot_at(l_from))\n", "move.add_effect(robot_at(l_from), False)\n", "move.add_effect(robot_at(l_to), True)\n", - "move.add_decrease_effect(battery_charge, distance(l_from, l_to)/2 + 5)\n", + "move.add_decrease_effect(battery_charge, distance(l_from, l_to) / 2 + 5)\n", "move.add_increase_effect(total_distance, distance(l_from, l_to))\n", "\n", "# Define the Location Objects\n", @@ -229,11 +240,13 @@ "problem.set_initial_value(distance(l3, l4), 10)\n", "\n", "# Create the plan to simulate\n", - "plan = SequentialPlan([\n", - " move(l1, l2),\n", - " move(l2, l3),\n", - " move(l3, l4),\n", - "])" + "plan = SequentialPlan(\n", + " [\n", + " move(l1, l2),\n", + " move(l2, l3),\n", + " move(l3, l4),\n", + " ]\n", + ")" ] }, { @@ -268,12 +281,14 @@ "outputs": [], "source": [ "a1, a2, a3, a4 = (DurativeAction(f\"a{i}\") for i in range(1, 5))\n", - "time_triggered_plan = TimeTriggeredPlan([\n", - " (0, a1(), 3),\n", - " (1, a2(), 3),\n", - " (2, a3(), 2),\n", - " (2, a4(), 1),\n", - "])\n", + "time_triggered_plan = TimeTriggeredPlan(\n", + " [\n", + " (0, a1(), 3),\n", + " (1, a2(), 3),\n", + " (2, a3(), 2),\n", + " (2, a4(), 1),\n", + " ]\n", + ")\n", "\n", "plot_plan(time_triggered_plan)" ] @@ -297,16 +312,20 @@ "metadata": {}, "outputs": [], "source": [ - "ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8 = (InstantaneousAction(f\"a{i}\")() for i in range(1, 9))\n", - "partial_order_plan = PartialOrderPlan({\n", - " ai1: [ai2],\n", - " ai2: [ai4],\n", - " ai3: [ai4],\n", - " ai4: [ai5, ai6],\n", - " ai5: [ai7],\n", - " ai6: [ai8],\n", - " ai7: [ai8],\n", - "})\n", + "ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8 = (\n", + " InstantaneousAction(f\"a{i}\")() for i in range(1, 9)\n", + ")\n", + "partial_order_plan = PartialOrderPlan(\n", + " {\n", + " ai1: [ai2],\n", + " ai2: [ai4],\n", + " ai3: [ai4],\n", + " ai4: [ai5, ai6],\n", + " ai5: [ai7],\n", + " ai6: [ai8],\n", + " ai7: [ai8],\n", + " }\n", + ")\n", "\n", "plot_partial_order_plan(partial_order_plan, font_size=16)" ] @@ -346,14 +365,26 @@ "end_a3 = STNPlanNode(TimepointKind.END, ai3)\n", "start_a4 = STNPlanNode(TimepointKind.START, ai4)\n", "end_a4 = STNPlanNode(TimepointKind.END, ai4)\n", - "stn_plan = STNPlan([\n", - " (start_a1, 1, 1, end_a1), # Link start to end actions\n", - " (start_a2, 0, 3, end_a2),\n", - " (start_a3, 0, 3, end_a3),\n", - " (start_a4, 0, 3, end_a4),\n", - " (end_a1, 0, None, start_a2), # Action 1 must finish before action 2 start (or in the same moment)\n", - " (end_a3, None, 1, end_a4), # Action 3 can finish AT most 1 after the end of Action4\n", - "])\n", + "stn_plan = STNPlan(\n", + " [\n", + " (start_a1, 1, 1, end_a1), # Link start to end actions\n", + " (start_a2, 0, 3, end_a2),\n", + " (start_a3, 0, 3, end_a3),\n", + " (start_a4, 0, 3, end_a4),\n", + " (\n", + " end_a1,\n", + " 0,\n", + " None,\n", + " start_a2,\n", + " ), # Action 1 must finish before action 2 start (or in the same moment)\n", + " (\n", + " end_a3,\n", + " None,\n", + " 1,\n", + " end_a4,\n", + " ), # Action 3 can finish AT most 1 after the end of Action4\n", + " ]\n", + ")\n", "\n", "plot_stn_plan(stn_plan)" ] @@ -378,6 +409,7 @@ "outputs": [], "source": [ "from unified_planning.shortcuts import *\n", + "\n", "ai1, ai2, ai3, ai4, ai5 = (InstantaneousAction(f\"a{i}\")() for i in range(1, 6))\n", "node_1 = ContingentPlanNode(ai1)\n", "node_2 = ContingentPlanNode(ai2)\n", @@ -391,7 +423,7 @@ "node_3.add_child({y(): FALSE()}, node_5)\n", "contingent_plan = ContingentPlan(node_1)\n", "\n", - "plot_contingent_plan(contingent_plan, font_size = 14, edge_font_size = 12)" + "plot_contingent_plan(contingent_plan, font_size=14, edge_font_size=12)" ] }, { diff --git a/docs/notebooks/12-plan-parsing-conversion.ipynb b/docs/notebooks/12-plan-parsing-conversion.ipynb index 8decbc580..5ee31a949 100644 --- a/docs/notebooks/12-plan-parsing-conversion.ipynb +++ b/docs/notebooks/12-plan-parsing-conversion.ipynb @@ -115,15 +115,15 @@ }, "outputs": [], "source": [ - "Supervisor = UserType('Supervisor')\n", - "Worker = UserType('Worker')\n", + "Supervisor = UserType(\"Supervisor\")\n", + "Worker = UserType(\"Worker\")\n", "\n", - "Location = UserType('Location')\n", + "Location = UserType(\"Location\")\n", "\n", - "is_supervisor_at = Fluent('is_supervisor_at', s=Supervisor, pos=Location)\n", - "is_worker_at = Fluent('is_worker_at', w=Worker, pos=Location)\n", + "is_supervisor_at = Fluent(\"is_supervisor_at\", s=Supervisor, pos=Location)\n", + "is_worker_at = Fluent(\"is_worker_at\", w=Worker, pos=Location)\n", "\n", - "is_fixed = Fluent('is_fixed', l=Location)" + "is_fixed = Fluent(\"is_fixed\", l=Location)" ] }, { @@ -145,7 +145,9 @@ }, "outputs": [], "source": [ - "move_supervisor = InstantaneousAction('move_supervisor', supervisor=Supervisor, l_from=Location, l_to=Location)\n", + "move_supervisor = InstantaneousAction(\n", + " \"move_supervisor\", supervisor=Supervisor, l_from=Location, l_to=Location\n", + ")\n", "supervisor = move_supervisor.supervisor\n", "l_from = move_supervisor.l_from\n", "l_to = move_supervisor.l_to\n", @@ -154,7 +156,9 @@ "move_supervisor.add_effect(is_supervisor_at(supervisor, l_from), False)\n", "move_supervisor.add_effect(is_supervisor_at(supervisor, l_to), True)\n", "\n", - "move_worker = InstantaneousAction('move_worker', worker=Worker, l_from=Location, l_to=Location)\n", + "move_worker = InstantaneousAction(\n", + " \"move_worker\", worker=Worker, l_from=Location, l_to=Location\n", + ")\n", "worker = move_worker.worker\n", "l_from = move_worker.l_from\n", "l_to = move_worker.l_to\n", @@ -163,13 +167,15 @@ "move_worker.add_effect(is_worker_at(worker, l_from), False)\n", "move_worker.add_effect(is_worker_at(worker, l_to), True)\n", "\n", - "fix_location = InstantaneousAction('fix_location', loc=Location, supervisor=Supervisor, worker=Worker)\n", + "fix_location = InstantaneousAction(\n", + " \"fix_location\", loc=Location, supervisor=Supervisor, worker=Worker\n", + ")\n", "loc = fix_location.loc\n", "supervisor = fix_location.supervisor\n", "worker = fix_location.worker\n", "fix_location.add_precondition(is_supervisor_at(supervisor, loc))\n", "fix_location.add_precondition(is_worker_at(worker, loc))\n", - "fix_location.add_effect(is_fixed(loc), True)\n" + "fix_location.add_effect(is_fixed(loc), True)" ] }, { @@ -198,17 +204,17 @@ }, "outputs": [], "source": [ - "problem = Problem('problem')\n", + "problem = Problem(\"problem\")\n", "\n", "problem.add_fluent(is_supervisor_at, default_initial_value=False)\n", "problem.add_fluent(is_worker_at, default_initial_value=False)\n", "problem.add_fluent(is_fixed, default_initial_value=False)\n", "\n", - "s0 = Object('s0', Supervisor)\n", - "w0 = Object('w0', Worker)\n", - "l0 = Object('l0', Location)\n", - "l1 = Object('l1', Location)\n", - "l2 = Object('l2', Location)\n", + "s0 = Object(\"s0\", Supervisor)\n", + "w0 = Object(\"w0\", Worker)\n", + "l0 = Object(\"l0\", Location)\n", + "l1 = Object(\"l1\", Location)\n", + "l2 = Object(\"l2\", Location)\n", "\n", "problem.add_objects((s0, w0, l0, l1, l2))\n", "\n", @@ -219,7 +225,7 @@ "problem.set_initial_value(is_supervisor_at(s0, l0), True)\n", "problem.set_initial_value(is_worker_at(w0, l0), True)\n", "\n", - "var_loc = Variable('l', Location)\n", + "var_loc = Variable(\"l\", Location)\n", "problem.add_goal(Forall(is_fixed(var_loc), var_loc))" ] }, diff --git a/docs/notebooks/14-task-and-motion-planning.ipynb b/docs/notebooks/14-task-and-motion-planning.ipynb index 91e236c6b..b3dab1f9b 100644 --- a/docs/notebooks/14-task-and-motion-planning.ipynb +++ b/docs/notebooks/14-task-and-motion-planning.ipynb @@ -89,7 +89,7 @@ }, "outputs": [], "source": [ - "occ_map = OccupancyMap(\"./maps/office-map-1.yaml\", (0, 0))\n" + "occ_map = OccupancyMap(\"./maps/office-map-1.yaml\", (0, 0))" ] }, { @@ -136,7 +136,9 @@ "t_parcel = UserType(\"parcel\")\n", "\n", "robot_at = Fluent(\"robot_at\", BoolType(), robot=t_robot, configuration=t_robot_config)\n", - "parcel_at = Fluent(\"parcel_at\", BoolType(), parcel=t_parcel, configuration=t_robot_config)\n", + "parcel_at = Fluent(\n", + " \"parcel_at\", BoolType(), parcel=t_parcel, configuration=t_robot_config\n", + ")\n", "carries = Fluent(\"carries\", BoolType(), robot=t_robot, parcel=t_parcel)" ] }, @@ -159,17 +161,17 @@ }, "outputs": [], "source": [ - "park1 = ConfigurationObject(\"parking-1\", t_robot_config, (46.0, 26.0, 3*math.pi/2))\n", - "park2 = ConfigurationObject(\"parking-2\", t_robot_config, (40.0, 26.0, 3*math.pi/2))\n", - "\n", - "office1 = ConfigurationObject(\"office-1\", t_robot_config, (4.0, 4.0, 3*math.pi/2))\n", - "office2 = ConfigurationObject(\"office-2\", t_robot_config, (14.0, 4.0, math.pi/2))\n", - "office3 = ConfigurationObject(\"office-3\", t_robot_config, (24.0, 4.0, 3*math.pi/2))\n", - "office4 = ConfigurationObject(\"office-4\", t_robot_config, (32.0, 4.0, 3*math.pi/2))\n", - "office5 = ConfigurationObject(\"office-5\", t_robot_config, (4.0, 24.0, 3*math.pi/2))\n", - "office6 = ConfigurationObject(\"office-6\", t_robot_config, (14.0, 24.0, math.pi/2))\n", - "office7 = ConfigurationObject(\"office-7\", t_robot_config, (24.0, 24.0, math.pi/2))\n", - "office8 = ConfigurationObject(\"office-8\", t_robot_config, (32.0, 24.0, math.pi/2))" + "park1 = ConfigurationObject(\"parking-1\", t_robot_config, (46.0, 26.0, 3 * math.pi / 2))\n", + "park2 = ConfigurationObject(\"parking-2\", t_robot_config, (40.0, 26.0, 3 * math.pi / 2))\n", + "\n", + "office1 = ConfigurationObject(\"office-1\", t_robot_config, (4.0, 4.0, 3 * math.pi / 2))\n", + "office2 = ConfigurationObject(\"office-2\", t_robot_config, (14.0, 4.0, math.pi / 2))\n", + "office3 = ConfigurationObject(\"office-3\", t_robot_config, (24.0, 4.0, 3 * math.pi / 2))\n", + "office4 = ConfigurationObject(\"office-4\", t_robot_config, (32.0, 4.0, 3 * math.pi / 2))\n", + "office5 = ConfigurationObject(\"office-5\", t_robot_config, (4.0, 24.0, 3 * math.pi / 2))\n", + "office6 = ConfigurationObject(\"office-6\", t_robot_config, (14.0, 24.0, math.pi / 2))\n", + "office7 = ConfigurationObject(\"office-7\", t_robot_config, (24.0, 24.0, math.pi / 2))\n", + "office8 = ConfigurationObject(\"office-8\", t_robot_config, (32.0, 24.0, math.pi / 2))" ] }, { @@ -266,7 +268,7 @@ "move.add_precondition(robot_at(robot, c_from))\n", "move.add_effect(robot_at(robot, c_from), False)\n", "move.add_effect(robot_at(robot, c_to), True)\n", - "move.add_motion_constraint(Waypoints(robot, c_from, [c_to]))\n" + "move.add_motion_constraint(Waypoints(robot, c_from, [c_to]))" ] }, { @@ -334,8 +336,7 @@ "place.add_precondition(Not(carries(place_robot, nothing)))\n", "place.add_effect(carries(place_robot, place_parcel), False)\n", "place.add_effect(carries(place_robot, nothing), True)\n", - "place.add_effect(parcel_at(place_parcel, place_loc), True)\n", - "\n" + "place.add_effect(parcel_at(place_parcel, place_loc), True)" ] }, { @@ -394,7 +395,7 @@ "\n", "problem.add_goal(robot_at(r1, park1))\n", "problem.add_goal(parcel_at(p1, office2))\n", - "problem.add_goal(parcel_at(p2, office3))\n" + "problem.add_goal(parcel_at(p2, office3))" ] }, { @@ -479,9 +480,9 @@ " print(a)\n", " print(a.motion_paths)\n", "\n", - " \n", + "\n", "else:\n", - " print(\"NO-PLAN-FOUND\")\n" + " print(\"NO-PLAN-FOUND\")" ] }, { diff --git a/docs/notebooks/io/01-pddl-usage-example.ipynb b/docs/notebooks/io/01-pddl-usage-example.ipynb index 8ca8cff53..fc345f84e 100644 --- a/docs/notebooks/io/01-pddl-usage-example.ipynb +++ b/docs/notebooks/io/01-pddl-usage-example.ipynb @@ -151,7 +151,9 @@ "from unified_planning.io import PDDLReader, PDDLWriter\n", "\n", "reader = PDDLReader()\n", - "pddl_problem = reader.parse_problem('/tmp/counters_domain.pddl', '/tmp/counters_problem.pddl')\n", + "pddl_problem = reader.parse_problem(\n", + " \"/tmp/counters_domain.pddl\", \"/tmp/counters_problem.pddl\"\n", + ")\n", "print(pddl_problem)" ] }, @@ -283,25 +285,33 @@ } ], "source": [ - "# Domain is a up.model.Problem that contains only the pddl domain. \n", - "domain = reader.parse_problem('/tmp/counters_domain.pddl', None) # None is the default, so it can be avoided\n", - "counter_type = domain.user_type(\"counter\") # get the counter type\n", - "domain.set_initial_value(domain.fluent(\"max_int\"), 10) # initialize the fluent \"max_int\"\n", - "value_fluent = domain.fluent(\"value\") # get the \"value\" fluent\n", + "# Domain is a up.model.Problem that contains only the pddl domain.\n", + "domain = reader.parse_problem(\n", + " \"/tmp/counters_domain.pddl\", None\n", + ") # None is the default, so it can be avoided\n", + "counter_type = domain.user_type(\"counter\") # get the counter type\n", + "domain.set_initial_value(\n", + " domain.fluent(\"max_int\"), 10\n", + ") # initialize the fluent \"max_int\"\n", + "value_fluent = domain.fluent(\"value\") # get the \"value\" fluent\n", "for i in range(4, 6):\n", - " problem = domain.clone() # Clone the parsed domain, then populate it\n", + " problem = domain.clone() # Clone the parsed domain, then populate it\n", " # Populate the problem. \"j\" iterates in [0, i], creates an object of type\n", " # \"counter\", sets it's initial value to 0, and then sets the goal:\n", - " # \"value(c{j-1}) + 1 <= value(c{j})\". \n", + " # \"value(c{j-1}) + 1 <= value(c{j})\".\n", " # This means that every value of the added objects must be\n", " # at least 1 bigger than the object added before.\n", " for j in range(i + 1):\n", - " object_j = problem.add_object(f\"c{str(j)}\", counter_type) # Create and add object\n", - " problem.set_initial_value(value_fluent(object_j), 0) # Set the initial value of \"value(object)\" to 0\n", - " if j > 0: \n", - " previous_object = problem.object(f\"c{str(j-1)}\") # Get previous object\n", - " problem.add_goal( # Add the goal \"value(c{j-1})+1 <= value(c{j})\"\n", - " value_fluent(previous_object)+1 <= value_fluent(object_j),\n", + " object_j = problem.add_object(\n", + " f\"c{str(j)}\", counter_type\n", + " ) # Create and add object\n", + " problem.set_initial_value(\n", + " value_fluent(object_j), 0\n", + " ) # Set the initial value of \"value(object)\" to 0\n", + " if j > 0:\n", + " previous_object = problem.object(f\"c{str(j-1)}\") # Get previous object\n", + " problem.add_goal( # Add the goal \"value(c{j-1})+1 <= value(c{j})\"\n", + " value_fluent(previous_object) + 1 <= value_fluent(object_j),\n", " )\n", " print(problem)" ] @@ -338,8 +348,8 @@ "outputs": [], "source": [ "w = PDDLWriter(problem)\n", - "w.write_domain('/tmp/written_counters_domain.pddl')\n", - "w.write_problem('/tmp/written_counters_problem.pddl')" + "w.write_domain(\"/tmp/written_counters_domain.pddl\")\n", + "w.write_problem(\"/tmp/written_counters_problem.pddl\")" ] }, { diff --git a/docs/notebooks/io/02-mapddl-writer-example.ipynb b/docs/notebooks/io/02-mapddl-writer-example.ipynb index 8834255b2..4838623d2 100644 --- a/docs/notebooks/io/02-mapddl-writer-example.ipynb +++ b/docs/notebooks/io/02-mapddl-writer-example.ipynb @@ -84,8 +84,8 @@ "package = UserType(\"package\", object)\n", "city = UserType(\"city\", object)\n", "airport = UserType(\"airport\", location)\n", - "truck_ = UserType(\"truck_\", vehicle) \n", - "airplane_ = UserType(\"airplane_\", vehicle) \n", + "truck_ = UserType(\"truck_\", vehicle)\n", + "airplane_ = UserType(\"airplane_\", vehicle)\n", "\n", "\n", "pos = Fluent(\"pos\", location=location)\n", @@ -124,7 +124,9 @@ "unload_truck.add_effect(at(obj, loc), True)\n", "\n", "\n", - "drive_truck = InstantaneousAction(\"drive_truck\", loc_from=location, loc_to=location, city_=city)\n", + "drive_truck = InstantaneousAction(\n", + " \"drive_truck\", loc_from=location, loc_to=location, city_=city\n", + ")\n", "loc_from = drive_truck.parameter(\"loc_from\")\n", "loc_to = drive_truck.parameter(\"loc_to\")\n", "city_ = drive_truck.parameter(\"city_\")\n", @@ -134,7 +136,7 @@ "drive_truck.add_effect(pos(loc_from), False)\n", "drive_truck.add_effect(pos(loc_to), True)\n", "\n", - "load_airplane = InstantaneousAction(\"load_airplane\", loc = airport, obj=package)\n", + "load_airplane = InstantaneousAction(\"load_airplane\", loc=airport, obj=package)\n", "loc = load_airplane.parameter(\"loc\")\n", "obj = load_airplane.parameter(\"obj\")\n", "load_airplane.add_precondition(at(obj, loc))\n", @@ -142,7 +144,7 @@ "load_airplane.add_effect(at(obj, loc), False)\n", "load_airplane.add_effect(on(obj), True)\n", "\n", - "unload_airplane = InstantaneousAction(\"unload_airplane\", loc = airport, obj=package)\n", + "unload_airplane = InstantaneousAction(\"unload_airplane\", loc=airport, obj=package)\n", "loc = load_airplane.parameter(\"loc\")\n", "obj = load_airplane.parameter(\"obj\")\n", "unload_airplane.add_precondition(on(obj))\n", @@ -171,7 +173,7 @@ "problem.add_agent(airplane)\n", "\n", "\n", - "#problem\n", + "# problem\n", "obj21 = Object(\"obj21\", package)\n", "obj22 = Object(\"obj22\", package)\n", "obj23 = Object(\"obj23\", package)\n", @@ -227,8 +229,8 @@ "problem.add_goal(at(obj21, pos1))\n", "\n", "w = MAPDDLWriter(problem)\n", - "w.write_ma_domain('logistic')\n", - "w.write_ma_problem('logistic')" + "w.write_ma_domain(\"logistic\")\n", + "w.write_ma_problem(\"logistic\")" ] }, { @@ -583,8 +585,8 @@ "outputs": [], "source": [ "w = MAPDDLWriter(problem)\n", - "w.write_ma_domain('ma_logistic_directory')\n", - "w.write_ma_problem('ma_logistic_directory')" + "w.write_ma_domain(\"ma_logistic_directory\")\n", + "w.write_ma_problem(\"ma_logistic_directory\")" ] }, { @@ -633,8 +635,8 @@ } ], "source": [ - "w.get_ma_domain_agent('truck1')\n", - "w.get_ma_problem_agent('airplane')" + "w.get_ma_domain_agent(\"truck1\")\n", + "w.get_ma_problem_agent(\"airplane\")" ] }, { @@ -744,8 +746,8 @@ } ], "source": [ - "w.print_ma_domain_agent('truck1')\n", - "w.print_ma_problem_agent('airplane')" + "w.print_ma_domain_agent(\"truck1\")\n", + "w.print_ma_problem_agent(\"airplane\")" ] } ], diff --git a/docs/notebooks/tutorial/modeling.ipynb b/docs/notebooks/tutorial/modeling.ipynb index f19fad07c..6502e3236 100644 --- a/docs/notebooks/tutorial/modeling.ipynb +++ b/docs/notebooks/tutorial/modeling.ipynb @@ -71,7 +71,7 @@ }, "outputs": [], "source": [ - "from unified_planning.shortcuts import * " + "from unified_planning.shortcuts import *" ] }, { @@ -388,7 +388,9 @@ "outputs": [], "source": [ "problem.add_object(\"Mum\", person)\n", - "problem.add_objects(Object(name, conference_attendee) for name in (\"Andrea\", \"Arthur\", \"Sebastian\"))\n", + "problem.add_objects(\n", + " Object(name, conference_attendee) for name in (\"Andrea\", \"Arthur\", \"Sebastian\")\n", + ")\n", "problem.add_objects(Object(name, location) for name in (\"Trento\", \"Toulouse\", \"Bremen\"))" ] }, @@ -519,10 +521,15 @@ }, "outputs": [], "source": [ - "initially_at = [(\"Andrea\", \"Trento\"), (\"Arthur\", \"Toulouse\"), (\"Sebastian\", \"Bremen\"),\n", - " (\"Gabi\", \"Basel\"), (\"Mum\", \"Basel\")]\n", + "initially_at = [\n", + " (\"Andrea\", \"Trento\"),\n", + " (\"Arthur\", \"Toulouse\"),\n", + " (\"Sebastian\", \"Bremen\"),\n", + " (\"Gabi\", \"Basel\"),\n", + " (\"Mum\", \"Basel\"),\n", + "]\n", "for name, loc in initially_at:\n", - " problem.set_initial_value(fluent_at(problem.object(name)), problem.object(loc))\n" + " problem.set_initial_value(fluent_at(problem.object(name)), problem.object(loc))" ] }, { @@ -654,7 +661,7 @@ } ], "source": [ - "travel = InstantaneousAction('travel', p=person, l_from=location, l_to=location)\n", + "travel = InstantaneousAction(\"travel\", p=person, l_from=location, l_to=location)\n", "p = travel.p\n", "l_from = travel.l_from\n", "l_to = travel.l_to\n", @@ -695,8 +702,10 @@ "travel_cost = Fluent(\"travel_cost\", IntType(), from_loc=location, to_loc=location)\n", "problem.add_fluent(travel_cost, default_initial_value=Int(0))\n", "\n", - "for loc1, loc2 in itertools.combinations([\"Prague\", \"Trento\", \"Toulouse\", \"Bremen\", \"Basel\"], 2):\n", - " dist = randint(1,100)\n", + "for loc1, loc2 in itertools.combinations(\n", + " [\"Prague\", \"Trento\", \"Toulouse\", \"Bremen\", \"Basel\"], 2\n", + "):\n", + " dist = randint(1, 100)\n", " l1 = problem.object(loc1)\n", " l2 = problem.object(loc2)\n", " problem.set_initial_value(travel_cost(l1, l2), Int(dist))\n", @@ -724,7 +733,9 @@ }, "outputs": [], "source": [ - "m = MinimizeActionCosts({travel : travel_cost(travel.l_from, travel.l_to)}, default=Int(1))\n", + "m = MinimizeActionCosts(\n", + " {travel: travel_cost(travel.l_from, travel.l_to)}, default=Int(1)\n", + ")\n", "problem.clear_quality_metrics()\n", "problem.add_quality_metric(m)" ] @@ -813,8 +824,8 @@ ], "source": [ "with OneshotPlanner(problem_kind=problem.kind) as planner:\n", - " res = planner.solve(problem)\n", - " print(res) " + " res = planner.solve(problem)\n", + " print(res)" ] }, { @@ -843,12 +854,11 @@ "outputs": [], "source": [ "with Compiler(\n", - " problem_kind = problem.kind,\n", - " compilation_kind = CompilationKind.USERTYPE_FLUENTS_REMOVING\n", - " ) as usertype_remover:\n", + " problem_kind=problem.kind,\n", + " compilation_kind=CompilationKind.USERTYPE_FLUENTS_REMOVING,\n", + ") as usertype_remover:\n", " utr_result = usertype_remover.compile(\n", - " problem,\n", - " CompilationKind.USERTYPE_FLUENTS_REMOVING\n", + " problem, CompilationKind.USERTYPE_FLUENTS_REMOVING\n", " )" ] }, @@ -1076,7 +1086,7 @@ ], "source": [ "with OneshotPlanner(problem_kind=utr_problem.kind) as planner:\n", - " res = planner.solve(utr_problem)" + " res = planner.solve(utr_problem)" ] }, { @@ -1286,9 +1296,11 @@ "source": [ "from unified_planning.engines import PlanGenerationResultStatus\n", "\n", - "with OneshotPlanner(problem_kind=utr_problem.kind,\n", - " optimality_guarantee=PlanGenerationResultStatus.SOLVED_OPTIMALLY) as planner:\n", - " res = planner.solve(utr_problem)\n" + "with OneshotPlanner(\n", + " problem_kind=utr_problem.kind,\n", + " optimality_guarantee=PlanGenerationResultStatus.SOLVED_OPTIMALLY,\n", + ") as planner:\n", + " res = planner.solve(utr_problem)" ] }, { @@ -1357,7 +1369,7 @@ "can_beam = Fluent(\"can_beam\", BoolType(), p=person)\n", "\n", "\n", - "beam = InstantaneousAction('beam_persons_to_prague')\n", + "beam = InstantaneousAction(\"beam_persons_to_prague\")\n", "# reminder: a was a variable of type person\n", "beam.add_precondition(Exists(Not(Equals(fluent_at(a), prague)), a))\n", "beam.add_effect(fluent_at(a), prague, condition=can_beam(a), forall=[a])\n", @@ -1406,7 +1418,7 @@ } ], "source": [ - "help(beam.add_effect) # also try beam.add_effect" + "help(beam.add_effect) # also try beam.add_effect" ] }, { @@ -1580,11 +1592,13 @@ ], "source": [ "problem.clear_quality_metrics()\n", - "m = MaximizeExpressionOnFinalState(acceptable_changes(problem.object(\"Andrea\")) +\n", - " acceptable_changes(problem.object(\"Sebastian\")) +\n", - " acceptable_changes(problem.object(\"Arthur\")) +\n", - " acceptable_changes(problem.object(\"Gabi\")) -\n", - " total_travel_time()/100)\n", + "m = MaximizeExpressionOnFinalState(\n", + " acceptable_changes(problem.object(\"Andrea\"))\n", + " + acceptable_changes(problem.object(\"Sebastian\"))\n", + " + acceptable_changes(problem.object(\"Arthur\"))\n", + " + acceptable_changes(problem.object(\"Gabi\"))\n", + " - total_travel_time() / 100\n", + ")\n", "problem.add_quality_metric(m)\n", "m" ] @@ -1620,17 +1634,16 @@ ], "source": [ "with Compiler(\n", - " problem_kind = problem.kind,\n", - " compilation_kind = CompilationKind.USERTYPE_FLUENTS_REMOVING\n", - " ) as usertype_remover:\n", + " problem_kind=problem.kind,\n", + " compilation_kind=CompilationKind.USERTYPE_FLUENTS_REMOVING,\n", + ") as usertype_remover:\n", " utr_result = usertype_remover.compile(\n", - " problem,\n", - " CompilationKind.USERTYPE_FLUENTS_REMOVING\n", + " problem, CompilationKind.USERTYPE_FLUENTS_REMOVING\n", " )\n", "utr_problem = utr_result.problem\n", "with OneshotPlanner(problem_kind=utr_problem.kind) as planner:\n", - " res = planner.solve(utr_problem)\n", - " print(res) " + " res = planner.solve(utr_problem)\n", + " print(res)" ] } ], diff --git a/docs/notebooks/tutorial/planner-integration.ipynb b/docs/notebooks/tutorial/planner-integration.ipynb index 75e0ed421..39a40ad55 100644 --- a/docs/notebooks/tutorial/planner-integration.ipynb +++ b/docs/notebooks/tutorial/planner-integration.ipynb @@ -63,14 +63,14 @@ "import unified_planning as up\n", "from unified_planning import engines\n", "\n", - "class MySolverImpl(up.engines.Engine,\n", - " up.engines.mixins.OneshotPlannerMixin):\n", + "\n", + "class MySolverImpl(up.engines.Engine, up.engines.mixins.OneshotPlannerMixin):\n", " def __init__(self, **options):\n", " # Read known user-options and store them for using in the `solve` method\n", " up.engines.Engine.__init__(self)\n", " up.engines.mixins.OneshotPlannerMixin.__init__(self)\n", - " self.max_tries = options.get('max_tries', None)\n", - " self.restart_probability = options.get('restart_probability', 0.00001)\n", + " self.max_tries = options.get(\"max_tries\", None)\n", + " self.restart_probability = options.get(\"restart_probability\", 0.00001)\n", "\n", " @property\n", " def name(self) -> str:\n", @@ -84,22 +84,22 @@ " supported_kind = up.model.ProblemKind()\n", " supported_kind.set_problem_class(\"ACTION_BASED\")\n", " supported_kind.set_problem_type(\"GENERAL_NUMERIC_PLANNING\")\n", - " supported_kind.set_typing('FLAT_TYPING')\n", - " supported_kind.set_typing('HIERARCHICAL_TYPING')\n", - " supported_kind.set_numbers('CONTINUOUS_NUMBERS')\n", - " supported_kind.set_numbers('DISCRETE_NUMBERS')\n", - " supported_kind.set_fluents_type('NUMERIC_FLUENTS')\n", - " supported_kind.set_numbers('BOUNDED_TYPES')\n", - " supported_kind.set_fluents_type('OBJECT_FLUENTS')\n", - " supported_kind.set_conditions_kind('NEGATIVE_CONDITIONS')\n", - " supported_kind.set_conditions_kind('DISJUNCTIVE_CONDITIONS')\n", - " supported_kind.set_conditions_kind('EQUALITIES')\n", - " supported_kind.set_conditions_kind('EXISTENTIAL_CONDITIONS')\n", - " supported_kind.set_conditions_kind('UNIVERSAL_CONDITIONS')\n", - " supported_kind.set_effects_kind('CONDITIONAL_EFFECTS')\n", - " supported_kind.set_effects_kind('INCREASE_EFFECTS')\n", - " supported_kind.set_effects_kind('DECREASE_EFFECTS')\n", - " supported_kind.set_effects_kind('FLUENTS_IN_NUMERIC_ASSIGNMENTS')\n", + " supported_kind.set_typing(\"FLAT_TYPING\")\n", + " supported_kind.set_typing(\"HIERARCHICAL_TYPING\")\n", + " supported_kind.set_numbers(\"CONTINUOUS_NUMBERS\")\n", + " supported_kind.set_numbers(\"DISCRETE_NUMBERS\")\n", + " supported_kind.set_fluents_type(\"NUMERIC_FLUENTS\")\n", + " supported_kind.set_numbers(\"BOUNDED_TYPES\")\n", + " supported_kind.set_fluents_type(\"OBJECT_FLUENTS\")\n", + " supported_kind.set_conditions_kind(\"NEGATIVE_CONDITIONS\")\n", + " supported_kind.set_conditions_kind(\"DISJUNCTIVE_CONDITIONS\")\n", + " supported_kind.set_conditions_kind(\"EQUALITIES\")\n", + " supported_kind.set_conditions_kind(\"EXISTENTIAL_CONDITIONS\")\n", + " supported_kind.set_conditions_kind(\"UNIVERSAL_CONDITIONS\")\n", + " supported_kind.set_effects_kind(\"CONDITIONAL_EFFECTS\")\n", + " supported_kind.set_effects_kind(\"INCREASE_EFFECTS\")\n", + " supported_kind.set_effects_kind(\"DECREASE_EFFECTS\")\n", + " supported_kind.set_effects_kind(\"FLUENTS_IN_NUMERIC_ASSIGNMENTS\")\n", "\n", " return supported_kind\n", "\n", @@ -107,27 +107,35 @@ " def supports(problem_kind):\n", " return problem_kind <= MySolverImpl.supported_kind()\n", "\n", - " def _solve(self, problem: 'up.model.Problem',\n", - " callback: Optional[Callable[['up.engines.PlanGenerationResult'], None]] = None,\n", - " timeout: Optional[float] = None,\n", - " output_stream: Optional[IO[str]] = None) -> 'up.engines.PlanGenerationResult':\n", + " def _solve(\n", + " self,\n", + " problem: \"up.model.Problem\",\n", + " callback: Optional[Callable[[\"up.engines.PlanGenerationResult\"], None]] = None,\n", + " timeout: Optional[float] = None,\n", + " output_stream: Optional[IO[str]] = None,\n", + " ) -> \"up.engines.PlanGenerationResult\":\n", " env = problem.environment\n", "\n", " # First we ground the problem\n", - " with env.factory.Compiler(problem_kind=problem.kind, compilation_kind=up.engines.CompilationKind.GROUNDING) as grounder:\n", - " grounding_result = grounder.compile(problem, up.engines.CompilationKind.GROUNDING)\n", + " with env.factory.Compiler(\n", + " problem_kind=problem.kind,\n", + " compilation_kind=up.engines.CompilationKind.GROUNDING,\n", + " ) as grounder:\n", + " grounding_result = grounder.compile(\n", + " problem, up.engines.CompilationKind.GROUNDING\n", + " )\n", " grounded_problem = grounding_result.problem\n", - " \n", + "\n", " # We store the grounded actions in a list\n", " actions = list(grounded_problem.instantaneous_actions)\n", - " \n", + "\n", " # The candidate plan, initially empty\n", " plan = up.plans.SequentialPlan([])\n", "\n", " # Ask for an instance of a PlanValidator by name\n", - " # (`sequential_plan_validator` is a python implementation of the \n", + " # (`sequential_plan_validator` is a python implementation of the\n", " # PlanValidator operation mode offered by the UP library)\n", - " with env.factory.PlanValidator(name='sequential_plan_validator') as pv:\n", + " with env.factory.PlanValidator(name=\"sequential_plan_validator\") as pv:\n", " counter = 0\n", " while True:\n", " # With a certain probability, restart from scratch to avoid dead-ends\n", @@ -146,16 +154,22 @@ " if res:\n", " # If the plan is valid, lift the action instances and\n", " # return the resulting plan\n", - " resplan = plan.replace_action_instances(grounding_result.map_back_action_instance)\n", + " resplan = plan.replace_action_instances(\n", + " grounding_result.map_back_action_instance\n", + " )\n", " # Sanity check\n", " assert pv.validate(problem, resplan)\n", - " status = up.engines.PlanGenerationResultStatus.SOLVED_SATISFICING\n", - " return up.engines.PlanGenerationResult(status, resplan, self.name)\n", + " status = (\n", + " up.engines.PlanGenerationResultStatus.SOLVED_SATISFICING\n", + " )\n", + " return up.engines.PlanGenerationResult(\n", + " status, resplan, self.name\n", + " )\n", " else:\n", " # If the plan is invalid, check if the reason is action\n", " # applicability (as opposed to goal satisfaction)\n", " einfo = res.log_messages[0].message\n", - " if 'Goals' not in einfo:\n", + " if \"Goals\" not in einfo:\n", " # If the plan is not executable, remove the last action\n", " plan.actions.pop()\n", " # Limit the number of tries, according to the user specification\n", @@ -197,7 +211,7 @@ "outputs": [], "source": [ "env = up.environment.get_environment()\n", - "env.factory.add_engine('yoloplanner', __name__, 'MySolverImpl')" + "env.factory.add_engine(\"yoloplanner\", __name__, \"MySolverImpl\")" ] }, { @@ -228,14 +242,14 @@ "metadata": {}, "outputs": [], "source": [ - "from unified_planning.shortcuts import * \n", + "from unified_planning.shortcuts import *\n", "\n", - "problem = Problem('robot')\n", - "Location = UserType('Location')\n", - "robot_at = problem.add_fluent('robot_at', BoolType(), loc=Location)\n", - "battery_charge = problem.add_fluent('battery_charge', RealType(0, 100))\n", + "problem = Problem(\"robot\")\n", + "Location = UserType(\"Location\")\n", + "robot_at = problem.add_fluent(\"robot_at\", BoolType(), loc=Location)\n", + "battery_charge = problem.add_fluent(\"battery_charge\", RealType(0, 100))\n", "\n", - "move = InstantaneousAction('move', l_from=Location, l_to=Location)\n", + "move = InstantaneousAction(\"move\", l_from=Location, l_to=Location)\n", "l_from = move.l_from\n", "l_to = move.l_to\n", "move.add_precondition(battery_charge >= 10)\n", @@ -246,8 +260,8 @@ "move.add_effect(battery_charge, battery_charge - 10)\n", "problem.add_action(move)\n", "\n", - "l1 = problem.add_object('l1', Location)\n", - "l2 = problem.add_object('l2', Location)\n", + "l1 = problem.add_object(\"l1\", Location)\n", + "l2 = problem.add_object(\"l2\", Location)\n", "problem.set_initial_value(robot_at(l1), True)\n", "problem.set_initial_value(robot_at(l2), False)\n", "problem.set_initial_value(battery_charge, 100)\n", @@ -279,13 +293,13 @@ } ], "source": [ - "with OneshotPlanner(name='yoloplanner', params = {'max_tries' : 5}) as p:\n", + "with OneshotPlanner(name=\"yoloplanner\", params={\"max_tries\": 5}) as p:\n", " result = p.solve(problem)\n", " if result.status == up.engines.PlanGenerationResultStatus.SOLVED_SATISFICING:\n", - " print(f'{p.name} found a valid plan!')\n", + " print(f\"{p.name} found a valid plan!\")\n", " print(result.plan)\n", " else:\n", - " print('No plan found!')\n" + " print(\"No plan found!\")" ] } ], diff --git a/unified_planning/engines/compilers/bounded_types_remover.py b/unified_planning/engines/compilers/bounded_types_remover.py index 06be39a35..ba5a580ba 100644 --- a/unified_planning/engines/compilers/bounded_types_remover.py +++ b/unified_planning/engines/compilers/bounded_types_remover.py @@ -163,7 +163,6 @@ def _compile( new_fluents: Dict[Fluent, Fluent] = {} for old_fluent in problem.fluents: - new_fluent = None # old_fluent.type != int_type is used to check if the type of the old_fluent # has lower or upper bound diff --git a/unified_planning/grpc/generated/unified_planning_pb2.py b/unified_planning/grpc/generated/unified_planning_pb2.py index adcc56996..d24680ea2 100644 --- a/unified_planning/grpc/generated/unified_planning_pb2.py +++ b/unified_planning/grpc/generated/unified_planning_pb2.py @@ -6,158 +6,158 @@ from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database + # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x16unified_planning.proto\"i\n\nExpression\x12\x13\n\x04\x61tom\x18\x01 \x01(\x0b\x32\x05.Atom\x12\x19\n\x04list\x18\x02 \x03(\x0b\x32\x0b.Expression\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x1d\n\x04kind\x18\x04 \x01(\x0e\x32\x0f.ExpressionKind\"\\\n\x04\x41tom\x12\x10\n\x06symbol\x18\x01 \x01(\tH\x00\x12\r\n\x03int\x18\x02 \x01(\x03H\x00\x12\x15\n\x04real\x18\x03 \x01(\x0b\x32\x05.RealH\x00\x12\x11\n\x07\x62oolean\x18\x04 \x01(\x08H\x00\x42\t\n\x07\x63ontent\".\n\x04Real\x12\x11\n\tnumerator\x18\x01 \x01(\x03\x12\x13\n\x0b\x64\x65nominator\x18\x02 \x01(\x03\"9\n\x0fTypeDeclaration\x12\x11\n\ttype_name\x18\x01 \x01(\t\x12\x13\n\x0bparent_type\x18\x02 \x01(\t\"\'\n\tParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\"n\n\x06\x46luent\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nvalue_type\x18\x02 \x01(\t\x12\x1e\n\nparameters\x18\x03 \x03(\x0b\x32\n.Parameter\x12\"\n\rdefault_value\x18\x04 \x01(\x0b\x32\x0b.Expression\"/\n\x11ObjectDeclaration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t\"\xea\x01\n\x10\x45\x66\x66\x65\x63tExpression\x12*\n\x04kind\x18\x01 \x01(\x0e\x32\x1c.EffectExpression.EffectKind\x12\x1b\n\x06\x66luent\x18\x02 \x01(\x0b\x32\x0b.Expression\x12\x1a\n\x05value\x18\x03 \x01(\x0b\x32\x0b.Expression\x12\x1e\n\tcondition\x18\x04 \x01(\x0b\x32\x0b.Expression\x12\x1b\n\x06\x66orall\x18\x05 \x03(\x0b\x32\x0b.Expression\"4\n\nEffectKind\x12\n\n\x06\x41SSIGN\x10\x00\x12\x0c\n\x08INCREASE\x10\x01\x12\x0c\n\x08\x44\x45\x43REASE\x10\x02\"M\n\x06\x45\x66\x66\x65\x63t\x12!\n\x06\x65\x66\x66\x65\x63t\x18\x01 \x01(\x0b\x32\x11.EffectExpression\x12 \n\x0foccurrence_time\x18\x02 \x01(\x0b\x32\x07.Timing\"C\n\tCondition\x12\x19\n\x04\x63ond\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1b\n\x04span\x18\x02 \x01(\x0b\x32\r.TimeInterval\"\x8d\x01\n\x06\x41\x63tion\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1b\n\x08\x64uration\x18\x03 \x01(\x0b\x32\t.Duration\x12\x1e\n\nconditions\x18\x04 \x03(\x0b\x32\n.Condition\x12\x18\n\x07\x65\x66\x66\x65\x63ts\x18\x05 \x03(\x0b\x32\x07.Effect\"\x90\x01\n\tTimepoint\x12&\n\x04kind\x18\x01 \x01(\x0e\x32\x18.Timepoint.TimepointKind\x12\x14\n\x0c\x63ontainer_id\x18\x02 \x01(\t\"E\n\rTimepointKind\x12\x10\n\x0cGLOBAL_START\x10\x00\x12\x0e\n\nGLOBAL_END\x10\x01\x12\t\n\x05START\x10\x02\x12\x07\n\x03\x45ND\x10\x03\"=\n\x06Timing\x12\x1d\n\ttimepoint\x18\x01 \x01(\x0b\x32\n.Timepoint\x12\x14\n\x05\x64\x65lay\x18\x02 \x01(\x0b\x32\x05.Real\"o\n\x08Interval\x12\x14\n\x0cis_left_open\x18\x01 \x01(\x08\x12\x1a\n\x05lower\x18\x02 \x01(\x0b\x32\x0b.Expression\x12\x15\n\ris_right_open\x18\x03 \x01(\x08\x12\x1a\n\x05upper\x18\x04 \x01(\x0b\x32\x0b.Expression\"k\n\x0cTimeInterval\x12\x14\n\x0cis_left_open\x18\x01 \x01(\x08\x12\x16\n\x05lower\x18\x02 \x01(\x0b\x32\x07.Timing\x12\x15\n\ris_right_open\x18\x03 \x01(\x08\x12\x16\n\x05upper\x18\x04 \x01(\x0b\x32\x07.Timing\"5\n\x08\x44uration\x12)\n\x16\x63ontrollable_in_bounds\x18\x01 \x01(\x0b\x32\t.Interval\"G\n\x17\x41\x62stractTaskDeclaration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\"F\n\x04Task\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\ttask_name\x18\x02 \x01(\t\x12\x1f\n\nparameters\x18\x03 \x03(\x0b\x32\x0b.Expression\"\xaf\x01\n\x06Method\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1c\n\rachieved_task\x18\x03 \x01(\x0b\x32\x05.Task\x12\x17\n\x08subtasks\x18\x04 \x03(\x0b\x32\x05.Task\x12 \n\x0b\x63onstraints\x18\x05 \x03(\x0b\x32\x0b.Expression\x12\x1e\n\nconditions\x18\x06 \x03(\x0b\x32\n.Condition\"g\n\x0bTaskNetwork\x12\x1d\n\tvariables\x18\x01 \x03(\x0b\x32\n.Parameter\x12\x17\n\x08subtasks\x18\x02 \x03(\x0b\x32\x05.Task\x12 \n\x0b\x63onstraints\x18\x03 \x03(\x0b\x32\x0b.Expression\"\x83\x01\n\tHierarchy\x12\x30\n\x0e\x61\x62stract_tasks\x18\x01 \x03(\x0b\x32\x18.AbstractTaskDeclaration\x12\x18\n\x07methods\x18\x02 \x03(\x0b\x32\x07.Method\x12*\n\x14initial_task_network\x18\x03 \x01(\x0b\x32\x0c.TaskNetwork\"\xb1\x01\n\x08\x41\x63tivity\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1b\n\x08\x64uration\x18\x03 \x01(\x0b\x32\t.Duration\x12\x1e\n\nconditions\x18\x04 \x03(\x0b\x32\n.Condition\x12\x18\n\x07\x65\x66\x66\x65\x63ts\x18\x05 \x03(\x0b\x32\x07.Effect\x12 \n\x0b\x63onstraints\x18\x06 \x03(\x0b\x32\x0b.Expression\"u\n\x13SchedulingExtension\x12\x1d\n\nactivities\x18\x01 \x03(\x0b\x32\t.Activity\x12\x1d\n\tvariables\x18\x02 \x03(\x0b\x32\n.Parameter\x12 \n\x0b\x63onstraints\x18\x05 \x03(\x0b\x32\x0b.Expression\"\xa3\x01\n\x08Schedule\x12\x12\n\nactivities\x18\x01 \x03(\t\x12@\n\x14variable_assignments\x18\x02 \x03(\x0b\x32\".Schedule.VariableAssignmentsEntry\x1a\x41\n\x18VariableAssignmentsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x14\n\x05value\x18\x02 \x01(\x0b\x32\x05.Atom:\x02\x38\x01\"@\n\x04Goal\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1d\n\x06timing\x18\x02 \x01(\x0b\x32\r.TimeInterval\"R\n\x0bTimedEffect\x12!\n\x06\x65\x66\x66\x65\x63t\x18\x01 \x01(\x0b\x32\x11.EffectExpression\x12 \n\x0foccurrence_time\x18\x02 \x01(\x0b\x32\x07.Timing\"E\n\nAssignment\x12\x1b\n\x06\x66luent\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1a\n\x05value\x18\x02 \x01(\x0b\x32\x0b.Expression\"B\n\x0eGoalWithWeight\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x15\n\x06weight\x18\x02 \x01(\x0b\x32\x05.Real\"f\n\x13TimedGoalWithWeight\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1d\n\x06timing\x18\x02 \x01(\x0b\x32\r.TimeInterval\x12\x15\n\x06weight\x18\x03 \x01(\x0b\x32\x05.Real\"\x9c\x04\n\x06Metric\x12 \n\x04kind\x18\x01 \x01(\x0e\x32\x12.Metric.MetricKind\x12\x1f\n\nexpression\x18\x02 \x01(\x0b\x32\x0b.Expression\x12.\n\x0c\x61\x63tion_costs\x18\x03 \x03(\x0b\x32\x18.Metric.ActionCostsEntry\x12(\n\x13\x64\x65\x66\x61ult_action_cost\x18\x04 \x01(\x0b\x32\x0b.Expression\x12\x1e\n\x05goals\x18\x05 \x03(\x0b\x32\x0f.GoalWithWeight\x12)\n\x0btimed_goals\x18\x06 \x03(\x0b\x32\x14.TimedGoalWithWeight\x1a?\n\x10\x41\x63tionCostsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1a\n\x05value\x18\x02 \x01(\x0b\x32\x0b.Expression:\x02\x38\x01\"\xe8\x01\n\nMetricKind\x12\x19\n\x15MINIMIZE_ACTION_COSTS\x10\x00\x12#\n\x1fMINIMIZE_SEQUENTIAL_PLAN_LENGTH\x10\x01\x12\x15\n\x11MINIMIZE_MAKESPAN\x10\x02\x12&\n\"MINIMIZE_EXPRESSION_ON_FINAL_STATE\x10\x03\x12&\n\"MAXIMIZE_EXPRESSION_ON_FINAL_STATE\x10\x04\x12\x14\n\x10OVERSUBSCRIPTION\x10\x05\x12\x1d\n\x19TEMPORAL_OVERSUBSCRIPTION\x10\x06\"\x8c\x04\n\x07Problem\x12\x13\n\x0b\x64omain_name\x18\x01 \x01(\t\x12\x14\n\x0cproblem_name\x18\x02 \x01(\t\x12\x1f\n\x05types\x18\x03 \x03(\x0b\x32\x10.TypeDeclaration\x12\x18\n\x07\x66luents\x18\x04 \x03(\x0b\x32\x07.Fluent\x12#\n\x07objects\x18\x05 \x03(\x0b\x32\x12.ObjectDeclaration\x12\x18\n\x07\x61\x63tions\x18\x06 \x03(\x0b\x32\x07.Action\x12\"\n\rinitial_state\x18\x07 \x03(\x0b\x32\x0b.Assignment\x12#\n\rtimed_effects\x18\x08 \x03(\x0b\x32\x0c.TimedEffect\x12\x14\n\x05goals\x18\t \x03(\x0b\x32\x05.Goal\x12\x1a\n\x08\x66\x65\x61tures\x18\n \x03(\x0e\x32\x08.Feature\x12\x18\n\x07metrics\x18\x0b \x03(\x0b\x32\x07.Metric\x12\x1d\n\thierarchy\x18\x0c \x01(\x0b\x32\n.Hierarchy\x12\x32\n\x14scheduling_extension\x18\x11 \x01(\x0b\x32\x14.SchedulingExtension\x12+\n\x16trajectory_constraints\x18\r \x03(\x0b\x32\x0b.Expression\x12\x15\n\rdiscrete_time\x18\x0e \x01(\x08\x12\x18\n\x10self_overlapping\x18\x0f \x01(\x08\x12\x16\n\x07\x65psilon\x18\x10 \x01(\x0b\x32\x05.Real\"\x80\x01\n\x0e\x41\x63tionInstance\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tion_name\x18\x02 \x01(\t\x12\x19\n\nparameters\x18\x03 \x03(\x0b\x32\x05.Atom\x12\x19\n\nstart_time\x18\x04 \x01(\x0b\x32\x05.Real\x12\x17\n\x08\x65nd_time\x18\x05 \x01(\x0b\x32\x05.Real\"\xae\x01\n\x0eMethodInstance\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\x19\n\nparameters\x18\x03 \x03(\x0b\x32\x05.Atom\x12/\n\x08subtasks\x18\x06 \x03(\x0b\x32\x1d.MethodInstance.SubtasksEntry\x1a/\n\rSubtasksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x96\x01\n\rPlanHierarchy\x12\x31\n\nroot_tasks\x18\x01 \x03(\x0b\x32\x1d.PlanHierarchy.RootTasksEntry\x12 \n\x07methods\x18\x02 \x03(\x0b\x32\x0f.MethodInstance\x1a\x30\n\x0eRootTasksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"h\n\x04Plan\x12 \n\x07\x61\x63tions\x18\x01 \x03(\x0b\x32\x0f.ActionInstance\x12!\n\thierarchy\x18\x02 \x01(\x0b\x32\x0e.PlanHierarchy\x12\x1b\n\x08schedule\x18\x03 \x01(\x0b\x32\t.Schedule\"\x83\x02\n\x0bPlanRequest\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12*\n\x0fresolution_mode\x18\x02 \x01(\x0e\x32\x11.PlanRequest.Mode\x12\x0f\n\x07timeout\x18\x03 \x01(\x01\x12\x37\n\x0e\x65ngine_options\x18\x04 \x03(\x0b\x32\x1f.PlanRequest.EngineOptionsEntry\x1a\x34\n\x12\x45ngineOptionsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"-\n\x04Mode\x12\x0f\n\x0bSATISFIABLE\x10\x00\x12\x14\n\x10SOLVED_OPTIMALLY\x10\x01\"C\n\x11ValidationRequest\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12\x13\n\x04plan\x18\x02 \x01(\x0b\x32\x05.Plan\"{\n\nLogMessage\x12#\n\x05level\x18\x01 \x01(\x0e\x32\x14.LogMessage.LogLevel\x12\x0f\n\x07message\x18\x02 \x01(\t\"7\n\x08LogLevel\x12\t\n\x05\x44\x45\x42UG\x10\x00\x12\x08\n\x04INFO\x10\x01\x12\x0b\n\x07WARNING\x10\x02\x12\t\n\x05\x45RROR\x10\x03\"\xbf\x03\n\x14PlanGenerationResult\x12,\n\x06status\x18\x01 \x01(\x0e\x32\x1c.PlanGenerationResult.Status\x12\x13\n\x04plan\x18\x02 \x01(\x0b\x32\x05.Plan\x12\x33\n\x07metrics\x18\x03 \x03(\x0b\x32\".PlanGenerationResult.MetricsEntry\x12!\n\x0clog_messages\x18\x04 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x05 \x01(\x0b\x32\x07.Engine\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xc2\x01\n\x06Status\x12\x16\n\x12SOLVED_SATISFICING\x10\x00\x12\x14\n\x10SOLVED_OPTIMALLY\x10\x01\x12\x15\n\x11UNSOLVABLE_PROVEN\x10\x02\x12\x1b\n\x17UNSOLVABLE_INCOMPLETELY\x10\x03\x12\x0b\n\x07TIMEOUT\x10\r\x12\n\n\x06MEMOUT\x10\x0e\x12\x12\n\x0eINTERNAL_ERROR\x10\x0f\x12\x17\n\x13UNSUPPORTED_PROBLEM\x10\x10\x12\x10\n\x0cINTERMEDIATE\x10\x11\"\x16\n\x06\x45ngine\x12\x0c\n\x04name\x18\x01 \x01(\t\"\xa8\x02\n\x10ValidationResult\x12\x38\n\x06status\x18\x01 \x01(\x0e\x32(.ValidationResult.ValidationResultStatus\x12/\n\x07metrics\x18\x04 \x03(\x0b\x32\x1e.ValidationResult.MetricsEntry\x12!\n\x0clog_messages\x18\x02 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x03 \x01(\x0b\x32\x07.Engine\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"=\n\x16ValidationResultStatus\x12\t\n\x05VALID\x10\x00\x12\x0b\n\x07INVALID\x10\x01\x12\x0b\n\x07UNKNOWN\x10\x02\"\xc4\x02\n\x0e\x43ompilerResult\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12\x37\n\rmap_back_plan\x18\x02 \x03(\x0b\x32 .CompilerResult.MapBackPlanEntry\x12-\n\x07metrics\x18\x05 \x03(\x0b\x32\x1c.CompilerResult.MetricsEntry\x12!\n\x0clog_messages\x18\x03 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x04 \x01(\x0b\x32\x07.Engine\x1a\x43\n\x10MapBackPlanEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.ActionInstance:\x02\x38\x01\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\xb0\x01\n\x0e\x45xpressionKind\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0c\n\x08\x43ONSTANT\x10\x01\x12\r\n\tPARAMETER\x10\x02\x12\x0c\n\x08VARIABLE\x10\x07\x12\x11\n\rFLUENT_SYMBOL\x10\x03\x12\x13\n\x0f\x46UNCTION_SYMBOL\x10\x04\x12\x12\n\x0eSTATE_VARIABLE\x10\x05\x12\x18\n\x14\x46UNCTION_APPLICATION\x10\x06\x12\x10\n\x0c\x43ONTAINER_ID\x10\x08*\xd5\x0e\n\x07\x46\x65\x61ture\x12\x10\n\x0c\x41\x43TION_BASED\x10\x00\x12\x10\n\x0cHIERARCHICAL\x10\x1a\x12\x0e\n\nSCHEDULING\x10\x38\x12\x1b\n\x17SIMPLE_NUMERIC_PLANNING\x10\x1e\x12\x1c\n\x18GENERAL_NUMERIC_PLANNING\x10\x1f\x12\x13\n\x0f\x43ONTINUOUS_TIME\x10\x01\x12\x11\n\rDISCRETE_TIME\x10\x02\x12\'\n#INTERMEDIATE_CONDITIONS_AND_EFFECTS\x10\x03\x12#\n\x1f\x45XTERNAL_CONDITIONS_AND_EFFECTS\x10\'\x12\x11\n\rTIMED_EFFECTS\x10\x04\x12\x0f\n\x0bTIMED_GOALS\x10\x05\x12\x19\n\x15\x44URATION_INEQUALITIES\x10\x06\x12\x14\n\x10SELF_OVERLAPPING\x10/\x12\x1f\n\x1bSTATIC_FLUENTS_IN_DURATIONS\x10\x1b\x12\x18\n\x14\x46LUENTS_IN_DURATIONS\x10\x1c\x12\x17\n\x13REAL_TYPE_DURATIONS\x10>\x12\x16\n\x12INT_TYPE_DURATIONS\x10?\x12\x16\n\x12\x43ONTINUOUS_NUMBERS\x10\x07\x12\x14\n\x10\x44ISCRETE_NUMBERS\x10\x08\x12\x11\n\rBOUNDED_TYPES\x10&\x12\x17\n\x13NEGATIVE_CONDITIONS\x10\t\x12\x1a\n\x16\x44ISJUNCTIVE_CONDITIONS\x10\n\x12\x0e\n\nEQUALITIES\x10\x0b\x12\x1a\n\x16\x45XISTENTIAL_CONDITIONS\x10\x0c\x12\x18\n\x14UNIVERSAL_CONDITIONS\x10\r\x12\x17\n\x13\x43ONDITIONAL_EFFECTS\x10\x0e\x12\x14\n\x10INCREASE_EFFECTS\x10\x0f\x12\x14\n\x10\x44\x45\x43REASE_EFFECTS\x10\x10\x12)\n%STATIC_FLUENTS_IN_BOOLEAN_ASSIGNMENTS\x10)\x12)\n%STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS\x10*\x12(\n$STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS\x10\x39\x12\"\n\x1e\x46LUENTS_IN_BOOLEAN_ASSIGNMENTS\x10+\x12\"\n\x1e\x46LUENTS_IN_NUMERIC_ASSIGNMENTS\x10,\x12!\n\x1d\x46LUENTS_IN_OBJECT_ASSIGNMENTS\x10:\x12\x12\n\x0e\x46ORALL_EFFECTS\x10;\x12\x0f\n\x0b\x46LAT_TYPING\x10\x11\x12\x17\n\x13HIERARCHICAL_TYPING\x10\x12\x12\x13\n\x0fNUMERIC_FLUENTS\x10\x13\x12\x12\n\x0eOBJECT_FLUENTS\x10\x14\x12\x0f\n\x0bINT_FLUENTS\x10<\x12\x10\n\x0cREAL_FLUENTS\x10=\x12\x1a\n\x16\x42OOL_FLUENT_PARAMETERS\x10\x32\x12!\n\x1d\x42OUNDED_INT_FLUENT_PARAMETERS\x10\x33\x12\x1a\n\x16\x42OOL_ACTION_PARAMETERS\x10\x34\x12!\n\x1d\x42OUNDED_INT_ACTION_PARAMETERS\x10\x35\x12#\n\x1fUNBOUNDED_INT_ACTION_PARAMETERS\x10\x36\x12\x1a\n\x16REAL_ACTION_PARAMETERS\x10\x37\x12\x10\n\x0c\x41\x43TIONS_COST\x10\x15\x12\x0f\n\x0b\x46INAL_VALUE\x10\x16\x12\x0c\n\x08MAKESPAN\x10\x17\x12\x0f\n\x0bPLAN_LENGTH\x10\x18\x12\x14\n\x10OVERSUBSCRIPTION\x10\x1d\x12\x1d\n\x19TEMPORAL_OVERSUBSCRIPTION\x10(\x12\"\n\x1eSTATIC_FLUENTS_IN_ACTIONS_COST\x10-\x12\x1b\n\x17\x46LUENTS_IN_ACTIONS_COST\x10.\x12 \n\x1cREAL_NUMBERS_IN_ACTIONS_COST\x10@\x12\x1f\n\x1bINT_NUMBERS_IN_ACTIONS_COST\x10\x41\x12$\n REAL_NUMBERS_IN_OVERSUBSCRIPTION\x10\x42\x12#\n\x1fINT_NUMBERS_IN_OVERSUBSCRIPTION\x10\x43\x12\x15\n\x11SIMULATED_EFFECTS\x10\x19\x12\x1a\n\x16TRAJECTORY_CONSTRAINTS\x10\x30\x12\x14\n\x10STATE_INVARIANTS\x10\x31\x12\x18\n\x14METHOD_PRECONDITIONS\x10 \x12\x1c\n\x18TASK_NETWORK_CONSTRAINTS\x10!\x12\"\n\x1eINITIAL_TASK_NETWORK_VARIABLES\x10\"\x12\x14\n\x10TASK_ORDER_TOTAL\x10#\x12\x16\n\x12TASK_ORDER_PARTIAL\x10$\x12\x17\n\x13TASK_ORDER_TEMPORAL\x10%\x12\x1d\n\x19UNDEFINED_INITIAL_NUMERIC\x10\x44\x12\x1e\n\x1aUNDEFINED_INITIAL_SYMBOLIC\x10\x45\x32\xd8\x01\n\x0fUnifiedPlanning\x12\x34\n\x0bplanAnytime\x12\x0c.PlanRequest\x1a\x15.PlanGenerationResult0\x01\x12\x32\n\x0bplanOneShot\x12\x0c.PlanRequest\x1a\x15.PlanGenerationResult\x12\x35\n\x0cvalidatePlan\x12\x12.ValidationRequest\x1a\x11.ValidationResult\x12$\n\x07\x63ompile\x12\x08.Problem\x1a\x0f.CompilerResultb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n\x16unified_planning.proto"i\n\nExpression\x12\x13\n\x04\x61tom\x18\x01 \x01(\x0b\x32\x05.Atom\x12\x19\n\x04list\x18\x02 \x03(\x0b\x32\x0b.Expression\x12\x0c\n\x04type\x18\x03 \x01(\t\x12\x1d\n\x04kind\x18\x04 \x01(\x0e\x32\x0f.ExpressionKind"\\\n\x04\x41tom\x12\x10\n\x06symbol\x18\x01 \x01(\tH\x00\x12\r\n\x03int\x18\x02 \x01(\x03H\x00\x12\x15\n\x04real\x18\x03 \x01(\x0b\x32\x05.RealH\x00\x12\x11\n\x07\x62oolean\x18\x04 \x01(\x08H\x00\x42\t\n\x07\x63ontent".\n\x04Real\x12\x11\n\tnumerator\x18\x01 \x01(\x03\x12\x13\n\x0b\x64\x65nominator\x18\x02 \x01(\x03"9\n\x0fTypeDeclaration\x12\x11\n\ttype_name\x18\x01 \x01(\t\x12\x13\n\x0bparent_type\x18\x02 \x01(\t"\'\n\tParameter\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t"n\n\x06\x46luent\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nvalue_type\x18\x02 \x01(\t\x12\x1e\n\nparameters\x18\x03 \x03(\x0b\x32\n.Parameter\x12"\n\rdefault_value\x18\x04 \x01(\x0b\x32\x0b.Expression"/\n\x11ObjectDeclaration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\t"\xea\x01\n\x10\x45\x66\x66\x65\x63tExpression\x12*\n\x04kind\x18\x01 \x01(\x0e\x32\x1c.EffectExpression.EffectKind\x12\x1b\n\x06\x66luent\x18\x02 \x01(\x0b\x32\x0b.Expression\x12\x1a\n\x05value\x18\x03 \x01(\x0b\x32\x0b.Expression\x12\x1e\n\tcondition\x18\x04 \x01(\x0b\x32\x0b.Expression\x12\x1b\n\x06\x66orall\x18\x05 \x03(\x0b\x32\x0b.Expression"4\n\nEffectKind\x12\n\n\x06\x41SSIGN\x10\x00\x12\x0c\n\x08INCREASE\x10\x01\x12\x0c\n\x08\x44\x45\x43REASE\x10\x02"M\n\x06\x45\x66\x66\x65\x63t\x12!\n\x06\x65\x66\x66\x65\x63t\x18\x01 \x01(\x0b\x32\x11.EffectExpression\x12 \n\x0foccurrence_time\x18\x02 \x01(\x0b\x32\x07.Timing"C\n\tCondition\x12\x19\n\x04\x63ond\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1b\n\x04span\x18\x02 \x01(\x0b\x32\r.TimeInterval"\x8d\x01\n\x06\x41\x63tion\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1b\n\x08\x64uration\x18\x03 \x01(\x0b\x32\t.Duration\x12\x1e\n\nconditions\x18\x04 \x03(\x0b\x32\n.Condition\x12\x18\n\x07\x65\x66\x66\x65\x63ts\x18\x05 \x03(\x0b\x32\x07.Effect"\x90\x01\n\tTimepoint\x12&\n\x04kind\x18\x01 \x01(\x0e\x32\x18.Timepoint.TimepointKind\x12\x14\n\x0c\x63ontainer_id\x18\x02 \x01(\t"E\n\rTimepointKind\x12\x10\n\x0cGLOBAL_START\x10\x00\x12\x0e\n\nGLOBAL_END\x10\x01\x12\t\n\x05START\x10\x02\x12\x07\n\x03\x45ND\x10\x03"=\n\x06Timing\x12\x1d\n\ttimepoint\x18\x01 \x01(\x0b\x32\n.Timepoint\x12\x14\n\x05\x64\x65lay\x18\x02 \x01(\x0b\x32\x05.Real"o\n\x08Interval\x12\x14\n\x0cis_left_open\x18\x01 \x01(\x08\x12\x1a\n\x05lower\x18\x02 \x01(\x0b\x32\x0b.Expression\x12\x15\n\ris_right_open\x18\x03 \x01(\x08\x12\x1a\n\x05upper\x18\x04 \x01(\x0b\x32\x0b.Expression"k\n\x0cTimeInterval\x12\x14\n\x0cis_left_open\x18\x01 \x01(\x08\x12\x16\n\x05lower\x18\x02 \x01(\x0b\x32\x07.Timing\x12\x15\n\ris_right_open\x18\x03 \x01(\x08\x12\x16\n\x05upper\x18\x04 \x01(\x0b\x32\x07.Timing"5\n\x08\x44uration\x12)\n\x16\x63ontrollable_in_bounds\x18\x01 \x01(\x0b\x32\t.Interval"G\n\x17\x41\x62stractTaskDeclaration\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter"F\n\x04Task\x12\n\n\x02id\x18\x01 \x01(\t\x12\x11\n\ttask_name\x18\x02 \x01(\t\x12\x1f\n\nparameters\x18\x03 \x03(\x0b\x32\x0b.Expression"\xaf\x01\n\x06Method\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1c\n\rachieved_task\x18\x03 \x01(\x0b\x32\x05.Task\x12\x17\n\x08subtasks\x18\x04 \x03(\x0b\x32\x05.Task\x12 \n\x0b\x63onstraints\x18\x05 \x03(\x0b\x32\x0b.Expression\x12\x1e\n\nconditions\x18\x06 \x03(\x0b\x32\n.Condition"g\n\x0bTaskNetwork\x12\x1d\n\tvariables\x18\x01 \x03(\x0b\x32\n.Parameter\x12\x17\n\x08subtasks\x18\x02 \x03(\x0b\x32\x05.Task\x12 \n\x0b\x63onstraints\x18\x03 \x03(\x0b\x32\x0b.Expression"\x83\x01\n\tHierarchy\x12\x30\n\x0e\x61\x62stract_tasks\x18\x01 \x03(\x0b\x32\x18.AbstractTaskDeclaration\x12\x18\n\x07methods\x18\x02 \x03(\x0b\x32\x07.Method\x12*\n\x14initial_task_network\x18\x03 \x01(\x0b\x32\x0c.TaskNetwork"\xb1\x01\n\x08\x41\x63tivity\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x1e\n\nparameters\x18\x02 \x03(\x0b\x32\n.Parameter\x12\x1b\n\x08\x64uration\x18\x03 \x01(\x0b\x32\t.Duration\x12\x1e\n\nconditions\x18\x04 \x03(\x0b\x32\n.Condition\x12\x18\n\x07\x65\x66\x66\x65\x63ts\x18\x05 \x03(\x0b\x32\x07.Effect\x12 \n\x0b\x63onstraints\x18\x06 \x03(\x0b\x32\x0b.Expression"u\n\x13SchedulingExtension\x12\x1d\n\nactivities\x18\x01 \x03(\x0b\x32\t.Activity\x12\x1d\n\tvariables\x18\x02 \x03(\x0b\x32\n.Parameter\x12 \n\x0b\x63onstraints\x18\x05 \x03(\x0b\x32\x0b.Expression"\xa3\x01\n\x08Schedule\x12\x12\n\nactivities\x18\x01 \x03(\t\x12@\n\x14variable_assignments\x18\x02 \x03(\x0b\x32".Schedule.VariableAssignmentsEntry\x1a\x41\n\x18VariableAssignmentsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x14\n\x05value\x18\x02 \x01(\x0b\x32\x05.Atom:\x02\x38\x01"@\n\x04Goal\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1d\n\x06timing\x18\x02 \x01(\x0b\x32\r.TimeInterval"R\n\x0bTimedEffect\x12!\n\x06\x65\x66\x66\x65\x63t\x18\x01 \x01(\x0b\x32\x11.EffectExpression\x12 \n\x0foccurrence_time\x18\x02 \x01(\x0b\x32\x07.Timing"E\n\nAssignment\x12\x1b\n\x06\x66luent\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1a\n\x05value\x18\x02 \x01(\x0b\x32\x0b.Expression"B\n\x0eGoalWithWeight\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x15\n\x06weight\x18\x02 \x01(\x0b\x32\x05.Real"f\n\x13TimedGoalWithWeight\x12\x19\n\x04goal\x18\x01 \x01(\x0b\x32\x0b.Expression\x12\x1d\n\x06timing\x18\x02 \x01(\x0b\x32\r.TimeInterval\x12\x15\n\x06weight\x18\x03 \x01(\x0b\x32\x05.Real"\x9c\x04\n\x06Metric\x12 \n\x04kind\x18\x01 \x01(\x0e\x32\x12.Metric.MetricKind\x12\x1f\n\nexpression\x18\x02 \x01(\x0b\x32\x0b.Expression\x12.\n\x0c\x61\x63tion_costs\x18\x03 \x03(\x0b\x32\x18.Metric.ActionCostsEntry\x12(\n\x13\x64\x65\x66\x61ult_action_cost\x18\x04 \x01(\x0b\x32\x0b.Expression\x12\x1e\n\x05goals\x18\x05 \x03(\x0b\x32\x0f.GoalWithWeight\x12)\n\x0btimed_goals\x18\x06 \x03(\x0b\x32\x14.TimedGoalWithWeight\x1a?\n\x10\x41\x63tionCostsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1a\n\x05value\x18\x02 \x01(\x0b\x32\x0b.Expression:\x02\x38\x01"\xe8\x01\n\nMetricKind\x12\x19\n\x15MINIMIZE_ACTION_COSTS\x10\x00\x12#\n\x1fMINIMIZE_SEQUENTIAL_PLAN_LENGTH\x10\x01\x12\x15\n\x11MINIMIZE_MAKESPAN\x10\x02\x12&\n"MINIMIZE_EXPRESSION_ON_FINAL_STATE\x10\x03\x12&\n"MAXIMIZE_EXPRESSION_ON_FINAL_STATE\x10\x04\x12\x14\n\x10OVERSUBSCRIPTION\x10\x05\x12\x1d\n\x19TEMPORAL_OVERSUBSCRIPTION\x10\x06"\x8c\x04\n\x07Problem\x12\x13\n\x0b\x64omain_name\x18\x01 \x01(\t\x12\x14\n\x0cproblem_name\x18\x02 \x01(\t\x12\x1f\n\x05types\x18\x03 \x03(\x0b\x32\x10.TypeDeclaration\x12\x18\n\x07\x66luents\x18\x04 \x03(\x0b\x32\x07.Fluent\x12#\n\x07objects\x18\x05 \x03(\x0b\x32\x12.ObjectDeclaration\x12\x18\n\x07\x61\x63tions\x18\x06 \x03(\x0b\x32\x07.Action\x12"\n\rinitial_state\x18\x07 \x03(\x0b\x32\x0b.Assignment\x12#\n\rtimed_effects\x18\x08 \x03(\x0b\x32\x0c.TimedEffect\x12\x14\n\x05goals\x18\t \x03(\x0b\x32\x05.Goal\x12\x1a\n\x08\x66\x65\x61tures\x18\n \x03(\x0e\x32\x08.Feature\x12\x18\n\x07metrics\x18\x0b \x03(\x0b\x32\x07.Metric\x12\x1d\n\thierarchy\x18\x0c \x01(\x0b\x32\n.Hierarchy\x12\x32\n\x14scheduling_extension\x18\x11 \x01(\x0b\x32\x14.SchedulingExtension\x12+\n\x16trajectory_constraints\x18\r \x03(\x0b\x32\x0b.Expression\x12\x15\n\rdiscrete_time\x18\x0e \x01(\x08\x12\x18\n\x10self_overlapping\x18\x0f \x01(\x08\x12\x16\n\x07\x65psilon\x18\x10 \x01(\x0b\x32\x05.Real"\x80\x01\n\x0e\x41\x63tionInstance\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0b\x61\x63tion_name\x18\x02 \x01(\t\x12\x19\n\nparameters\x18\x03 \x03(\x0b\x32\x05.Atom\x12\x19\n\nstart_time\x18\x04 \x01(\x0b\x32\x05.Real\x12\x17\n\x08\x65nd_time\x18\x05 \x01(\x0b\x32\x05.Real"\xae\x01\n\x0eMethodInstance\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0bmethod_name\x18\x02 \x01(\t\x12\x19\n\nparameters\x18\x03 \x03(\x0b\x32\x05.Atom\x12/\n\x08subtasks\x18\x06 \x03(\x0b\x32\x1d.MethodInstance.SubtasksEntry\x1a/\n\rSubtasksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"\x96\x01\n\rPlanHierarchy\x12\x31\n\nroot_tasks\x18\x01 \x03(\x0b\x32\x1d.PlanHierarchy.RootTasksEntry\x12 \n\x07methods\x18\x02 \x03(\x0b\x32\x0f.MethodInstance\x1a\x30\n\x0eRootTasksEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"h\n\x04Plan\x12 \n\x07\x61\x63tions\x18\x01 \x03(\x0b\x32\x0f.ActionInstance\x12!\n\thierarchy\x18\x02 \x01(\x0b\x32\x0e.PlanHierarchy\x12\x1b\n\x08schedule\x18\x03 \x01(\x0b\x32\t.Schedule"\x83\x02\n\x0bPlanRequest\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12*\n\x0fresolution_mode\x18\x02 \x01(\x0e\x32\x11.PlanRequest.Mode\x12\x0f\n\x07timeout\x18\x03 \x01(\x01\x12\x37\n\x0e\x65ngine_options\x18\x04 \x03(\x0b\x32\x1f.PlanRequest.EngineOptionsEntry\x1a\x34\n\x12\x45ngineOptionsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"-\n\x04Mode\x12\x0f\n\x0bSATISFIABLE\x10\x00\x12\x14\n\x10SOLVED_OPTIMALLY\x10\x01"C\n\x11ValidationRequest\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12\x13\n\x04plan\x18\x02 \x01(\x0b\x32\x05.Plan"{\n\nLogMessage\x12#\n\x05level\x18\x01 \x01(\x0e\x32\x14.LogMessage.LogLevel\x12\x0f\n\x07message\x18\x02 \x01(\t"7\n\x08LogLevel\x12\t\n\x05\x44\x45\x42UG\x10\x00\x12\x08\n\x04INFO\x10\x01\x12\x0b\n\x07WARNING\x10\x02\x12\t\n\x05\x45RROR\x10\x03"\xbf\x03\n\x14PlanGenerationResult\x12,\n\x06status\x18\x01 \x01(\x0e\x32\x1c.PlanGenerationResult.Status\x12\x13\n\x04plan\x18\x02 \x01(\x0b\x32\x05.Plan\x12\x33\n\x07metrics\x18\x03 \x03(\x0b\x32".PlanGenerationResult.MetricsEntry\x12!\n\x0clog_messages\x18\x04 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x05 \x01(\x0b\x32\x07.Engine\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"\xc2\x01\n\x06Status\x12\x16\n\x12SOLVED_SATISFICING\x10\x00\x12\x14\n\x10SOLVED_OPTIMALLY\x10\x01\x12\x15\n\x11UNSOLVABLE_PROVEN\x10\x02\x12\x1b\n\x17UNSOLVABLE_INCOMPLETELY\x10\x03\x12\x0b\n\x07TIMEOUT\x10\r\x12\n\n\x06MEMOUT\x10\x0e\x12\x12\n\x0eINTERNAL_ERROR\x10\x0f\x12\x17\n\x13UNSUPPORTED_PROBLEM\x10\x10\x12\x10\n\x0cINTERMEDIATE\x10\x11"\x16\n\x06\x45ngine\x12\x0c\n\x04name\x18\x01 \x01(\t"\xa8\x02\n\x10ValidationResult\x12\x38\n\x06status\x18\x01 \x01(\x0e\x32(.ValidationResult.ValidationResultStatus\x12/\n\x07metrics\x18\x04 \x03(\x0b\x32\x1e.ValidationResult.MetricsEntry\x12!\n\x0clog_messages\x18\x02 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x03 \x01(\x0b\x32\x07.Engine\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"=\n\x16ValidationResultStatus\x12\t\n\x05VALID\x10\x00\x12\x0b\n\x07INVALID\x10\x01\x12\x0b\n\x07UNKNOWN\x10\x02"\xc4\x02\n\x0e\x43ompilerResult\x12\x19\n\x07problem\x18\x01 \x01(\x0b\x32\x08.Problem\x12\x37\n\rmap_back_plan\x18\x02 \x03(\x0b\x32 .CompilerResult.MapBackPlanEntry\x12-\n\x07metrics\x18\x05 \x03(\x0b\x32\x1c.CompilerResult.MetricsEntry\x12!\n\x0clog_messages\x18\x03 \x03(\x0b\x32\x0b.LogMessage\x12\x17\n\x06\x65ngine\x18\x04 \x01(\x0b\x32\x07.Engine\x1a\x43\n\x10MapBackPlanEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.ActionInstance:\x02\x38\x01\x1a.\n\x0cMetricsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01*\xb0\x01\n\x0e\x45xpressionKind\x12\x0b\n\x07UNKNOWN\x10\x00\x12\x0c\n\x08\x43ONSTANT\x10\x01\x12\r\n\tPARAMETER\x10\x02\x12\x0c\n\x08VARIABLE\x10\x07\x12\x11\n\rFLUENT_SYMBOL\x10\x03\x12\x13\n\x0f\x46UNCTION_SYMBOL\x10\x04\x12\x12\n\x0eSTATE_VARIABLE\x10\x05\x12\x18\n\x14\x46UNCTION_APPLICATION\x10\x06\x12\x10\n\x0c\x43ONTAINER_ID\x10\x08*\xd5\x0e\n\x07\x46\x65\x61ture\x12\x10\n\x0c\x41\x43TION_BASED\x10\x00\x12\x10\n\x0cHIERARCHICAL\x10\x1a\x12\x0e\n\nSCHEDULING\x10\x38\x12\x1b\n\x17SIMPLE_NUMERIC_PLANNING\x10\x1e\x12\x1c\n\x18GENERAL_NUMERIC_PLANNING\x10\x1f\x12\x13\n\x0f\x43ONTINUOUS_TIME\x10\x01\x12\x11\n\rDISCRETE_TIME\x10\x02\x12\'\n#INTERMEDIATE_CONDITIONS_AND_EFFECTS\x10\x03\x12#\n\x1f\x45XTERNAL_CONDITIONS_AND_EFFECTS\x10\'\x12\x11\n\rTIMED_EFFECTS\x10\x04\x12\x0f\n\x0bTIMED_GOALS\x10\x05\x12\x19\n\x15\x44URATION_INEQUALITIES\x10\x06\x12\x14\n\x10SELF_OVERLAPPING\x10/\x12\x1f\n\x1bSTATIC_FLUENTS_IN_DURATIONS\x10\x1b\x12\x18\n\x14\x46LUENTS_IN_DURATIONS\x10\x1c\x12\x17\n\x13REAL_TYPE_DURATIONS\x10>\x12\x16\n\x12INT_TYPE_DURATIONS\x10?\x12\x16\n\x12\x43ONTINUOUS_NUMBERS\x10\x07\x12\x14\n\x10\x44ISCRETE_NUMBERS\x10\x08\x12\x11\n\rBOUNDED_TYPES\x10&\x12\x17\n\x13NEGATIVE_CONDITIONS\x10\t\x12\x1a\n\x16\x44ISJUNCTIVE_CONDITIONS\x10\n\x12\x0e\n\nEQUALITIES\x10\x0b\x12\x1a\n\x16\x45XISTENTIAL_CONDITIONS\x10\x0c\x12\x18\n\x14UNIVERSAL_CONDITIONS\x10\r\x12\x17\n\x13\x43ONDITIONAL_EFFECTS\x10\x0e\x12\x14\n\x10INCREASE_EFFECTS\x10\x0f\x12\x14\n\x10\x44\x45\x43REASE_EFFECTS\x10\x10\x12)\n%STATIC_FLUENTS_IN_BOOLEAN_ASSIGNMENTS\x10)\x12)\n%STATIC_FLUENTS_IN_NUMERIC_ASSIGNMENTS\x10*\x12(\n$STATIC_FLUENTS_IN_OBJECT_ASSIGNMENTS\x10\x39\x12"\n\x1e\x46LUENTS_IN_BOOLEAN_ASSIGNMENTS\x10+\x12"\n\x1e\x46LUENTS_IN_NUMERIC_ASSIGNMENTS\x10,\x12!\n\x1d\x46LUENTS_IN_OBJECT_ASSIGNMENTS\x10:\x12\x12\n\x0e\x46ORALL_EFFECTS\x10;\x12\x0f\n\x0b\x46LAT_TYPING\x10\x11\x12\x17\n\x13HIERARCHICAL_TYPING\x10\x12\x12\x13\n\x0fNUMERIC_FLUENTS\x10\x13\x12\x12\n\x0eOBJECT_FLUENTS\x10\x14\x12\x0f\n\x0bINT_FLUENTS\x10<\x12\x10\n\x0cREAL_FLUENTS\x10=\x12\x1a\n\x16\x42OOL_FLUENT_PARAMETERS\x10\x32\x12!\n\x1d\x42OUNDED_INT_FLUENT_PARAMETERS\x10\x33\x12\x1a\n\x16\x42OOL_ACTION_PARAMETERS\x10\x34\x12!\n\x1d\x42OUNDED_INT_ACTION_PARAMETERS\x10\x35\x12#\n\x1fUNBOUNDED_INT_ACTION_PARAMETERS\x10\x36\x12\x1a\n\x16REAL_ACTION_PARAMETERS\x10\x37\x12\x10\n\x0c\x41\x43TIONS_COST\x10\x15\x12\x0f\n\x0b\x46INAL_VALUE\x10\x16\x12\x0c\n\x08MAKESPAN\x10\x17\x12\x0f\n\x0bPLAN_LENGTH\x10\x18\x12\x14\n\x10OVERSUBSCRIPTION\x10\x1d\x12\x1d\n\x19TEMPORAL_OVERSUBSCRIPTION\x10(\x12"\n\x1eSTATIC_FLUENTS_IN_ACTIONS_COST\x10-\x12\x1b\n\x17\x46LUENTS_IN_ACTIONS_COST\x10.\x12 \n\x1cREAL_NUMBERS_IN_ACTIONS_COST\x10@\x12\x1f\n\x1bINT_NUMBERS_IN_ACTIONS_COST\x10\x41\x12$\n REAL_NUMBERS_IN_OVERSUBSCRIPTION\x10\x42\x12#\n\x1fINT_NUMBERS_IN_OVERSUBSCRIPTION\x10\x43\x12\x15\n\x11SIMULATED_EFFECTS\x10\x19\x12\x1a\n\x16TRAJECTORY_CONSTRAINTS\x10\x30\x12\x14\n\x10STATE_INVARIANTS\x10\x31\x12\x18\n\x14METHOD_PRECONDITIONS\x10 \x12\x1c\n\x18TASK_NETWORK_CONSTRAINTS\x10!\x12"\n\x1eINITIAL_TASK_NETWORK_VARIABLES\x10"\x12\x14\n\x10TASK_ORDER_TOTAL\x10#\x12\x16\n\x12TASK_ORDER_PARTIAL\x10$\x12\x17\n\x13TASK_ORDER_TEMPORAL\x10%\x12\x1d\n\x19UNDEFINED_INITIAL_NUMERIC\x10\x44\x12\x1e\n\x1aUNDEFINED_INITIAL_SYMBOLIC\x10\x45\x32\xd8\x01\n\x0fUnifiedPlanning\x12\x34\n\x0bplanAnytime\x12\x0c.PlanRequest\x1a\x15.PlanGenerationResult0\x01\x12\x32\n\x0bplanOneShot\x12\x0c.PlanRequest\x1a\x15.PlanGenerationResult\x12\x35\n\x0cvalidatePlan\x12\x12.ValidationRequest\x1a\x11.ValidationResult\x12$\n\x07\x63ompile\x12\x08.Problem\x1a\x0f.CompilerResultb\x06proto3' +) _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'unified_planning_pb2', globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "unified_planning_pb2", globals()) if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - _SCHEDULE_VARIABLEASSIGNMENTSENTRY._options = None - _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_options = b'8\001' - _METRIC_ACTIONCOSTSENTRY._options = None - _METRIC_ACTIONCOSTSENTRY._serialized_options = b'8\001' - _METHODINSTANCE_SUBTASKSENTRY._options = None - _METHODINSTANCE_SUBTASKSENTRY._serialized_options = b'8\001' - _PLANHIERARCHY_ROOTTASKSENTRY._options = None - _PLANHIERARCHY_ROOTTASKSENTRY._serialized_options = b'8\001' - _PLANREQUEST_ENGINEOPTIONSENTRY._options = None - _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_options = b'8\001' - _PLANGENERATIONRESULT_METRICSENTRY._options = None - _PLANGENERATIONRESULT_METRICSENTRY._serialized_options = b'8\001' - _VALIDATIONRESULT_METRICSENTRY._options = None - _VALIDATIONRESULT_METRICSENTRY._serialized_options = b'8\001' - _COMPILERRESULT_MAPBACKPLANENTRY._options = None - _COMPILERRESULT_MAPBACKPLANENTRY._serialized_options = b'8\001' - _COMPILERRESULT_METRICSENTRY._options = None - _COMPILERRESULT_METRICSENTRY._serialized_options = b'8\001' - _EXPRESSIONKIND._serialized_start=6166 - _EXPRESSIONKIND._serialized_end=6342 - _FEATURE._serialized_start=6345 - _FEATURE._serialized_end=8222 - _EXPRESSION._serialized_start=26 - _EXPRESSION._serialized_end=131 - _ATOM._serialized_start=133 - _ATOM._serialized_end=225 - _REAL._serialized_start=227 - _REAL._serialized_end=273 - _TYPEDECLARATION._serialized_start=275 - _TYPEDECLARATION._serialized_end=332 - _PARAMETER._serialized_start=334 - _PARAMETER._serialized_end=373 - _FLUENT._serialized_start=375 - _FLUENT._serialized_end=485 - _OBJECTDECLARATION._serialized_start=487 - _OBJECTDECLARATION._serialized_end=534 - _EFFECTEXPRESSION._serialized_start=537 - _EFFECTEXPRESSION._serialized_end=771 - _EFFECTEXPRESSION_EFFECTKIND._serialized_start=719 - _EFFECTEXPRESSION_EFFECTKIND._serialized_end=771 - _EFFECT._serialized_start=773 - _EFFECT._serialized_end=850 - _CONDITION._serialized_start=852 - _CONDITION._serialized_end=919 - _ACTION._serialized_start=922 - _ACTION._serialized_end=1063 - _TIMEPOINT._serialized_start=1066 - _TIMEPOINT._serialized_end=1210 - _TIMEPOINT_TIMEPOINTKIND._serialized_start=1141 - _TIMEPOINT_TIMEPOINTKIND._serialized_end=1210 - _TIMING._serialized_start=1212 - _TIMING._serialized_end=1273 - _INTERVAL._serialized_start=1275 - _INTERVAL._serialized_end=1386 - _TIMEINTERVAL._serialized_start=1388 - _TIMEINTERVAL._serialized_end=1495 - _DURATION._serialized_start=1497 - _DURATION._serialized_end=1550 - _ABSTRACTTASKDECLARATION._serialized_start=1552 - _ABSTRACTTASKDECLARATION._serialized_end=1623 - _TASK._serialized_start=1625 - _TASK._serialized_end=1695 - _METHOD._serialized_start=1698 - _METHOD._serialized_end=1873 - _TASKNETWORK._serialized_start=1875 - _TASKNETWORK._serialized_end=1978 - _HIERARCHY._serialized_start=1981 - _HIERARCHY._serialized_end=2112 - _ACTIVITY._serialized_start=2115 - _ACTIVITY._serialized_end=2292 - _SCHEDULINGEXTENSION._serialized_start=2294 - _SCHEDULINGEXTENSION._serialized_end=2411 - _SCHEDULE._serialized_start=2414 - _SCHEDULE._serialized_end=2577 - _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_start=2512 - _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_end=2577 - _GOAL._serialized_start=2579 - _GOAL._serialized_end=2643 - _TIMEDEFFECT._serialized_start=2645 - _TIMEDEFFECT._serialized_end=2727 - _ASSIGNMENT._serialized_start=2729 - _ASSIGNMENT._serialized_end=2798 - _GOALWITHWEIGHT._serialized_start=2800 - _GOALWITHWEIGHT._serialized_end=2866 - _TIMEDGOALWITHWEIGHT._serialized_start=2868 - _TIMEDGOALWITHWEIGHT._serialized_end=2970 - _METRIC._serialized_start=2973 - _METRIC._serialized_end=3513 - _METRIC_ACTIONCOSTSENTRY._serialized_start=3215 - _METRIC_ACTIONCOSTSENTRY._serialized_end=3278 - _METRIC_METRICKIND._serialized_start=3281 - _METRIC_METRICKIND._serialized_end=3513 - _PROBLEM._serialized_start=3516 - _PROBLEM._serialized_end=4040 - _ACTIONINSTANCE._serialized_start=4043 - _ACTIONINSTANCE._serialized_end=4171 - _METHODINSTANCE._serialized_start=4174 - _METHODINSTANCE._serialized_end=4348 - _METHODINSTANCE_SUBTASKSENTRY._serialized_start=4301 - _METHODINSTANCE_SUBTASKSENTRY._serialized_end=4348 - _PLANHIERARCHY._serialized_start=4351 - _PLANHIERARCHY._serialized_end=4501 - _PLANHIERARCHY_ROOTTASKSENTRY._serialized_start=4453 - _PLANHIERARCHY_ROOTTASKSENTRY._serialized_end=4501 - _PLAN._serialized_start=4503 - _PLAN._serialized_end=4607 - _PLANREQUEST._serialized_start=4610 - _PLANREQUEST._serialized_end=4869 - _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_start=4770 - _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_end=4822 - _PLANREQUEST_MODE._serialized_start=4824 - _PLANREQUEST_MODE._serialized_end=4869 - _VALIDATIONREQUEST._serialized_start=4871 - _VALIDATIONREQUEST._serialized_end=4938 - _LOGMESSAGE._serialized_start=4940 - _LOGMESSAGE._serialized_end=5063 - _LOGMESSAGE_LOGLEVEL._serialized_start=5008 - _LOGMESSAGE_LOGLEVEL._serialized_end=5063 - _PLANGENERATIONRESULT._serialized_start=5066 - _PLANGENERATIONRESULT._serialized_end=5513 - _PLANGENERATIONRESULT_METRICSENTRY._serialized_start=5270 - _PLANGENERATIONRESULT_METRICSENTRY._serialized_end=5316 - _PLANGENERATIONRESULT_STATUS._serialized_start=5319 - _PLANGENERATIONRESULT_STATUS._serialized_end=5513 - _ENGINE._serialized_start=5515 - _ENGINE._serialized_end=5537 - _VALIDATIONRESULT._serialized_start=5540 - _VALIDATIONRESULT._serialized_end=5836 - _VALIDATIONRESULT_METRICSENTRY._serialized_start=5270 - _VALIDATIONRESULT_METRICSENTRY._serialized_end=5316 - _VALIDATIONRESULT_VALIDATIONRESULTSTATUS._serialized_start=5775 - _VALIDATIONRESULT_VALIDATIONRESULTSTATUS._serialized_end=5836 - _COMPILERRESULT._serialized_start=5839 - _COMPILERRESULT._serialized_end=6163 - _COMPILERRESULT_MAPBACKPLANENTRY._serialized_start=6048 - _COMPILERRESULT_MAPBACKPLANENTRY._serialized_end=6115 - _COMPILERRESULT_METRICSENTRY._serialized_start=5270 - _COMPILERRESULT_METRICSENTRY._serialized_end=5316 - _UNIFIEDPLANNING._serialized_start=8225 - _UNIFIEDPLANNING._serialized_end=8441 + DESCRIPTOR._options = None + _SCHEDULE_VARIABLEASSIGNMENTSENTRY._options = None + _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_options = b"8\001" + _METRIC_ACTIONCOSTSENTRY._options = None + _METRIC_ACTIONCOSTSENTRY._serialized_options = b"8\001" + _METHODINSTANCE_SUBTASKSENTRY._options = None + _METHODINSTANCE_SUBTASKSENTRY._serialized_options = b"8\001" + _PLANHIERARCHY_ROOTTASKSENTRY._options = None + _PLANHIERARCHY_ROOTTASKSENTRY._serialized_options = b"8\001" + _PLANREQUEST_ENGINEOPTIONSENTRY._options = None + _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_options = b"8\001" + _PLANGENERATIONRESULT_METRICSENTRY._options = None + _PLANGENERATIONRESULT_METRICSENTRY._serialized_options = b"8\001" + _VALIDATIONRESULT_METRICSENTRY._options = None + _VALIDATIONRESULT_METRICSENTRY._serialized_options = b"8\001" + _COMPILERRESULT_MAPBACKPLANENTRY._options = None + _COMPILERRESULT_MAPBACKPLANENTRY._serialized_options = b"8\001" + _COMPILERRESULT_METRICSENTRY._options = None + _COMPILERRESULT_METRICSENTRY._serialized_options = b"8\001" + _EXPRESSIONKIND._serialized_start = 6166 + _EXPRESSIONKIND._serialized_end = 6342 + _FEATURE._serialized_start = 6345 + _FEATURE._serialized_end = 8222 + _EXPRESSION._serialized_start = 26 + _EXPRESSION._serialized_end = 131 + _ATOM._serialized_start = 133 + _ATOM._serialized_end = 225 + _REAL._serialized_start = 227 + _REAL._serialized_end = 273 + _TYPEDECLARATION._serialized_start = 275 + _TYPEDECLARATION._serialized_end = 332 + _PARAMETER._serialized_start = 334 + _PARAMETER._serialized_end = 373 + _FLUENT._serialized_start = 375 + _FLUENT._serialized_end = 485 + _OBJECTDECLARATION._serialized_start = 487 + _OBJECTDECLARATION._serialized_end = 534 + _EFFECTEXPRESSION._serialized_start = 537 + _EFFECTEXPRESSION._serialized_end = 771 + _EFFECTEXPRESSION_EFFECTKIND._serialized_start = 719 + _EFFECTEXPRESSION_EFFECTKIND._serialized_end = 771 + _EFFECT._serialized_start = 773 + _EFFECT._serialized_end = 850 + _CONDITION._serialized_start = 852 + _CONDITION._serialized_end = 919 + _ACTION._serialized_start = 922 + _ACTION._serialized_end = 1063 + _TIMEPOINT._serialized_start = 1066 + _TIMEPOINT._serialized_end = 1210 + _TIMEPOINT_TIMEPOINTKIND._serialized_start = 1141 + _TIMEPOINT_TIMEPOINTKIND._serialized_end = 1210 + _TIMING._serialized_start = 1212 + _TIMING._serialized_end = 1273 + _INTERVAL._serialized_start = 1275 + _INTERVAL._serialized_end = 1386 + _TIMEINTERVAL._serialized_start = 1388 + _TIMEINTERVAL._serialized_end = 1495 + _DURATION._serialized_start = 1497 + _DURATION._serialized_end = 1550 + _ABSTRACTTASKDECLARATION._serialized_start = 1552 + _ABSTRACTTASKDECLARATION._serialized_end = 1623 + _TASK._serialized_start = 1625 + _TASK._serialized_end = 1695 + _METHOD._serialized_start = 1698 + _METHOD._serialized_end = 1873 + _TASKNETWORK._serialized_start = 1875 + _TASKNETWORK._serialized_end = 1978 + _HIERARCHY._serialized_start = 1981 + _HIERARCHY._serialized_end = 2112 + _ACTIVITY._serialized_start = 2115 + _ACTIVITY._serialized_end = 2292 + _SCHEDULINGEXTENSION._serialized_start = 2294 + _SCHEDULINGEXTENSION._serialized_end = 2411 + _SCHEDULE._serialized_start = 2414 + _SCHEDULE._serialized_end = 2577 + _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_start = 2512 + _SCHEDULE_VARIABLEASSIGNMENTSENTRY._serialized_end = 2577 + _GOAL._serialized_start = 2579 + _GOAL._serialized_end = 2643 + _TIMEDEFFECT._serialized_start = 2645 + _TIMEDEFFECT._serialized_end = 2727 + _ASSIGNMENT._serialized_start = 2729 + _ASSIGNMENT._serialized_end = 2798 + _GOALWITHWEIGHT._serialized_start = 2800 + _GOALWITHWEIGHT._serialized_end = 2866 + _TIMEDGOALWITHWEIGHT._serialized_start = 2868 + _TIMEDGOALWITHWEIGHT._serialized_end = 2970 + _METRIC._serialized_start = 2973 + _METRIC._serialized_end = 3513 + _METRIC_ACTIONCOSTSENTRY._serialized_start = 3215 + _METRIC_ACTIONCOSTSENTRY._serialized_end = 3278 + _METRIC_METRICKIND._serialized_start = 3281 + _METRIC_METRICKIND._serialized_end = 3513 + _PROBLEM._serialized_start = 3516 + _PROBLEM._serialized_end = 4040 + _ACTIONINSTANCE._serialized_start = 4043 + _ACTIONINSTANCE._serialized_end = 4171 + _METHODINSTANCE._serialized_start = 4174 + _METHODINSTANCE._serialized_end = 4348 + _METHODINSTANCE_SUBTASKSENTRY._serialized_start = 4301 + _METHODINSTANCE_SUBTASKSENTRY._serialized_end = 4348 + _PLANHIERARCHY._serialized_start = 4351 + _PLANHIERARCHY._serialized_end = 4501 + _PLANHIERARCHY_ROOTTASKSENTRY._serialized_start = 4453 + _PLANHIERARCHY_ROOTTASKSENTRY._serialized_end = 4501 + _PLAN._serialized_start = 4503 + _PLAN._serialized_end = 4607 + _PLANREQUEST._serialized_start = 4610 + _PLANREQUEST._serialized_end = 4869 + _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_start = 4770 + _PLANREQUEST_ENGINEOPTIONSENTRY._serialized_end = 4822 + _PLANREQUEST_MODE._serialized_start = 4824 + _PLANREQUEST_MODE._serialized_end = 4869 + _VALIDATIONREQUEST._serialized_start = 4871 + _VALIDATIONREQUEST._serialized_end = 4938 + _LOGMESSAGE._serialized_start = 4940 + _LOGMESSAGE._serialized_end = 5063 + _LOGMESSAGE_LOGLEVEL._serialized_start = 5008 + _LOGMESSAGE_LOGLEVEL._serialized_end = 5063 + _PLANGENERATIONRESULT._serialized_start = 5066 + _PLANGENERATIONRESULT._serialized_end = 5513 + _PLANGENERATIONRESULT_METRICSENTRY._serialized_start = 5270 + _PLANGENERATIONRESULT_METRICSENTRY._serialized_end = 5316 + _PLANGENERATIONRESULT_STATUS._serialized_start = 5319 + _PLANGENERATIONRESULT_STATUS._serialized_end = 5513 + _ENGINE._serialized_start = 5515 + _ENGINE._serialized_end = 5537 + _VALIDATIONRESULT._serialized_start = 5540 + _VALIDATIONRESULT._serialized_end = 5836 + _VALIDATIONRESULT_METRICSENTRY._serialized_start = 5270 + _VALIDATIONRESULT_METRICSENTRY._serialized_end = 5316 + _VALIDATIONRESULT_VALIDATIONRESULTSTATUS._serialized_start = 5775 + _VALIDATIONRESULT_VALIDATIONRESULTSTATUS._serialized_end = 5836 + _COMPILERRESULT._serialized_start = 5839 + _COMPILERRESULT._serialized_end = 6163 + _COMPILERRESULT_MAPBACKPLANENTRY._serialized_start = 6048 + _COMPILERRESULT_MAPBACKPLANENTRY._serialized_end = 6115 + _COMPILERRESULT_METRICSENTRY._serialized_start = 5270 + _COMPILERRESULT_METRICSENTRY._serialized_end = 5316 + _UNIFIEDPLANNING._serialized_start = 8225 + _UNIFIEDPLANNING._serialized_end = 8441 # @@protoc_insertion_point(module_scope) diff --git a/unified_planning/grpc/generated/unified_planning_pb2_grpc.py b/unified_planning/grpc/generated/unified_planning_pb2_grpc.py index 4d8b80d57..7a6d90f78 100644 --- a/unified_planning/grpc/generated/unified_planning_pb2_grpc.py +++ b/unified_planning/grpc/generated/unified_planning_pb2_grpc.py @@ -15,25 +15,25 @@ def __init__(self, channel): channel: A grpc.Channel. """ self.planAnytime = channel.unary_stream( - '/UnifiedPlanning/planAnytime', - request_serializer=unified__planning__pb2.PlanRequest.SerializeToString, - response_deserializer=unified__planning__pb2.PlanGenerationResult.FromString, - ) + "/UnifiedPlanning/planAnytime", + request_serializer=unified__planning__pb2.PlanRequest.SerializeToString, + response_deserializer=unified__planning__pb2.PlanGenerationResult.FromString, + ) self.planOneShot = channel.unary_unary( - '/UnifiedPlanning/planOneShot', - request_serializer=unified__planning__pb2.PlanRequest.SerializeToString, - response_deserializer=unified__planning__pb2.PlanGenerationResult.FromString, - ) + "/UnifiedPlanning/planOneShot", + request_serializer=unified__planning__pb2.PlanRequest.SerializeToString, + response_deserializer=unified__planning__pb2.PlanGenerationResult.FromString, + ) self.validatePlan = channel.unary_unary( - '/UnifiedPlanning/validatePlan', - request_serializer=unified__planning__pb2.ValidationRequest.SerializeToString, - response_deserializer=unified__planning__pb2.ValidationResult.FromString, - ) + "/UnifiedPlanning/validatePlan", + request_serializer=unified__planning__pb2.ValidationRequest.SerializeToString, + response_deserializer=unified__planning__pb2.ValidationResult.FromString, + ) self.compile = channel.unary_unary( - '/UnifiedPlanning/compile', - request_serializer=unified__planning__pb2.Problem.SerializeToString, - response_deserializer=unified__planning__pb2.CompilerResult.FromString, - ) + "/UnifiedPlanning/compile", + request_serializer=unified__planning__pb2.Problem.SerializeToString, + response_deserializer=unified__planning__pb2.CompilerResult.FromString, + ) class UnifiedPlanningServicer(object): @@ -46,130 +46,179 @@ def planAnytime(self, request, context): - the last message is of type `FinalReport` """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") def planOneShot(self, request, context): """A oneshot plan request to the engine. The engine replies with athe PlanGenerationResult """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") def validatePlan(self, request, context): """A validation request to the engine. The engine replies with the ValidationResult """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") def compile(self, request, context): """A compiler request to the engine. The engine replies with the CompilerResult """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") def add_UnifiedPlanningServicer_to_server(servicer, server): rpc_method_handlers = { - 'planAnytime': grpc.unary_stream_rpc_method_handler( - servicer.planAnytime, - request_deserializer=unified__planning__pb2.PlanRequest.FromString, - response_serializer=unified__planning__pb2.PlanGenerationResult.SerializeToString, - ), - 'planOneShot': grpc.unary_unary_rpc_method_handler( - servicer.planOneShot, - request_deserializer=unified__planning__pb2.PlanRequest.FromString, - response_serializer=unified__planning__pb2.PlanGenerationResult.SerializeToString, - ), - 'validatePlan': grpc.unary_unary_rpc_method_handler( - servicer.validatePlan, - request_deserializer=unified__planning__pb2.ValidationRequest.FromString, - response_serializer=unified__planning__pb2.ValidationResult.SerializeToString, - ), - 'compile': grpc.unary_unary_rpc_method_handler( - servicer.compile, - request_deserializer=unified__planning__pb2.Problem.FromString, - response_serializer=unified__planning__pb2.CompilerResult.SerializeToString, - ), + "planAnytime": grpc.unary_stream_rpc_method_handler( + servicer.planAnytime, + request_deserializer=unified__planning__pb2.PlanRequest.FromString, + response_serializer=unified__planning__pb2.PlanGenerationResult.SerializeToString, + ), + "planOneShot": grpc.unary_unary_rpc_method_handler( + servicer.planOneShot, + request_deserializer=unified__planning__pb2.PlanRequest.FromString, + response_serializer=unified__planning__pb2.PlanGenerationResult.SerializeToString, + ), + "validatePlan": grpc.unary_unary_rpc_method_handler( + servicer.validatePlan, + request_deserializer=unified__planning__pb2.ValidationRequest.FromString, + response_serializer=unified__planning__pb2.ValidationResult.SerializeToString, + ), + "compile": grpc.unary_unary_rpc_method_handler( + servicer.compile, + request_deserializer=unified__planning__pb2.Problem.FromString, + response_serializer=unified__planning__pb2.CompilerResult.SerializeToString, + ), } generic_handler = grpc.method_handlers_generic_handler( - 'UnifiedPlanning', rpc_method_handlers) + "UnifiedPlanning", rpc_method_handlers + ) server.add_generic_rpc_handlers((generic_handler,)) - # This class is part of an EXPERIMENTAL API. +# This class is part of an EXPERIMENTAL API. class UnifiedPlanning(object): """Missing associated documentation comment in .proto file.""" @staticmethod - def planAnytime(request, + def planAnytime( + request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None, + ): + return grpc.experimental.unary_stream( + request, target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_stream(request, target, '/UnifiedPlanning/planAnytime', + "/UnifiedPlanning/planAnytime", unified__planning__pb2.PlanRequest.SerializeToString, unified__planning__pb2.PlanGenerationResult.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + ) @staticmethod - def planOneShot(request, + def planOneShot( + request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None, + ): + return grpc.experimental.unary_unary( + request, target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/UnifiedPlanning/planOneShot', + "/UnifiedPlanning/planOneShot", unified__planning__pb2.PlanRequest.SerializeToString, unified__planning__pb2.PlanGenerationResult.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + ) @staticmethod - def validatePlan(request, + def validatePlan( + request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None, + ): + return grpc.experimental.unary_unary( + request, target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/UnifiedPlanning/validatePlan', + "/UnifiedPlanning/validatePlan", unified__planning__pb2.ValidationRequest.SerializeToString, unified__planning__pb2.ValidationResult.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + ) @staticmethod - def compile(request, + def compile( + request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None, + ): + return grpc.experimental.unary_unary( + request, target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None): - return grpc.experimental.unary_unary(request, target, '/UnifiedPlanning/compile', + "/UnifiedPlanning/compile", unified__planning__pb2.Problem.SerializeToString, unified__planning__pb2.CompilerResult.FromString, - options, channel_credentials, - insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + options, + channel_credentials, + insecure, + call_credentials, + compression, + wait_for_ready, + timeout, + metadata, + ) diff --git a/unified_planning/io/anml_grammar.py b/unified_planning/io/anml_grammar.py index e6892d786..83852ce38 100644 --- a/unified_planning/io/anml_grammar.py +++ b/unified_planning/io/anml_grammar.py @@ -110,7 +110,6 @@ class ANMLGrammar: """ def __init__(self): - # Data structures to populate while parsing self.types: List[ParseResults] = [] self.constant_fluents: List[ParseResults] = [] diff --git a/unified_planning/model/action.py b/unified_planning/model/action.py index ab01f10cf..9e0d77b27 100644 --- a/unified_planning/model/action.py +++ b/unified_planning/model/action.py @@ -154,9 +154,10 @@ def is_conditional(self) -> bool: """Returns `True` if the `Action` has `conditional effects`, `False` otherwise.""" raise NotImplementedError - + class InstantaneousTransitionMixin(Action): """Represents an instantaneous action.""" + def __init__( self, _name: str, @@ -174,7 +175,7 @@ def __init__( ] = {} # fluent_inc_dec is the set of the fluents that have an unconditional increase or decrease self._fluents_inc_dec: Set["up.model.fnode.FNode"] = set() - + def __eq__(self, oth: object) -> bool: if isinstance(oth, InstantaneousAction): cond = ( @@ -458,6 +459,7 @@ def set_simulated_effect(self, simulated_effect: "up.model.effect.SimulatedEffec def _set_preconditions(self, preconditions: List["up.model.fnode.FNode"]): self._preconditions = preconditions + class InstantaneousAction(InstantaneousTransitionMixin): def __repr__(self) -> str: s = [] @@ -485,7 +487,8 @@ def __repr__(self) -> str: s.append(f" simulated effect = {self._simulated_effect}\n") s.append(" }") return "".join(s) - + + class DurativeAction(Action, TimedCondsEffs): """Represents a durative action.""" @@ -691,6 +694,7 @@ def is_conditional(self) -> bool: # re-implemenation needed for inheritance, delegate implementation. return TimedCondsEffs.is_conditional(self) + class SensingAction(InstantaneousAction): """This class represents a sensing action.""" @@ -771,6 +775,7 @@ def __repr__(self) -> str: Events dictate the analogous of urgent transitions in timed automata theory """ + class Process(Action): """This is the `Process` class, which implements the abstract `Action` class.""" @@ -953,6 +958,7 @@ def add_derivative( ) ) + class Event(InstantaneousTransitionMixin): """This class represents an event.""" @@ -981,7 +987,7 @@ def __hash__(self) -> int: res += hash(e) res += hash(self._simulated_effect) return res - + def __repr__(self) -> str: s = [] s.append(f"event {self.name}") @@ -1008,4 +1014,3 @@ def __repr__(self) -> str: s.append(f" simulated effect = {self._simulated_effect}\n") s.append(" }") return "".join(s) - diff --git a/unified_planning/model/effect.py b/unified_planning/model/effect.py index 2d7fed516..1a7d8f240 100644 --- a/unified_planning/model/effect.py +++ b/unified_planning/model/effect.py @@ -111,7 +111,7 @@ def __repr__(self) -> str: s.append(f"forall {', '.join(str(v) for v in self._forall)}") if self.is_conditional(): s.append(f"if {str(self._condition)} then") - if not(self.is_derivative()): + if not (self.is_derivative()): s.append(f"{str(self._fluent)}") if self.is_assignment(): s.append(":=") @@ -249,6 +249,7 @@ def is_increase(self) -> bool: def is_decrease(self) -> bool: """Returns `True` if the :func:`kind ` of this `Effect` is a `decrease`, `False` otherwise.""" return self._kind == EffectKind.DECREASE + def is_derivative(self) -> bool: """Returns `True` if the :func:`kind ` of this `Effect` is a `derivative`, `False` otherwise.""" return self._kind == EffectKind.DERIVATIVE diff --git a/unified_planning/model/htn/hierarchical_problem.py b/unified_planning/model/htn/hierarchical_problem.py index ac98fb660..ac11160e2 100644 --- a/unified_planning/model/htn/hierarchical_problem.py +++ b/unified_planning/model/htn/hierarchical_problem.py @@ -171,7 +171,8 @@ def has_name(self, name: str) -> bool: Returns `True` if the given `name` is already in the `HierarchicalProblem`, `False` otherwise. :param name: The target name to find in the `HierarchicalProblem`. - :return: `True` if the given `name` is already in the `HierarchicalProblem`, `False` otherwise.""" + :return: `True` if the given `name` is already in the `HierarchicalProblem`, `False` otherwise. + """ return ( self.has_action(name) or self.has_fluent(name) diff --git a/unified_planning/model/mixins/metrics.py b/unified_planning/model/mixins/metrics.py index 7e74d9e54..6a1632e31 100644 --- a/unified_planning/model/mixins/metrics.py +++ b/unified_planning/model/mixins/metrics.py @@ -59,7 +59,8 @@ def __hash__(self): def _clone_to(self, other: "MetricsMixin", new_actions: Optional[ActionsSetMixin]): """Returns the list of cloned metric. - We make sure that any action appearing in hte metric is from the new set passed as parameter.""" + We make sure that any action appearing in hte metric is from the new set passed as parameter. + """ cloned: List[PlanQualityMetric] = [] for m in self._metrics: if m.is_minimize_action_costs(): diff --git a/unified_planning/model/multi_agent/ma_environment.py b/unified_planning/model/multi_agent/ma_environment.py index b546c5d1c..f30069e69 100644 --- a/unified_planning/model/multi_agent/ma_environment.py +++ b/unified_planning/model/multi_agent/ma_environment.py @@ -49,7 +49,8 @@ def has_name(self, name: str) -> bool: Returns `True` if the given `name` is already in the `MultiAgentProblem`, `False` otherwise. :param name: The target name to find in the `MultiAgentProblem`. - :return: `True` if the given `name` is already in the `MultiAgentProblem`, `False` otherwise.""" + :return: `True` if the given `name` is already in the `MultiAgentProblem`, `False` otherwise. + """ return self.has_fluent(name) def __repr__(self) -> str: diff --git a/unified_planning/model/problem.py b/unified_planning/model/problem.py index 865b10a20..f6df3b520 100644 --- a/unified_planning/model/problem.py +++ b/unified_planning/model/problem.py @@ -254,7 +254,8 @@ def has_name(self, name: str) -> bool: Returns `True` if the given `name` is already in the `Problem`, `False` otherwise. :param name: The target name to find in the `Problem`. - :return: `True` if the given `name` is already in the `Problem`, `False` otherwise.""" + :return: `True` if the given `name` is already in the `Problem`, `False` otherwise. + """ return ( self.has_action(name) or self.has_fluent(name) @@ -310,7 +311,9 @@ def _get_static_and_unused_fluents( (f.fluent() for e in exps for f in fve.get(e)) ) for a in self._actions: - if isinstance(a, up.model.action.InstantaneousAction) or isinstance(a, up.model.action.Event): + if isinstance(a, up.model.action.InstantaneousAction) or isinstance( + a, up.model.action.Event + ): remove_used_fluents(*a.preconditions) for e in a.effects: remove_used_fluents(e.fluent, e.value, e.condition) @@ -991,7 +994,9 @@ def update_problem_kind_action( if isinstance(action, up.model.tamp.InstantaneousMotionAction): if len(action.motion_constraints) > 0: self.kind.set_problem_class("TAMP") - if isinstance(action, up.model.action.InstantaneousAction) or isinstance(action, up.model.action.Event): + if isinstance(action, up.model.action.InstantaneousAction) or isinstance( + action, up.model.action.Event + ): for c in action.preconditions: self.update_problem_kind_expression(c) for e in action.effects: diff --git a/unified_planning/model/timing.py b/unified_planning/model/timing.py index 6d42d9f29..848c5f413 100644 --- a/unified_planning/model/timing.py +++ b/unified_planning/model/timing.py @@ -50,7 +50,8 @@ class Timepoint: - global end: plan horizon, at which the plan goals must hold. - start time or end time of an action, activity or task/method. - Used to define the point in the time from which a :class:`~unified_planning.model.timing.Timing` is considered.""" + Used to define the point in the time from which a :class:`~unified_planning.model.timing.Timing` is considered. + """ def __init__(self, kind: TimepointKind, container: Optional[str] = None): """ diff --git a/unified_planning/model/walkers/generic.py b/unified_planning/model/walkers/generic.py index bf1256b7a..ed5474898 100644 --- a/unified_planning/model/walkers/generic.py +++ b/unified_planning/model/walkers/generic.py @@ -24,6 +24,7 @@ from unified_planning.model.fnode import FNode from unified_planning.model.operators import OperatorKind + # NodeType to Function Name def nt_to_fun(o: OperatorKind) -> str: """Returns the name of the walk function for the given nodetype.""" diff --git a/unified_planning/model/walkers/type_checker.py b/unified_planning/model/walkers/type_checker.py index 2380a233a..49b39641b 100644 --- a/unified_planning/model/walkers/type_checker.py +++ b/unified_planning/model/walkers/type_checker.py @@ -73,7 +73,7 @@ def walk_fluent_exp( f = expression.fluent() if len(args) != len(f.signature): return None - for (param, arg) in zip(f.signature, args): + for param, arg in zip(f.signature, args): if not param.type.is_compatible(arg): return None return f.type diff --git a/unified_planning/plans/time_triggered_plan.py b/unified_planning/plans/time_triggered_plan.py index 1101038ed..b0b4ce379 100644 --- a/unified_planning/plans/time_triggered_plan.py +++ b/unified_planning/plans/time_triggered_plan.py @@ -503,7 +503,6 @@ def _extract_instantenous_actions( for i, timing in enumerate( _extract_action_timings(action, start, duration, epsilon) ): - inst_action = InstantaneousAction( f"{action.name}_{i}", _parameters=OrderedDict(((p.name, p.type) for p in action.parameters)), diff --git a/unified_planning/plot/plan_plot.py b/unified_planning/plot/plan_plot.py index 653151664..a2b72607d 100644 --- a/unified_planning/plot/plan_plot.py +++ b/unified_planning/plot/plan_plot.py @@ -656,7 +656,6 @@ def _plot_expressions( filename: Optional[str] = None, figsize: Optional[Tuple[float, float]] = None, ): - import plotly.express as px # type: ignore[import] if figsize is None: @@ -785,7 +784,6 @@ def get_bool_value_from_state(expression: FNode, state: State) -> int: class GraphvizGenerator: - available_colors = [ "firebrick2", "gold2", diff --git a/unified_planning/test/__init__.py b/unified_planning/test/__init__.py index b825f7085..8bc6a3cf5 100644 --- a/unified_planning/test/__init__.py +++ b/unified_planning/test/__init__.py @@ -169,7 +169,6 @@ def __init__( valid_plans: Optional[List[Plan]] = None, invalid_plans: Optional[List[Plan]] = None, ): - self._problem = problem self._solvable = solvable self._optimum = optimum @@ -204,7 +203,6 @@ def invalid_plans(self) -> List[Plan]: def get_test_cases(): - # import unified_planning.test.examples as examples from unified_planning.test import examples diff --git a/unified_planning/test/test_model.py b/unified_planning/test/test_model.py index 6e9d23a2e..2260da508 100644 --- a/unified_planning/test/test_model.py +++ b/unified_planning/test/test_model.py @@ -113,33 +113,32 @@ def test_clone_effect(self): def test_process(self): Vehicle = UserType("Vehicle") - a = Fluent("a",BoolType()) + a = Fluent("a", BoolType()) x = Fluent("x", IntType()) - move = Process("moving",car = Vehicle) + move = Process("moving", car=Vehicle) move.add_precondition(a) - move.add_derivative(x,1) + move.add_derivative(x, 1) e = Effect( FluentExp(x), Int(1), TRUE(), unified_planning.model.EffectKind.DERIVATIVE ) - self.assertEqual(move.effects[0],e) - self.assertEqual(move.name,"moving") - self.assertEqual(isinstance(move,Process),True) - + self.assertEqual(move.effects[0], e) + self.assertEqual(move.name, "moving") + self.assertEqual(isinstance(move, Process), True) + def test_event(self): Vehicle = UserType("Vehicle") - a = Fluent("a",BoolType()) + a = Fluent("a", BoolType()) x = Fluent("x", IntType()) - fell = Event("fell",car = Vehicle) + fell = Event("fell", car=Vehicle) fell.add_precondition(a) - fell.add_effect(x,1) + fell.add_effect(x, 1) e = Effect( FluentExp(x), Int(1), TRUE(), unified_planning.model.EffectKind.ASSIGN ) - self.assertEqual(fell.effects[0],e) - self.assertEqual(fell.name,"fell") - self.assertEqual(isinstance(fell,Event),True) - self.assertEqual(isinstance(fell,InstantaneousAction),False) - + self.assertEqual(fell.effects[0], e) + self.assertEqual(fell.name, "fell") + self.assertEqual(isinstance(fell, Event), True) + self.assertEqual(isinstance(fell, InstantaneousAction), False) def test_istantaneous_action(self): Location = UserType("Location") diff --git a/unified_planning/test/test_pddl_io.py b/unified_planning/test/test_pddl_io.py index 5ac9b1e16..6ee9fa2cb 100644 --- a/unified_planning/test/test_pddl_io.py +++ b/unified_planning/test/test_pddl_io.py @@ -520,7 +520,6 @@ def test_htn_transport_reader(self): self._test_htn_transport_reader(problem_2) def test_examples_io(self): - for example in self.problems.values(): problem = example.problem kind = problem.kind diff --git a/unified_planning/test/test_planner.py b/unified_planning/test/test_planner.py index c6eceec87..9fe6e29c1 100644 --- a/unified_planning/test/test_planner.py +++ b/unified_planning/test/test_planner.py @@ -290,7 +290,6 @@ def test_check_flags(self): problem = self.problems["robot"].problem error_msg = "We cannot establish whether ENHSP can solve this problem!" with OneshotPlanner(name="opt-pddl-planner") as planner: - # By default, when getting an Engine by name, we get a warning if the problem is not # supported with warnings.catch_warnings(record=True) as w: diff --git a/unified_planning/test/test_problem.py b/unified_planning/test/test_problem.py index 687ae4bd8..baf2cb5fa 100644 --- a/unified_planning/test/test_problem.py +++ b/unified_planning/test/test_problem.py @@ -502,7 +502,6 @@ def test_problem_defaults(self): ) def test_simple_numeric_planning_kind(self): - problem = self.problems["robot"].problem # False because the problem has an assignment instead of a decrease self.assertFalse(problem.kind.has_simple_numeric_planning()) diff --git a/unified_planning/test/test_sequential_simulator.py b/unified_planning/test/test_sequential_simulator.py index 55816aedf..05d00be0d 100644 --- a/unified_planning/test/test_sequential_simulator.py +++ b/unified_planning/test/test_sequential_simulator.py @@ -167,7 +167,6 @@ def test_bounded_types(self): self.assertIsNone(double_dec_state) def test_exceptions(self): - condition1 = Fluent("condition1") condition2 = Fluent("condition2") condition3 = Fluent("condition3") diff --git a/unified_planning/test/test_ttp_to_stn.py b/unified_planning/test/test_ttp_to_stn.py index c3bacf3f8..1c00bffbf 100644 --- a/unified_planning/test/test_ttp_to_stn.py +++ b/unified_planning/test/test_ttp_to_stn.py @@ -81,7 +81,6 @@ def test_matchcellar_to_stn(self): self.assertEqual(len(total_stn_nodes), len(plan.timed_actions) * 2 + 2) def test_all_valid(self): - for name, tc in self.problems.items(): for valid_plan in tc.valid_plans: if valid_plan.kind == PlanKind.TIME_TRIGGERED_PLAN: @@ -100,7 +99,6 @@ def test_all_valid(self): @skipIfNoPlanValidatorForProblemKind(sim_problem.kind) def test_simultaneity(self): - a = sim_problem.action("a") b = sim_problem.action("b") c = sim_problem.action("c") diff --git a/up_test_cases/builtin/multiagent/depot.py b/up_test_cases/builtin/multiagent/depot.py index bc7e5aeb2..f1bc43657 100644 --- a/up_test_cases/builtin/multiagent/depot.py +++ b/up_test_cases/builtin/multiagent/depot.py @@ -5,7 +5,6 @@ def get_test_cases(): - res = {} place = UserType("place") diff --git a/up_test_cases/builtin/multiagent/procter_and_gamble.py b/up_test_cases/builtin/multiagent/procter_and_gamble.py index 6417045b4..48d3e1437 100644 --- a/up_test_cases/builtin/multiagent/procter_and_gamble.py +++ b/up_test_cases/builtin/multiagent/procter_and_gamble.py @@ -5,7 +5,6 @@ def get_test_cases(): - res = {} problem = MultiAgentProblem("P&G") diff --git a/up_test_cases/builtin/numeric/block_grouping.py b/up_test_cases/builtin/numeric/block_grouping.py index 20cdf41eb..e26494c8f 100644 --- a/up_test_cases/builtin/numeric/block_grouping.py +++ b/up_test_cases/builtin/numeric/block_grouping.py @@ -17,7 +17,6 @@ def get_test_cases(): - res = {} base_problem = Problem() diff --git a/up_test_cases/builtin/processes/constant_derivative.py b/up_test_cases/builtin/processes/constant_derivative.py index 0c9e6d6ed..e79aa5649 100644 --- a/up_test_cases/builtin/processes/constant_derivative.py +++ b/up_test_cases/builtin/processes/constant_derivative.py @@ -7,19 +7,19 @@ def get_test_cases(): res = {} x = Fluent("on") - d = Fluent("d",RealType()) + d = Fluent("d", RealType()) a = InstantaneousAction("turn_on") a.add_precondition(Not(x)) a.add_effect(x, True) evt = Event("turn_off_automatically") - evt.add_precondition(GE(d,200)) - evt.add_effect(x,False) + evt.add_precondition(GE(d, 200)) + evt.add_effect(x, False) b = Process("moving") b.add_precondition(x) - b.add_derivative(d,1) + b.add_derivative(d, 1) problem = Problem("basic") problem.add_fluent(x) @@ -29,8 +29,8 @@ def get_test_cases(): problem.add_action(evt) problem.set_initial_value(x, False) problem.set_initial_value(d, 0) - problem.add_goal(GE(d,10)) + problem.add_goal(GE(d, 10)) res[problem.name] = TestCase(problem=problem, solvable=True) - return res \ No newline at end of file + return res diff --git a/up_test_cases/builtin/tamp/construction/test_01.py b/up_test_cases/builtin/tamp/construction/test_01.py index b351f3eb4..ecb179255 100644 --- a/up_test_cases/builtin/tamp/construction/test_01.py +++ b/up_test_cases/builtin/tamp/construction/test_01.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/builtin/tamp/construction/test_02.py b/up_test_cases/builtin/tamp/construction/test_02.py index 14573e958..4e38df3eb 100644 --- a/up_test_cases/builtin/tamp/construction/test_02.py +++ b/up_test_cases/builtin/tamp/construction/test_02.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/builtin/tamp/construction/test_03.py b/up_test_cases/builtin/tamp/construction/test_03.py index ac0a79eca..034bdb11c 100644 --- a/up_test_cases/builtin/tamp/construction/test_03.py +++ b/up_test_cases/builtin/tamp/construction/test_03.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/builtin/tamp/office/test_01.py b/up_test_cases/builtin/tamp/office/test_01.py index a99fcab5d..4e6d57923 100644 --- a/up_test_cases/builtin/tamp/office/test_01.py +++ b/up_test_cases/builtin/tamp/office/test_01.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/builtin/tamp/office/test_02.py b/up_test_cases/builtin/tamp/office/test_02.py index 13eaa56cc..5a04c0736 100644 --- a/up_test_cases/builtin/tamp/office/test_02.py +++ b/up_test_cases/builtin/tamp/office/test_02.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/builtin/tamp/office/test_03.py b/up_test_cases/builtin/tamp/office/test_03.py index 3153a7b78..981ed73c9 100644 --- a/up_test_cases/builtin/tamp/office/test_03.py +++ b/up_test_cases/builtin/tamp/office/test_03.py @@ -7,7 +7,6 @@ def get_test_cases(): - res = {} t_robot = MovableType("robot") diff --git a/up_test_cases/performance/numeric/block_grouping.py b/up_test_cases/performance/numeric/block_grouping.py index 8249f63e9..a0362beda 100644 --- a/up_test_cases/performance/numeric/block_grouping.py +++ b/up_test_cases/performance/numeric/block_grouping.py @@ -19,7 +19,6 @@ def get_test_cases(): - res = {} base_problem = Problem() diff --git a/up_test_cases/report.py b/up_test_cases/report.py index c3ae28384..51a6eb8e4 100644 --- a/up_test_cases/report.py +++ b/up_test_cases/report.py @@ -273,7 +273,6 @@ def report_oneshot( for planner_id in planners: planner = OneshotPlanner(name=planner_id) if planner.supports(pb.kind): - if not name_printed: name_printed = True print() @@ -355,7 +354,6 @@ def report_plan_repair( for planner_id in planners: planner = PlanRepairer(name=planner_id) if planner.supports(pb.kind) and planner.supports_plan(plan.kind): - if not name_printed: problems_run += 1 name_printed = True @@ -461,7 +459,6 @@ def report_anytime( for planner_id in planners: planner = AnytimePlanner(name=planner_id) if planner.supports(pb.kind): - if not name_printed: name_printed = True print() @@ -636,7 +633,6 @@ def is_grounder(engine_name): for engine_id in grounders: compiler = Compiler(name=engine_id) if compiler.supports(kind): - if not name_printed: name_printed = True problems_run += 1 diff --git a/up_test_cases/utils.py b/up_test_cases/utils.py index 7e489c067..09c9a28e2 100644 --- a/up_test_cases/utils.py +++ b/up_test_cases/utils.py @@ -16,7 +16,6 @@ def _get_test_cases(package_name: str) -> Dict[str, TestCase]: - stack = [(package_name, True, "")] res = {} while len(stack) > 0: