6.2 Forward Planning


A forward planner treats the planning problem as a path planning problem in the state-space graph. In a state-space graph, nodes are states, and arcs correspond to actions from one state to another. The arcs coming out of a state correspond to all of the legal actions that can be carried out in that state. A plan is a path from the initial state to a state that satisfies the achievement goal.

A forward planner searches the state-space graph from the initial state looking for a state that satisfies a goal description. It can use any of the search strategies we learnt before (see Chapter 3).

You can run each cell by selecting it and pressing Ctrl+Enter in Windows or Shift+Return in MacOS. Alternatively, you can click the Play button in the toolbar, to the left of the stop button. For more information, check out our AISpace2 Tutorial.

Feel free to modify our codes either in this notebook or somewhere outside (e.g. python files in /aipython/). If you want to modify our codes outside, you might find this helpful for how your changes can take effect.

You need to run the following command to import our pre-defined problems. You can also define your own problems (how?).

In [ ]:
# Run this to import pre-defined problems
from aipython.stripsProblem import strips_delivery1, strips_delivery2, strips_delivery3, strips_blocks1, strips_blocks2, strips_blocks3, strips_elevator

In [ ]:
from aipython.searchMPP import SearcherMPP
from aipython.stripsForwardPlanner import Forward_STRIPS
from aipython.stripsHeuristic import heuristic_fun

search_forward = Forward_STRIPS(planning_problem=strips_delivery2)
# If you want a heuristic, use this instead:
# search_forward = Forward_STRIPS(planning_problem=strips_delivery2, heur=heuristic_fun)
s_mpp = SearcherMPP(problem=search_forward)

# Visualization options
# For more explanation please visit:
s_mpp.sleep_time = 0.2 # The time, in seconds, between each step in auto solving
s_mpp.line_width = 2.0 # The thickness of edges
s_mpp.text_size = 13 # The fontsize of the text
s_mpp.detail_level = 2 # 0=no text, 1=truncated text, 2=full text
s_mpp.show_edge_costs = False
s_mpp.show_node_heuristics = False

# Display the widget

In [ ]: