diff --git a/AP-Jupyternotebook.ipynb b/AP-Jupyternotebook.ipynb index 426549a1ca70eed8e6410595828fc74e60c1ac31..326e1a1076d7ca725bd557124f090ffcf55cab30 100644 --- a/AP-Jupyternotebook.ipynb +++ b/AP-Jupyternotebook.ipynb @@ -1768,19 +1768,14 @@ " super().__init__(verbose, collect_stats)\n", " self.h = heuristic\n", "\n", - " # -----------------------------------------------\n", - " # Solve\n", - " # -----------------------------------------------\n", - "\n", - " # =====================================\n", - " # Params:\n", - " # actions -> list of grounded actions\n", - " # state -> initial state of the problem file\n", - " # goals -> tuple with (positive predicates, negative predicates) of the goal\n", - " # =====================================\n", - "\n", - " # Positive goals and negative goals in a tuple.\n", + " # maybe I can use some kind of structure to control the level of the tree.\n", + " # keep only the things that changed in next state.\n", " def solve(self, actions, state, goals):\n", + " \"\"\"\n", + " actions: list of grounded actions\n", + " state: initial state of the problem file\n", + " goals: tuple with (positive predicates, negative predicates) of the goal\n", + " \"\"\"\n", " frontier = queue.PriorityQueue()\n", " came_from = {}\n", " cost_so_far = {}\n", @@ -1811,6 +1806,7 @@ " ):\n", " new_state = apply(current_state, (action.add_effects, action.del_effects))\n", " # +1 because this is the cost to move from one state to another.\n", + " # When not used, the result is the same.\n", " cost = cost_so_far[current_state] + 1\n", " if new_state not in cost_so_far or cost < cost_so_far[new_state]:\n", " cost_so_far[new_state] = cost\n", @@ -1967,10 +1963,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { + "ExecuteTime": { + "end_time": "2020-05-16T18:10:58.555811Z", + "start_time": "2020-05-16T18:10:48.913387Z" + }, "deletable": false, - "editable": false, "nbgrader": { "cell_type": "code", "checksum": "c07eca3f711fd6ebae434c43df578f51", @@ -1982,9 +1981,18 @@ "solution": false } }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Elapsed time: 9.634910106658936 Passed!\n", + "Elapsed time: 0 Passed!\n" + ] + } + ], "source": [ - "#Student_tests\n", + "# Reset to non-editable.\n", "dwr = \"examples/dwr/dwr.pddl\"\n", "pb1 = \"examples/dwr/pb1.pddl\"\n", "pb2 = \"examples/dwr/pb2.pddl\"\n", @@ -1994,7 +2002,7 @@ "print(\"Elapsed time:\", str(time) + (\" Passed!\" if time <= 60.0 else \" Timeout!\"))\n", "\n", "plan, time = planner.solve_file(dwr, pb2)\n", - "print(\"Elapsed time:\", str(time) + (\" Passed!\" if time <= 60.0 else \" Timeout!\"))\n" + "print(\"Elapsed time:\", str(time) + (\" Passed!\" if time <= 60.0 else \" Timeout!\"))" ] }, {