PDDLWriter

class unified_planning.io.PDDLWriter(problem: Problem, needs_requirements: bool = True, rewrite_bool_assignments: bool = False, empty_preconditions: bool = False)[source]

Bases: object

This class can be used to write a Problem in PDDL. The constructor of this class takes the problem to write and 3 flags: needs_requirements determines if the printed problem must have the :requirements, rewrite_bool_assignments determines if this writer will write non constant boolean assignment as conditional effects. empty_preconditions determines if this writer will write ‘:precondition ()’ in case of an instantenuous action without preconditions instead of writing nothing or similar with conditions in durative actions.

print_domain()[source]

Prints to std output the PDDL domain.

print_problem()[source]

Prints to std output the PDDL problem.

print_plan(plan: Plan)[source]

Prints to std output the PDDL plan.

get_domain() str[source]

Returns the PDDL domain.

get_problem() str[source]

Returns the PDDL problem.

get_plan(plan: Plan) str[source]

Returns the PDDL plan.

write_domain(filename: str)[source]

Dumps to file the PDDL domain.

write_problem(filename: str)[source]

Dumps to file the PDDL problem.

write_plan(plan: Plan, filename: str)[source]

Dumps to file the PDDL plan.

get_item_named(name: str) Type | Action | Fluent | Object | Parameter | Variable | Agent | Method | Task[source]

Since PDDL has a stricter set of possible naming compared to the unified_planning, when writing a Problem it is possible that some things must be renamed. This is why the PDDLWriter offers this method, that takes a PDDL name and returns the original unified_planning data structure that corresponds to the PDDL entity with the given name.

This method takes a name used in the PDDL domain or PDDL problem generated by this PDDLWriter and returns the original item in the unified_planning Problem.

Parameters:

name – The name used in the generated PDDL.

Returns:

The unified_planning model entity corresponding to the given name.

get_pddl_name(item: Type | Action | Fluent | Object | Parameter | Variable | Agent | Method | Task) str[source]

This method takes an item in the Problem and returns the chosen name for the same item in the PDDL problem or PDDL domain generated by this PDDLWriter.

Parameters:

item – The unified_planning entity renamed by this PDDLWriter.

Returns:

The PDDL name of the given item.