PDDLReader
- class unified_planning.io.PDDLReader(environment: Environment | None = None, force_up_pddl_reader: bool = False, force_ai_planning_reader: bool = False, deactivate_fallback: bool = False, disable_warnings: bool = False)[source]
Bases:
objectUses the unified_planning.interop.from_pddl.from_ai_pddl if the requirements are respected, otherwise uses the UPPDDLReader to parse the PDDL domain and the PDDL problem; generates the equivalent
Problem.Note: in the error report messages, a tabulation counts as one column; and due to PDDL case-insensitivity, everything in the PDDL files will be turned to lower case, so the names of fluents, actions etc. and the error report will all be in lower-case.
- parse_problem(domain_filename: str, problem_filename: str | None = None) Problem[source]
Takes in input a filename containing the PDDL domain and optionally a filename containing the PDDL problem and returns the parsed Problem; the Problem is parsed using from_ai_pddl if all the requirements specified in the domain are supported, if this fails or the requirements specified are not supported, falls back to the UPPDDLReader.
Note: that if the problem_filename is None, an incomplete Problem will be returned.
Note: due to PDDL case-insensitivity, everything in the PDDL files will be turned to lower case, so the names of fluents, actions etc. and the error report will all be in lower-case.
- Parameters:
domain_filename – The path to the file containing the PDDL domain.
problem_filename – Optionally the path to the file containing the PDDL problem.
- Returns:
The Problem parsed from the given pddl domain + problem.
- parse_problem_string(domain_str: str, problem_str: str | None = None) Problem[source]
Takes in input a str representing the PDDL domain and optionally a str representing the PDDL problem and returns the parsed Problem; the Problem is parsed using from_ai_pddl if all the requirements specified in the domain are supported, if this fails or the requirements specified are not supported, falls back to the UPPDDLReader.
Note that if the problem_str is None, an incomplete Problem will be returned.
Note: due to PDDL case-insensitivity, everything in the PDDL files will be turned to lower case, so the names of fluents, actions etc. and the error report will all be in lower-case.
- Parameters:
domain_filename – The string representing the PDDL domain.
problem_filename – Optionally the string representing the PDDL problem.
- Returns:
The Problem parsed from the given pddl domain + problem.
- parse_plan(problem: Problem, plan_filename: str, get_item_named: Callable[[str], Type | Action | NaturalTransition | Fluent | Object | Parameter | Variable | Agent | Method | Task] | None = None) Plan[source]
Takes a problem, a filename and optionally a map of renaming and returns the plan parsed from the file.
The format of the file must be:
(action-name param1 param2 ... paramN)in each line for SequentialPlansstart-time: (action-name param1 param2 ... paramN) [duration]in each line for TimeTriggeredPlans, where[duration]is optional and not specified for InstantaneousActions.- Parameters:
problem – The up.model.problem.Problem instance for which the plan is generated.
plan_filename – The path of the file in which the plan is written.
get_item_named – A function that takes a name and returns the original up.model element instance linked to that renaming; if None the problem is used to retrieve the actions and objects in the plan from their name.
- Returns:
The up.plans.Plan corresponding to the parsed plan from the file
- parse_plan_string(problem: Problem, plan_str: str, get_item_named: Callable[[str], Type | Action | NaturalTransition | Fluent | Object | Parameter | Variable | Agent | Method | Task] | None = None) Plan[source]
Takes a problem, a string and optionally a map of renaming and returns the plan parsed from the string.
The format of the file must be:
(action-name param1 param2 ... paramN)in each line for SequentialPlansstart-time: (action-name param1 param2 ... paramN) [duration]in each line for TimeTriggeredPlans, where[duration]is optional and not specified for InstantaneousActions.- Parameters:
problem – The up.model.problem.Problem instance for which the plan is generated.
plan_str – The plan in string.
get_item_named – A function that takes a name and returns the original up.model element instance linked to that renaming; if None the problem is used to retrieve the actions and objects in the plan from their name.:return: The up.plans.Plan corresponding to the parsed plan from the string