Skip to content
Yash Bansod edited this page Jun 26, 2022 · 6 revisions

If you use this repository please cite our work:

@inproceedings{bansod2022htn,
  title={HTN Replanning from the Middle},
  author={Bansod, Yash and Patra, Sunandita and Nau, Dana and Roberts, Mark},
  booktitle={The International FLAIRS Conference Proceedings},
  volume={35},
  year={2022}
}

IPyHOP is a Re-entrant Iterative GTPyHOP written in Python 3. PyHOP is an acronym for Python Hierarchical Ordered Planner.

IPyHOP is a Totally-Ordered Goal Task Network (GTN) Planner written in Python 3. It effectively plans like a re-entrant iterative version of GTPyHOP. However, IPyHOP produces a solution tree (a task decomposition network) to accomplish a to-do list T consisting of actions, tasks, and goals. The solution tree preserves the hierarchy of the decompositions performed to obtain the solution plan. The solution plan can be obtained by listing the actions in the solution tree in a pre-ordered depth-first search manner. The plan presents the sequence of actions that accomplishes all of the items in T, in the order that they occur in T.

IPyHOP can also re-enter any point in the task decomposition network and re-plan from there. Alternatively, it can be fed a partially solved task decomposition network to solve the planning problem.

For more details on IPyHOP's planning algorithm please read the paper: HTN Replanning from the Middle

For examples of how to use it, see the example files that come with IPyHOP.

IPyHOP provides the following classes and functions:

  • state = State('foo') tells IPyHOP to create an empty state object named 'foo'.
    To put variables and values into it, you should do assignments such as foo.var1 = val1

  • methods = Methods() tells IPyHOP to create an empty methods container.
    To add tasks and associated task methods into it, you should use methods.declare_task_methods(task_name, method_list).
    To add tasks and associated goal methods into it, you should use methods.declare_goal_methods(goal_name, method_list).
    To add tasks and associated multigoal methods into it, you should use methods.declare_multigoal_methods(goal_tag, method_list).

  • actions = Actions() tells IPyHOP to create an empty actions container.
    To add actions into it, you should use actions.declare_actions(action_list).
    declare_actions([a1, a2, ..., ak]) tells IPyHOP that a1, a2, ..., ak are all of the planning actions.
    This supersedes any previous call to declare_actions([a1, a2, ..., ak]).

  • planner = IPyHOP(methods, actions) tells IPyHOP to create a IPyHOP planner object.
    To plan using the planner, you should use planner.plan(state, task_list).

  • planner.replan(state, fail_node_id) can be used to re-plan from a failure node in the planner's solution tree.
    fail_node_id is the id of the node in the solution tree that failed.
    Let fail_node describe the action, task, or goal that caused the failure. Ex. ('move', 'a', 'b').
    Then, to mark fail_node as a deterministic failure, you should blacklist it using planner.blacklist_command(fail_node).

  • planar_plot(planner.sol_tree) can be used to visualize the solution tree graphically.

  • planner.simulate(state) can be used to deterministically simulate the plan generated by the planner from a given initial state.

Please see the code doc strings for detailed descriptions of IPyHOP's classes and functions.

Wiki Contents: