From f8eff5ac216398d6599eb952d0d0d5c013db04d3 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 25 Dec 2024 11:06:05 -0500 Subject: [PATCH 01/15] initial paper reconstruction files created + clean up code --- README.md | 2 + l2p/domain_builder.py | 18 +- l2p/feedback_builder.py | 1 + l2p/task_builder.py | 2 +- l2p/utils/__init__.py | 2 +- l2p/utils/pddl_parser.py | 41 +- l2p/utils/pddl_planner.py | 8 +- l2p/utils/utils.py | 10 - paper_reconstructions/isr-llm/main.py | 7 + .../llm+dm/{llm+dm.py => main.py} | 24 +- .../llm+dm/results/domain.pddl | 41 +- .../llm+p/{llm+p.py => main.py} | 20 +- .../nl2plan/{nl2plan.py => main.py} | 104 ++--- .../nl2plan/results/domain.pddl | 141 ++++-- .../nl2plan/results/problem.pddl | 35 +- paper_reconstructions/p+s/main.py | 7 + .../proc2pddl/{proc2pddl.py => main.py} | 23 +- .../proc2pddl/results/domain.pddl | 418 +++++++++--------- paper_reconstructions/there-and-back/main.py | 7 + tests/test_domain_builder.py | 2 +- 20 files changed, 523 insertions(+), 390 deletions(-) delete mode 100644 l2p/utils/utils.py create mode 100644 paper_reconstructions/isr-llm/main.py rename paper_reconstructions/llm+dm/{llm+dm.py => main.py} (92%) rename paper_reconstructions/llm+p/{llm+p.py => main.py} (78%) rename paper_reconstructions/nl2plan/{nl2plan.py => main.py} (87%) create mode 100644 paper_reconstructions/p+s/main.py rename paper_reconstructions/proc2pddl/{proc2pddl.py => main.py} (86%) create mode 100644 paper_reconstructions/there-and-back/main.py diff --git a/README.md b/README.md index 92ac085..df4a951 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,8 @@ huggingface_model = HUGGING_FACE(model_path=args.model_path, max_tokens=args.max ## Planner For ease of use, our library contains submodule [FastDownward](https://github.com/aibasel/downward/tree/308812cf7315fe896dbcd319493277d82aa36bd2). Fast Downward is a domain-independent classical planning system that users can run their PDDL domain and problem files on. The motivation is that the majority of papers involving PDDL-LLM usage uses this library as their planner. +**IMPORTANT** FastDownward is a submodule in L2P. To use the planner, you must clone the GitHub repo of [FastDownward](https://github.com/aibasel/downward/tree/308812cf7315fe896dbcd319493277d82aa36bd2) and run the `planner_path` to that directory. + ## Current Works Reconstructed Using L2P The following are papers that have been reconstructed so far. This list will be updated in the future. diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index 7c6257d..f2cc1e2 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -729,25 +729,25 @@ def generate_domain( """ desc = "" desc += f"(define (domain {domain})\n" - desc += indent(string=f"(:requirements\n {' '.join(requirements)}\n)\n") - desc += f" (:types \n{indent(types)}\n )\n\n" - desc += f" (:predicates \n{indent(predicates)}\n )" + desc += indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + "\n\n" + desc += f" (:types \n{indent(string=types, level=2)}\n )\n\n" + desc += f" (:predicates \n{indent(string=predicates, level=2)}\n )" desc += self.action_descs(actions) desc += "\n)" desc = desc.replace("AND", "and").replace( "OR", "or" - ) # The python PDDL package can't handle capital AND and OR + ) return desc def action_desc(self, action: Action) -> str: """Helper function to format individual action descriptions""" param_str = "\n".join( - [f"{name} - {type}" for name, type in action["parameters"].items()] + [f"{name} - {type}" for name, type in action["params"].items()] ) # name includes ? desc = f"(:action {action['name']}\n" - desc += f" :parameters (\n{param_str}\n )\n" - desc += f" :precondition\n{action['preconditions']}\n" - desc += f" :effect\n{action['effects']}\n" + desc += f" :parameters (\n{indent(string=param_str, level=2)}\n )\n" + desc += f" :precondition\n{indent(string=action['preconditions'], level=2)}\n" + desc += f" :effect\n{indent(string=action['effects'], level=2)}\n" desc += ")" return desc @@ -755,7 +755,7 @@ def action_descs(self, actions) -> str: """Helper function to combine all action descriptions""" desc = "" for action in actions: - desc += "\n\n" + self.action_desc(action) + desc += "\n\n" + indent(self.action_desc(action), level=1) return desc def format_predicates(self, predicates: list[Predicate]) -> str: diff --git a/l2p/feedback_builder.py b/l2p/feedback_builder.py index 9bcc48f..f965da8 100644 --- a/l2p/feedback_builder.py +++ b/l2p/feedback_builder.py @@ -159,6 +159,7 @@ def nl_action_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + nl_actions, llm_response = domain_builder.extract_type_hierarchy( model, domain_desc, prompt ) diff --git a/l2p/task_builder.py b/l2p/task_builder.py index 348b6ef..8291034 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -424,7 +424,7 @@ def format_action(self, actions: list[Action]) -> str: desc = "" for action in actions: param_str = "\n".join( - [f"{name} - {type}" for name, type in action["parameters"].items()] + [f"{name} - {type}" for name, type in action["params"].items()] ) # name includes ? desc += f"(:action {action['name']}\n" desc += f" :parameters (\n{indent(param_str,2)}\n )\n" diff --git a/l2p/utils/__init__.py b/l2p/utils/__init__.py index 9e8c564..6d8c10f 100644 --- a/l2p/utils/__init__.py +++ b/l2p/utils/__init__.py @@ -1,4 +1,4 @@ from .pddl_parser import * from .pddl_types import * from .pddl_validator import * -from .utils import * +from .pddl_planner import * diff --git a/l2p/utils/pddl_parser.py b/l2p/utils/pddl_parser.py index a204bdb..24d3aa8 100644 --- a/l2p/utils/pddl_parser.py +++ b/l2p/utils/pddl_parser.py @@ -2,11 +2,20 @@ This file contains collection of functions for extracting/parsing information from LLM output """ +from pddl.formatter import domain_to_string, problem_to_string +from pddl import parse_domain, parse_problem from .pddl_types import Action, Predicate from collections import OrderedDict from copy import deepcopy -import re, ast, json +import re, ast, json, sys, os +def load_file(file_path): + _, ext = os.path.splitext(file_path) + with open(file_path, "r") as file: + if ext == ".json": + return json.load(file) + else: + return file.read().strip() def parse_params(llm_output): """ @@ -189,7 +198,7 @@ def parse_action(llm_response: str, action_name: str) -> Action: ) return { "name": action_name, - "parameters": parameters, + "params": parameters, "preconditions": preconditions, "effects": effects, } @@ -315,7 +324,7 @@ def prune_types( break else: for action in actions: - if type.split(" ")[0] in action["parameters"].values(): + if type.split(" ")[0] in action["params"].values(): used_types[type] = types[type] break if ( @@ -460,3 +469,29 @@ def format_predicates(predicates: list[Predicate]) -> str: def indent(string: str, level: int = 2): """Indent string helper function to format PDDL domain/task""" return " " * level + string.replace("\n", f"\n{' ' * level}") + + +def check_parse_domain(file_path: str): + """Run PDDL library to check if file is syntactically correct""" + try: + domain = parse_domain(file_path) + pddl_domain = domain_to_string(domain) + return pddl_domain + except Exception as e: + print("------------------") + print(f"Error parsing domain: {e}", file=sys.stderr) + print("------------------") + sys.exit(1) + + +def check_parse_problem(file_path: str): + """Run PDDL library to check if file is syntactically correct""" + try: + problem = parse_problem(file_path) + pddl_problem = problem_to_string(problem) + return pddl_problem + except Exception as e: + print("------------------") + print(f"Error parsing domain: {e}", file=sys.stderr) + print("------------------") + sys.exit(1) diff --git a/l2p/utils/pddl_planner.py b/l2p/utils/pddl_planner.py index 68b0019..45dfc20 100644 --- a/l2p/utils/pddl_planner.py +++ b/l2p/utils/pddl_planner.py @@ -27,14 +27,18 @@ class FastDownward: + + def __init__(self, planner_path: str): + self.planner_path = planner_path def run_fast_downward(self, domain_file, problem_file, plan_file="sas_plan"): try: - downward_path = "downward/fast-downward.py" + + print(self.planner_path) # lmcut() = landmark-cut heuristic - refer to: https://www.fast-downward.org/PlannerUsage result = subprocess.run( - [downward_path, "--alias", "lama-first", domain_file, problem_file], + [self.planner_path, "--alias", "lama-first", domain_file, problem_file], capture_output=True, text=True, ) diff --git a/l2p/utils/utils.py b/l2p/utils/utils.py deleted file mode 100644 index 5df3a80..0000000 --- a/l2p/utils/utils.py +++ /dev/null @@ -1,10 +0,0 @@ -import os, json - - -def load_file(file_path): - _, ext = os.path.splitext(file_path) - with open(file_path, "r") as file: - if ext == ".json": - return json.load(file) - else: - return file.read().strip() diff --git a/paper_reconstructions/isr-llm/main.py b/paper_reconstructions/isr-llm/main.py new file mode 100644 index 0000000..b1dedf1 --- /dev/null +++ b/paper_reconstructions/isr-llm/main.py @@ -0,0 +1,7 @@ +""" +Paper: "ISR-LLM: Iterative Self-Refined Large Language Model for Long-Horizon Sequential Task Planning" Zhou et al. (2023) +Source code: https://github.com/ma-labo/ISR-LLM +Run: python3 -m paper_reconstructions.isr-llm.main +""" + +# TODO: implementation \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/llm+dm.py b/paper_reconstructions/llm+dm/main.py similarity index 92% rename from paper_reconstructions/llm+dm/llm+dm.py rename to paper_reconstructions/llm+dm/main.py index c780e45..cd6fc0c 100644 --- a/paper_reconstructions/llm+dm/llm+dm.py +++ b/paper_reconstructions/llm+dm/main.py @@ -1,7 +1,7 @@ """ Paper: "Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning" Guan et al. (2023) Source code: https://github.com/GuanSuns/LLMs-World-Models-for-Planning -Run: python3 -m paper_reconstructions.llm+dm.llm+dm +Run: python3 -m paper_reconstructions.llm+dm.main Assumes the following: 1. NL descriptions of all the actions @@ -9,23 +9,11 @@ 3. Information of the object types and hierarchy - fixed set of object types specified in prompt """ -import os, json +import os from copy import deepcopy from l2p import * -def open_txt(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - - -def open_json(file_path): - with open(file_path, "r") as file: - file = json.load(file) - return file - - def construct_action_model( domain_desc, prompt_template, @@ -118,12 +106,12 @@ def construct_action_model( if __name__ == "__main__": # setup prompt templates - action_model = open_json("paper_reconstructions/llm+dm/prompts/action_model.json") - domain_desc = open_txt("paper_reconstructions/llm+dm/prompts/domain_desc.txt") - hierarchy_requirements = open_json( + action_model = load_file("paper_reconstructions/llm+dm/prompts/action_model.json") + domain_desc = load_file("paper_reconstructions/llm+dm/prompts/domain_desc.txt") + hierarchy_requirements = load_file( "paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json" ) - prompt_template = open_txt("paper_reconstructions/llm+dm/prompts/pddl_prompt.txt") + prompt_template = load_file("paper_reconstructions/llm+dm/prompts/pddl_prompt.txt") # setup LLM engine engine = "gpt-4o-mini" diff --git a/paper_reconstructions/llm+dm/results/domain.pddl b/paper_reconstructions/llm+dm/results/domain.pddl index 2b06ea9..1141dc6 100644 --- a/paper_reconstructions/llm+dm/results/domain.pddl +++ b/paper_reconstructions/llm+dm/results/domain.pddl @@ -11,20 +11,22 @@ ) (:predicates - (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l (package-at ?p - package ?l - location) ; true if the package ?p is located at location ?l + (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l (truck-has-space ?t - truck) ; true if the truck ?t has space to load more packages (truck-has-package ?t - truck ?p - package) ; true if the truck ?t is carrying the package ?p - (truck-holding ?t - truck ?p - package) ; true if the truck ?t is holding the package ?p - (airplane-at ?a - plane ?l - location) ; true if the airplane ?a is located at location ?l - (airplane-full ?a - plane) ; true if the airplane ?a cannot carry more packages - (airplane-has-package ?a - plane ?p - package) ; true if the airplane ?a is carrying the package ?p - (airplane-holding ?a - plane ?p - package) ; true if the airplane ?a is currently holding the package ?p - (at-airplane ?a - plane ?l - location) ; true if the airplane ?a is located at the location ?l - (location-connected ?l1 - location ?l2 - location ?c - city) ; true if location ?l1 is directly connected to location ?l2 in city ?c - (at-airport ?plane - plane ?city - city) ; true if the airplane ?plane is at the airport in city ?city + (truck-holding ?t - truck ?p - package) ; true if the truck ?t is currently holding the package ?p (truck-at-location ?t - truck ?l - location) ; true if the truck ?t is at the location ?l (package-at-location ?p - package ?l - location) ; true if the package ?p is at the location ?l + (airplane-at-airport ?a - plane) ; true if the airplane ?a is at the designated airport location + (airplane-has-space ?a - plane) ; true if the airplane ?a has space available to load more packages + (airplane-has-package ?a - plane ?p - package) ; true if the airplane ?a is carrying the package ?p + (airplane-holding ?a - plane ?p - package) ; true if the airplane ?a is holding the package ?p + (at-airport ?a - plane ?l - location) ; true if the airplane ?a is at the airport located at ?l + (location-connected ?l1 - location ?l2 - location ?c - city) ; true if location ?l1 is directly connected to location ?l2 in city ?c + (package-on-ground ?p - package) ; true if the package ?p is on the ground and not loaded onto any vehicle + (at-airplane ?a - plane ?l - location) ; true if the airplane ?a is currently at the location ?l + (airplane-in-city ?plane - plane, ?city - city) ; true if the airplane ?plane is currently in the city ?city ) (:action load_truck @@ -68,17 +70,16 @@ :parameters ( ?p - package ?a - plane -?l - location ) :precondition (and - (package-at ?p ?l) - (airplane-at ?a ?l) - (not (airplane-full ?a)) + (package-on-ground ?p) + (airplane-at-airport ?a) + (airplane-has-space ?a) ) :effect (and - (not (package-at ?p ?l)) + (not (package-on-ground ?p)) (airplane-has-package ?a ?p) ) ) @@ -123,21 +124,19 @@ (:action fly_airplane :parameters ( ?plane - plane -?from_airport - location -?to_airport - location ?from_city - city ?to_city - city ) :precondition (and - (at-airport ?from_airport ?from_city) - (at-airport ?to_airport ?to_city) - (airplane-at ?plane ?from_airport) + (at-airport ?from_city) + (at-airport ?to_city) + (airplane-in-city ?plane ?from_city) ) :effect (and - (not (airplane-at ?plane ?from_airport)) - (airplane-at ?plane ?to_airport) + (not (airplane-in-city ?plane ?from_city)) + (airplane-in-city ?plane ?to_city) ) ) ) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/llm+p.py b/paper_reconstructions/llm+p/main.py similarity index 78% rename from paper_reconstructions/llm+p/llm+p.py rename to paper_reconstructions/llm+p/main.py index c528b7b..cd7797a 100644 --- a/paper_reconstructions/llm+p/llm+p.py +++ b/paper_reconstructions/llm+p/main.py @@ -1,7 +1,7 @@ """ Paper: "LLM+P: Empowering Large Language Models with Optimal Planning Proficiency" Liu et al (2023) Source code: https://github.com/Cranial-XIX/llm-pddl -Run: python3 -m tests.paper_reconstructions.llm+p.llm+p +Run: python3 -m paper_reconstructions.llm+p.main Assumes the following: 1. NL task description @@ -12,14 +12,6 @@ import os from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def open_file(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - if __name__ == "__main__": @@ -27,14 +19,14 @@ def open_file(file_path): engine = "gpt-4o-mini" api_key = os.environ.get("OPENAI_API_KEY") openai_llm = OPENAI(model=engine, api_key=api_key) - planner = FastDownward() + planner = FastDownward(planner_path="downward/fast-downward.py") # prompts taken from LLM+P - role = open_file("paper_reconstructions/llm+p/prompts/role.txt") - example = open_file("paper_reconstructions/llm+p/prompts/example.txt") - task = open_file("paper_reconstructions/llm+p/prompts/task.txt") + role = load_file("paper_reconstructions/llm+p/prompts/role.txt") + example = load_file("paper_reconstructions/llm+p/prompts/example.txt") + task = load_file("paper_reconstructions/llm+p/prompts/task.txt") - problem_desc = open_file("paper_reconstructions/llm+p/prompts/problem_desc.txt") + problem_desc = load_file("paper_reconstructions/llm+p/prompts/problem_desc.txt") # assemble prompt builder prompt_builder = PromptBuilder(role=role, examples=[example], task=task) diff --git a/paper_reconstructions/nl2plan/nl2plan.py b/paper_reconstructions/nl2plan/main.py similarity index 87% rename from paper_reconstructions/nl2plan/nl2plan.py rename to paper_reconstructions/nl2plan/main.py index 1d9fb88..abe85ce 100644 --- a/paper_reconstructions/nl2plan/nl2plan.py +++ b/paper_reconstructions/nl2plan/main.py @@ -1,19 +1,11 @@ """ Paper: "NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions" Gestrin et al (2024) Source code: https://github.com/mrlab-ai/NL2Plan -Run: python3 -m paper_reconstructions.nl2plan.nl2plan +Run: python3 -m paper_reconstructions.nl2plan.main """ import os, json from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def open_file(file_path): - with open(file_path, "r") as file: - file = file.read().strip() - return file - def format_json_output(data): return json.dumps(data, indent=4) @@ -23,27 +15,27 @@ def format_json_output(data): api_key = os.environ.get("OPENAI_API_KEY") openai_llm = OPENAI(model=engine, api_key=api_key) -domain_desc = open_file("paper_reconstructions/nl2plan/prompts/blocksworld.txt") -problem_desc = open_file("paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt") +domain_desc = load_file("paper_reconstructions/nl2plan/prompts/blocksworld.txt") +problem_desc = load_file("paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt") # open and create type extraction prompt builder class -role_desc = open_file("paper_reconstructions/nl2plan/prompts/type_extraction/role.txt") -tech_desc = open_file( +role_desc = load_file("paper_reconstructions/nl2plan/prompts/type_extraction/role.txt") +tech_desc = load_file( "paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt" ) -task_desc = open_file("paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") +task_desc = load_file("paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") type_extraction_prompt = PromptBuilder( role=role_desc, technique=tech_desc, task=task_desc ) # open and create type hierarchy prompt builder class -role_desc = open_file( +role_desc = load_file( "paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt" ) -tech_desc = open_file( +tech_desc = load_file( "paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt" ) -task_desc = open_file( +task_desc = load_file( "paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt" ) type_hierarchy_prompt = PromptBuilder( @@ -51,13 +43,13 @@ def format_json_output(data): ) # open and create NL action prompt builder class -role_desc = open_file( +role_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_extraction/role.txt" ) -tech_desc = open_file( +tech_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt" ) -task_desc = open_file( +task_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_extraction/task.txt" ) action_extraction_prompt = PromptBuilder( @@ -65,13 +57,13 @@ def format_json_output(data): ) # open and create PDDL action prompt builder class -role_desc = open_file( +role_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_construction/role.txt" ) -tech_desc = open_file( +tech_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_construction/technique.txt" ) -task_desc = open_file( +task_desc = load_file( "paper_reconstructions/nl2plan/prompts/action_construction/task.txt" ) action_construction_prompt = PromptBuilder( @@ -79,11 +71,11 @@ def format_json_output(data): ) # open and create compact action prompt builder class -role_desc = open_file("paper_reconstructions/nl2plan/prompts/task_extraction/role.txt") -tech_desc = open_file( +role_desc = load_file("paper_reconstructions/nl2plan/prompts/task_extraction/role.txt") +tech_desc = load_file( "paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt" ) -task_desc = open_file("paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") +task_desc = load_file("paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") task_extraction_prompt = PromptBuilder( role=role_desc, technique=tech_desc, task=task_desc ) @@ -91,7 +83,7 @@ def format_json_output(data): domain_builder = DomainBuilder() task_builder = TaskBuilder() syntax_validator = SyntaxValidator() -planner = FastDownward() +planner = FastDownward(planner_path="downward/fast-downward.py") feedback_builder = FeedbackBuilder() unsupported_keywords = ["object", "pddl", "lisp"] @@ -105,7 +97,7 @@ def type_extraction( model, domain_desc, type_extraction_prompt.generate_prompt() ) - feedback_template = open_file( + feedback_template = load_file( "paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt" ) types, _ = feedback_builder.type_feedback( @@ -116,8 +108,7 @@ def type_extraction( types=types, llm_response=response, ) - - print("Types:", format_json_output(types)) + return types @@ -132,7 +123,7 @@ def hierarchy_construction( types=types, ) - feedback_template = open_file( + feedback_template = load_file( "paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt" ) type_hierarchy, _ = feedback_builder.type_hierarchy_feedback( @@ -144,7 +135,6 @@ def hierarchy_construction( llm_response=response, ) - print("Type Hierarchy", format_json_output(type_hierarchy)) return type_hierarchy @@ -159,7 +149,7 @@ def action_extraction( types=type_hierarchy, ) - feedback_template = open_file( + feedback_template = load_file( "paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt" ) nl_actions, _ = feedback_builder.nl_action_feedback( @@ -172,9 +162,6 @@ def action_extraction( type_hierarchy=type_hierarchy, ) - print("Natural Language Actions") - for i in nl_actions: - print(i) return nl_actions @@ -192,7 +179,7 @@ def action_construction( for action_name, action_desc in nl_actions.items(): - feedback_template = open_file( + feedback_template = load_file( "paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt" ) @@ -224,18 +211,20 @@ def action_construction( "\n\nThe following is a syntax error with your response:\n" + feedback_msg ) + + # TODO: currently buggy - run feedback at the end of the pipline # RUN FEEDBACK - action, new_predicates, _ = feedback_builder.pddl_action_feedback( - model=model, - domain_desc=domain_desc, - llm_response=llm_response, - feedback_template=feedback_template, - feedback_type="llm", - action=action, - predicates=predicates, - types=types, - ) + # action, new_predicates, _ = feedback_builder.pddl_action_feedback( + # model=model, + # domain_desc=domain_desc, + # llm_response=llm_response, + # feedback_template=feedback_template, + # feedback_type="llm", + # action=action, + # predicates=predicates, + # types=types, + # ) actions.append(action) predicates.extend(new_predicates) @@ -254,7 +243,7 @@ def task_extraction( model, problem_desc, task_extraction_prompt, types, predicates, actions ) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: # STEP FIVE: task extraction - feedback_template = open_file( + feedback_template = load_file( "paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt" ) @@ -311,10 +300,6 @@ def task_extraction( initial = task_builder.format_initial(initial) goal = task_builder.format_goal(goal) - print("Objects:\n", objects) - print("Initial States:\n", initial) - print("Goal States:\n", goal) - return objects, initial, goal @@ -323,6 +308,7 @@ def task_extraction( # STEP ONE: type extraction types = type_extraction(openai_llm, domain_desc, type_extraction_prompt) + print("Types:", format_json_output(types)) print("END OF STEP ONE") # STEP TWO: hierarchy construction @@ -330,6 +316,7 @@ def task_extraction( openai_llm, domain_desc, type_hierarchy_prompt, types ) + print("Type Hierarchy", format_json_output(type_hierarchy)) print("END OF STEP TWO") # STEP THREE: action extraction @@ -337,6 +324,9 @@ def task_extraction( openai_llm, domain_desc, action_extraction_prompt, type_hierarchy ) + print("Natural Language Actions") + for i in nl_actions: + print(i) print("END OF STEP THREE") # STEP FOUR: action construction @@ -344,6 +334,13 @@ def task_extraction( openai_llm, domain_desc, action_construction_prompt, nl_actions, type_hierarchy ) + print("PDDL Actions") + for i in actions: + print(i) + print("--------------------") + print("PDDL Predicates") + for i in predicates: + print(i) print("END OF STEP FOUR") types = format_types(type_hierarchy) # retrieve types @@ -361,6 +358,9 @@ def task_extraction( openai_llm, problem_desc, task_extraction_prompt, types, predicates, actions ) + print("Objects:\n", objects) + print("Initial States:\n", initial) + print("Goal States:\n", goal) print("END OF STEP FIVE") # format strings diff --git a/paper_reconstructions/nl2plan/results/domain.pddl b/paper_reconstructions/nl2plan/results/domain.pddl index 8550a6f..1497ce6 100644 --- a/paper_reconstructions/nl2plan/results/domain.pddl +++ b/paper_reconstructions/nl2plan/results/domain.pddl @@ -1,30 +1,115 @@ (define (domain test_domain) - (:requirements :conditional-effects :disjunctive-preconditions :equality :negative-preconditions :strips :typing :universal-preconditions) - (:types arm - mechanism block table - physical_object) - (:predicates (at ?a - arm ?t - table) (clear ?b - block) (holding ?a - arm ?b - block) (on ?b1 - block ?b2 - block)) - (:action check_clear - :parameters (?a - arm ?b - block) - :precondition (and (at ?a ?t) (not (holding ?a ?b)) (clear ?b)) - :effect (clear ?b) - ) - (:action pickup - :parameters (?a - arm ?b - block ?t - table) - :precondition (and (at ?a ?t) (clear ?b) (not (holding ?a ?b)) (at ?b ?t)) - :effect (and (holding ?a ?b) (not (at ?b ?t)) (not (clear ?b))) - ) - (:action putdown - :parameters (?a - arm ?b - block ?t - table) - :precondition (and (holding ?a ?b) (not (at ?b ?t))) - :effect (and (not (holding ?a ?b)) (at ?b ?t) (clear ?b)) - ) - (:action stack - :parameters (?a - arm ?b1 - block ?b2 - block ?t - table) - :precondition (and (holding ?a ?b1) (clear ?b2) (at ?a ?t)) - :effect (and (not (holding ?a ?b1)) (on ?b1 ?b2) (not (clear ?b2))) - ) - (:action unstack - :parameters (?a - arm ?b1 - block ?b2 - block ?t - table) - :precondition (and (at ?a ?t) (clear ?b1) (not (holding ?a ?b1)) (on ?b1 ?b2)) - :effect (and (holding ?a ?b1) (not (on ?b1 ?b2)) (clear ?b2)) - ) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - physical_object + table - physical_object + arm - tool + ) + + (:predicates + (at ?b - block ?t - table) ; true if the block ?b is at the table ?t + (clear ?b - block) ; true if the block ?b is clear (not covered by another block) + (empty ?a - arm) ; true if the arm ?a is empty (not holding any block) + (holding ?a - arm ?b - block) ; true if the arm ?a is holding the block ?b + (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + ) + + (:action pickup + :parameters ( + ?a - arm + ?b - block + ?t - table + ) + :precondition + (and + (at ?b ?t) ; The block is at the table + (clear ?b) ; The block is clear (not covered by another block) + (empty ?a) ; The arm is empty (not holding any block) + ) + :effect + (and + (not (at ?b ?t)) ; The block is no longer at the table + (not (clear ?b)) ; The block is no longer clear + (holding ?a ?b) ; The arm is now holding the block + ) + ) + + (:action putdown + :parameters ( + ?a - arm + ?b - block + ?t - table + ) + :precondition + (and + (holding ?a ?b) ; The arm is holding the block + (clear ?t) ; The location on the table is clear + ) + :effect + (and + (not (holding ?a ?b)) ; The arm is no longer holding the block + (at ?b ?t) ; The block is now on the table + (clear ?b) ; The block is now clear + ) + ) + + (:action stack + :parameters ( + ?a - arm + ?b1 - block + ?b2 - block + ) + :precondition + (and + (holding ?a ?b1) ; The arm is holding the top block + (clear ?b2) ; The bottom block is clear + (not (on ?b1 ?b2)) ; The top block is not already on the bottom block + ) + :effect + (and + (not (holding ?a ?b1)) ; The arm is no longer holding the top block + (on ?b1 ?b2) ; The top block is now on the bottom block + (not (clear ?b2)) ; The bottom block is no longer clear + (empty ?a) ; The arm is now empty + ) + ) + + (:action unstack + :parameters ( + ?a - arm + ?b1 - block + ?b2 - block + ) + :precondition + (and + (empty ?a) ; The arm is empty + (clear ?b1) ; The top block is clear + (on ?b1 ?b2) ; The top block is on the bottom block + ) + :effect + (and + (holding ?a ?b1) ; The arm is now holding the top block + (not (on ?b1 ?b2)) ; The top block is no longer on the bottom block + (clear ?b2) ; The bottom block is now clear + (not (clear ?b1)) ; The top block is no longer clear + ) + ) + + (:action check_clear + :parameters ( + ?b - block + ?a - arm + ) + :precondition + (and + (at ?b ?t) ; The block is at the table + (empty ?a) ; The arm is empty + ) + :effect + (and + (clear ?b) ; The block is confirmed to be clear + ) + ) ) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/problem.pddl b/paper_reconstructions/nl2plan/results/problem.pddl index dd9201d..47173ab 100644 --- a/paper_reconstructions/nl2plan/results/problem.pddl +++ b/paper_reconstructions/nl2plan/results/problem.pddl @@ -1,6 +1,31 @@ -(define (problem test_problem) - (:domain test_domain) - (:objects blue_block green_block red_block yellow_block - block table1 - table) - (:init (clear green_block) (clear yellow_block) (on blue_block red_block) (on green_block table1) (on red_block yellow_block) (on yellow_block table1)) - (:goal (on red_block green_block)) +(define + (problem test_problem) + (:domain test_domain) + + (:objects + blue_block - block + red_block - block + yellow_block - block + green_block - block + table1 - table + ) + + (:init + (on blue_block red_block) + (on red_block yellow_block) + (at yellow_block table1) + (at green_block table1) + (clear blue_block) + (clear green_block) + (clear red_block) + (and ) + (on red_block green_block) + ) + + (:goal + (and + (on red_block green_block) + ) + ) + ) \ No newline at end of file diff --git a/paper_reconstructions/p+s/main.py b/paper_reconstructions/p+s/main.py new file mode 100644 index 0000000..19b4e01 --- /dev/null +++ b/paper_reconstructions/p+s/main.py @@ -0,0 +1,7 @@ +""" +Paper: "Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behavior in out-of-distribution reasoning tasks" Collins et al. (2022) +Source code: https://github.com/collinskatie/structured_flexible_and_robust +Run: python3 -m paper_reconstructions.p+s.main +""" + +# TODO: implementation \ No newline at end of file diff --git a/paper_reconstructions/proc2pddl/proc2pddl.py b/paper_reconstructions/proc2pddl/main.py similarity index 86% rename from paper_reconstructions/proc2pddl/proc2pddl.py rename to paper_reconstructions/proc2pddl/main.py index b2a269d..ca39bbd 100644 --- a/paper_reconstructions/proc2pddl/proc2pddl.py +++ b/paper_reconstructions/proc2pddl/main.py @@ -1,22 +1,11 @@ """ Paper: "PROC2PDDL: Open-Domain Planning Representations from Texts" Zhang et al. (2024) Source code: https://github.com/zharry29/proc2pddl -Run: python3 -m paper_reconstructions.proc2pddl.proc2pddl +Run: python3 -m paper_reconstructions.proc2pddl.main """ -import os, json +import os from l2p import * -from l2p.utils.pddl_planner import FastDownward - - -def load_file(file_path): - with open(file_path, "r") as file: - return file.read().strip() - - -def load_json(file_path): - with open(file_path, "r") as file: - return json.load(file) engine = "gpt-4o-mini" @@ -27,12 +16,12 @@ def load_json(file_path): task_builder = TaskBuilder() feedback_builder = FeedbackBuilder() prompt_builder = PromptBuilder() -planner = FastDownward() +planner = FastDownward(planner_path="downward/fast-downward.py") # annotated original domain header -types = load_json("paper_reconstructions/proc2pddl/prompts/types.json") -predicates = load_json("paper_reconstructions/proc2pddl/prompts/predicates.json") -nl_actions = load_json("paper_reconstructions/proc2pddl/prompts/nl_actions.json") +types = load_file("paper_reconstructions/proc2pddl/prompts/types.json") +predicates = load_file("paper_reconstructions/proc2pddl/prompts/predicates.json") +nl_actions = load_file("paper_reconstructions/proc2pddl/prompts/nl_actions.json") if __name__ == "__main__": diff --git a/paper_reconstructions/proc2pddl/results/domain.pddl b/paper_reconstructions/proc2pddl/results/domain.pddl index b9bfbce..466edbc 100644 --- a/paper_reconstructions/proc2pddl/results/domain.pddl +++ b/paper_reconstructions/proc2pddl/results/domain.pddl @@ -1,8 +1,8 @@ (define (domain survive_deserted_island) - (:requirements - :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects - ) - (:types + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types item - object water - item wood - item @@ -45,235 +45,237 @@ (cooked ?item - item) ) -(:action go - :parameters ( -?player - human -?from - location -?to - location + (:action go + :parameters ( + ?player - human + ?from - location + ?to - location + ) + :precondition + (and + (at ?player ?from) ; The player is at the current location + (connected ?from ?to) ; The current location is connected to the new location + ) + :effect + (and + (not (at ?player ?from)) ; The player is no longer at the current location + (at ?player ?to) ; The player is now at the new adjacent location + ) ) - :precondition -(and - (at ?player ?from) ; The player is at the current location - (connected ?from ?to) ; The current location is connected to the adjacent location -) - :effect -(and - (not (at ?player ?from)) ; The player is no longer at the current location - (at ?player ?to) ; The player is now at the adjacent location -) -) -(:action get - :parameters ( -?player - human -?item - object -?loc - location + (:action get + :parameters ( + ?player - human + ?item - object + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (at ?item ?loc) ; The item is present in the current location + ) + :effect + (and + (not (at ?item ?loc)) ; The item is no longer in the environment + (inventory ?player ?item) ; The item is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (at ?item ?loc) ; The item is present in the current location -) - :effect -(and - (inventory ?player ?item) ; The item is now in the player's inventory - (not (at ?item ?loc)) ; The item is no longer in the current location -) -) -(:action get_water - :parameters ( -?player - human -?water - water -?loc - location + (:action get_water + :parameters ( + ?player - human + ?water - water + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_water_source ?loc) ; The location has a water source + ) + :effect + (and + (inventory ?player ?water) ; The water is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (has_water_source ?loc) ; The location has a water source -) - :effect -(and - (inventory ?player ?water) ; The player has water in their inventory -) -) -(:action chop_wood - :parameters ( -?player - human -?wood - wood -?loc - location + (:action chop_wood + :parameters ( + ?player - human + ?wood - wood + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_wood ?loc) ; The location has wood + ) + :effect + (and + (inventory ?player ?wood) ; The wood is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the current location - (has_wood ?loc) ; The location has wood available -) - :effect -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (not (has_wood ?loc)) ; The wood is no longer in the current location -) -) -(:action carve_groove - :parameters ( -?player - human -?wood - wood + (:action carve_groove + :parameters ( + ?player - human + ?wood - wood + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + ) + :effect + (and + (groove ?wood) ; The wood now has a groove + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory -) - :effect -(and - (groove ?wood) ; The wood now has a groove made in it -) -) -(:action light_fire - :parameters ( -?player - human -?loc - location + (:action light_fire + :parameters ( + ?player - human + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (can_light_fire ?loc) ; The location is safe for lighting a fire + ) + :effect + (and + (has_fire ?loc) ; A fire is now lit at the location + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at the location - (can_light_fire ?loc) ; The location is safe for lighting a fire -) - :effect -(and - (has_fire ?loc) ; A fire is now lit at the location -) -) -(:action build_shelter - :parameters ( -?player - human -?wood - wood -?loc - location + (:action build_shelter + :parameters ( + ?player - human + ?wood - wood + ?loc - location + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (is_safe ?loc) ; The location is safe to make shelter + ) + :effect + (and + (has_shelter ?loc) ; A shelter is now built at the location + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (is_safe ?loc) ; The location is safe for making shelter -) - :effect -(and - (has_shelter ?loc) ; A shelter is now built at the location -) -) -(:action clean_water - :parameters ( -?player - human -?water - water -?loc - location + (:action clean_water + :parameters ( + ?player - human + ?water - water + ?loc - location + ) + :precondition + (and + (inventory ?player ?water) ; The player has untreated water in their inventory + (has_fire ?loc) ; There is a fire lit at the location + ) + :effect + (and + (treated ?water) ; The water is now treated and safe for drinking + ) ) - :precondition -(and - (inventory ?player ?water) ; The player has untreated water in their inventory - (has_fire ?loc) ; There is a fire at the location -) - :effect -(and - (treated ?water) ; The water is now treated and safe for drinking -) -) -(:action drink_water - :parameters ( -?player - human -?water - water + (:action drink_water + :parameters ( + ?player - human + ?water - water + ) + :precondition + (and + (inventory ?player ?water) ; The player has water in their inventory + ) + :effect + (and + (not (inventory ?player ?water)) ; The water is removed from the inventory + (drank ?player) ; The player has consumed the water + ) ) - :precondition -(and - (inventory ?player ?water) ; The player has treated water in their inventory -) - :effect -(and - (drank ?player) ; The player has now drunk the water - (not (inventory ?player ?water)) ; The water is removed from the player's inventory -) -) -(:action find_other_survivors - :parameters ( -?player - human + (:action find_other_survivors + :parameters ( + ?player - human + ) + :precondition + (and + ; The player must navigate to various locations (no specific predicates needed) + ) + :effect + (and + (has_friend ?player) ; The player may have found a survivor + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at a location -) - :effect -(and - (has_friend ?player) ; The player may have found a survivor -) -) -(:action build_raft - :parameters ( -?player - human -?raft - raft + (:action build_raft + :parameters ( + ?player - human + ?wood - wood + ?vines - vines + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (inventory ?player ?vines) ; The player has vines in their inventory + ) + :effect + (and + (has_escaped ?player) ; The player has built a raft and is ready to escape + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory - (inventory ?player ?vines) ; The player has vines in their inventory -) - :effect -(and - (has_escaped ?player) ; A raft is now built and ready for use -) -) -(:action make_weapon - :parameters ( -?player - human -?wood - wood -?spear - spear + (:action make_weapon + :parameters ( + ?player - human + ?wood - wood + ?rock - rock + ?spear - spear + ) + :precondition + (and + (inventory ?player ?wood) ; The player has wood in their inventory + (inventory ?player ?rock) ; The player has a sharp rock in their inventory + ) + :effect + (and + (inventory ?player ?spear) ; The spear is now in the player's inventory + ) ) - :precondition -(and - (inventory ?player ?wood) ; The player has wood in their inventory -) - :effect -(and - (inventory ?player ?spear) ; A spear is now created and available for use -) -) -(:action hunt_fish - :parameters ( -?player - human -?fish - fish -?loc - location + (:action hunt_fish + :parameters ( + ?player - human + ?fish - fish + ?loc - location + ) + :precondition + (and + (at ?player ?loc) ; The player is at the current location + (has_fish ?loc) ; The location has fish + ) + :effect + (and + (inventory ?player ?fish) ; The fish is now in the player's inventory + ) ) - :precondition -(and - (at ?player ?loc) ; The player is at a location - (has_fish ?loc) ; The location has fish -) - :effect -(and - (inventory ?player ?fish) ; The player has fish in their inventory -) -) -(:action cook_fish - :parameters ( -?player - human -?fish - fish -?loc - location + (:action cook_fish + :parameters ( + ?player - human + ?fish - fish + ?loc - location + ) + :precondition + (and + (inventory ?player ?fish) ; The player has fish in their inventory + (has_fire ?loc) ; There is a fire lit at the location + ) + :effect + (and + (cooked ?fish) ; The fish is now cooked and safe for consumption + ) ) - :precondition -(and - (inventory ?player ?fish) ; The player has fish in their inventory - (has_fire ?loc) ; There is a fire at the location -) - :effect -(and - (cooked ?fish) ; The fish is now cooked and ready to eat -) -) ) \ No newline at end of file diff --git a/paper_reconstructions/there-and-back/main.py b/paper_reconstructions/there-and-back/main.py new file mode 100644 index 0000000..a6cc992 --- /dev/null +++ b/paper_reconstructions/there-and-back/main.py @@ -0,0 +1,7 @@ +""" +Paper: "There and Back Again:Extracting Formal Domains for Controllable Neurosymbolic Story Authoring" Kelly et al. (2023) +Source code: https://github.com/alex-calderwood/there-and-back +Run: python3 -m paper_reconstructions.there-and-back.main +""" + +# TODO: implementation \ No newline at end of file diff --git a/tests/test_domain_builder.py b/tests/test_domain_builder.py index cc46bd9..a92d7f5 100644 --- a/tests/test_domain_builder.py +++ b/tests/test_domain_builder.py @@ -1,6 +1,6 @@ import unittest from l2p.domain_builder import DomainBuilder -from l2p.utils import * +from l2p.utils.pddl_parser import load_file from .mock_llm import MockLLM From c7b2c282a591840b0aed411405124322dff64d52 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 25 Dec 2024 12:19:06 -0500 Subject: [PATCH 02/15] added generate domain test done --- l2p/domain_builder.py | 5 +-- l2p/feedback_builder.py | 3 +- l2p/prompt_builder.py | 3 -- l2p/task_builder.py | 3 +- tests/test_domain_builder.py | 71 +++++++++++++++++++++++++++++++++--- 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index f2cc1e2..d1d1016 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -3,8 +3,7 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm from collections import OrderedDict import re, time @@ -729,7 +728,7 @@ def generate_domain( """ desc = "" desc += f"(define (domain {domain})\n" - desc += indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + "\n\n" + desc += indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + "\n\n" desc += f" (:types \n{indent(string=types, level=2)}\n )\n\n" desc += f" (:predicates \n{indent(string=predicates, level=2)}\n )" desc += self.action_descs(actions) diff --git a/l2p/feedback_builder.py b/l2p/feedback_builder.py index f965da8..f9f6110 100644 --- a/l2p/feedback_builder.py +++ b/l2p/feedback_builder.py @@ -3,8 +3,7 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm from .domain_builder import DomainBuilder from .task_builder import TaskBuilder from collections import OrderedDict diff --git a/l2p/prompt_builder.py b/l2p/prompt_builder.py index 52297b9..5bb8e87 100644 --- a/l2p/prompt_builder.py +++ b/l2p/prompt_builder.py @@ -3,9 +3,6 @@ have to use this class, but it is generally advisable for ease of use. """ -import os - - class PromptBuilder: def __init__( self, diff --git a/l2p/task_builder.py b/l2p/task_builder.py index 8291034..f36795e 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -3,8 +3,7 @@ """ from .utils import * -from .llm_builder import LLM -from .llm_builder import require_llm +from .llm_builder import LLM, require_llm import time diff --git a/tests/test_domain_builder.py b/tests/test_domain_builder.py index a92d7f5..e761dd5 100644 --- a/tests/test_domain_builder.py +++ b/tests/test_domain_builder.py @@ -1,4 +1,4 @@ -import unittest +import unittest, textwrap from l2p.domain_builder import DomainBuilder from l2p.utils.pddl_parser import load_file from .mock_llm import MockLLM @@ -48,6 +48,7 @@ def test_extract_type(self): self.assertIn("Max retries exceeded", str(context.exception)) def test_extract_type_hierarchy(self): + mock_llm_1 = MockLLM( [load_file("tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/01.txt")] ) @@ -112,10 +113,6 @@ def test_extract_type_hierarchy(self): ) self.assertIn("Max retries exceeded", str(context.exception)) - # TODO: implement rest of test domain builder functions - def test_extract_nl_actions(self): - pass - def test_extract_pddl_action(self): pass @@ -135,8 +132,70 @@ def test_extract_predicates(self): pass def test_generate_domain(self): - pass + + domain = "test_domain" + types = "robot location" + predicates = "(at ?r - robot ?l - location)\n(connected ?l1 ?l2 - location)" + actions = [ + { + "name": "move", + "params": {"?r": "robot", "?l1": "location", "?l2": "location"}, + "preconditions": "(and (at ?r ?l1) (connected ?l1 ?l2))", + "effects": "(and (not (at ?r ?l1)) (at ?r ?l2))", + }, + { + "name": "pick", + "params": {"?r": "robot", "?l": "location"}, + "preconditions": "(and (at ?r ?l) (not (holding ?r)))", + "effects": "(holding ?r)", + }, + ] + requirements = [":strips", ":typing"] + + expected_output = textwrap.dedent("""\ + (define (domain test_domain) + (:requirements + :strips :typing) + + (:types + robot location + ) + + (:predicates + (at ?r - robot ?l - location) + (connected ?l1 ?l2 - location) + ) + + (:action move + :parameters ( + ?r - robot + ?l1 - location + ?l2 - location + ) + :precondition + (and (at ?r ?l1) (connected ?l1 ?l2)) + :effect + (and (not (at ?r ?l1)) (at ?r ?l2)) + ) + + (:action pick + :parameters ( + ?r - robot + ?l - location + ) + :precondition + (and (at ?r ?l) (not (holding ?r))) + :effect + (holding ?r) + ) + ) + """).strip() + + result = self.domain_builder.generate_domain(domain=domain, types=types, predicates=predicates, actions=actions, requirements=requirements) + + self.assertEqual(result.strip(), expected_output.strip()) if __name__ == "__main__": unittest.main() + From 56b62d761deec6bcad696ad2b447563b0d50268b Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 25 Dec 2024 17:41:55 -0500 Subject: [PATCH 03/15] added in P+S paper reconstruction --- l2p/task_builder.py | 2 +- paper_reconstructions/p+s/main.py | 205 +++++++++++++++++- .../p+s/problems/goal/000.txt | 2 + .../p+s/problems/goal/001.txt | 7 + .../p+s/problems/goal/002.txt | 6 + .../p+s/problems/initial/000.txt | 5 + .../p+s/problems/initial/001.txt | 6 + .../p+s/problems/initial/002.txt | 7 + .../p+s/prompts/examples/goal/example_01.txt | 16 ++ .../p+s/prompts/examples/goal/example_02.txt | 18 ++ .../p+s/prompts/examples/goal/example_03.txt | 20 ++ .../prompts/examples/initial/example_01.txt | 14 ++ .../prompts/examples/initial/example_02.txt | 16 ++ .../prompts/examples/initial/example_03.txt | 19 ++ paper_reconstructions/p+s/results/domain.pddl | 29 +++ .../p+s/results/problem_01/plan.txt | 6 + .../p+s/results/problem_01/problem-01.pddl | 33 +++ .../p+s/results/problem_02/plan.txt | 3 + .../p+s/results/problem_02/problem-02.pddl | 39 ++++ .../p+s/results/problem_03/plan.txt | 5 + .../p+s/results/problem_03/problem-03.pddl | 39 ++++ 21 files changed, 495 insertions(+), 2 deletions(-) create mode 100644 paper_reconstructions/p+s/problems/goal/000.txt create mode 100644 paper_reconstructions/p+s/problems/goal/001.txt create mode 100644 paper_reconstructions/p+s/problems/goal/002.txt create mode 100644 paper_reconstructions/p+s/problems/initial/000.txt create mode 100644 paper_reconstructions/p+s/problems/initial/001.txt create mode 100644 paper_reconstructions/p+s/problems/initial/002.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/goal/example_01.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/goal/example_02.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/goal/example_03.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/initial/example_01.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/initial/example_02.txt create mode 100644 paper_reconstructions/p+s/prompts/examples/initial/example_03.txt create mode 100644 paper_reconstructions/p+s/results/domain.pddl create mode 100644 paper_reconstructions/p+s/results/problem_01/plan.txt create mode 100644 paper_reconstructions/p+s/results/problem_01/problem-01.pddl create mode 100644 paper_reconstructions/p+s/results/problem_02/plan.txt create mode 100644 paper_reconstructions/p+s/results/problem_02/problem-02.pddl create mode 100644 paper_reconstructions/p+s/results/problem_03/plan.txt create mode 100644 paper_reconstructions/p+s/results/problem_03/problem-03.pddl diff --git a/l2p/task_builder.py b/l2p/task_builder.py index f36795e..4686031 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -433,7 +433,7 @@ def format_action(self, actions: list[Action]) -> str: return desc def format_objects(self, objects: dict[str, str]) -> str: - objects = "\n".join([f"{obj} - {type}" for obj, type in objects.items()]) + objects = "\n".join([f"{obj} - {type}" if type else f"{obj}" for obj, type in objects.items()]) return objects def format_initial(self, initial_states: list[dict[str, str]]) -> str: diff --git a/paper_reconstructions/p+s/main.py b/paper_reconstructions/p+s/main.py index 19b4e01..a4889b1 100644 --- a/paper_reconstructions/p+s/main.py +++ b/paper_reconstructions/p+s/main.py @@ -2,6 +2,209 @@ Paper: "Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behavior in out-of-distribution reasoning tasks" Collins et al. (2022) Source code: https://github.com/collinskatie/structured_flexible_and_robust Run: python3 -m paper_reconstructions.p+s.main + +This framework (Part II of paper) utilizes "Language-of-Thought" (LOT) prompting where thinking operates like formal language. +Mental representations are structured symbolically with rules for logical reasoning and problem-solving. L2P follows this paradigm. +In this paper, they are tasking the LLM to translate natural language initial and goal states to PDDL via few shot prompting. """ -# TODO: implementation \ No newline at end of file +from l2p import * +from itertools import combinations + + +def run_parse_and_solve( + model: LLM, + prompt_initial: str, + prompt_goal: str, + problem_path: str, + problem_name: str, + objects: dict[str,str] + ): + """ + Main framework of P+S - translate initial and goal states to PDDL from NL + + Args: + model (LLM): LLM model to run inference + prompt_initial (str): prompt for translating initial state + prompt_goal (str): prompt for translating goal state + problem_path (str): directory of specific problem + problem_name (str): PDDL problem name + objects (dict[str,str]): objects of task file + """ + + # extract initial states + initial_states, _ = task_builder.extract_initial_state( + model=model, + problem_desc="", + prompt_template=prompt_initial, + objects="") + + # extract goal states + goal_states, _ = task_builder.extract_goal_state( + model=model, + problem_desc="", + prompt_template=prompt_goal, + objects="") + + # convert Python components to string + objects_str = task_builder.format_objects(objects) + initial_state_str = task_builder.format_initial(initial_states) + goal_state_str = task_builder.format_goal(goal_states) + + # insert `(noteq)` predicate manually (due to domain from paper) + objects = objects_str.split("\n") + for obj1, obj2 in combinations(objects, 2): # create all combinations + initial_state_str += f"\n(noteq {obj1} {obj2})" + + # take components and generate PDDL task format + pddl_problem = task_builder.generate_task( + "simple-blocks", + problem_name, + objects=objects_str, + initial=initial_state_str, + goal=goal_state_str) + + # write the problem file to respective directory + problem_file = problem_path + f"/{problem_name}.pddl" + with open(problem_file, "w") as f: + f.write(pddl_problem) + + return problem_file + + +def run_problem_01(init_examples, goal_examples): + # PROBLEM 1 + problem_path = "paper_reconstructions/p+s/results/problem_01" + objects_01 = {'sketchbook':'', 'sweatshirt':'', 'keyboard':'', 'novel':''} + + # assemble prompt template for initial and goal state extraction + prompt_initial_01 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/000.txt")) + + prompt_goal_01 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/000.txt")) + + # run framework + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_01.generate_prompt(), + prompt_goal=prompt_goal_01.generate_prompt(), + problem_path=problem_path, + problem_name="problem-01", + objects=objects_01) + + # run FastDownward planner + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + # write result of plan + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +def run_problem_02(init_examples, goal_examples): + # PROBLEM 2 + problem_path = "paper_reconstructions/p+s/results/problem_02" + objects_02 = {'newspaper':'', 'accordion':'', 'saucepan':'', 'peacoat':''} + + prompt_initial_02 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/001.txt")) + + prompt_goal_02 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/001.txt")) + + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_02.generate_prompt(), + prompt_goal=prompt_goal_02.generate_prompt(), + problem_path=problem_path, + problem_name="problem-02", + objects=objects_02) + + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +def run_problem_03(init_examples, goal_examples): + # PROBLEM 3 + problem_path = "paper_reconstructions/p+s/results/problem_03" + objects_03 = {'mouse-pad':'', 'hacksaw':'', 'saucepan':'', 'raincoat':''} + + # assemble prompt template for initial and goal state extraction + prompt_initial_03 = PromptBuilder( + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/002.txt")) + + prompt_goal_03 = PromptBuilder( + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/002.txt")) + + problem_file = run_parse_and_solve( + model=openai_llm, + prompt_initial=prompt_initial_03.generate_prompt(), + prompt_goal=prompt_goal_03.generate_prompt(), + problem_path=problem_path, + problem_name="problem-03", + objects=objects_03) + + _, result = planner.run_fast_downward( + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file) + + with open(problem_path + "/plan.txt", "w") as f: + f.write(result) + + +if __name__ == "__main__": + + # setup L2P requirements + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + openai_llm = OPENAI(model=engine, api_key=api_key) + planner = FastDownward(planner_path="downward/fast-downward.py") + + # load in few shot examples + folder_path = "paper_reconstructions/p+s/prompts/examples/initial" + init_examples = [] + + for filename in os.listdir(folder_path): + if filename.endswith(".txt"): + file_path = os.path.join(folder_path, filename) + file_content = load_file(file_path) + init_examples.append(file_content) + + folder_path = "paper_reconstructions/p+s/prompts/examples/goal" + goal_examples = [] + + for filename in os.listdir(folder_path): + if filename.endswith(".txt"): + file_path = os.path.join(folder_path, filename) + file_content = load_file(file_path) + goal_examples.append(file_content) + + # load in base templates + ROLE = "Your task is to convert the natural language states into PDDL initial state predicates.\n\n" + ROLE_INITIAL = ROLE + load_file("templates/task_templates/extract_initial.txt") + ROLE_GOAL = ROLE + load_file("templates/task_templates/extract_goal.txt") + DOMAIN_DIR = "paper_reconstructions/p+s/domain.pddl" + + # run problem sets + run_problem_01(init_examples, goal_examples) + run_problem_02(init_examples, goal_examples) + run_problem_03(init_examples, goal_examples) + \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/000.txt b/paper_reconstructions/p+s/problems/goal/000.txt new file mode 100644 index 0000000..49af523 --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/000.txt @@ -0,0 +1,2 @@ +;The keyboard is on the sketchbook. +;The sweatshirt rests on the table. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/001.txt b/paper_reconstructions/p+s/problems/goal/001.txt new file mode 100644 index 0000000..07c8213 --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/001.txt @@ -0,0 +1,7 @@ +;There is nothing on the newspaper. +;The accordion rests on the table. +;There is nothing on the saucepan. +;The saucepan rests on the table. +;The newspaper is on the accordion. +;The peacoat rests on the table. +;There is nothing on the peacoat. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/goal/002.txt b/paper_reconstructions/p+s/problems/goal/002.txt new file mode 100644 index 0000000..52bb76e --- /dev/null +++ b/paper_reconstructions/p+s/problems/goal/002.txt @@ -0,0 +1,6 @@ +;The mouse pad rests on the table. +;The saucepan rests on the table. +;There is nothing on the hacksaw. +;The raincoat is on the mouse pad. +;The hacksaw is on the raincoat. +;There is nothing on the saucepan. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/000.txt b/paper_reconstructions/p+s/problems/initial/000.txt new file mode 100644 index 0000000..1585038 --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/000.txt @@ -0,0 +1,5 @@ +;The sketchbook rests on the table. +;The sweatshirt is on the sketchbook. +;The keyboard is on the sweatshirt. +;The novel is on the keyboard. +;There is nothing on the novel. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/001.txt b/paper_reconstructions/p+s/problems/initial/001.txt new file mode 100644 index 0000000..a76fcda --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/001.txt @@ -0,0 +1,6 @@ +;The accordion rests on the table. +;The newspaper is on the accordion. +;The saucepan is on the newspaper. +;There is nothing on the saucepan. +;The peacoat rests on the table. +;There is nothing on the peacoat. \ No newline at end of file diff --git a/paper_reconstructions/p+s/problems/initial/002.txt b/paper_reconstructions/p+s/problems/initial/002.txt new file mode 100644 index 0000000..defd1d4 --- /dev/null +++ b/paper_reconstructions/p+s/problems/initial/002.txt @@ -0,0 +1,7 @@ +;The raincoat rests on the table. +;There is nothing on the raincoat. +;The hacksaw rests on the table. +;There is nothing on the hacksaw. +;The saucepan rests on the table. +;The mouse pad is on the saucepan. +;There is nothing on the mouse pad. \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt new file mode 100644 index 0000000..0922ab3 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_01.txt @@ -0,0 +1,16 @@ +;The phone rests on the table. +;The plate is on the phone. +;The notebook is on the plate. +;The textbook is on the notebook. +;There is nothing on the textbook. + +### GOAL +``` +(and + (ontable phone) + (on plate phone) + (on notebook plate) + (on textbook notebook) + (clear textbook) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt new file mode 100644 index 0000000..93d3c00 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_02.txt @@ -0,0 +1,18 @@ +;The newspaper rests on the table. +;The plate is on the newspaper. +;There is nothing on the plate. +;The tissue box rests on the table. +;The textbook is on the tissue box. +;There is nothing on the textbook. + +### GOAL +``` +(and + (ontable newspaper) + (on plate newspaper) + (clear plate) + (ontable tissue-box) + (on textbook tissue-box) + (clear textbook) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt b/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt new file mode 100644 index 0000000..5b21fdc --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/goal/example_03.txt @@ -0,0 +1,20 @@ +;The phone rests on the table. +;The plate is on the phone. +;There is nothing on the plate. +;The novel rests on the table. +;There is nothing on the novel. +;The writing pad rests on the table. +;There is nothing on the writing pad. + +### GOAL +``` +(and + (ontable phone) + (on plate phone) + (clear plate) + (ontable novel) + (clear novel) + (ontable writing-pad) + (clear writing-pad) +) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt new file mode 100644 index 0000000..fb5e883 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_01.txt @@ -0,0 +1,14 @@ +;The phone rests on the table. +;The plate is on the phone. +;The notebook is on the plate. +;The textbook is on the notebook. +;There is nothing on the textbook. + +### INITIAL +``` +(ontable phone) +(on plate phone) +(on notebook plate) +(on textbook notebook) +(clear textbook) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt new file mode 100644 index 0000000..1d82f00 --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_02.txt @@ -0,0 +1,16 @@ +;The newspaper rests on the table. +;The plate is on the newspaper. +;There is nothing on the plate. +;The tissue box rests on the table. +;The textbook is on the tissue box. +;There is nothing on the textbook. + +### INITIAL +``` +(ontable newspaper) +(on plate newspaper) +(clear plate) +(ontable tissue-box) +(on textbook tissue-box) +(clear textbook) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt b/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt new file mode 100644 index 0000000..9d1e83e --- /dev/null +++ b/paper_reconstructions/p+s/prompts/examples/initial/example_03.txt @@ -0,0 +1,19 @@ +;The phone rests on the table. +;The plate is on the phone. +;There is nothing on the plate. +;The novel rests on the table. +;There is nothing on the novel. +;The writing pad rests on the table. +;There is nothing on the writing pad. +``` + +### INITIAL +``` +(ontable phone) +(on plate phone) +(clear plate) +(ontable novel) +(clear novel) +(ontable writing-pad) +(clear writing-pad) +``` \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/domain.pddl b/paper_reconstructions/p+s/results/domain.pddl new file mode 100644 index 0000000..91da5a7 --- /dev/null +++ b/paper_reconstructions/p+s/results/domain.pddl @@ -0,0 +1,29 @@ +(define (domain simple-blocks) + (:requirements :strips) + (:predicates (on ?x ?y) + (clear ?x) + (ontable ?x) + ) + (:action stack + :parameters (?obj ?oldunder ?newunder) + :precondition + (and (clear ?newunder) (clear ?obj) (on ?obj ?oldunder)) + :effect + (and (not (clear ?newunder)) + (on ?obj ?newunder) + (not (on ?obj ?oldunder)) + (clear ?oldunder))) + (:action unstack + :parameters (?sob ?sunderob) + :precondition (and (on ?sob ?sunderob) (clear ?sob)) + :effect + (and (clear ?sunderob) + (ontable ?sob) + (not (on ?sob ?sunderob)))) + (:action stackfromtable + :parameters (?obj ?newunder) + :precondition (and (clear ?obj) (clear ?newunder) (ontable ?obj)) + :effect + (and (not (clear ?newunder)) + (on ?obj ?newunder) + (not (ontable ?obj))))) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_01/plan.txt b/paper_reconstructions/p+s/results/problem_01/plan.txt new file mode 100644 index 0000000..d1009bc --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_01/plan.txt @@ -0,0 +1,6 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +stack novel keyboard novel (1) +unstack keyboard sweatshirt (1) +unstack sweatshirt sketchbook (1) +stackfromtable keyboard sketchbook (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_01/problem-01.pddl b/paper_reconstructions/p+s/results/problem_01/problem-01.pddl new file mode 100644 index 0000000..5d190a0 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_01/problem-01.pddl @@ -0,0 +1,33 @@ +(define + (problem problem-01) + (:domain simple-blocks) + + (:objects + sketchbook + sweatshirt + keyboard + novel + ) + + (:init + (ontable sketchbook) + (on sweatshirt sketchbook) + (on keyboard sweatshirt) + (on novel keyboard) + (clear novel) + (noteq sketchbook sweatshirt) + (noteq sketchbook keyboard) + (noteq sketchbook novel) + (noteq sweatshirt keyboard) + (noteq sweatshirt novel) + (noteq keyboard novel) + ) + + (:goal + (and + (on keyboard sketchbook) + (ontable sweatshirt) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_02/plan.txt b/paper_reconstructions/p+s/results/problem_02/plan.txt new file mode 100644 index 0000000..5ef0726 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_02/plan.txt @@ -0,0 +1,3 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack saucepan newspaper (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_02/problem-02.pddl b/paper_reconstructions/p+s/results/problem_02/problem-02.pddl new file mode 100644 index 0000000..4206464 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_02/problem-02.pddl @@ -0,0 +1,39 @@ +(define + (problem problem-02) + (:domain simple-blocks) + + (:objects + newspaper + accordion + saucepan + peacoat + ) + + (:init + (ontable accordion) + (on newspaper accordion) + (on saucepan newspaper) + (clear saucepan) + (ontable peacoat) + (clear peacoat) + (noteq newspaper accordion) + (noteq newspaper saucepan) + (noteq newspaper peacoat) + (noteq accordion saucepan) + (noteq accordion peacoat) + (noteq saucepan peacoat) + ) + + (:goal + (and + (clear newspaper) + (ontable accordion) + (clear saucepan) + (ontable saucepan) + (on newspaper accordion) + (ontable peacoat) + (clear peacoat) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_03/plan.txt b/paper_reconstructions/p+s/results/problem_03/plan.txt new file mode 100644 index 0000000..2a5c18c --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_03/plan.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack mouse-pad saucepan (1) +stackfromtable raincoat mouse-pad (1) +stackfromtable hacksaw raincoat (1) \ No newline at end of file diff --git a/paper_reconstructions/p+s/results/problem_03/problem-03.pddl b/paper_reconstructions/p+s/results/problem_03/problem-03.pddl new file mode 100644 index 0000000..bb2f4f1 --- /dev/null +++ b/paper_reconstructions/p+s/results/problem_03/problem-03.pddl @@ -0,0 +1,39 @@ +(define + (problem problem-03) + (:domain simple-blocks) + + (:objects + mouse-pad + hacksaw + saucepan + raincoat + ) + + (:init + (ontable raincoat) + (clear raincoat) + (ontable hacksaw) + (clear hacksaw) + (ontable saucepan) + (on mouse-pad saucepan) + (clear mouse-pad) + (noteq mouse-pad hacksaw) + (noteq mouse-pad saucepan) + (noteq mouse-pad raincoat) + (noteq hacksaw saucepan) + (noteq hacksaw raincoat) + (noteq saucepan raincoat) + ) + + (:goal + (and + (ontable mouse-pad) + (ontable saucepan) + (clear hacksaw) + (on raincoat mouse-pad) + (on hacksaw raincoat) + (clear saucepan) + ) + ) + +) \ No newline at end of file From 8706b120257960bf3622bf66ceeb5f9852ec189b Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 1 Jan 2025 23:43:40 -0500 Subject: [PATCH 04/15] refined LLM+P recreation and experimentation --- l2p/utils/pddl_parser.py | 1 + paper_reconstructions/isr-llm/main.py | 7 - paper_reconstructions/llm+p/domain.py | 102 +++++++++++ .../llm+p/domains/barman/domain.nl | 35 ++++ .../llm+p/domains/barman/domain.pddl | 155 +++++++++++++++++ .../llm+p/domains/barman/p_example.nl | 5 + .../llm+p/domains/barman/p_example.pddl | 40 +++++ .../llm+p/domains/barman/p_example.sol | 10 ++ .../llm+p/domains/barman/problems/p01.nl | 7 + .../llm+p/domains/barman/problems/p02.nl | 7 + .../llm+p/domains/barman/problems/p03.nl | 7 + .../llm+p/domains/barman/problems/p04.nl | 7 + .../domains/barman/results/pddl/p01.pddl | 56 ++++++ .../domains/barman/results/pddl/p02.pddl | 56 ++++++ .../domains/barman/results/pddl/p03.pddl | 56 ++++++ .../domains/barman/results/pddl/p04.pddl | 56 ++++++ .../llm+p/domains/barman/results/plan/p01.txt | 50 ++++++ .../llm+p/domains/barman/results/plan/p02.txt | 52 ++++++ .../llm+p/domains/barman/results/plan/p03.txt | 50 ++++++ .../llm+p/domains/barman/results/plan/p04.txt | 52 ++++++ .../llm+p/domains/blocksworld/domain.nl | 6 + .../llm+p/domains/blocksworld/domain.pddl | 32 ++++ .../llm+p/domains/blocksworld/p_example.nl | 10 ++ .../llm+p/domains/blocksworld/p_example.pddl | 20 +++ .../llm+p/domains/blocksworld/p_example.sol | 10 ++ .../llm+p/domains/blocksworld/problems/p01.nl | 9 + .../blocksworld/problems/p02.nl} | 4 +- .../llm+p/domains/blocksworld/problems/p03.nl | 11 ++ .../llm+p/domains/blocksworld/problems/p04.nl | 11 ++ .../domains/blocksworld/results/pddl/p01.pddl | 26 +++ .../blocksworld/results/pddl/p02.pddl} | 2 +- .../domains/blocksworld/results/pddl/p03.pddl | 29 ++++ .../domains/blocksworld/results/pddl/p04.pddl | 29 ++++ .../domains/blocksworld/results/plan/p01.txt | 2 + .../domains/blocksworld/results/plan/p02.txt | 8 + .../domains/blocksworld/results/plan/p03.txt | 8 + .../domains/blocksworld/results/plan/p04.txt | 18 ++ .../llm+p/domains/floortile/domain.nl | 15 ++ .../llm+p/domains/floortile/domain.pddl | 81 +++++++++ .../llm+p/domains/floortile/p_example.nl | 11 ++ .../llm+p/domains/floortile/p_example.pddl | 67 +++++++ .../llm+p/domains/floortile/p_example.sol | 5 + .../llm+p/domains/floortile/problems/p01.nl | 12 ++ .../llm+p/domains/floortile/problems/p02.nl | 12 ++ .../llm+p/domains/floortile/problems/p03.nl | 12 ++ .../llm+p/domains/floortile/problems/p04.nl | 12 ++ .../domains/floortile/results/pddl/p01.pddl | 110 ++++++++++++ .../domains/floortile/results/pddl/p02.pddl | 113 ++++++++++++ .../domains/floortile/results/pddl/p03.pddl | 112 ++++++++++++ .../domains/floortile/results/pddl/p04.pddl | 142 +++++++++++++++ .../domains/floortile/results/plan/p01.txt | 50 ++++++ .../domains/floortile/results/plan/p02.txt | 27 +++ .../domains/floortile/results/plan/p03.txt | 31 ++++ .../domains/floortile/results/plan/p04.txt | 55 ++++++ .../llm+p/domains/grippers/domain.nl | 9 + .../llm+p/domains/grippers/domain.pddl | 27 +++ .../llm+p/domains/grippers/p_example.nl | 12 ++ .../llm+p/domains/grippers/p_example.pddl | 31 ++++ .../llm+p/domains/grippers/p_example.sol | 11 ++ .../llm+p/domains/grippers/problems/p01.nl | 8 + .../llm+p/domains/grippers/problems/p02.nl | 10 ++ .../llm+p/domains/grippers/problems/p03.nl | 8 + .../llm+p/domains/grippers/problems/p04.nl | 10 ++ .../domains/grippers/results/pddl/p01.pddl | 36 ++++ .../domains/grippers/results/pddl/p02.pddl | 43 +++++ .../domains/grippers/results/pddl/p03.pddl | 39 +++++ .../domains/grippers/results/pddl/p04.pddl | 50 ++++++ .../domains/grippers/results/plan/p01.txt | 2 + .../domains/grippers/results/plan/p02.txt | 13 ++ .../domains/grippers/results/plan/p03.txt | 8 + .../domains/grippers/results/plan/p04.txt | 5 + .../llm+p/domains/storage/domain.nl | 13 ++ .../llm+p/domains/storage/domain.pddl | 48 +++++ .../llm+p/domains/storage/p_example.nl | 22 +++ .../llm+p/domains/storage/p_example.pddl | 75 ++++++++ .../llm+p/domains/storage/p_example.sol | 11 ++ .../llm+p/domains/storage/problems/p01.nl | 16 ++ .../llm+p/domains/storage/problems/p02.nl | 17 ++ .../llm+p/domains/storage/problems/p03.nl | 18 ++ .../llm+p/domains/storage/problems/p04.nl | 19 ++ .../domains/storage/results/pddl/p01.pddl | 35 ++++ .../domains/storage/results/pddl/p02.pddl | 39 +++++ .../domains/storage/results/pddl/p03.pddl | 44 +++++ .../domains/storage/results/pddl/p04.pddl | 59 +++++++ .../domains/storage/results/plan/p01.txt | 5 + .../domains/storage/results/plan/p02.txt | 5 + .../domains/storage/results/plan/p03.txt | 5 + .../domains/storage/results/plan/p04.txt | 10 ++ .../llm+p/domains/termes/domain.nl | 15 ++ .../llm+p/domains/termes/domain.pddl | 134 ++++++++++++++ .../llm+p/domains/termes/p_example.nl | 9 + .../llm+p/domains/termes/p_example.pddl | 77 ++++++++ .../llm+p/domains/termes/p_example.sol | 3 + .../llm+p/domains/termes/problems/p01.nl | 10 ++ .../llm+p/domains/termes/problems/p02.nl | 10 ++ .../llm+p/domains/termes/problems/p03.nl | 10 ++ .../llm+p/domains/termes/problems/p04.nl | 10 ++ .../domains/termes/results/pddl/p01.pddl | 91 ++++++++++ .../domains/termes/results/pddl/p02.pddl | 93 ++++++++++ .../domains/termes/results/pddl/p03.pddl | 95 ++++++++++ .../domains/termes/results/pddl/p04.pddl | 84 +++++++++ .../llm+p/domains/termes/results/plan/p01.txt | 52 ++++++ .../llm+p/domains/termes/results/plan/p02.txt | 1 + .../llm+p/domains/termes/results/plan/p03.txt | 1 + .../llm+p/domains/termes/results/plan/p04.txt | 150 ++++++++++++++++ .../llm+p/domains/tyreworld/domain.nl | 29 ++++ .../llm+p/domains/tyreworld/domain.pddl | 102 +++++++++++ .../llm+p/domains/tyreworld/p_example.nl | 9 + .../llm+p/domains/tyreworld/p_example.pddl | 55 ++++++ .../llm+p/domains/tyreworld/p_example.sol | 26 +++ .../llm+p/domains/tyreworld/problems/p01.nl | 9 + .../llm+p/domains/tyreworld/problems/p02.nl | 9 + .../llm+p/domains/tyreworld/problems/p03.nl | 9 + .../llm+p/domains/tyreworld/problems/p04.nl | 9 + .../domains/tyreworld/results/pddl/p01.pddl | 44 +++++ .../domains/tyreworld/results/pddl/p02.pddl | 164 ++++++++++++++++++ .../domains/tyreworld/results/pddl/p03.pddl | 73 ++++++++ .../domains/tyreworld/results/pddl/p04.pddl | 89 ++++++++++ .../domains/tyreworld/results/plan/p01.txt | 27 +++ .../domains/tyreworld/results/plan/p02.txt | 115 ++++++++++++ .../domains/tyreworld/results/plan/p03.txt | 1 + .../domains/tyreworld/results/plan/p04.txt | 60 +++++++ paper_reconstructions/llm+p/main.py | 128 ++++++++++---- .../llm+p/prompts/example.txt | 48 ----- paper_reconstructions/llm+p/prompts/role.txt | 28 --- paper_reconstructions/llm+p/prompts/task.txt | 3 - .../llm+p/results/domain.pddl | 25 --- .../nl2plan/domains/blocksworld/desc.txt | 0 .../nl2plan/domains/blocksworld/task1.txt | 0 .../nl2plan/domains/blocksworld/task2.txt | 0 .../nl2plan/domains/blocksworld/task3.txt | 0 .../nl2plan/domains/household/desc.txt | 0 .../nl2plan/domains/household/task1.txt | 0 .../nl2plan/domains/household/task2.txt | 0 .../nl2plan/domains/household/task3.txt | 0 .../nl2plan/domains/isr-assisted/desc.txt | 0 .../nl2plan/domains/isr-assisted/task1.txt | 0 .../nl2plan/domains/isr-assisted/task2.txt | 0 .../nl2plan/domains/isr-assisted/task3.txt | 0 .../nl2plan/domains/isr/desc.txt | 0 .../nl2plan/domains/isr/task1.txt | 0 .../nl2plan/domains/isr/task2.txt | 0 .../nl2plan/domains/isr/task3.txt | 0 .../nl2plan/domains/logistics/desc.txt | 0 .../nl2plan/domains/logistics/task1.txt | 0 .../nl2plan/domains/logistics/task2.txt | 0 .../nl2plan/domains/logistics/task3.txt | 0 .../nl2plan/domains/tyreworld/desc.txt | 0 .../nl2plan/domains/tyreworld/task1.txt | 0 .../nl2plan/domains/tyreworld/task2.txt | 0 .../nl2plan/domains/tyreworld/task3.txt | 0 paper_reconstructions/there-and-back/main.py | 7 - templates/task_templates/extract_task.txt | 4 +- 153 files changed, 4435 insertions(+), 159 deletions(-) delete mode 100644 paper_reconstructions/isr-llm/main.py create mode 100644 paper_reconstructions/llm+p/domain.py create mode 100644 paper_reconstructions/llm+p/domains/barman/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/barman/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl rename paper_reconstructions/llm+p/{prompts/problem_desc.txt => domains/blocksworld/problems/p02.nl} (83%) create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl rename paper_reconstructions/llm+p/{results/problem.pddl => domains/blocksworld/results/pddl/p02.pddl} (90%) create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/floortile/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/floortile/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/grippers/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/grippers/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/storage/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/storage/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/termes/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/termes/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/domain.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/domain.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/p_example.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/p_example.sol create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt create mode 100644 paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt delete mode 100644 paper_reconstructions/llm+p/prompts/example.txt delete mode 100644 paper_reconstructions/llm+p/prompts/role.txt delete mode 100644 paper_reconstructions/llm+p/prompts/task.txt delete mode 100644 paper_reconstructions/llm+p/results/domain.pddl create mode 100644 paper_reconstructions/nl2plan/domains/blocksworld/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/blocksworld/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/blocksworld/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/blocksworld/task3.txt create mode 100644 paper_reconstructions/nl2plan/domains/household/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/household/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/household/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/household/task3.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/isr/task3.txt create mode 100644 paper_reconstructions/nl2plan/domains/logistics/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/logistics/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/logistics/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/logistics/task3.txt create mode 100644 paper_reconstructions/nl2plan/domains/tyreworld/desc.txt create mode 100644 paper_reconstructions/nl2plan/domains/tyreworld/task1.txt create mode 100644 paper_reconstructions/nl2plan/domains/tyreworld/task2.txt create mode 100644 paper_reconstructions/nl2plan/domains/tyreworld/task3.txt delete mode 100644 paper_reconstructions/there-and-back/main.py diff --git a/l2p/utils/pddl_parser.py b/l2p/utils/pddl_parser.py index 24d3aa8..b36609a 100644 --- a/l2p/utils/pddl_parser.py +++ b/l2p/utils/pddl_parser.py @@ -217,6 +217,7 @@ def parse_objects(llm_response: str) -> dict[str, str]: objects_head = extract_heading(llm_response, "OBJECTS") objects_raw = combine_blocks(objects_head) + objects_clean = clear_comments( text=objects_raw, comments=[":", "//", "#", ";", "(", ")"] ) # Remove comments diff --git a/paper_reconstructions/isr-llm/main.py b/paper_reconstructions/isr-llm/main.py deleted file mode 100644 index b1dedf1..0000000 --- a/paper_reconstructions/isr-llm/main.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -Paper: "ISR-LLM: Iterative Self-Refined Large Language Model for Long-Horizon Sequential Task Planning" Zhou et al. (2023) -Source code: https://github.com/ma-labo/ISR-LLM -Run: python3 -m paper_reconstructions.isr-llm.main -""" - -# TODO: implementation \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domain.py b/paper_reconstructions/llm+p/domain.py new file mode 100644 index 0000000..6d0474f --- /dev/null +++ b/paper_reconstructions/llm+p/domain.py @@ -0,0 +1,102 @@ +""" +This module contains the Domain class which contains all domains found in LLM+P +""" + +import glob + +def postprocess(x): + return x.strip() + +class Domain: + def __init__(self, name): + self.name = name + self.context = ("p_example.nl", "p_example.pddl", "p_example.sol") + self.tasks = [] + self.grab_tasks() + + def grab_tasks(self): + path = f"paper_reconstructions/llm+p/domains/{self.name}/problems" + nls = [] + for fn in glob.glob(f"{path}/*.nl"): + + fn_ = fn.split("/")[-1] + nls.append(fn_) + + self.tasks = sorted(nls) + + def get_task_name(self, i): + name = self.tasks[i] + name = name.replace("nl", "pddl") + return name + + def get_task_file(self, i): + nl = self.tasks[i] + return f"paper_reconstructions/llm+p/domains/{self.name}/problems/{nl}" + + def get_task(self, i): + nl_f = self.get_task_file(i) + + with open(nl_f, 'r') as f: + nl = f.read() + + return postprocess(nl) + + def get_context(self): + nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[0]}" + pddl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[1]}" + sol_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[2]}" + with open(nl_f, 'r') as f: + nl = f.read() + with open(pddl_f, 'r') as f: + pddl = f.read() + with open(sol_f, 'r') as f: + sol = f.read() + return postprocess(nl), postprocess(pddl), postprocess(sol) + + def get_domain_pddl(self): + domain_pddl_f = self.get_domain_pddl_file() + with open(domain_pddl_f, 'r') as f: + domain_pddl = f.read() + return postprocess(domain_pddl) + + def get_domain_pddl_file(self): + domain_pddl_f = f"paper_reconstructions/llm+p/domains/{self.name}/domain.pddl" + return domain_pddl_f + + def get_domain_nl(self): + domain_nl_f = self.get_domain_nl_file() + try: + with open(domain_nl_f, 'r') as f: + domain_nl = f.read() + except: + domain_nl = "Nothing" + return postprocess(domain_nl) + + def get_domain_nl_file(self): + domain_nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/domain.nl" + return domain_nl_f + + +class Barman(Domain): + name = "barman" + +class Floortile(Domain): + name = "floortile" + +class Termes(Domain): + name = "termes" + +class Tyreworld(Domain): + name = "tyreworld" + +class Grippers(Domain): + name = "grippers" + +class Storage(Domain): + name = "storage" + +class Blocksworld(Domain): + name = "blocksworld" + +class Manipulation(Domain): + name = "manipulation" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/domain.nl b/paper_reconstructions/llm+p/domains/barman/domain.nl new file mode 100644 index 0000000..31b2ab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/domain.nl @@ -0,0 +1,35 @@ +You are a robot barman that manipulates drink dispensers, shot glasses and a shaker. You have two hands. The goal is to find a plan that serves a desired set of drinks. Here are the actions you can do + +Grasp a container +Leave a container on the table +Fill a shot glass with an ingredient +Refill a shot glass with an ingredient +Empty a shot glass +Clean a shot glass +Pour an ingredient from a shot glass to a clean shaker +Pour an ingredient from a shot glass to a used shaker +Empty a shaker +Clean a shaker +Shake a cocktail in a shaker +Pour from a shaker to a shot glass + +You have the following restrictions on your actions: +You can only grasp a container if your hand is empty and it is on the table. +You can only leave a container if you are holding it. +You can only fill a shot glass if you are holding the shot glass, your other hand is empty, the shot glass is empty and clean. +You can only refill a shot glass if you are holding the shot glass, your other hand is empty, the shot glass is empty and has contained the saree ingredient before. +You can only empty a shot glass if you are holding the shot glass and it contains a beverage. +You can only clean a shot glass if you are holding the shot glass and it is empty, and your other hand is empty. +You can only pour from a shot glass to a clean shaker if you are holding the shot glass, the shot glass contains an ingredient, and the shaker is empty and clean. +You can only pour from a shot glass to a used shaker if you are holding the shot glass, the shot glass contains an ingredient, the shaker is unshaked and at a level not full. +You can only empty a shaker if you are holding the shaker and the shaker contains a shaked beverage. +You can only clean a shaker if you are holding the shaker, your other hand is empty, and the shaker is empty. +You can only shake a cocktail if you are holding the shaker, your other hand is empty, the shaker is unshaked, and the shaker contains two ingredients, and both ingredients are parts of a cocktail. +You can only pour from a shaker to a shot glass if you are holding the shaker, the shaker contains the cocktail, the shaker is shaked, and the shot glass is empty and clean. + +Once you grasp a container, you are holding the container and the container is not on the table. +Once you leave a container on the table, your hand become empty. +Once you pour an ingredient from a shot glass to a shaker, the shaker contains the ingredient and is at one level above the previous level, and the shot glass becomes empty. +Once you empty a shaker, the shaker is at the empty level. +Once you shake, the two ingredients in the shaker become a cocktail. +Once you pour from a shaker to a shot glass, the shot glass contains the beverage in the shaker, the shot glass is no longer clean and empty, and the shaker is at one level below the previous level. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/domain.pddl b/paper_reconstructions/llm+p/domains/barman/domain.pddl new file mode 100644 index 0000000..db9b07c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/domain.pddl @@ -0,0 +1,155 @@ +(define (domain barman) + (:requirements :strips :typing) + (:types hand level beverage dispenser container - object + ingredient cocktail - beverage + shot shaker - container) + (:predicates (ontable ?c - container) + (holding ?h - hand ?c - container) + (handempty ?h - hand) + (empty ?c - container) + (contains ?c - container ?b - beverage) + (clean ?c - container) + (used ?c - container ?b - beverage) + (dispenses ?d - dispenser ?i - ingredient) + (shaker-empty-level ?s - shaker ?l - level) + (shaker-level ?s - shaker ?l - level) + (next ?l1 ?l2 - level) + (unshaked ?s - shaker) + (shaked ?s - shaker) + (cocktail-part1 ?c - cocktail ?i - ingredient) + (cocktail-part2 ?c - cocktail ?i - ingredient)) + + (:action grasp + :parameters (?h - hand ?c - container) + :precondition (and (ontable ?c) (handempty ?h)) + :effect (and (not (ontable ?c)) + (not (handempty ?h)) + (holding ?h ?c))) + + (:action leave + :parameters (?h - hand ?c - container) + :precondition (holding ?h ?c) + :effect (and (not (holding ?h ?c)) + (handempty ?h) + (ontable ?c))) + + (:action fill-shot + :parameters (?s - shot ?i - ingredient ?h1 ?h2 - hand ?d - dispenser) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (dispenses ?d ?i) + (empty ?s) + (clean ?s)) + :effect (and (not (empty ?s)) + (contains ?s ?i) + (not (clean ?s)) + (used ?s ?i))) + + + (:action refill-shot + :parameters (?s - shot ?i - ingredient ?h1 ?h2 - hand ?d - dispenser) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (dispenses ?d ?i) + (empty ?s) + (used ?s ?i)) + :effect (and (not (empty ?s)) + (contains ?s ?i))) + + (:action empty-shot + :parameters (?h - hand ?p - shot ?b - beverage) + :precondition (and (holding ?h ?p) + (contains ?p ?b)) + :effect (and (not (contains ?p ?b)) + (empty ?p))) + + (:action clean-shot + :parameters (?s - shot ?b - beverage ?h1 ?h2 - hand) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (empty ?s) + (used ?s ?b)) + :effect (and (not (used ?s ?b)) + (clean ?s))) + + (:action pour-shot-to-clean-shaker + :parameters (?s - shot ?i - ingredient ?d - shaker ?h1 - hand ?l ?l1 - level) + :precondition (and (holding ?h1 ?s) + (contains ?s ?i) + (empty ?d) + (clean ?d) + (shaker-level ?d ?l) + (next ?l ?l1)) + :effect (and (not (contains ?s ?i)) + (empty ?s) + (contains ?d ?i) + (not (empty ?d)) + (not (clean ?d)) + (unshaked ?d) + (not (shaker-level ?d ?l)) + (shaker-level ?d ?l1))) + + + (:action pour-shot-to-used-shaker + :parameters (?s - shot ?i - ingredient ?d - shaker ?h1 - hand ?l ?l1 - level) + :precondition (and (holding ?h1 ?s) + (contains ?s ?i) + (unshaked ?d) + (shaker-level ?d ?l) + (next ?l ?l1)) + :effect (and (not (contains ?s ?i)) + (contains ?d ?i) + (empty ?s) + (not (shaker-level ?d ?l)) + (shaker-level ?d ?l1))) + + (:action empty-shaker + :parameters (?h - hand ?s - shaker ?b - cocktail ?l ?l1 - level) + :precondition (and (holding ?h ?s) + (contains ?s ?b) + (shaked ?s) + (shaker-level ?s ?l) + (shaker-empty-level ?s ?l1)) + :effect (and (not (shaked ?s)) + (not (shaker-level ?s ?l)) + (shaker-level ?s ?l1) + (not (contains ?s ?b)) + (empty ?s))) + + (:action clean-shaker + :parameters (?h1 ?h2 - hand ?s - shaker) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (empty ?s)) + :effect (and (clean ?s))) + + (:action shake + :parameters (?b - cocktail ?d1 ?d2 - ingredient ?s - shaker ?h1 ?h2 - hand) + :precondition (and (holding ?h1 ?s) + (handempty ?h2) + (contains ?s ?d1) + (contains ?s ?d2) + (cocktail-part1 ?b ?d1) + (cocktail-part2 ?b ?d2) + (unshaked ?s)) + :effect (and (not (unshaked ?s)) + (not (contains ?s ?d1)) + (not (contains ?s ?d2)) + (shaked ?s) + (contains ?s ?b))) + + (:action pour-shaker-to-shot + :parameters (?b - beverage ?d - shot ?h - hand ?s - shaker ?l ?l1 - level) + :precondition (and (holding ?h ?s) + (shaked ?s) + (empty ?d) + (clean ?d) + (contains ?s ?b) + (shaker-level ?s ?l) + (next ?l1 ?l)) + :effect (and (not (clean ?d)) + (not (empty ?d)) + (contains ?d ?b) + (shaker-level ?s ?l1) + (not (shaker-level ?s ?l)))) + ) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.nl b/paper_reconstructions/llm+p/domains/barman/p_example.nl new file mode 100644 index 0000000..d025773 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.nl @@ -0,0 +1,5 @@ +You have 1 shaker with 3 levels, 3 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient3. The second ingredient of cocktail1 is ingredient1. +Your goal is to make 1 cocktails. +shot1 contains cocktail1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.pddl b/paper_reconstructions/llm+p/domains/barman/p_example.pddl new file mode 100644 index 0000000..470f855 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.pddl @@ -0,0 +1,40 @@ +(define (problem prob) + (:domain barman) + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level +) + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient3) + (cocktail-part2 cocktail1 ingredient1) +) + (:goal + (and + (contains shot1 cocktail1) +))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/p_example.sol b/paper_reconstructions/llm+p/domains/barman/p_example.sol new file mode 100644 index 0000000..8bea1a3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/p_example.sol @@ -0,0 +1,10 @@ +Grasp shot2 with right hand, +fill shot2 with ingredient1 from dispenser1 using right and left hands, +pour shot2 with ingredient1 into clean shaker1 using right hand, +clean shot2 with right and left hands, +fill shot2 with ingredient3 from dispenser3 using right and left hands, +grasp shaker1 with left hand, +pour shot2 with ingredient3 into used shaker1 using right hand, +leave shot2 with right hand, +shake cocktail1 with ingredient3 and ingredient1 in shaker1 using left and right hands, +pour shaker1 with cocktail1 into shot1 using left hand. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p01.nl b/paper_reconstructions/llm+p/domains/barman/problems/p01.nl new file mode 100644 index 0000000..31ebe54 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p01.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient1. The second ingredient of cocktail1 is ingredient3. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient1. The second ingredient of cocktail3 is ingredient2. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p02.nl b/paper_reconstructions/llm+p/domains/barman/problems/p02.nl new file mode 100644 index 0000000..ce65c7c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p02.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient3. The second ingredient of cocktail1 is ingredient1. +The first ingredient of cocktail2 is ingredient3. The second ingredient of cocktail2 is ingredient2. +The first ingredient of cocktail3 is ingredient3. The second ingredient of cocktail3 is ingredient1. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p03.nl b/paper_reconstructions/llm+p/domains/barman/problems/p03.nl new file mode 100644 index 0000000..17e4683 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p03.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient1. The second ingredient of cocktail1 is ingredient3. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient2. The second ingredient of cocktail3 is ingredient1. +Your goal is to make 3 cocktails. +shot1 contains cocktail2. shot2 contains cocktail1. shot3 contains cocktail3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/problems/p04.nl b/paper_reconstructions/llm+p/domains/barman/problems/p04.nl new file mode 100644 index 0000000..c826dde --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/problems/p04.nl @@ -0,0 +1,7 @@ +You have 1 shaker with 3 levels, 4 shot glasses, 3 dispensers for 3 ingredients. +The shaker and shot glasses are clean, empty, and on the table. Your left and right hands are empty. +The first ingredient of cocktail1 is ingredient2. The second ingredient of cocktail1 is ingredient1. +The first ingredient of cocktail2 is ingredient2. The second ingredient of cocktail2 is ingredient3. +The first ingredient of cocktail3 is ingredient1. The second ingredient of cocktail3 is ingredient2. +Your goal is to make 3 cocktails. +shot1 contains cocktail1. shot2 contains cocktail3. shot3 contains cocktail2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl new file mode 100644 index 0000000..5262b49 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p01.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient1) + (cocktail-part2 cocktail1 ingredient3) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient1) + (cocktail-part2 cocktail3 ingredient2) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl new file mode 100644 index 0000000..ce4e561 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p02.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient3) + (cocktail-part2 cocktail1 ingredient1) + (cocktail-part1 cocktail2 ingredient3) + (cocktail-part2 cocktail2 ingredient2) + (cocktail-part1 cocktail3 ingredient3) + (cocktail-part2 cocktail3 ingredient1) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl new file mode 100644 index 0000000..af035c8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p03.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient1) + (cocktail-part2 cocktail1 ingredient3) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient2) + (cocktail-part2 cocktail3 ingredient1) + ) + + (:goal + (and + (contains shot1 cocktail2) + (contains shot2 cocktail1) + (contains shot3 cocktail3) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl new file mode 100644 index 0000000..367949e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/pddl/p04.pddl @@ -0,0 +1,56 @@ +(define + (problem barman_problem) + (:domain barman) + + (:objects + shaker1 - shaker + left right - hand + shot1 shot2 shot3 shot4 - shot + ingredient1 ingredient2 ingredient3 - ingredient + cocktail1 cocktail2 cocktail3 - cocktail + dispenser1 dispenser2 dispenser3 - dispenser + l0 l1 l2 - level + ) + + (:init + (ontable shaker1) + (ontable shot1) + (ontable shot2) + (ontable shot3) + (ontable shot4) + (dispenses dispenser1 ingredient1) + (dispenses dispenser2 ingredient2) + (dispenses dispenser3 ingredient3) + (clean shaker1) + (clean shot1) + (clean shot2) + (clean shot3) + (clean shot4) + (empty shaker1) + (empty shot1) + (empty shot2) + (empty shot3) + (empty shot4) + (handempty left) + (handempty right) + (shaker-empty-level shaker1 l0) + (shaker-level shaker1 l0) + (next l0 l1) + (next l1 l2) + (cocktail-part1 cocktail1 ingredient2) + (cocktail-part2 cocktail1 ingredient1) + (cocktail-part1 cocktail2 ingredient2) + (cocktail-part2 cocktail2 ingredient3) + (cocktail-part1 cocktail3 ingredient1) + (cocktail-part2 cocktail3 ingredient2) + ) + + (:goal + (and + (contains shot1 cocktail1) + (contains shot2 cocktail3) + (contains shot3 cocktail2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt new file mode 100644 index 0000000..d3d7aea --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt @@ -0,0 +1,50 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient1 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +leave right shot4 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient1 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient1 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt new file mode 100644 index 0000000..5e37878 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt @@ -0,0 +1,52 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient3 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient3 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot3 (1) +leave left shaker1 (1) +grasp left shot4 (1) +pour-shot-to-clean-shaker shot4 ingredient2 shaker1 left l0 l1 (1) +leave right shot3 (1) +clean-shot shot4 ingredient2 left right (1) +leave left shot4 (1) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient3 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail2 ingredient3 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot1 (1) +leave left shaker1 (1) +fill-shot shot1 ingredient3 right left dispenser3 (1) +pour-shot-to-clean-shaker shot1 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot1 ingredient3 right left (1) +fill-shot shot1 ingredient1 right left dispenser1 (1) +pour-shot-to-used-shaker shot1 ingredient1 shaker1 right l1 l2 (1) +clean-shot shot1 ingredient1 right left (1) +grasp left shaker1 (1) +leave right shot1 (1) +shake cocktail1 ingredient3 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt new file mode 100644 index 0000000..66eb897 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt @@ -0,0 +1,50 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient2 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot1 left shaker1 l2 l1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +leave right shot4 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient3 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient1 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient1 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot2 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt new file mode 100644 index 0000000..32519c0 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt @@ -0,0 +1,52 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave left shaker1 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient3 right left dispenser3 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail3 ingredient1 ingredient2 shaker1 left right (1) +pour-shaker-to-shot cocktail3 shot2 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail3 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot3 (1) +leave left shaker1 (1) +grasp left shot4 (1) +pour-shot-to-clean-shaker shot4 ingredient3 shaker1 left l0 l1 (1) +leave right shot3 (1) +clean-shot shot4 ingredient3 left right (1) +leave left shot4 (1) +grasp left shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +clean-shot shot4 ingredient2 right left (1) +fill-shot shot4 ingredient1 right left dispenser1 (1) +grasp left shaker1 (1) +leave right shot4 (1) +shake cocktail2 ingredient2 ingredient3 shaker1 left right (1) +pour-shaker-to-shot cocktail2 shot3 left shaker1 l2 l1 (1) +empty-shaker left shaker1 cocktail2 l1 l0 (1) +clean-shaker left right shaker1 (1) +grasp right shot4 (1) +leave left shaker1 (1) +pour-shot-to-clean-shaker shot4 ingredient1 shaker1 right l0 l1 (1) +clean-shot shot4 ingredient1 right left (1) +fill-shot shot4 ingredient2 right left dispenser2 (1) +grasp left shaker1 (1) +pour-shot-to-used-shaker shot4 ingredient2 shaker1 right l1 l2 (1) +leave right shot4 (1) +shake cocktail1 ingredient2 ingredient1 shaker1 left right (1) +pour-shaker-to-shot cocktail1 shot1 left shaker1 l2 l1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/domain.nl b/paper_reconstructions/llm+p/domains/blocksworld/domain.nl new file mode 100644 index 0000000..e4b544f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/domain.nl @@ -0,0 +1,6 @@ +The robot has four actions: pickup, putdown, stack, and unstack. The domain assumes a world where there are a set of blocks that can be stacked on top of each other, an arm that can hold one block at a time, and a table where blocks can be placed. +The actions defined in this domain include: +pickup: allows the arm to pick up a block from the table if it is clear and the arm is empty. After the pickup action, the arm will be holding the block, and the block will no longer be on the table or clear. +putdown: allows the arm to put down a block on the table if it is holding a block. After the putdown action, the arm will be empty, and the block will be on the table and clear. +stack: allows the arm to stack a block on top of another block if the arm is holding the top block and the bottom block is clear. After the stack action, the arm will be empty, the top block will be on top of the bottom block, and the bottom block will no longer be clear. +unstack: allows the arm to unstack a block from on top of another block if the arm is empty and the top block is clear. After the unstack action, the arm will be holding the top block, the top block will no longer be on top of the bottom block, and the bottom block will be clear. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl b/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl new file mode 100644 index 0000000..5e69df1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/domain.pddl @@ -0,0 +1,32 @@ +(define (domain blocksworld) + (:requirements :strips) + (:types block - object) +(:predicates (clear ?x) + (on-table ?x) + (arm-empty) + (holding ?x) + (on ?x ?y)) + +(:action pickup + :parameters (?ob - block) + :precondition (and (clear ?ob) (on-table ?ob) (arm-empty)) + :effect (and (holding ?ob) (not (clear ?ob)) (not (on-table ?ob)) + (not (arm-empty)))) + +(:action putdown + :parameters (?ob - block) + :precondition (holding ?ob) + :effect (and (clear ?ob) (arm-empty) (on-table ?ob) + (not (holding ?ob)))) + +(:action stack + :parameters (?ob ?underob - block) + :precondition (and (clear ?underob) (holding ?ob)) + :effect (and (arm-empty) (clear ?ob) (on ?ob ?underob) + (not (clear ?underob)) (not (holding ?ob)))) + +(:action unstack + :parameters (?ob ?underob - block) + :precondition (and (on ?ob ?underob) (clear ?ob) (arm-empty)) + :effect (and (holding ?ob) (clear ?underob) + (not (on ?ob ?underob)) (not (clear ?ob)) (not (arm-empty))))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl b/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl new file mode 100644 index 0000000..3db1f60 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.nl @@ -0,0 +1,10 @@ +You have 5 blocks. +b2 is on top of b5. +b5 is on top of b1. +b1 is on top of b4. +b3 is on top of b2. +b4 is on the table. +b3 is clear. +Your arm is empty. +Your goal is to move the blocks. +b4 should be on top of b3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl b/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl new file mode 100644 index 0000000..32b4dbc --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.pddl @@ -0,0 +1,20 @@ + + +(define (problem BW-rand-5) +(:domain blocksworld-4ops) +(:objects b1 b2 b3 b4 b5 ) +(:init +(arm-empty) +(on b1 b4) +(on b2 b5) +(on b3 b2) +(on-table b4) +(on b5 b1) +(clear b3) +) +(:goal +(and +(on b4 b3)) +) +) + diff --git a/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol b/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol new file mode 100644 index 0000000..9e8b2e6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/p_example.sol @@ -0,0 +1,10 @@ +unstack b3 from b2, +putdown b3, +unstack b2 from b5, +putdown b2, +unstack b5 from b1, +putdown b5, +unstack b1 from b4, +putdown b1, +pickup b4, +stack b4 on b3 \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl new file mode 100644 index 0000000..9c4bab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p01.nl @@ -0,0 +1,9 @@ +You have 3 blocks. +b2 is on top of b3. +b3 is on top of b1. +b1 is on the table. +b2 is clear. +Your arm is empty. +Your goal is to move the blocks. +b2 should be on top of b3. +b3 should be on top of b1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/problem_desc.txt b/paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl similarity index 83% rename from paper_reconstructions/llm+p/prompts/problem_desc.txt rename to paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl index 81b3a5b..900ce4f 100644 --- a/paper_reconstructions/llm+p/prompts/problem_desc.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p02.nl @@ -1,4 +1,3 @@ -""" You have 3 blocks. b3 is on top of b2. b1 is on top of b3. @@ -7,5 +6,4 @@ b1 is clear. Your arm is empty. Your goal is to move the blocks. b2 should be on top of b3. -b3 should be on top of b1. -""" \ No newline at end of file +b3 should be on top of b1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl new file mode 100644 index 0000000..979dbcf --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p03.nl @@ -0,0 +1,11 @@ +You have 4 blocks. +b3 is on top of b2. +b1 is on top of b3. +b4 is on the table. +b2 is on the table. +b1 is clear. +b4 is clear. +Your arm is empty. +Your goal is to move the blocks. +b2 should be on top of b1. +b3 should be on top of b4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl b/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl new file mode 100644 index 0000000..c50786b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/problems/p04.nl @@ -0,0 +1,11 @@ +You have 4 blocks. +b4 is on top of b2. +b3 is on top of b1. +b1 is on top of b4. +b2 is on the table. +b3 is clear. +Your arm is empty. +Your goal is to move the blocks. +b1 should be on top of b2. +b2 should be on top of b3. +b3 should be on top of b4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl new file mode 100644 index 0000000..4574d83 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p01.pddl @@ -0,0 +1,26 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + ) + + (:init + (on b2 b3) + (on b3 b1) + (on-table b1) + (clear b2) + (arm-empty ) + ) + + (:goal + (and + (on b2 b3) + (on b3 b1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/results/problem.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl similarity index 90% rename from paper_reconstructions/llm+p/results/problem.pddl rename to paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl index 58073e0..49d1ab9 100644 --- a/paper_reconstructions/llm+p/results/problem.pddl +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p02.pddl @@ -1,6 +1,6 @@ (define (problem blocksworld-4ops_problem) - (:domain blocksworld-4ops) + (:domain blocksworld) (:objects b1 - block diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl new file mode 100644 index 0000000..7fb72b3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p03.pddl @@ -0,0 +1,29 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + b4 - block + ) + + (:init + (on b1 b3) + (on b3 b2) + (on-table b4) + (on-table b2) + (clear b1) + (clear b4) + (arm-empty ) + ) + + (:goal + (and + (on b2 b1) + (on b3 b4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl new file mode 100644 index 0000000..32b3340 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/pddl/p04.pddl @@ -0,0 +1,29 @@ +(define + (problem blocksworld-4ops_problem) + (:domain blocksworld) + + (:objects + b1 - block + b2 - block + b3 - block + b4 - block + ) + + (:init + (on b1 b4) + (on b4 b2) + (on b3 b1) + (on-table b2) + (clear b3) + (arm-empty ) + ) + + (:goal + (and + (on b1 b2) + (on b2 b3) + (on b3 b4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt new file mode 100644 index 0000000..c8e6d32 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt @@ -0,0 +1,2 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt new file mode 100644 index 0000000..225e635 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt @@ -0,0 +1,8 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack b1 b3 (1) +putdown b1 (1) +unstack b3 b2 (1) +stack b3 b1 (1) +pickup b2 (1) +stack b2 b3 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt new file mode 100644 index 0000000..ad7fffb --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt @@ -0,0 +1,8 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack b1 b3 (1) +putdown b1 (1) +unstack b3 b2 (1) +stack b3 b4 (1) +pickup b2 (1) +stack b2 b1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt new file mode 100644 index 0000000..2afe549 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt @@ -0,0 +1,18 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +unstack b3 b1 (1) +putdown b3 (1) +unstack b1 b4 (1) +putdown b1 (1) +unstack b4 b2 (1) +putdown b4 (1) +pickup b1 (1) +stack b1 b2 (1) +pickup b3 (1) +stack b3 b4 (1) +unstack b1 b2 (1) +putdown b1 (1) +pickup b2 (1) +stack b2 b3 (1) +pickup b1 (1) +stack b1 b2 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/domain.nl b/paper_reconstructions/llm+p/domains/floortile/domain.nl new file mode 100644 index 0000000..21feca7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/domain.nl @@ -0,0 +1,15 @@ +You control a set of robots that use different colors to paint patterns in floor tiles. The robots can move around the floor tiles in four directions (up, down, left and right). Robots paint with one color at a time, but can change their spray guns to any available color. However, robots can only paint the tile that is in front (up) and behind (down) them, and once a tile has been painted no robot can stand on it. + +Here are the actions each robot can do +Change the spray gun color +Paint the tile that is up from the robot +Paint the tile that is down from the robot +Move up +Move down +Move right +Move left + +You have the following restrictions on your actions: +A robot can only paint a tile if the tile has not been painted. +A robot can only paint a tile to the color of its spray gun. +A robot cannot move to a tile that has been painted. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/domain.pddl b/paper_reconstructions/llm+p/domains/floortile/domain.pddl new file mode 100644 index 0000000..190b603 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/domain.pddl @@ -0,0 +1,81 @@ +;;Created by Tomas de la Rosa +;;Domain for painting floor tiles with two colors + +(define (domain floortile) +(:requirements :typing :action-costs) +(:types robot tile color - object) + +(:predicates + (robot-at ?r - robot ?x - tile) + (up ?x - tile ?y - tile) + (down ?x - tile ?y - tile) + (right ?x - tile ?y - tile) + (left ?x - tile ?y - tile) + + (clear ?x - tile) + (painted ?x - tile ?c - color) + (robot-has ?r - robot ?c - color) + (available-color ?c - color) + (free-color ?r - robot)) + +(:functions (total-cost)) + +(:action change-color + :parameters (?r - robot ?c - color ?c2 - color) + :precondition (and (robot-has ?r ?c) (available-color ?c2)) + :effect (and (not (robot-has ?r ?c)) (robot-has ?r ?c2) + (increase (total-cost) 5)) +) + + +(:action paint-up + :parameters (?r - robot ?y - tile ?x - tile ?c - color) + :precondition (and (robot-has ?r ?c) (robot-at ?r ?x) (up ?y ?x) (clear ?y)) + :effect (and (not (clear ?y)) (painted ?y ?c) + (increase (total-cost) 2)) +) + + +(:action paint-down + :parameters (?r - robot ?y - tile ?x - tile ?c - color) + :precondition (and (robot-has ?r ?c) (robot-at ?r ?x) (down ?y ?x) (clear ?y)) + :effect (and (not (clear ?y)) (painted ?y ?c) +(increase (total-cost) 2)) +) + + +; Robot movements +(:action up + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (up ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 3)) +) + + +(:action down + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (down ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +(:action right + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (right ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +(:action left + :parameters (?r - robot ?x - tile ?y - tile) + :precondition (and (robot-at ?r ?x) (left ?y ?x) (clear ?y)) + :effect (and (robot-at ?r ?y) (not (robot-at ?r ?x)) + (clear ?x) (not (clear ?y)) + (increase (total-cost) 1)) +) + +) diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.nl b/paper_reconstructions/llm+p/domains/floortile/p_example.nl new file mode 100644 index 0000000..e1021ef --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.nl @@ -0,0 +1,11 @@ +You have 4 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +You have 1 robot. +Each robot can paint in color white. +robot2 is at tile_2-2. +robot1 is at tile_0-1. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is white; tile_1-3 is white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.pddl b/paper_reconstructions/llm+p/domains/floortile/p_example.pddl new file mode 100644 index 0000000..a945788 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.pddl @@ -0,0 +1,67 @@ +(define (problem p01-432) + (:domain floor-tile) + (:objects tile_0-1 tile_0-2 tile_0-3 + tile_1-1 tile_1-2 tile_1-3 + tile_2-1 tile_2-2 tile_2-3 + tile_3-1 tile_3-2 tile_3-3 - tile + robot1 - robot + white - color +) + (:init + (robot-at robot1 tile_0-1) + (robot-has robot1 white) + (robot-at robot2 tile_2-2) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) +) + (:goal (and + (painted tile_1-1 white) + (painted tile_1-2 white) + (painted tile_1-3 white) +)) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/p_example.sol b/paper_reconstructions/llm+p/domains/floortile/p_example.sol new file mode 100644 index 0000000..bfa6f25 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/p_example.sol @@ -0,0 +1,5 @@ +Robot 1 paints tile_1-1 white, +Robot 1 moves right to tile_0-2, +Robot 1 paints tile_1-2 white, +Robot 1 moves right to tile_0-3, +Robot 1 paints tile_1-3 white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl new file mode 100644 index 0000000..1d9caa9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p01.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot1 is at tile_4-1. +robot2 is at tile_4-3. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl new file mode 100644 index 0000000..c27f608 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p02.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot2 is at tile_4-1. +robot1 is at tile_3-2. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl new file mode 100644 index 0000000..df4e675 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p03.nl @@ -0,0 +1,12 @@ +You have 5 rows and 3 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 +tile_1-1 tile_1-2 tile_1-3 +tile_2-1 tile_2-2 tile_2-3 +tile_3-1 tile_3-2 tile_3-3 +tile_4-1 tile_4-2 tile_4-3 +You have 2 robots. +Each robot can paint in color white or black. +robot2 is at tile_1-1. +robot1 is at tile_2-3. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl b/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl new file mode 100644 index 0000000..8e10fd6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/problems/p04.nl @@ -0,0 +1,12 @@ +You have 5 rows and 4 columns of unpainted floor tiles. +tile_0-1 tile_0-2 tile_0-3 tile_0-4 +tile_1-1 tile_1-2 tile_1-3 tile_1-4 +tile_2-1 tile_2-2 tile_2-3 tile_2-4 +tile_3-1 tile_3-2 tile_3-3 tile_3-4 +tile_4-1 tile_4-2 tile_4-3 tile_4-4 +You have 2 robots. +Each robot can paint in color white or black. +robot1 is at tile_0-3. +robot2 is at tile_3-4. +Your goal is to paint the grid in the following pattern: +tile_1-1 is white; tile_1-2 is black; tile_1-3 is white; tile_1-4 is black; tile_2-1 is black; tile_2-2 is white; tile_2-3 is black; tile_2-4 is white; tile_3-1 is white; tile_3-2 is black; tile_3-3 is white; tile_3-4 is black; tile_4-1 is black; tile_4-2 is white; tile_4-3 is black; tile_4-4 is white. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl new file mode 100644 index 0000000..3207b31 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p01.pddl @@ -0,0 +1,110 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_4-1) + (robot-at robot2 tile_4-3) + (robot-has robot1 black) + (robot-has robot2 white) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-2) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl new file mode 100644 index 0000000..7da0e99 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p02.pddl @@ -0,0 +1,113 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_3-2) + (robot-at robot2 tile_4-1) + (robot-has robot1 white) + (robot-has robot1 black) + (robot-has robot2 white) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-2) + (clear tile_4-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl new file mode 100644 index 0000000..7420cf9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p03.pddl @@ -0,0 +1,112 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_2-3) + (robot-at robot2 tile_1-1) + (robot-has robot1 white) + (robot-has robot1 black) + (robot-has robot2 white) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-3) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-1) + (clear tile_4-2) + (clear tile_4-3) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl new file mode 100644 index 0000000..9202ab1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/pddl/p04.pddl @@ -0,0 +1,142 @@ +(define + (problem floortile_problem) + (:domain floortile) + + (:objects + tile_0-1 - tile + tile_0-2 - tile + tile_0-3 - tile + tile_0-4 - tile + tile_1-1 - tile + tile_1-2 - tile + tile_1-3 - tile + tile_1-4 - tile + tile_2-1 - tile + tile_2-2 - tile + tile_2-3 - tile + tile_2-4 - tile + tile_3-1 - tile + tile_3-2 - tile + tile_3-3 - tile + tile_3-4 - tile + tile_4-1 - tile + tile_4-2 - tile + tile_4-3 - tile + tile_4-4 - tile + robot1 - robot + robot2 - robot + white - color + black - color + ) + + (:init + (robot-at robot1 tile_0-3) + (robot-has robot1 white) + (robot-at robot2 tile_3-4) + (robot-has robot2 black) + (available-color white) + (available-color black) + (clear tile_0-1) + (clear tile_0-2) + (clear tile_0-4) + (clear tile_1-1) + (clear tile_1-2) + (clear tile_1-3) + (clear tile_1-4) + (clear tile_2-1) + (clear tile_2-2) + (clear tile_2-3) + (clear tile_2-4) + (clear tile_3-1) + (clear tile_3-2) + (clear tile_3-3) + (clear tile_4-1) + (clear tile_4-2) + (clear tile_4-3) + (clear tile_4-4) + (up tile_1-1 tile_0-1) + (up tile_1-2 tile_0-2) + (up tile_1-3 tile_0-3) + (up tile_1-4 tile_0-4) + (up tile_2-1 tile_1-1) + (up tile_2-2 tile_1-2) + (up tile_2-3 tile_1-3) + (up tile_2-4 tile_1-4) + (up tile_3-1 tile_2-1) + (up tile_3-2 tile_2-2) + (up tile_3-3 tile_2-3) + (up tile_3-4 tile_2-4) + (up tile_4-1 tile_3-1) + (up tile_4-2 tile_3-2) + (up tile_4-3 tile_3-3) + (up tile_4-4 tile_3-4) + (down tile_0-1 tile_1-1) + (down tile_0-2 tile_1-2) + (down tile_0-3 tile_1-3) + (down tile_0-4 tile_1-4) + (down tile_1-1 tile_2-1) + (down tile_1-2 tile_2-2) + (down tile_1-3 tile_2-3) + (down tile_1-4 tile_2-4) + (down tile_2-1 tile_3-1) + (down tile_2-2 tile_3-2) + (down tile_2-3 tile_3-3) + (down tile_2-4 tile_3-4) + (down tile_3-1 tile_4-1) + (down tile_3-2 tile_4-2) + (down tile_3-3 tile_4-3) + (down tile_3-4 tile_4-4) + (right tile_0-2 tile_0-1) + (right tile_0-3 tile_0-2) + (right tile_0-4 tile_0-3) + (right tile_1-2 tile_1-1) + (right tile_1-3 tile_1-2) + (right tile_1-4 tile_1-3) + (right tile_2-2 tile_2-1) + (right tile_2-3 tile_2-2) + (right tile_2-4 tile_2-3) + (right tile_3-2 tile_3-1) + (right tile_3-3 tile_3-2) + (right tile_3-4 tile_3-3) + (right tile_4-2 tile_4-1) + (right tile_4-3 tile_4-2) + (right tile_4-4 tile_4-3) + (left tile_0-1 tile_0-2) + (left tile_0-2 tile_0-3) + (left tile_0-3 tile_0-4) + (left tile_1-1 tile_1-2) + (left tile_1-2 tile_1-3) + (left tile_1-3 tile_1-4) + (left tile_2-1 tile_2-2) + (left tile_2-2 tile_2-3) + (left tile_2-3 tile_2-4) + (left tile_3-1 tile_3-2) + (left tile_3-2 tile_3-3) + (left tile_3-3 tile_3-4) + (left tile_4-1 tile_4-2) + (left tile_4-2 tile_4-3) + (left tile_4-3 tile_4-4) + ) + + (:goal + (and + (painted tile_1-1 white) + (painted tile_1-2 black) + (painted tile_1-3 white) + (painted tile_1-4 black) + (painted tile_2-1 black) + (painted tile_2-2 white) + (painted tile_2-3 black) + (painted tile_2-4 white) + (painted tile_3-1 white) + (painted tile_3-2 black) + (painted tile_3-3 white) + (painted tile_3-4 black) + (painted tile_4-1 black) + (painted tile_4-2 white) + (painted tile_4-3 black) + (painted tile_4-4 white) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt new file mode 100644 index 0000000..190544f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt @@ -0,0 +1,50 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +down robot1 tile_4-1 tile_3-1 (1) +paint-up robot1 tile_4-1 tile_3-1 black (1) +down robot1 tile_3-1 tile_2-1 (1) +down robot2 tile_4-3 tile_3-3 (1) +change-color robot2 white black (1) +paint-up robot2 tile_4-3 tile_3-3 black (1) +change-color robot1 black white (1) +paint-up robot1 tile_3-1 tile_2-1 white (1) +change-color robot2 black white (1) +change-color robot1 white black (1) +down robot1 tile_2-1 tile_1-1 (1) +paint-up robot1 tile_2-1 tile_1-1 black (1) +down robot1 tile_1-1 tile_0-1 (1) +change-color robot1 black white (1) +paint-up robot1 tile_1-1 tile_0-1 white (1) +change-color robot1 white black (1) +right robot1 tile_0-1 tile_0-2 (1) +down robot2 tile_3-3 tile_2-3 (1) +paint-up robot2 tile_3-3 tile_2-3 white (1) +left robot1 tile_0-2 tile_0-1 (1) +change-color robot2 white black (1) +left robot2 tile_2-3 tile_2-2 (1) +down robot2 tile_2-2 tile_1-2 (1) +down robot2 tile_1-2 tile_0-2 (1) +right robot2 tile_0-2 tile_0-3 (1) +right robot1 tile_0-1 tile_0-2 (1) +change-color robot2 black white (1) +change-color robot1 black white (1) +up robot1 tile_0-2 tile_1-2 (1) +up robot1 tile_1-2 tile_2-2 (1) +up robot1 tile_2-2 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +down robot1 tile_3-2 tile_2-2 (1) +change-color robot1 white black (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot1 tile_2-2 tile_1-2 (1) +change-color robot1 black white (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +change-color robot1 white black (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +change-color robot2 white black (1) +up robot2 tile_0-3 tile_1-3 (1) +paint-up robot2 tile_2-3 tile_1-3 black (1) +change-color robot1 black white (1) +down robot2 tile_1-3 tile_0-3 (1) +change-color robot2 black white (1) +paint-up robot2 tile_1-3 tile_0-3 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt new file mode 100644 index 0000000..4c7cee2 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt @@ -0,0 +1,27 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +paint-up robot1 tile_4-2 tile_3-2 white (1) +right robot1 tile_3-2 tile_3-3 (1) +paint-up robot1 tile_4-3 tile_3-3 black (1) +down robot1 tile_3-3 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +left robot1 tile_2-3 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot2 tile_4-1 tile_3-1 (1) +paint-up robot2 tile_4-1 tile_3-1 black (1) +right robot1 tile_2-2 tile_2-3 (1) +down robot1 tile_2-3 tile_1-3 (1) +paint-up robot1 tile_2-3 tile_1-3 black (1) +down robot1 tile_1-3 tile_0-3 (1) +paint-up robot1 tile_1-3 tile_0-3 white (1) +left robot1 tile_0-3 tile_0-2 (1) +down robot2 tile_3-1 tile_2-1 (1) +paint-up robot2 tile_3-1 tile_2-1 white (1) +up robot1 tile_0-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +down robot2 tile_2-1 tile_1-1 (1) +paint-up robot2 tile_2-1 tile_1-1 black (1) +down robot2 tile_1-1 tile_0-1 (1) +paint-up robot2 tile_1-1 tile_0-1 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt new file mode 100644 index 0000000..fd79632 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt @@ -0,0 +1,31 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +up robot1 tile_2-3 tile_3-3 (1) +paint-up robot1 tile_4-3 tile_3-3 black (1) +up robot2 tile_1-1 tile_2-1 (1) +up robot2 tile_2-1 tile_3-1 (1) +paint-up robot2 tile_4-1 tile_3-1 black (1) +down robot1 tile_3-3 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +down robot1 tile_2-3 tile_1-3 (1) +paint-up robot1 tile_2-3 tile_1-3 black (1) +down robot1 tile_1-3 tile_0-3 (1) +paint-up robot1 tile_1-3 tile_0-3 white (1) +left robot1 tile_0-3 tile_0-2 (1) +down robot2 tile_3-1 tile_2-1 (1) +paint-up robot2 tile_3-1 tile_2-1 white (1) +down robot2 tile_2-1 tile_1-1 (1) +paint-up robot2 tile_2-1 tile_1-1 black (1) +up robot1 tile_0-2 tile_1-2 (1) +down robot2 tile_1-1 tile_0-1 (1) +paint-up robot2 tile_1-1 tile_0-1 white (1) +up robot1 tile_1-2 tile_2-2 (1) +change-color robot2 black white (1) +up robot1 tile_2-2 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +down robot1 tile_3-2 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +down robot1 tile_2-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt new file mode 100644 index 0000000..e3bbe92 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt @@ -0,0 +1,55 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +left robot1 tile_0-3 tile_0-2 (1) +up robot1 tile_0-2 tile_1-2 (1) +left robot1 tile_1-2 tile_1-1 (1) +change-color robot2 black white (1) +paint-up robot2 tile_4-4 tile_3-4 white (1) +up robot1 tile_1-1 tile_2-1 (1) +change-color robot2 white black (1) +left robot2 tile_3-4 tile_3-3 (1) +paint-up robot2 tile_4-3 tile_3-3 black (1) +change-color robot1 white black (1) +right robot2 tile_3-3 tile_3-4 (1) +up robot1 tile_2-1 tile_3-1 (1) +paint-up robot1 tile_4-1 tile_3-1 black (1) +down robot2 tile_3-4 tile_2-4 (1) +paint-up robot2 tile_3-4 tile_2-4 black (1) +change-color robot1 black white (1) +right robot1 tile_3-1 tile_3-2 (1) +paint-up robot1 tile_4-2 tile_3-2 white (1) +change-color robot2 black white (1) +left robot1 tile_3-2 tile_3-1 (1) +down robot2 tile_2-4 tile_1-4 (1) +paint-up robot2 tile_2-4 tile_1-4 white (1) +down robot2 tile_1-4 tile_0-4 (1) +down robot1 tile_3-1 tile_2-1 (1) +paint-up robot1 tile_3-1 tile_2-1 white (1) +change-color robot2 white black (1) +paint-up robot2 tile_1-4 tile_0-4 black (1) +change-color robot1 white black (1) +right robot1 tile_2-1 tile_2-2 (1) +paint-up robot1 tile_3-2 tile_2-2 black (1) +change-color robot2 black white (1) +change-color robot1 black white (1) +right robot1 tile_2-2 tile_2-3 (1) +paint-up robot1 tile_3-3 tile_2-3 white (1) +left robot1 tile_2-3 tile_2-2 (1) +left robot2 tile_0-4 tile_0-3 (1) +down robot1 tile_2-2 tile_1-2 (1) +paint-up robot1 tile_2-2 tile_1-2 white (1) +down robot1 tile_1-2 tile_0-2 (1) +change-color robot1 white black (1) +paint-up robot1 tile_1-2 tile_0-2 black (1) +left robot1 tile_0-2 tile_0-1 (1) +up robot1 tile_0-1 tile_1-1 (1) +paint-up robot1 tile_2-1 tile_1-1 black (1) +change-color robot1 black white (1) +down robot1 tile_1-1 tile_0-1 (1) +paint-up robot1 tile_1-1 tile_0-1 white (1) +change-color robot2 white black (1) +up robot2 tile_0-3 tile_1-3 (1) +paint-up robot2 tile_2-3 tile_1-3 black (1) +change-color robot2 black white (1) +down robot2 tile_1-3 tile_0-3 (1) +paint-up robot2 tile_1-3 tile_0-3 white (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/domain.nl b/paper_reconstructions/llm+p/domains/grippers/domain.nl new file mode 100644 index 0000000..2548ab6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/domain.nl @@ -0,0 +1,9 @@ +You are a robot with a gripper that can move objects between different rooms. + +There are three actions defined in this domain: + +The move action: This action allows the robot to move from one room to another.The action has a single precondition, which is that the robot is currently in a room. The effect of this action is to move the robot to another room and to remove the fact that it is in the original room. + +The pick action: This action allows the robot to pick up an object using the gripper. The action has three preconditions: (1) the object is located in a room (2) the robot is currently in the same room and (3) the gripper is free (i.e., not holding any object). The effect of this action is to update the state of the world to show that the robot is carrying the object using the gripper, the object is no longer in the room, and the gripper is no longer free. + +The drop action: This action allows the robot to drop an object that it is carrying. The action has two preconditions: (1) the robot is currently carrying the object using the gripper, and (2) the robot is currently in a room. The effect of this action is to update the state of the world to show that the robot is no longer carrying the object using the gripper, the object is now located in the room, and the gripper is now free. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/domain.pddl b/paper_reconstructions/llm+p/domains/grippers/domain.pddl new file mode 100644 index 0000000..bcba5bd --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/domain.pddl @@ -0,0 +1,27 @@ +(define (domain grippers) + (:requirements :strips :typing) + (:types room object robot gripper) + (:predicates (at-robby ?r - robot ?x - room) + (at ?o - object ?x - room) + (free ?r - robot ?g - gripper) + (carry ?r - robot ?o - object ?g - gripper)) + + (:action move + :parameters (?r - robot ?from ?to - room) + :precondition (and (at-robby ?r ?from)) + :effect (and (at-robby ?r ?to) + (not (at-robby ?r ?from)))) + + (:action pick + :parameters (?r - robot ?obj - object ?room - room ?g - gripper) + :precondition (and (at ?obj ?room) (at-robby ?r ?room) (free ?r ?g)) + :effect (and (carry ?r ?obj ?g) + (not (at ?obj ?room)) + (not (free ?r ?g)))) + + (:action drop + :parameters (?r - robot ?obj - object ?room - room ?g - gripper) + :precondition (and (carry ?r ?obj ?g) (at-robby ?r ?room)) + :effect (and (at ?obj ?room) + (free ?r ?g) + (not (carry ?r ?obj ?g))))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.nl b/paper_reconstructions/llm+p/domains/grippers/p_example.nl new file mode 100644 index 0000000..af2162c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.nl @@ -0,0 +1,12 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 4 rooms and 6 balls. +robot2 is in room3. robot1 is in room2. +ball1 is in room3. ball2 is in room1. ball3 is in room3. ball4 is in room2. ball5 is in room4. ball6 is in room4. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room4. +ball2 should be in room1. +ball3 should be in room1. +ball4 should be in room2. +ball5 should be in room1. +ball6 should be in room1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.pddl b/paper_reconstructions/llm+p/domains/grippers/p_example.pddl new file mode 100644 index 0000000..8ddce33 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.pddl @@ -0,0 +1,31 @@ +(define (problem gripper-2-4-6) +(:domain gripper-strips) +(:objects robot1 robot2 - robot +rgripper1 lgripper1 rgripper2 lgripper2 - gripper +room1 room2 room3 room4 - room +ball1 ball2 ball3 ball4 ball5 ball6 - object) +(:init +(at-robby robot1 room2) +(free robot1 rgripper1) +(free robot1 lgripper1) +(at-robby robot2 room3) +(free robot2 rgripper2) +(free robot2 lgripper2) +(at ball1 room3) +(at ball2 room1) +(at ball3 room3) +(at ball4 room2) +(at ball5 room4) +(at ball6 room4) +) +(:goal +(and +(at ball1 room4) +(at ball2 room1) +(at ball3 room1) +(at ball4 room2) +(at ball5 room1) +(at ball6 room1) +) +) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/p_example.sol b/paper_reconstructions/llm+p/domains/grippers/p_example.sol new file mode 100644 index 0000000..563230e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/p_example.sol @@ -0,0 +1,11 @@ +Robot2 picks up ball1 with its left gripper in room3. +Robot2 picks up ball3 with its right gripper in room3. +Robot2 moves from room3 to room1. +Robot2 drops ball3 in room1 with its right gripper. +Robot2 moves from room1 to room4. +Robot2 picks up ball5 with its right gripper in room4. +Robot2 drops ball1 in room4 with its left gripper. +Robot2 picks up ball6 with its left gripper in room4. +Robot2 moves from room4 to room1. +Robot2 drops ball6 in room1 with its left gripper. +Robot2 drops ball5 in room1 with its right gripper. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl new file mode 100644 index 0000000..4e67f28 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p01.nl @@ -0,0 +1,8 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 2 rooms and 2 balls. +robot1 is in room1. robot2 is in room1. +ball2 is in room1. ball1 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room1. +ball2 should be in room1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl new file mode 100644 index 0000000..4e88348 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p02.nl @@ -0,0 +1,10 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 3 rooms and 4 balls. +robot2 is in room3. robot1 is in room2. +ball1 is in room3. ball2 is in room1. ball4 is in room3. ball3 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room2. +ball2 should be in room2. +ball3 should be in room3. +ball4 should be in room3. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl new file mode 100644 index 0000000..73eccc7 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p03.nl @@ -0,0 +1,8 @@ +You control 2 robots, each robot has a left gripper and a right gripper. +There are 5 rooms and 2 balls. +robot1 is in room1. robot2 is in room2. +ball2 is in room1. ball1 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room5. +ball2 should be in room4. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl b/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl new file mode 100644 index 0000000..00a6229 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/problems/p04.nl @@ -0,0 +1,10 @@ +You control 3 robots, each robot has a left gripper and a right gripper. +There are 4 rooms and 4 balls. +robot1 is in room4. robot3 is in room1. robot2 is in room4. +ball2 is in room1. ball4 is in room2. ball1 is in room1. ball3 is in room1. +The robots' grippers are free. +Your goal is to transport the balls to their destinations. +ball1 should be in room1. +ball2 should be in room1. +ball3 should be in room3. +ball4 should be in room2. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl new file mode 100644 index 0000000..ae51550 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p01.pddl @@ -0,0 +1,36 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + lgripper1 - gripper + rgripper1 - gripper + lgripper2 - gripper + rgripper2 - gripper + room1 - room + room2 - room + ball1 - object + ball2 - object + ) + + (:init + (at-robby robot1 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room1) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room1) + (at ball2 room1) + ) + + (:goal + (and + (at ball1 room1) + (at ball2 room1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl new file mode 100644 index 0000000..f451de0 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p02.pddl @@ -0,0 +1,43 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + rgripper1 - gripper + lgripper1 - gripper + rgripper2 - gripper + lgripper2 - gripper + room1 - room + room2 - room + room3 - room + ball1 - object + ball2 - object + ball3 - object + ball4 - object + ) + + (:init + (at-robby robot1 room2) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room3) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room3) + (at ball2 room1) + (at ball3 room1) + (at ball4 room3) + ) + + (:goal + (and + (at ball1 room2) + (at ball2 room2) + (at ball3 room3) + (at ball4 room3) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl new file mode 100644 index 0000000..8dfaf92 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p03.pddl @@ -0,0 +1,39 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + rgripper1 - gripper + lgripper1 - gripper + rgripper2 - gripper + lgripper2 - gripper + room1 - room + room2 - room + room3 - room + room4 - room + room5 - room + ball1 - object + ball2 - object + ) + + (:init + (at-robby robot1 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (at-robby robot2 room2) + (free robot2 rgripper2) + (free robot2 lgripper2) + (at ball1 room1) + (at ball2 room1) + ) + + (:goal + (and + (at ball1 room5) + (at ball2 room4) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl new file mode 100644 index 0000000..7ac538a --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/pddl/p04.pddl @@ -0,0 +1,50 @@ +(define + (problem grippers_problem) + (:domain grippers) + + (:objects + robot1 - robot + robot2 - robot + robot3 - robot + lgripper1 - gripper + rgripper1 - gripper + lgripper2 - gripper + rgripper2 - gripper + lgripper3 - gripper + rgripper3 - gripper + room1 - room + room2 - room + room3 - room + room4 - room + ball1 - object + ball2 - object + ball3 - object + ball4 - object + ) + + (:init + (at-robby robot1 room4) + (at-robby robot2 room4) + (at-robby robot3 room1) + (free robot1 rgripper1) + (free robot1 lgripper1) + (free robot2 rgripper2) + (free robot2 lgripper2) + (free robot3 rgripper3) + (free robot3 lgripper3) + (at ball1 room1) + (at ball2 room1) + (at ball3 room1) + (at ball4 room2) + ) + + (:goal + (and + (at ball1 room1) + (at ball2 room1) + (at ball3 room3) + (at ball4 room2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt new file mode 100644 index 0000000..c8e6d32 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt @@ -0,0 +1,2 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt new file mode 100644 index 0000000..9296f1c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt @@ -0,0 +1,13 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +move robot2 room3 room1 (1) +pick robot2 ball2 room1 lgripper2 (1) +move robot2 room1 room2 (1) +drop robot2 ball2 room2 lgripper2 (1) +move robot1 room2 room1 (1) +pick robot1 ball3 room1 lgripper1 (1) +move robot1 room1 room3 (1) +pick robot1 ball1 room3 rgripper1 (1) +drop robot1 ball3 room3 lgripper1 (1) +move robot1 room3 room2 (1) +drop robot1 ball1 room2 rgripper1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt new file mode 100644 index 0000000..b82fec1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt @@ -0,0 +1,8 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +pick robot1 ball1 room1 lgripper1 (1) +pick robot1 ball2 room1 rgripper1 (1) +move robot1 room1 room4 (1) +drop robot1 ball2 room4 rgripper1 (1) +move robot1 room4 room5 (1) +drop robot1 ball1 room5 lgripper1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt new file mode 100644 index 0000000..8aac8c1 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +pick robot3 ball3 room1 lgripper3 (1) +move robot3 room1 room3 (1) +drop robot3 ball3 room3 lgripper3 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/domain.nl b/paper_reconstructions/llm+p/domains/storage/domain.nl new file mode 100644 index 0000000..5a0719e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/domain.nl @@ -0,0 +1,13 @@ +Your goal is to move all crates to a depot. + +There are five actions in the domain: "lift", "drop", "move", "go-out" and "go-in", each with their own parameters, preconditions, and effects. + +"lift" action lifts a crate using a hoist from a store area to an area that is connected to it, and places the crate in a place. The preconditions for the "lift" action require that the hoist is available, the hoist is at the destination area, the crate is on the surface in the source store area, and the source store area is in the place. The effects of the "lift" action remove the crate from the source store area, make the source area clear, make the hoist unavailable, make the hoist lifting the crate, and remove the crate from the place. + +"drop" action drops a crate from the hoist onto a surface in a store area that is connected to the area where the hoist is currently located. The preconditions for the "drop" action require that the hoist is at the destination area, the hoist is lifting the crate, the destination store area is clear, and the destination store area is in the place. The effects of the "drop" action remove the hoist lifting the crate, make the hoist available, make the destination area occupied by the crate, and make the crate in the destination store area. + +"move" action moves a hoist from one store area to another connected store area. The preconditions for the "move" action require that the hoist is in the source store area, the destination store area is clear, and the source and destination areas are connected. The effects of the "move" action remove the hoist from the source area, place the hoist in the destination area, make the source area occupied, and make the destination area clear. + +"go-out" action moves a hoist from a store area to a transit area that is connected to it. The preconditions for the "go-out" action require that the hoist is in the source store area, and the source and destination areas are connected. The effects of the "go-out" action remove the hoist from the source area, place the hoist in the transit area, and make the source area clear. + +"go-in" action moves a hoist from a transit area to a store area that is connected to it. The preconditions for the "go-in" action require that the hoist is in the transit area, the source and destination areas are connected, and the destination area is clear. The effects of the "go-in" action remove the hoist from the transit area, place the hoist in the destination store area, and make the destination store area occupied. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/domain.pddl b/paper_reconstructions/llm+p/domains/storage/domain.pddl new file mode 100644 index 0000000..90b58cb --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/domain.pddl @@ -0,0 +1,48 @@ +; IPC5 Domain: Storage Propositional +; Authors: Alfonso Gerevini and Alessandro Saetti + +(define (domain storage) +(:requirements :typing) +(:types hoist surface place area - object + container depot - place + storearea transitarea - area + area crate - surface) + +(:predicates (clear ?s - storearea) + (in ?x - (either storearea crate) ?p - place) + (available ?h - hoist) + (lifting ?h - hoist ?c - crate) + (at ?h - hoist ?a - area) + (on ?c - crate ?s - storearea) + (connected ?a1 ?a2 - area) + (compatible ?c1 ?c2 - crate)) + +(:action lift + :parameters (?h - hoist ?c - crate ?a1 - storearea ?a2 - area ?p - place) + :precondition (and (connected ?a1 ?a2) (at ?h ?a2) (available ?h) + (on ?c ?a1) (in ?a1 ?p)) + :effect (and (not (on ?c ?a1)) (clear ?a1) + (not (available ?h)) (lifting ?h ?c) (not (in ?c ?p)))) + +(:action drop + :parameters (?h - hoist ?c - crate ?a1 - storearea ?a2 - area ?p - place) + :precondition (and (connected ?a1 ?a2) (at ?h ?a2) (lifting ?h ?c) + (clear ?a1) (in ?a1 ?p)) + :effect (and (not (lifting ?h ?c)) (available ?h) + (not (clear ?a1)) (on ?c ?a1) (in ?c ?p))) + +(:action move + :parameters (?h - hoist ?from ?to - storearea) + :precondition (and (at ?h ?from) (clear ?to) (connected ?from ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (not (clear ?to)) (clear ?from))) + +(:action go-out + :parameters (?h - hoist ?from - storearea ?to - transitarea) + :precondition (and (at ?h ?from) (connected ?from ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (clear ?from))) + +(:action go-in + :parameters (?h - hoist ?from - transitarea ?to - storearea) + :precondition (and (at ?h ?from) (connected ?from ?to) (clear ?to)) + :effect (and (not (at ?h ?from)) (at ?h ?to) (not (clear ?to)))) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.nl b/paper_reconstructions/llm+p/domains/storage/p_example.nl new file mode 100644 index 0000000..237dafc --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.nl @@ -0,0 +1,22 @@ +You have 6 depot storeareas, 3 container storeareas, 3 hoists, 3 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-1-3 depot48-2-1 depot48-2-2 depot48-2-3 +Container storeareas are: container-0-0 container-0-1 container-0-2 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 depot48-1-3 +depot48-2-1 depot48-2-2 depot48-2-3 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate2 is on container-0-2. +crate1 is on container-0-1. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-2-2 and loadarea are connected. +depot48-1-3 depot48-2-1 depot48-1-2 are clear. +hoist2 is in depot48-2-3 +hoist1 is in depot48-1-1 +hoist0 is in depot48-2-2 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.pddl b/paper_reconstructions/llm+p/domains/storage/p_example.pddl new file mode 100644 index 0000000..fa6c2b8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.pddl @@ -0,0 +1,75 @@ +; Domain designed by Alfonso Gerevini and Alessandro Saetti +; This file has been automatically generated by the generator available from +; http://zeus.ing.unibs.it/ipc-5/generators/index.html +; +; Map of the Depots: +; 000 +; 0*0 +;---- +; 48: depot48 area +; *: Depot access point +; =: Transit area + +(define (problem storage-9) +(:domain Storage-Propositional) +(:objects + depot48-1-1 depot48-1-2 depot48-1-3 depot48-2-1 depot48-2-2 depot48-2-3 container-0-0 container-0-1 container-0-2 - storearea + hoist0 hoist1 hoist2 - hoist + crate0 crate1 crate2 - crate + container0 - container + depot48 - depot + loadarea - transitarea) + +(:init + (connected depot48-1-1 depot48-2-1) + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-2 depot48-2-2) + (connected depot48-1-2 depot48-1-3) + (connected depot48-1-2 depot48-1-1) + (connected depot48-1-3 depot48-2-3) + (connected depot48-1-3 depot48-1-2) + (connected depot48-2-1 depot48-1-1) + (connected depot48-2-1 depot48-2-2) + (connected depot48-2-2 depot48-1-2) + (connected depot48-2-2 depot48-2-3) + (connected depot48-2-2 depot48-2-1) + (connected depot48-2-3 depot48-1-3) + (connected depot48-2-3 depot48-2-2) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-1-3 depot48) + (in depot48-2-1 depot48) + (in depot48-2-2 depot48) + (in depot48-2-3 depot48) + (on crate0 container-0-0) + (on crate1 container-0-1) + (on crate2 container-0-2) + (in crate0 container0) + (in crate1 container0) + (in crate2 container0) + (in container-0-0 container0) + (in container-0-1 container0) + (in container-0-2 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected loadarea container-0-1) + (connected container-0-1 loadarea) + (connected loadarea container-0-2) + (connected container-0-2 loadarea) + (connected depot48-2-2 loadarea) + (connected loadarea depot48-2-2) + (clear depot48-2-1) + (clear depot48-1-2) + (clear depot48-1-3) + (at hoist0 depot48-2-2) + (available hoist0) + (at hoist1 depot48-1-1) + (available hoist1) + (at hoist2 depot48-2-3) + (available hoist2)) + +(:goal (and + (in crate0 depot48) + (in crate1 depot48) + (in crate2 depot48))) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/p_example.sol b/paper_reconstructions/llm+p/domains/storage/p_example.sol new file mode 100644 index 0000000..68ec20b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/p_example.sol @@ -0,0 +1,11 @@ +Go out with hoist0 from depot48-2-2 to loadarea. +Lift crate0 in container-0-0 in container 0 with hoist0 from loadarea. +Go in with hoist0 from loadarea to depot48-2-2. +Drop crate0 with hoist0 from depot48-2-2 to depot48-1-2 in depot48. +Go out with hoist0 from depot48-2-2 to loadarea. +Lift crate1 in container-0-1 in container 0 with hoist0 from loadarea. +Drop crate1 with hoist0 from loadarea to depot48-2-2 in depot48. +Lift crate2 in container-0-2 in container0 with hoist0 from loadarea. +Lift crate1 in depot48-2-2 in depot48 with hoist2 from depot48-2-3. +Drop crate2 with hoist0 from loadarea to depot48-2-2 in depot48. +Drop crate1 with hoist2 from depot48-2-3 to depot48-1-3 in depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p01.nl b/paper_reconstructions/llm+p/domains/storage/problems/p01.nl new file mode 100644 index 0000000..589e485 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p01.nl @@ -0,0 +1,16 @@ +You have 1 depot storeareas, 1 container storeareas, 1 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-1 and loadarea are connected. +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p02.nl b/paper_reconstructions/llm+p/domains/storage/problems/p02.nl new file mode 100644 index 0000000..da6a4d6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p02.nl @@ -0,0 +1,17 @@ +You have 2 depot storeareas, 1 container storeareas, 2 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-1 and loadarea are connected. +hoist1 is in depot48-1-2 +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p03.nl b/paper_reconstructions/llm+p/domains/storage/problems/p03.nl new file mode 100644 index 0000000..9878a5b --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p03.nl @@ -0,0 +1,18 @@ +You have 3 depot storeareas, 1 container storeareas, 3 hoists, 1 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-1-3 +Container storeareas are: container-0-0 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 depot48-1-3 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-1-2 and loadarea are connected. +hoist0 is in depot48-1-2 +hoist2 is in depot48-1-1 +hoist1 is in depot48-1-3 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/problems/p04.nl b/paper_reconstructions/llm+p/domains/storage/problems/p04.nl new file mode 100644 index 0000000..592cc10 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/problems/p04.nl @@ -0,0 +1,19 @@ +You have 4 depot storeareas, 2 container storeareas, 1 hoists, 2 crates, 1 container0, 1 depot48, 1 loadarea. +Depot storeareas are: depot48-1-1 depot48-1-2 depot48-2-1 depot48-2-2 +Container storeareas are: container-0-0 container-0-1 +Here is a map of depot storeareas: + +depot48-1-1 depot48-1-2 +depot48-2-1 depot48-2-2 + +According to the map, adjacent depot storeareas are connected. +All depot storeareas are in depot48. +crate1 is on container-0-1. +crate0 is on container-0-0. +All crates and container storeareas are in container0. +All container storeareas are connected to loadarea. +depot48-2-1 and loadarea are connected. +depot48-2-2 depot48-2-1 depot48-1-2 are clear. +hoist0 is in depot48-1-1 +All hoists are available. +Your goal is to move all crates to depot48. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl new file mode 100644 index 0000000..37a39d3 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p01.pddl @@ -0,0 +1,35 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 - storearea + container-0-0 - storearea + hoist0 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-1) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-1 loadarea) + (connected loadarea depot48-1-1) + (at hoist0 depot48-1-1) + (available hoist0) + (in depot48-1-1 depot48) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl new file mode 100644 index 0000000..d437fd5 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p02.pddl @@ -0,0 +1,39 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 depot48-1-2 - storearea + container-0-0 - storearea + hoist0 hoist1 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-1 loadarea) + (at hoist0 depot48-1-1) + (available hoist0) + (at hoist1 depot48-1-2) + (available hoist1) + (clear depot48-1-1) + (clear depot48-1-2) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl new file mode 100644 index 0000000..f1868a5 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p03.pddl @@ -0,0 +1,44 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 depot48-1-2 depot48-1-3 - storearea + container-0-0 - storearea + hoist0 hoist1 hoist2 - hoist + crate0 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-2 depot48-1-3) + (connected depot48-1-1 depot48-1-3) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-1-3 depot48) + (on crate0 container-0-0) + (in crate0 container0) + (in container-0-0 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected depot48-1-2 loadarea) + (clear depot48-1-1) + (clear depot48-1-3) + (at hoist0 depot48-1-2) + (available hoist0) + (at hoist1 depot48-1-3) + (available hoist1) + (at hoist2 depot48-1-1) + (available hoist2) + ) + + (:goal + (and + (in crate0 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl new file mode 100644 index 0000000..de3bdbe --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/pddl/p04.pddl @@ -0,0 +1,59 @@ +(define + (problem storage_problem) + (:domain storage) + + (:objects + depot48-1-1 - storearea + depot48-1-2 - storearea + depot48-2-1 - storearea + depot48-2-2 - storearea + container-0-0 - storearea + container-0-1 - storearea + hoist0 - hoist + crate0 - crate + crate1 - crate + container0 - container + depot48 - depot + loadarea - transitarea + ) + + (:init + (connected depot48-1-1 depot48-1-2) + (connected depot48-1-1 depot48-2-1) + (connected depot48-1-2 depot48-1-1) + (connected depot48-1-2 depot48-2-2) + (connected depot48-2-1 depot48-1-1) + (connected depot48-2-1 depot48-2-2) + (connected depot48-2-2 depot48-1-2) + (connected depot48-2-2 depot48-2-1) + (in depot48-1-1 depot48) + (in depot48-1-2 depot48) + (in depot48-2-1 depot48) + (in depot48-2-2 depot48) + (on crate0 container-0-0) + (on crate1 container-0-1) + (in crate0 container0) + (in crate1 container0) + (in container-0-0 container0) + (in container-0-1 container0) + (connected loadarea container-0-0) + (connected container-0-0 loadarea) + (connected loadarea container-0-1) + (connected container-0-1 loadarea) + (connected depot48-2-1 loadarea) + (connected loadarea depot48-2-1) + (clear depot48-2-2) + (clear depot48-2-1) + (clear depot48-1-2) + (at hoist0 depot48-1-1) + (available hoist0) + ) + + (:goal + (and + (in crate0 depot48) + (in crate1 depot48) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt new file mode 100644 index 0000000..c167d67 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +go-out hoist0 depot48-1-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt new file mode 100644 index 0000000..c167d67 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +go-out hoist0 depot48-1-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt new file mode 100644 index 0000000..d31f3b5 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt @@ -0,0 +1,5 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +go-out hoist0 depot48-1-2 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +drop hoist0 crate0 depot48-1-2 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt new file mode 100644 index 0000000..3da78ad --- /dev/null +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt @@ -0,0 +1,10 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +move hoist0 depot48-1-1 depot48-2-1 (1) +go-out hoist0 depot48-2-1 loadarea (1) +lift hoist0 crate0 container-0-0 loadarea container0 (1) +go-in hoist0 loadarea depot48-2-1 (1) +drop hoist0 crate0 depot48-1-1 depot48-2-1 depot48 (1) +go-out hoist0 depot48-2-1 loadarea (1) +lift hoist0 crate1 container-0-1 loadarea container0 (1) +drop hoist0 crate1 depot48-2-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/domain.nl b/paper_reconstructions/llm+p/domains/termes/domain.nl new file mode 100644 index 0000000..3c89ec0 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/domain.nl @@ -0,0 +1,15 @@ +You control a robot that can take the following actions to build complex structures. + +Move from a position to another. The new position and the old position must be at the same height. + +Move up from a position to another, and the height at the new position is one block higher than the old position. + +Move down from a position to another, and the height at the new position is one block lower than the old position. + +Place a block at a neighboring position from the robot's current position. The robot must have a block. The current height at the robot's position and the block's position must be the same. A block cannot be placed at the depot. The height at the block's position will be one block higher than the current height. + +Remove a block at a neighboring position from the robot's current position. The robot must not have a block. A block cannot be removed from the depot. The current height at the robot's position must be the same as the new height at the block's position. The new height at the block's position will be one block lower than the current height. + +Create a block at the depot. The robot will have the block. + +Destroy a block at the depot. The robot must have a block. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/domain.pddl b/paper_reconstructions/llm+p/domains/termes/domain.pddl new file mode 100644 index 0000000..cdcaf30 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/domain.pddl @@ -0,0 +1,134 @@ +(define (domain termes) +(:requirements :typing :negative-preconditions) +(:types + numb - object + position - object +) +(:predicates + (height ?p - position ?h - numb) + (at ?p - position) + (has-block) + ; + ; static predicates + (SUCC ?n1 - numb ?n2 - numb) + (NEIGHBOR ?p1 - position ?p2 - position) + (IS-DEPOT ?p - position) +) +(:action move + :parameters (?from - position ?to - position ?h - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?h) + (height ?to ?h) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action move-up + :parameters (?from - position ?hfrom - numb ?to - position ?hto - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?hfrom) + (height ?to ?hto) + (SUCC ?hto ?hfrom) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action move-down + :parameters (?from - position ?hfrom - numb ?to - position ?hto - numb) + :precondition + (and + (at ?from) + (NEIGHBOR ?from ?to) + (height ?from ?hfrom) + (height ?to ?hto) + (SUCC ?hfrom ?hto) + ) + :effect + (and + (not (at ?from)) + (at ?to) + ) +) + +(:action place-block + :parameters (?rpos - position ?bpos - position ?hbefore - numb ?hafter - numb) + :precondition + (and + (at ?rpos) + (NEIGHBOR ?rpos ?bpos) + (height ?rpos ?hbefore) + (height ?bpos ?hbefore) + (SUCC ?hafter ?hbefore) + (has-block) + (not (IS-DEPOT ?bpos)) + ) + :effect + (and + (not (height ?bpos ?hbefore)) + (height ?bpos ?hafter) + (not (has-block)) + ) +) + +(:action remove-block + :parameters (?rpos - position ?bpos - position ?hbefore - numb ?hafter - numb) + :precondition + (and + (at ?rpos) + (NEIGHBOR ?rpos ?bpos) + (height ?rpos ?hafter) + (height ?bpos ?hbefore) + (SUCC ?hbefore ?hafter) + (not (has-block)) + ) + :effect + (and + (not (height ?bpos ?hbefore)) + (height ?bpos ?hafter) + (has-block) + ) +) + +(:action create-block + :parameters (?p - position) + :precondition + (and + (at ?p) + (not (has-block)) + (IS-DEPOT ?p) + ) + :effect + (and + (has-block) + ) +) + +(:action destroy-block + :parameters (?p - position) + :precondition + (and + (at ?p) + (has-block) + (IS-DEPOT ?p) + ) + :effect + (and + (not (has-block)) + ) +) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.nl b/paper_reconstructions/llm+p/domains/termes/p_example.nl new file mode 100644 index 0000000..3d2a393 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.nl @@ -0,0 +1,9 @@ +The robot is on a grid with 3 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 1. +Your goal is to build blocks so that the height at pos-1-1 is 1. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.pddl b/paper_reconstructions/llm+p/domains/termes/p_example.pddl new file mode 100644 index 0000000..f7973cf --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.pddl @@ -0,0 +1,77 @@ +(define (problem prob) +(:domain termes) +; Initial state: +; 0 0 R0D +; 0 0 0 +; 0 0 0 +; Goal state: +; 0 0 0 +; 0 1 0 +; 0 0 0 +; Maximal height: 1 +(:objects + n0 - numb + n1 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position +) +(:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (NEIGHBOR pos-0-0 pos-1-0) + (NEIGHBOR pos-0-0 pos-0-1) + (NEIGHBOR pos-0-1 pos-1-1) + (NEIGHBOR pos-0-1 pos-0-0) + (NEIGHBOR pos-0-1 pos-0-2) + (NEIGHBOR pos-0-2 pos-1-2) + (NEIGHBOR pos-0-2 pos-0-1) + (NEIGHBOR pos-1-0 pos-0-0) + (NEIGHBOR pos-1-0 pos-2-0) + (NEIGHBOR pos-1-0 pos-1-1) + (NEIGHBOR pos-1-1 pos-0-1) + (NEIGHBOR pos-1-1 pos-2-1) + (NEIGHBOR pos-1-1 pos-1-0) + (NEIGHBOR pos-1-1 pos-1-2) + (NEIGHBOR pos-1-2 pos-0-2) + (NEIGHBOR pos-1-2 pos-2-2) + (NEIGHBOR pos-1-2 pos-1-1) + (NEIGHBOR pos-2-0 pos-1-0) + (NEIGHBOR pos-2-0 pos-2-1) + (NEIGHBOR pos-2-1 pos-1-1) + (NEIGHBOR pos-2-1 pos-2-0) + (NEIGHBOR pos-2-1 pos-2-2) + (NEIGHBOR pos-2-2 pos-1-2) + (NEIGHBOR pos-2-2 pos-2-1) + (IS-DEPOT pos-2-0) +) +(:goal +(and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n1) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (not (has-block)) +) +) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/p_example.sol b/paper_reconstructions/llm+p/domains/termes/p_example.sol new file mode 100644 index 0000000..3edc184 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/p_example.sol @@ -0,0 +1,3 @@ +Create block at pos-2-0, +move to pos-2-1, +place block at pos-1-1. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p01.nl b/paper_reconstructions/llm+p/domains/termes/problems/p01.nl new file mode 100644 index 0000000..83f6258 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p01.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 3. +Your goal is to build blocks so that the height at pos-1-2 is 3. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p02.nl b/paper_reconstructions/llm+p/domains/termes/problems/p02.nl new file mode 100644 index 0000000..441911e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p02.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 3. +Your goal is to build blocks so that the height at pos-2-1 is 3, the height at pos-3-0 is 3. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p03.nl b/paper_reconstructions/llm+p/domains/termes/problems/p03.nl new file mode 100644 index 0000000..b509432 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p03.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The robot is at pos-2-0. +The depot for new blocks is at pos-2-0. +The maximum height of blocks is 4. +Your goal is to build blocks so that the height at pos-3-1 is 4. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/problems/p04.nl b/paper_reconstructions/llm+p/domains/termes/problems/p04.nl new file mode 100644 index 0000000..7d6f9be --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/problems/p04.nl @@ -0,0 +1,10 @@ +The robot is on a grid with 4 rows and 3 columns. +pos-0-0 pos-0-1 pos-0-2 +pos-1-0 pos-1-1 pos-1-2 +pos-2-0 pos-2-1 pos-2-2 +pos-3-0 pos-3-1 pos-3-2 +The depot for new blocks is at pos-1-0. +The robot is at pos-1-0. +The maximum height of blocks is 4. +Your goal is to build blocks so that the height at pos-2-0 is 3, the height at pos-3-2 is 4. +You cannot have an unplaced block at the end. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl new file mode 100644 index 0000000..cfea6da --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p01.pddl @@ -0,0 +1,91 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n3) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl new file mode 100644 index 0000000..c8a8b56 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p02.pddl @@ -0,0 +1,93 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-2-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-2-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n3) + (height pos-2-2 n0) + (height pos-3-0 n3) + (height pos-3-1 n0) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl new file mode 100644 index 0000000..ed16d07 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p03.pddl @@ -0,0 +1,95 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + n4 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-2-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (SUCC n4 n3) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-2-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-2-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-2-0) + ) + + (:goal + (and + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n4) + (height pos-3-2 n0) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl new file mode 100644 index 0000000..f6f30c6 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/pddl/p04.pddl @@ -0,0 +1,84 @@ +(define + (problem termes_problem) + (:domain termes) + + (:objects + n0 - numb + n1 - numb + n2 - numb + n3 - numb + n4 - numb + pos-0-0 - position + pos-0-1 - position + pos-0-2 - position + pos-1-0 - position + pos-1-1 - position + pos-1-2 - position + pos-2-0 - position + pos-2-1 - position + pos-2-2 - position + pos-3-0 - position + pos-3-1 - position + pos-3-2 - position + ) + + (:init + (height pos-0-0 n0) + (height pos-0-1 n0) + (height pos-0-2 n0) + (height pos-1-0 n0) + (height pos-1-1 n0) + (height pos-1-2 n0) + (height pos-2-0 n0) + (height pos-2-1 n0) + (height pos-2-2 n0) + (height pos-3-0 n0) + (height pos-3-1 n0) + (height pos-3-2 n0) + (at pos-1-0) + (SUCC n1 n0) + (SUCC n2 n1) + (SUCC n3 n2) + (SUCC n4 n3) + (NEIGHBor pos-0-0 pos-1-0) + (NEIGHBor pos-0-0 pos-0-1) + (NEIGHBor pos-0-1 pos-1-1) + (NEIGHBor pos-0-1 pos-0-0) + (NEIGHBor pos-0-1 pos-0-2) + (NEIGHBor pos-0-2 pos-1-2) + (NEIGHBor pos-0-2 pos-0-1) + (NEIGHBor pos-1-0 pos-0-0) + (NEIGHBor pos-1-0 pos-2-0) + (NEIGHBor pos-1-0 pos-1-1) + (NEIGHBor pos-1-1 pos-0-1) + (NEIGHBor pos-1-1 pos-2-1) + (NEIGHBor pos-1-1 pos-1-0) + (NEIGHBor pos-1-1 pos-1-2) + (NEIGHBor pos-1-2 pos-0-2) + (NEIGHBor pos-1-2 pos-2-2) + (NEIGHBor pos-1-2 pos-1-1) + (NEIGHBor pos-2-0 pos-1-0) + (NEIGHBor pos-2-0 pos-3-0) + (NEIGHBor pos-2-0 pos-2-1) + (NEIGHBor pos-2-1 pos-1-1) + (NEIGHBor pos-2-1 pos-2-0) + (NEIGHBor pos-2-1 pos-2-2) + (NEIGHBor pos-2-2 pos-1-2) + (NEIGHBor pos-2-2 pos-2-1) + (NEIGHBor pos-3-0 pos-2-0) + (NEIGHBor pos-3-0 pos-3-1) + (NEIGHBor pos-3-1 pos-3-0) + (NEIGHBor pos-3-1 pos-3-2) + (NEIGHBor pos-3-2 pos-3-1) + (IS-DEPOT pos-1-0) + ) + + (:goal + (and + (height pos-2-0 n3) + (height pos-3-2 n4) + (has-block ) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt new file mode 100644 index 0000000..9cd904f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt @@ -0,0 +1,52 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +place-block pos-1-0 pos-1-1 n0 n1 (1) +move pos-1-0 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +move-up pos-1-0 n0 pos-1-1 n1 (1) +move-down pos-1-1 n1 pos-1-2 n0 (1) +move pos-1-2 pos-2-2 n0 (1) +place-block pos-2-2 pos-2-1 n0 n1 (1) +move pos-2-2 pos-1-2 n0 (1) +remove-block pos-1-2 pos-1-1 n1 n0 (1) +move pos-1-2 pos-2-2 n0 (1) +place-block pos-2-2 pos-1-2 n0 n1 (1) +move-up pos-2-2 n0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +move pos-1-0 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move pos-2-0 pos-1-0 n0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-0-1 n0 n1 (1) +remove-block pos-1-1 pos-2-1 n1 n0 (1) +move pos-1-1 pos-2-1 n0 (1) +place-block pos-2-1 pos-2-2 n0 n1 (1) +move pos-2-1 pos-1-1 n0 (1) +remove-block pos-1-1 pos-0-1 n1 n0 (1) +move-up pos-1-1 n0 pos-1-2 n1 (1) +move pos-1-2 pos-2-2 n1 (1) +place-block pos-2-2 pos-1-2 n1 n2 (1) +move-down pos-2-2 n1 pos-2-1 n0 (1) +move pos-2-1 pos-2-0 n0 (1) +create-block pos-2-0 (1) +place-block pos-2-0 pos-2-1 n0 n1 (1) +create-block pos-2-0 (1) +move-up pos-2-0 n0 pos-2-1 n1 (1) +place-block pos-2-1 pos-2-2 n1 n2 (1) +move-down pos-2-1 n1 pos-2-0 n0 (1) +create-block pos-2-0 (1) +move-up pos-2-0 n0 pos-2-1 n1 (1) +move-up pos-2-1 n1 pos-2-2 n2 (1) +place-block pos-2-2 pos-1-2 n2 n3 (1) +move-down pos-2-2 n2 pos-2-1 n1 (1) +remove-block pos-2-1 pos-2-2 n2 n1 (1) +move-down pos-2-1 n1 pos-2-0 n0 (1) +destroy-block pos-2-0 (1) +remove-block pos-2-0 pos-2-1 n1 n0 (1) +destroy-block pos-2-0 (1) +move pos-2-0 pos-2-1 n0 (1) +remove-block pos-2-1 pos-2-2 n1 n0 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p02.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p03.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt new file mode 100644 index 0000000..77b058c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt @@ -0,0 +1,150 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +create-block pos-1-0 (1) +move pos-1-0 pos-2-0 n0 (1) +move pos-2-0 pos-3-0 n0 (1) +move pos-3-0 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-0 n0 n1 (1) +move-up pos-3-1 n0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-2-0 n0 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-2 n0 n1 (1) +remove-block pos-3-1 pos-3-0 n1 n0 (1) +move pos-3-1 pos-3-0 n0 (1) +place-block pos-3-0 pos-3-1 n0 n1 (1) +remove-block pos-3-0 pos-2-0 n1 n0 (1) +move-up pos-3-0 n0 pos-3-1 n1 (1) +place-block pos-3-1 pos-3-2 n1 n2 (1) +move-down pos-3-1 n1 pos-3-0 n0 (1) +remove-block pos-3-0 pos-3-1 n1 n0 (1) +move pos-3-0 pos-3-1 n0 (1) +place-block pos-3-1 pos-3-0 n0 n1 (1) +move-up pos-3-1 n0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-2-0 n0 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-down pos-3-0 n1 pos-3-1 n0 (1) +remove-block pos-3-1 pos-3-0 n1 n0 (1) +move pos-3-1 pos-3-0 n0 (1) +place-block pos-3-0 pos-3-1 n0 n1 (1) +remove-block pos-3-0 pos-2-0 n1 n0 (1) +move pos-3-0 pos-2-0 n0 (1) +place-block pos-2-0 pos-3-0 n0 n1 (1) +move pos-2-0 pos-1-0 n0 (1) +create-block pos-1-0 (1) +place-block pos-1-0 pos-2-0 n0 n1 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +place-block pos-3-0 pos-3-1 n1 n2 (1) +move pos-3-0 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +move-up pos-3-0 n1 pos-3-1 n2 (1) +place-block pos-3-1 pos-3-2 n2 n3 (1) +move-down pos-3-1 n2 pos-3-0 n1 (1) +move pos-3-0 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +place-block pos-2-0 pos-3-0 n1 n2 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +move pos-3-0 pos-3-1 n2 (1) +remove-block pos-3-1 pos-3-2 n3 n2 (1) +move pos-3-1 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move-down pos-2-0 n1 pos-1-0 n0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-2-1 n0 n1 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +place-block pos-3-0 pos-3-1 n2 n3 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-1-2 n0 n1 (1) +remove-block pos-1-1 pos-2-1 n1 n0 (1) +move pos-1-1 pos-2-1 n0 (1) +place-block pos-2-1 pos-1-1 n0 n1 (1) +move pos-2-1 pos-2-2 n0 (1) +remove-block pos-2-2 pos-1-2 n1 n0 (1) +move pos-2-2 pos-2-1 n0 (1) +place-block pos-2-1 pos-2-2 n0 n1 (1) +remove-block pos-2-1 pos-1-1 n1 n0 (1) +move pos-2-1 pos-1-1 n0 (1) +place-block pos-1-1 pos-2-1 n0 n1 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +place-block pos-1-1 pos-1-2 n0 n1 (1) +move-up pos-1-1 n0 pos-2-1 n1 (1) +move pos-2-1 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +remove-block pos-3-0 pos-3-1 n3 n2 (1) +move pos-3-0 pos-3-1 n2 (1) +place-block pos-3-1 pos-3-2 n2 n3 (1) +move pos-3-1 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +place-block pos-3-0 pos-3-1 n2 n3 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move-up pos-1-0 n0 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +move-up pos-3-0 n2 pos-3-1 n3 (1) +place-block pos-3-1 pos-3-2 n3 n4 (1) +move-down pos-3-1 n3 pos-3-0 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move pos-2-0 pos-2-1 n1 (1) +move-down pos-2-1 n1 pos-1-1 n0 (1) +move pos-1-1 pos-1-0 n0 (1) +create-block pos-1-0 (1) +move pos-1-0 pos-1-1 n0 (1) +move-up pos-1-1 n0 pos-2-1 n1 (1) +move pos-2-1 pos-2-2 n1 (1) +place-block pos-2-2 pos-2-1 n1 n2 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-3-0 n2 (1) +remove-block pos-3-0 pos-3-1 n3 n2 (1) +move-down pos-3-0 n2 pos-2-0 n1 (1) +move-up pos-2-0 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +place-block pos-2-2 pos-1-2 n1 n2 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-0 n1 (1) +remove-block pos-2-0 pos-3-0 n2 n1 (1) +move pos-2-0 pos-3-0 n1 (1) +place-block pos-3-0 pos-2-0 n1 n2 (1) +move-up pos-3-0 n1 pos-2-0 n2 (1) +move pos-2-0 pos-2-1 n2 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +remove-block pos-2-2 pos-1-2 n2 n1 (1) +move-up pos-2-2 n1 pos-2-1 n2 (1) +place-block pos-2-1 pos-2-0 n2 n3 (1) +move-down pos-2-1 n2 pos-2-2 n1 (1) +remove-block pos-2-2 pos-2-1 n2 n1 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/domain.nl b/paper_reconstructions/llm+p/domains/tyreworld/domain.nl new file mode 100644 index 0000000..f2f560a --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/domain.nl @@ -0,0 +1,29 @@ +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. + +There are 13 actions defined in this domain: + +"open" action: The precondition for this action is that the container is unlocked and closed. The effect of this action is that the container is open and not closed. + +"close" action: The precondition for this action is that the container is open. The effect of this action is that the container is closed and not open. + +"fetch" action: The precondition for this action is that the object is inside the container and the container is open. The effect of this action is that the object is held by the agent and not inside the container. + +"put-away" action: The precondition for this action is that the object is held by the agent and the container is open. The effect of this action is that the object is inside the container and not held by the agent. + +"loosen" action: The precondition for this action is that the agent has a wrench, the nut on hub is tight, and the hub is on the ground. The effect of this action is that the nut on hub is loose and not tight. + +"tighten" action: The precondition for this action is that the agent has a wrench, the nut on hub is loose, and the hub is on the ground. The effect of this action is that the nut on hub is tight and not loose. + +"jack-up" action: This action represents the process of lifting a hub off the ground using a jack. It requires the agent to have a jack and for the hub to be on the ground. After performing this action, the hub will no longer be on the ground and the agent will no longer have the jack. + +"jack-down" action: This action represents the process of lowering a hub back to the ground from an elevated position using a jack. It requires the agent to have the hub off the ground. After performing this action, the hub will be back on the ground and the agent will have the jack. + +"undo" action: This action undo the fastening of a nut on a hub. The preconditions are the hub is not on the ground (i.e., it has been jacked up), the hub is fastened, the agent has a wrench and the nut is loose. The effects are the agent has the nut, the hub is unfastened, the hub is no longer loose and the hub is not fastened anymore. + +"do-up" action: This action fasten a nut on a hub. The preconditions are the agent has a wrench, the hub is unfastened, the hub is not on the ground (i.e., it has been jacked up) and the agent has the nut to be fastened. The effects are the nut is now loose on the hub, the hub is fastened, the hub is no longer unfastened and the agent no longer has the nut. + +"remove-wheel" action: This action removes a wheel from a hub. It can only be performed if the hub is not on the ground, the wheel is currently on the hub, and the hub is unfastened. After the action is performed, the agent will have the removed wheel and the hub will be free, meaning that the wheel is no longer on the hub. + +"put-on-wheel" action: This action puts a wheel onto a hub. It can only be performed if the agent has the wheel, the hub is free, the hub is unfastened, and the hub is not on the ground. After the action is performed, the wheel will be on the hub, the hub will no longer be free, and the agent will no longer have the wheel. + +"inflate" action: This action inflates a wheel using a pump. It can only be performed if the agent has a pump, the wheel is not inflated, and the wheel is intact. After the action is performed, the wheel will be inflated. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl b/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl new file mode 100644 index 0000000..51d1d2c --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/domain.pddl @@ -0,0 +1,102 @@ +(define (domain tyreworld) + (:types obj - object + tool wheel nut - obj + container hub - object) +(:predicates (open ?x) + (closed ?x) + (have ?x) + (in ?x ?y) + (loose ?x ?y) + (tight ?x ?y) + (unlocked ?x) + (on-ground ?x) + (not-on-ground ?x) + (inflated ?x) + (not-inflated ?x) + (fastened ?x) + (unfastened ?x) + (free ?x) + (on ?x ?y) + (intact ?x)) + + +(:action open +:parameters (?x - container) +:precondition (and (unlocked ?x) + (closed ?x)) +:effect (and (open ?x) + (not (closed ?x)))) + +(:action close +:parameters (?x - container) +:precondition (open ?x) +:effect (and (closed ?x) + (not (open ?x)))) + +(:action fetch +:parameters (?x - obj ?y - container) +:precondition (and (in ?x ?y) (open ?y)) +:effect (and (have ?x) + (not (in ?x ?y)))) + +(:action put-away +:parameters (?x - obj ?y - container) +:precondition (and (have ?x) (open ?y)) +:effect (and (in ?x ?y) + (not (have ?x)))) + +(:action loosen +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (tight ?x ?y) (on-ground ?y)) +:effect (and (loose ?x ?y) + (not (tight ?x ?y)))) + +(:action tighten +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (loose ?x ?y) (on-ground ?y)) +:effect (and (tight ?x ?y) + (not (loose ?x ?y)))) + +(:action jack-up +:parameters (?y - hub) +:precondition (and (on-ground ?y) (have jack)) +:effect (and (not-on-ground ?y) + (not (on-ground ?y)) (not (have jack)))) + +(:action jack-down +:parameters (?y - hub) +:precondition (not-on-ground ?y) +:effect (and (on-ground ?y) (have jack) + (not (not-on-ground ?y)))) + +(:action undo +:parameters (?x - nut ?y - hub) +:precondition (and (not-on-ground ?y) (fastened ?y) (have wrench) (loose ?x ?y)) +:effect (and (have ?x) (unfastened ?y) + (not (fastened ?y)) (not (loose ?x ?y)))) + +(:action do-up +:parameters (?x - nut ?y - hub) +:precondition (and (have wrench) (unfastened ?y) (not-on-ground ?y) (have ?x)) +:effect (and (loose ?x ?y) (fastened ?y) + (not (unfastened ?y)) (not (have ?x)))) + +(:action remove-wheel +:parameters (?x - wheel ?y - hub) +:precondition (and (not-on-ground ?y) (on ?x ?y) (unfastened ?y)) +:effect (and (have ?x) (free ?y) + (not (on ?x ?y)))) + +(:action put-on-wheel +:parameters (?x - wheel ?y - hub) +:precondition (and (have ?x) (free ?y) (unfastened ?y) (not-on-ground ?y)) +:effect (and (on ?x ?y) + (not (free ?y)) (not (have ?x)))) + +(:action inflate +:parameters (?x - wheel) +:precondition (and (have pump) (not-inflated ?x) (intact ?x)) +:effect (and (inflated ?x) + (not (not-inflated ?x))))) + + diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl b/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl new file mode 100644 index 0000000..50b63f4 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 2 hubs, 2 nuts, 2 flat tyres, and 2 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl b/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl new file mode 100644 index 0000000..c4262d8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.pddl @@ -0,0 +1,55 @@ + + + +(define (problem tireworld-2) +(:domain tyreworld) +(:objects +wrench jack pump - tool +the-hub1 the-hub2 +- hub +nuts1 nuts2 +- nut + +boot - container +r1 w1 r2 w2 +- wheel +) +(:init +(in jack boot) +(in pump boot) +(in wrench boot) +(unlocked boot) +(closed boot) +(intact r1) +(in r1 boot) +(not-inflated r1) +(intact r2) +(in r2 boot) +(not-inflated r2) +(on w1 the-hub1) +(on-ground the-hub1) +(tight nuts1 the-hub1) +(fastened the-hub1) +(on w2 the-hub2) +(on-ground the-hub2) +(tight nuts2 the-hub2) +(fastened the-hub2) +) +(:goal +(and +(on r1 the-hub1) +(inflated r1) +(tight nuts1 the-hub1) +(in w1 boot) +(on r2 the-hub2) +(inflated r2) +(tight nuts2 the-hub2) +(in w2 boot) +(in wrench boot) +(in jack boot) +(in pump boot) +(closed boot) +) +) +) + diff --git a/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol b/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol new file mode 100644 index 0000000..3e91359 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/p_example.sol @@ -0,0 +1,26 @@ +Open boot, +fetch r2, r1, pump, +inflate r2, r1, +put away pump, +fetch wrench, jack, +loosen nuts1, +jack-up the-hub1, +undo nuts1, +remove wheel w1, +put away w1, +put on wheel r1, +do-up nuts1, +jack-down the-hub1, +tighten nuts1, +loosen nuts2, +jack-up the-hub2, +undo nuts2, +remove wheel w2, +put away w2, +put on wheel r2, +do-up nuts2, +jack-down the-hub2, +put away jack, +tighten nuts2, +put away wrench, +close boot. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl new file mode 100644 index 0000000..66ce07f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p01.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 1 hubs, 1 nuts, 1 flat tyres, and 1 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl new file mode 100644 index 0000000..48ba897 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p02.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 9 hubs, 9 nuts, 9 flat tyres, and 9 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl new file mode 100644 index 0000000..3d2e69e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p03.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 3 hubs, 3 nuts, 3 flat tyres, and 3 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl b/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl new file mode 100644 index 0000000..2c51c1e --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/problems/p04.nl @@ -0,0 +1,9 @@ +You have a jack, a pump, a wrench, a boot, 4 hubs, 4 nuts, 4 flat tyres, and 4 intact tyres. +The jack, pump, wrench, and intact tyres are in the boot. +The boot is unlocked but is closed. +The intact tyres are not inflated. +The flat tyres are on the hubs. +The hubs are on the ground. +The nuts are tight on the hubs. +The hubs are fastened. +Your goal is to replace flat tyres with intact tyres on the hubs. Intact tyres should be inflated. The nuts should be tight on the hubs. The flat tyres, wrench, jack, and pump should be in the boot. The boot should be closed. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl new file mode 100644 index 0000000..ed4a1a9 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p01.pddl @@ -0,0 +1,44 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub - hub + nut - nut + boot - container + r1 - wheel + w1 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (on w1 the-hub) + (on-ground the-hub) + (tight nut the-hub) + (fastened the-hub) + ) + + (:goal + (and + (on r1 the-hub) + (inflated r1) + (tight nut the-hub) + (in w1 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl new file mode 100644 index 0000000..b1aacc8 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p02.pddl @@ -0,0 +1,164 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + the-hub4 - hub + the-hub5 - hub + the-hub6 - hub + the-hub7 - hub + the-hub8 - hub + the-hub9 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + nuts4 - nut + nuts5 - nut + nuts6 - nut + nuts7 - nut + nuts8 - nut + nuts9 - nut + boot - container + r1 - wheel + w1 - wheel + r2 - wheel + w2 - wheel + r3 - wheel + w3 - wheel + r4 - wheel + w4 - wheel + r5 - wheel + w5 - wheel + r6 - wheel + w6 - wheel + r7 - wheel + w7 - wheel + r8 - wheel + w8 - wheel + r9 - wheel + w9 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (intact r4) + (in r4 boot) + (not-inflated r4) + (intact r5) + (in r5 boot) + (not-inflated r5) + (intact r6) + (in r6 boot) + (not-inflated r6) + (intact r7) + (in r7 boot) + (not-inflated r7) + (intact r8) + (in r8 boot) + (not-inflated r8) + (intact r9) + (in r9 boot) + (not-inflated r9) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + (on w4 the-hub4) + (on-ground the-hub4) + (tight nuts4 the-hub4) + (fastened the-hub4) + (on w5 the-hub5) + (on-ground the-hub5) + (tight nuts5 the-hub5) + (fastened the-hub5) + (on w6 the-hub6) + (on-ground the-hub6) + (tight nuts6 the-hub6) + (fastened the-hub6) + (on w7 the-hub7) + (on-ground the-hub7) + (tight nuts7 the-hub7) + (fastened the-hub7) + (on w8 the-hub8) + (on-ground the-hub8) + (tight nuts8 the-hub8) + (fastened the-hub8) + (on w9 the-hub9) + (on-ground the-hub9) + (tight nuts9 the-hub9) + (fastened the-hub9) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (on r4 the-hub4) + (inflated r4) + (tight nuts4 the-hub4) + (in w4 boot) + (on r5 the-hub5) + (inflated r5) + (tight nuts5 the-hub5) + (in w5 boot) + (on r6 the-hub6) + (inflated r6) + (tight nuts6 the-hub6) + (in w6 boot) + (on r7 the-hub7) + (inflated r7) + (tight nuts7 the-hub7) + (in w7 boot) + (on r8 the-hub8) + (inflated r8) + (tight nuts8 the-hub8) + (in w8 boot) + (on r9 the-hub9) + (inflated r9) + (tight nuts9 the-hub9) + (in w9 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl new file mode 100644 index 0000000..56f370f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p03.pddl @@ -0,0 +1,73 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + r1 - wheel + r2 - wheel + r3 - wheel + w1 - wheel + w2 - wheel + w3 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl new file mode 100644 index 0000000..5292c6d --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/pddl/p04.pddl @@ -0,0 +1,89 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + wrench - tool + jack - tool + pump - tool + boot - container + the-hub1 - hub + the-hub2 - hub + the-hub3 - hub + the-hub4 - hub + nuts1 - nut + nuts2 - nut + nuts3 - nut + nuts4 - nut + r1 - wheel + r2 - wheel + r3 - wheel + r4 - wheel + w1 - wheel + w2 - wheel + w3 - wheel + w4 - wheel + ) + + (:init + (in jack boot) + (in pump boot) + (in wrench boot) + (unlocked boot) + (closed boot) + (intact r1) + (in r1 boot) + (not-inflated r1) + (intact r2) + (in r2 boot) + (not-inflated r2) + (intact r3) + (in r3 boot) + (not-inflated r3) + (intact r4) + (in r4 boot) + (not-inflated r4) + (on w1 the-hub1) + (on-ground the-hub1) + (tight nuts1 the-hub1) + (fastened the-hub1) + (on w2 the-hub2) + (on-ground the-hub2) + (tight nuts2 the-hub2) + (fastened the-hub2) + (on w3 the-hub3) + (on-ground the-hub3) + (tight nuts3 the-hub3) + (fastened the-hub3) + (on w4 the-hub4) + (on-ground the-hub4) + (tight nuts4 the-hub4) + (fastened the-hub4) + ) + + (:goal + (and + (on r1 the-hub1) + (inflated r1) + (tight nuts1 the-hub1) + (in w1 boot) + (on r2 the-hub2) + (inflated r2) + (tight nuts2 the-hub2) + (in w2 boot) + (on r3 the-hub3) + (inflated r3) + (tight nuts3 the-hub3) + (in w3 boot) + (on r4 the-hub4) + (inflated r4) + (tight nuts4 the-hub4) + (in w4 boot) + (in wrench boot) + (in jack boot) + (in pump boot) + (closed boot) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt new file mode 100644 index 0000000..bcf43c2 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt @@ -0,0 +1,27 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +open boot (1) +fetch wrench boot (1) +fetch pump boot (1) +fetch r1 boot (1) +loosen nut the-hub (1) +inflate r1 (1) +put-away pump boot (1) +fetch jack boot (1) +jack-up the-hub (1) +undo nut the-hub (1) +put-away wrench boot (1) +remove-wheel w1 the-hub (1) +put-away w1 boot (1) +close boot (1) +put-on-wheel r1 the-hub (1) +open boot (1) +fetch wrench boot (1) +do-up nut the-hub (1) +jack-down the-hub (1) +put-away jack boot (1) +close boot (1) +tighten nut the-hub (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt new file mode 100644 index 0000000..faf9b5f --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt @@ -0,0 +1,115 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +open boot (1) +fetch r9 boot (1) +fetch r8 boot (1) +fetch r7 boot (1) +fetch r6 boot (1) +fetch r5 boot (1) +fetch r4 boot (1) +fetch r3 boot (1) +fetch r2 boot (1) +fetch r1 boot (1) +fetch pump boot (1) +inflate r9 (1) +inflate r8 (1) +inflate r7 (1) +inflate r6 (1) +inflate r5 (1) +inflate r4 (1) +inflate r3 (1) +inflate r2 (1) +inflate r1 (1) +fetch wrench boot (1) +put-away pump boot (1) +loosen nuts1 the-hub1 (1) +loosen nuts2 the-hub2 (1) +loosen nuts3 the-hub3 (1) +loosen nuts4 the-hub4 (1) +loosen nuts5 the-hub5 (1) +loosen nuts6 the-hub6 (1) +loosen nuts7 the-hub7 (1) +loosen nuts8 the-hub8 (1) +loosen nuts9 the-hub9 (1) +fetch jack boot (1) +jack-up the-hub1 (1) +undo nuts1 the-hub1 (1) +remove-wheel w1 the-hub1 (1) +put-away w1 boot (1) +put-on-wheel r1 the-hub1 (1) +do-up nuts1 the-hub1 (1) +jack-down the-hub1 (1) +tighten nuts1 the-hub1 (1) +jack-up the-hub2 (1) +undo nuts2 the-hub2 (1) +remove-wheel w2 the-hub2 (1) +put-away w2 boot (1) +put-on-wheel r2 the-hub2 (1) +do-up nuts2 the-hub2 (1) +jack-down the-hub2 (1) +tighten nuts2 the-hub2 (1) +jack-up the-hub3 (1) +undo nuts3 the-hub3 (1) +remove-wheel w3 the-hub3 (1) +put-away w3 boot (1) +put-on-wheel r3 the-hub3 (1) +do-up nuts3 the-hub3 (1) +jack-down the-hub3 (1) +tighten nuts3 the-hub3 (1) +jack-up the-hub4 (1) +undo nuts4 the-hub4 (1) +remove-wheel w4 the-hub4 (1) +put-away w4 boot (1) +put-on-wheel r4 the-hub4 (1) +do-up nuts4 the-hub4 (1) +jack-down the-hub4 (1) +tighten nuts4 the-hub4 (1) +jack-up the-hub5 (1) +undo nuts5 the-hub5 (1) +remove-wheel w5 the-hub5 (1) +put-away w5 boot (1) +put-on-wheel r5 the-hub5 (1) +do-up nuts5 the-hub5 (1) +jack-down the-hub5 (1) +tighten nuts5 the-hub5 (1) +jack-up the-hub6 (1) +undo nuts6 the-hub6 (1) +remove-wheel w6 the-hub6 (1) +put-away w6 boot (1) +put-on-wheel r6 the-hub6 (1) +do-up nuts6 the-hub6 (1) +jack-down the-hub6 (1) +tighten nuts6 the-hub6 (1) +jack-up the-hub7 (1) +undo nuts7 the-hub7 (1) +remove-wheel w7 the-hub7 (1) +put-away w7 boot (1) +put-on-wheel r7 the-hub7 (1) +do-up nuts7 the-hub7 (1) +jack-down the-hub7 (1) +tighten nuts7 the-hub7 (1) +jack-up the-hub8 (1) +undo nuts8 the-hub8 (1) +remove-wheel w8 the-hub8 (1) +put-away w8 boot (1) +put-on-wheel r8 the-hub8 (1) +do-up nuts8 the-hub8 (1) +jack-down the-hub8 (1) +tighten nuts8 the-hub8 (1) +jack-up the-hub9 (1) +undo nuts9 the-hub9 (1) +put-away wrench boot (1) +remove-wheel w9 the-hub9 (1) +put-away w9 boot (1) +close boot (1) +put-on-wheel r9 the-hub9 (1) +open boot (1) +fetch wrench boot (1) +do-up nuts9 the-hub9 (1) +jack-down the-hub9 (1) +put-away jack boot (1) +close boot (1) +tighten nuts9 the-hub9 (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p03.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt new file mode 100644 index 0000000..0f5b238 --- /dev/null +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt @@ -0,0 +1,60 @@ +INFO Running search (release) +INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) +open boot (1) +fetch r4 boot (1) +fetch r3 boot (1) +fetch r2 boot (1) +fetch r1 boot (1) +fetch pump boot (1) +inflate r4 (1) +inflate r3 (1) +inflate r2 (1) +inflate r1 (1) +put-away pump boot (1) +fetch wrench boot (1) +loosen nuts1 the-hub1 (1) +loosen nuts2 the-hub2 (1) +loosen nuts3 the-hub3 (1) +loosen nuts4 the-hub4 (1) +fetch jack boot (1) +jack-up the-hub1 (1) +undo nuts1 the-hub1 (1) +remove-wheel w1 the-hub1 (1) +put-away w1 boot (1) +put-on-wheel r1 the-hub1 (1) +do-up nuts1 the-hub1 (1) +jack-down the-hub1 (1) +tighten nuts1 the-hub1 (1) +jack-up the-hub2 (1) +undo nuts2 the-hub2 (1) +remove-wheel w2 the-hub2 (1) +put-away w2 boot (1) +put-on-wheel r2 the-hub2 (1) +do-up nuts2 the-hub2 (1) +jack-down the-hub2 (1) +tighten nuts2 the-hub2 (1) +jack-up the-hub3 (1) +undo nuts3 the-hub3 (1) +remove-wheel w3 the-hub3 (1) +put-away w3 boot (1) +put-on-wheel r3 the-hub3 (1) +do-up nuts3 the-hub3 (1) +jack-down the-hub3 (1) +tighten nuts3 the-hub3 (1) +jack-up the-hub4 (1) +undo nuts4 the-hub4 (1) +put-away wrench boot (1) +remove-wheel w4 the-hub4 (1) +put-away w4 boot (1) +close boot (1) +put-on-wheel r4 the-hub4 (1) +open boot (1) +fetch wrench boot (1) +do-up nuts4 the-hub4 (1) +jack-down the-hub4 (1) +put-away jack boot (1) +close boot (1) +tighten nuts4 the-hub4 (1) +open boot (1) +put-away wrench boot (1) +close boot (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/main.py b/paper_reconstructions/llm+p/main.py index cd7797a..7624497 100644 --- a/paper_reconstructions/llm+p/main.py +++ b/paper_reconstructions/llm+p/main.py @@ -7,37 +7,74 @@ 1. NL task description 2. Ground-truth PDDL domain -This library only focuses on model generation, so it is not concerned with the other phase of LLM+P: LLM translating PDDL plans to NL +This library only focuses on model generation, so it is not concerned with the other phase of LLM+P: LLM translating PDDL plans to NL. +This module contains all domains from LLM+P code (except Manipulation domain as L2P currently does not support cost actions). +Experimentation recreation was only done on first four problems of each domain. Example results found in `./domains/blocksworld/results` """ -import os +import os, argparse +from .domain import Domain from l2p import * -if __name__ == "__main__": - - # setup L2P requirements - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - openai_llm = OPENAI(model=engine, api_key=api_key) - planner = FastDownward(planner_path="downward/fast-downward.py") +DOMAINS = [ + "barman", + "blocksworld", + "floortile", + "grippers", + "storage", + "termes", + "tyreworld", + "manipulation" +] - # prompts taken from LLM+P - role = load_file("paper_reconstructions/llm+p/prompts/role.txt") - example = load_file("paper_reconstructions/llm+p/prompts/example.txt") - task = load_file("paper_reconstructions/llm+p/prompts/task.txt") +def create_llm_ic_pddl_prompt(task_nl, domain_pddl, context): + # (LM+P), create the problem PDDL given the context + + context_nl, context_pddl, context_sol = context - problem_desc = load_file("paper_reconstructions/llm+p/prompts/problem_desc.txt") + prompt = f"I want you to solve planning problems. " + \ + f"An example planning problem is: \n{context_nl} \n" + \ + f"The problem PDDL file to this problem is: \n{context_pddl} \n" + \ + f"Now I have a new planning problem and its description is: \n{task_nl} \n" + \ + f"Provide me with the problem PDDL file that describes " + \ + f"the new planning problem directly without further explanations. Do not return anything else." + + # add in L2P default format prompt + prompt += "\n\n" + load_file("templates/task_templates/extract_task.txt") + return prompt + - # assemble prompt builder - prompt_builder = PromptBuilder(role=role, examples=[example], task=task) - - task_builder = TaskBuilder() - - # extract PDDL from prompt +def llm_ic_pddl_planner(args, problem_name): + + # create necessary classes + task_builder = TaskBuilder() # L2P task builder + domain = Domain(name=args.domain) + planner = FastDownward(planner_path=args.planner) # FastDownward planner + + # initialize OpenAI engine + api_key = os.environ.get("OPENAI_API_KEY") + model = OPENAI(model=args.model, api_key=api_key) + + # extract assumptions + context = domain.get_context() + domain_pddl = domain.get_domain_pddl() + domain_pddl_file = domain.get_domain_pddl_file() + + # create the tmp / result folders + result_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/pddl" + plan_results_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/plan" + + task = args.task # extract task arguments + + # A. generate problem pddl file + task_nl = domain.get_task(task) + prompt = create_llm_ic_pddl_prompt(task_nl, domain_pddl, context) + + # query LLM using L2P objects, initial, goal, llm_response = task_builder.extract_task( - model=openai_llm, - problem_desc=problem_desc, - prompt_template=prompt_builder.generate_prompt(), + model=model, + problem_desc="", + prompt_template=prompt, ) # construct PDDL components into PDDL problem file @@ -45,21 +82,42 @@ initial_state_str = task_builder.format_initial(initial) goal_state_str = task_builder.format_goal(goal) + # generate proper PDDL structure pddl_problem = task_builder.generate_task( - "blocksworld-4ops", - "blocksworld-4ops_problem", + domain.name, + problem_name, object_str, initial_state_str, goal_state_str, ) + + # write generated pddl into folder + pddl_file_path = os.path.join(result_folder, domain.get_task_name(task)) + os.makedirs(result_folder, exist_ok=True) + with open(pddl_file_path, 'w') as file: + file.write(pddl_problem) + + # B. run planner + plan_name = domain.get_task_name(task).replace("pddl", "txt") + _, output = planner.run_fast_downward(domain_file=domain_pddl_file, problem_file=pddl_file_path) + + # write generated plan into folder + plan_file_path = os.path.join(plan_results_folder, plan_name) + os.makedirs(plan_results_folder, exist_ok=True) + with open(plan_file_path, 'w') as file: + file.write(output) + + - # write down PDDL problem file - problem_file = "paper_reconstructions/llm+p/results/problem.pddl" - domain_file = "paper_reconstructions/llm+p/results/domain.pddl" - with open(problem_file, "w") as f: - f.write(pddl_problem) - - print("PDDL problem:\n", pddl_problem) - - # run planner - planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) +if __name__ == "__main__": + + # load in arguments to run program + parser = argparse.ArgumentParser(description="LLM+P") + parser.add_argument('--model', type=str, default="gpt-4o-mini") + parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument('--task', type=int, default=0) # task to run + parser.add_argument('--planner', type=str, default="downward/fast-downward.py") + args = parser.parse_args() + + # run LLM+P method + llm_ic_pddl_planner(args=args, problem_name="blocksworld_problem") diff --git a/paper_reconstructions/llm+p/prompts/example.txt b/paper_reconstructions/llm+p/prompts/example.txt deleted file mode 100644 index 19ff829..0000000 --- a/paper_reconstructions/llm+p/prompts/example.txt +++ /dev/null @@ -1,48 +0,0 @@ -An example planning problem is: -""" -You have 5 blocks. -b2 is on top of b5. -b5 is on top of b1. -b1 is on top of b4. -b3 is on top of b2. -b4 is on the table. -b3 is clear. -Your arm is empty. -Your goal is to move the blocks. -b4 should be on top of b3. -""" - -The problem PDDL file to this problem is: -""" -(define (problem BW-rand-5) -(:domain blocksworld-4ops) -(:objects b1 b2 b3 b4 b5 ) -(:init -(arm-empty) -(on b1 b4) -(on b2 b5) -(on b3 b2) -(on-table b4) -(on b5 b1) -(clear b3) -) -(:goal -(and -(on b4 b3)) -) -) -""" - -The solution to this problem is: -""" -unstack b3 from b2, -putdown b3, -unstack b2 from b5, -putdown b2, -unstack b5 from b1, -putdown b5, -unstack b1 from b4, -putdown b1, -pickup b4, -stack b4 on b3 -""" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/role.txt b/paper_reconstructions/llm+p/prompts/role.txt deleted file mode 100644 index 6eceb87..0000000 --- a/paper_reconstructions/llm+p/prompts/role.txt +++ /dev/null @@ -1,28 +0,0 @@ -Your role is to solve planning problems. - -Do not attempt to declare any types. - -The problem you are to extract from is under the header '## Problem description' - -Do not, under any circumstance, output the answers in PDDL format. Final answer must be in the following format at the end: - -""" -## Problem description - -### OBJECTS -``` -truck1 - truck -``` - -### INITIAL -``` -(at truck1 chicago_depot): truck1 is at the chicago_depot -``` - -### GOAL -``` -(AND ; all the following should be done - (finalised house1) ; house 1 is done -) -``` -""" \ No newline at end of file diff --git a/paper_reconstructions/llm+p/prompts/task.txt b/paper_reconstructions/llm+p/prompts/task.txt deleted file mode 100644 index 36354b6..0000000 --- a/paper_reconstructions/llm+p/prompts/task.txt +++ /dev/null @@ -1,3 +0,0 @@ -Now I have a new planning problem and its description is: - -{problem_desc} \ No newline at end of file diff --git a/paper_reconstructions/llm+p/results/domain.pddl b/paper_reconstructions/llm+p/results/domain.pddl deleted file mode 100644 index 95cf297..0000000 --- a/paper_reconstructions/llm+p/results/domain.pddl +++ /dev/null @@ -1,25 +0,0 @@ -(define (domain blocksworld-4ops) - (:requirements :conditional-effects :disjunctive-preconditions :negative-preconditions :strips :typing :universal-preconditions) - (:types block - object) - (:predicates (arm-empty) (clear ?x - block) (holding ?x - block) (on ?x - block ?y - block) (on-table ?x - block)) - (:action pickup - :parameters (?ob - block) - :precondition (and (clear ?ob) (on-table ?ob) (arm-empty)) - :effect (and (holding ?ob) (not (clear ?ob)) (not (on-table ?ob)) (not (arm-empty))) - ) - (:action putdown - :parameters (?ob - block) - :precondition (holding ?ob) - :effect (and (clear ?ob) (arm-empty) (on-table ?ob) (not (holding ?ob))) - ) - (:action stack - :parameters (?ob - block ?underob - block) - :precondition (and (clear ?underob) (holding ?ob)) - :effect (and (arm-empty) (clear ?ob) (on ?ob ?underob) (not (clear ?underob)) (not (holding ?ob))) - ) - (:action unstack - :parameters (?ob - block ?underob - block) - :precondition (and (on ?ob ?underob) (clear ?ob) (arm-empty)) - :effect (and (holding ?ob) (clear ?underob) (not (on ?ob ?underob)) (not (clear ?ob)) (not (arm-empty))) - ) -) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt b/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/household/desc.txt b/paper_reconstructions/nl2plan/domains/household/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/household/task1.txt b/paper_reconstructions/nl2plan/domains/household/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/household/task2.txt b/paper_reconstructions/nl2plan/domains/household/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/household/task3.txt b/paper_reconstructions/nl2plan/domains/household/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr/desc.txt b/paper_reconstructions/nl2plan/domains/isr/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr/task1.txt b/paper_reconstructions/nl2plan/domains/isr/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr/task2.txt b/paper_reconstructions/nl2plan/domains/isr/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/isr/task3.txt b/paper_reconstructions/nl2plan/domains/isr/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/logistics/desc.txt b/paper_reconstructions/nl2plan/domains/logistics/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/logistics/task1.txt b/paper_reconstructions/nl2plan/domains/logistics/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/logistics/task2.txt b/paper_reconstructions/nl2plan/domains/logistics/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/logistics/task3.txt b/paper_reconstructions/nl2plan/domains/logistics/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt b/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/there-and-back/main.py b/paper_reconstructions/there-and-back/main.py deleted file mode 100644 index a6cc992..0000000 --- a/paper_reconstructions/there-and-back/main.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -Paper: "There and Back Again:Extracting Formal Domains for Controllable Neurosymbolic Story Authoring" Kelly et al. (2023) -Source code: https://github.com/alex-calderwood/there-and-back -Run: python3 -m paper_reconstructions.there-and-back.main -""" - -# TODO: implementation \ No newline at end of file diff --git a/templates/task_templates/extract_task.txt b/templates/task_templates/extract_task.txt index a3ff29a..c486b68 100644 --- a/templates/task_templates/extract_task.txt +++ b/templates/task_templates/extract_task.txt @@ -1,4 +1,4 @@ -End your final answer starting with headers (in order) "### OBJECTS" "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: +End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: ### OBJECTS ``` @@ -21,4 +21,4 @@ object3 - type_1 ) ``` -Even if there is one goal state, it must contain the PDDL 'and' syntax \ No newline at end of file +Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. \ No newline at end of file From 58319f9195dab047ac59b2d1701709eb22c8f6c6 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 1 Jan 2025 23:48:10 -0500 Subject: [PATCH 05/15] cleaned up personal directory leakage in planner --- .../llm+p/domains/barman/results/plan/p01.txt | 2 -- .../llm+p/domains/barman/results/plan/p02.txt | 2 -- .../llm+p/domains/barman/results/plan/p03.txt | 2 -- .../llm+p/domains/barman/results/plan/p04.txt | 2 -- .../llm+p/domains/blocksworld/results/plan/p01.txt | 3 +-- .../llm+p/domains/blocksworld/results/plan/p02.txt | 2 -- .../llm+p/domains/blocksworld/results/plan/p03.txt | 2 -- .../llm+p/domains/blocksworld/results/plan/p04.txt | 2 -- .../llm+p/domains/floortile/results/plan/p01.txt | 2 -- .../llm+p/domains/floortile/results/plan/p02.txt | 2 -- .../llm+p/domains/floortile/results/plan/p03.txt | 2 -- .../llm+p/domains/floortile/results/plan/p04.txt | 2 -- .../llm+p/domains/grippers/results/plan/p01.txt | 3 +-- .../llm+p/domains/grippers/results/plan/p02.txt | 2 -- .../llm+p/domains/grippers/results/plan/p03.txt | 2 -- .../llm+p/domains/grippers/results/plan/p04.txt | 2 -- .../llm+p/domains/storage/results/plan/p01.txt | 2 -- .../llm+p/domains/storage/results/plan/p02.txt | 2 -- .../llm+p/domains/storage/results/plan/p03.txt | 2 -- .../llm+p/domains/storage/results/plan/p04.txt | 2 -- .../llm+p/domains/termes/results/plan/p01.txt | 2 -- .../llm+p/domains/termes/results/plan/p04.txt | 2 -- .../llm+p/domains/tyreworld/results/plan/p01.txt | 2 -- .../llm+p/domains/tyreworld/results/plan/p02.txt | 2 -- .../llm+p/domains/tyreworld/results/plan/p04.txt | 2 -- 25 files changed, 2 insertions(+), 50 deletions(-) diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt index d3d7aea..3332513 100644 --- a/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p01.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) grasp left shaker1 (1) grasp right shot4 (1) leave left shaker1 (1) diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt index 5e37878..9972c1e 100644 --- a/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) grasp left shaker1 (1) grasp right shot4 (1) leave left shaker1 (1) diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt index 66eb897..473618b 100644 --- a/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p03.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) grasp left shaker1 (1) grasp right shot4 (1) leave left shaker1 (1) diff --git a/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt index 32519c0..4076b18 100644 --- a/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/barman/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) grasp left shaker1 (1) grasp right shot4 (1) leave left shaker1 (1) diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt index c8e6d32..bcc1701 100644 --- a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p01.txt @@ -1,2 +1 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) \ No newline at end of file +Success. Goal state already met. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt index 225e635..cdce7cd 100644 --- a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) unstack b1 b3 (1) putdown b1 (1) unstack b3 b2 (1) diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt index ad7fffb..f6915d6 100644 --- a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p03.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) unstack b1 b3 (1) putdown b1 (1) unstack b3 b2 (1) diff --git a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt index 2afe549..9beb791 100644 --- a/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/blocksworld/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) unstack b3 b1 (1) putdown b3 (1) unstack b1 b4 (1) diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt index 190544f..acf01fe 100644 --- a/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p01.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) down robot1 tile_4-1 tile_3-1 (1) paint-up robot1 tile_4-1 tile_3-1 black (1) down robot1 tile_3-1 tile_2-1 (1) diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt index 4c7cee2..73c96bd 100644 --- a/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) paint-up robot1 tile_4-2 tile_3-2 white (1) right robot1 tile_3-2 tile_3-3 (1) paint-up robot1 tile_4-3 tile_3-3 black (1) diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt index fd79632..a328d46 100644 --- a/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p03.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) up robot1 tile_2-3 tile_3-3 (1) paint-up robot1 tile_4-3 tile_3-3 black (1) up robot2 tile_1-1 tile_2-1 (1) diff --git a/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt index e3bbe92..a6c8cfb 100644 --- a/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/floortile/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) left robot1 tile_0-3 tile_0-2 (1) up robot1 tile_0-2 tile_1-2 (1) left robot1 tile_1-2 tile_1-1 (1) diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt index c8e6d32..bcc1701 100644 --- a/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p01.txt @@ -1,2 +1 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) \ No newline at end of file +Success. Goal state already met. \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt index 9296f1c..a480b32 100644 --- a/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) move robot2 room3 room1 (1) pick robot2 ball2 room1 lgripper2 (1) move robot2 room1 room2 (1) diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt index b82fec1..2511d65 100644 --- a/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p03.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) pick robot1 ball1 room1 lgripper1 (1) pick robot1 ball2 room1 rgripper1 (1) move robot1 room1 room4 (1) diff --git a/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt index 8aac8c1..a11eeb7 100644 --- a/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/grippers/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) pick robot3 ball3 room1 lgripper3 (1) move robot3 room1 room3 (1) drop robot3 ball3 room3 lgripper3 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt index c167d67..f294261 100644 --- a/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p01.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) go-out hoist0 depot48-1-1 loadarea (1) lift hoist0 crate0 container-0-0 loadarea container0 (1) drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt index c167d67..f294261 100644 --- a/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) go-out hoist0 depot48-1-1 loadarea (1) lift hoist0 crate0 container-0-0 loadarea container0 (1) drop hoist0 crate0 depot48-1-1 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt index d31f3b5..a10e9bd 100644 --- a/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p03.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) go-out hoist0 depot48-1-2 loadarea (1) lift hoist0 crate0 container-0-0 loadarea container0 (1) drop hoist0 crate0 depot48-1-2 loadarea depot48 (1) \ No newline at end of file diff --git a/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt index 3da78ad..dae98b4 100644 --- a/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/storage/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) move hoist0 depot48-1-1 depot48-2-1 (1) go-out hoist0 depot48-2-1 loadarea (1) lift hoist0 crate0 container-0-0 loadarea container0 (1) diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt index 9cd904f..f13deda 100644 --- a/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p01.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) create-block pos-2-0 (1) move pos-2-0 pos-1-0 n0 (1) place-block pos-1-0 pos-1-1 n0 n1 (1) diff --git a/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt index 77b058c..d0784a2 100644 --- a/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/termes/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) create-block pos-1-0 (1) move pos-1-0 pos-2-0 n0 (1) move pos-2-0 pos-3-0 n0 (1) diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt index bcf43c2..e55e176 100644 --- a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p01.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) open boot (1) fetch wrench boot (1) fetch pump boot (1) diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt index faf9b5f..a8964d7 100644 --- a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p02.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) open boot (1) fetch r9 boot (1) fetch r8 boot (1) diff --git a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt index 0f5b238..94f8f00 100644 --- a/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt +++ b/paper_reconstructions/llm+p/domains/tyreworld/results/plan/p04.txt @@ -1,5 +1,3 @@ -INFO Running search (release) -INFO search command line string: /Users/marcustantakoun/Downloads/downward/builds/release/bin/downward --search 'let(hlm,landmark_sum(lm_factory=lm_reasonable_orders_hps(lm_rhw()),transform=adapt_costs(one),pref=false),let(hff,ff(transform=adapt_costs(one)),lazy_greedy([hff,hlm],preferred=[hff,hlm],cost_type=one,reopen_closed=false))) open boot (1) fetch r4 boot (1) fetch r3 boot (1) From 8c1d6d8cec9f71e48a6cf2afafd9c98a691cf50b Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Fri, 3 Jan 2025 11:56:56 -0500 Subject: [PATCH 06/15] completely rebuilt NL2Plan --- l2p/domain_builder.py | 67 ++- l2p/feedback_builder.py | 149 ++++- l2p/task_builder.py | 12 +- l2p/utils/pddl_parser.py | 13 +- l2p/utils/pddl_validator.py | 20 + .../nl2plan/domains/blocksworld/desc.txt | 1 + .../nl2plan/domains/blocksworld/task1.txt | 1 + .../nl2plan/domains/blocksworld/task2.txt | 1 + .../nl2plan/domains/blocksworld/task3.txt | 1 + .../nl2plan/domains/household/desc.txt | 1 + .../nl2plan/domains/household/task1.txt | 23 + .../nl2plan/domains/household/task2.txt | 34 ++ .../nl2plan/domains/household/task3.txt | 74 +++ .../nl2plan/domains/isr-assisted/desc.txt | 1 + .../nl2plan/domains/isr-assisted/task1.txt | 12 + .../nl2plan/domains/isr-assisted/task2.txt | 22 + .../nl2plan/domains/isr-assisted/task3.txt | 33 ++ .../nl2plan/domains/isr/desc.txt | 1 + .../nl2plan/domains/isr/task1.txt | 12 + .../nl2plan/domains/isr/task2.txt | 22 + .../nl2plan/domains/isr/task3.txt | 33 ++ .../nl2plan/domains/logistics/desc.txt | 1 + .../nl2plan/domains/logistics/task1.txt | 1 + .../nl2plan/domains/logistics/task2.txt | 0 .../nl2plan/domains/logistics/task3.txt | 0 .../nl2plan/domains/tyreworld/desc.txt | 1 + .../nl2plan/domains/tyreworld/task1.txt | 1 + .../nl2plan/domains/tyreworld/task2.txt | 1 + .../nl2plan/domains/tyreworld/task3.txt | 1 + paper_reconstructions/nl2plan/main.py | 522 ++++++------------ .../nl2plan/nl2plan/action_construction.py | 255 +++++++++ .../nl2plan/nl2plan/action_extraction.py | 94 ++++ .../nl2plan/nl2plan/hierarchy_construction.py | 77 +++ .../nl2plan/nl2plan/task_extraction.py | 151 +++++ .../nl2plan/nl2plan/type_extraction.py | 73 +++ .../prompts/action_construction/error.txt | 5 +- .../examples/{example.txt => example1.txt} | 57 +- .../prompts/action_construction/feedback.txt | 33 +- .../prompts/action_construction/role.txt | 23 +- .../prompts/action_construction/task.txt | 12 +- .../prompts/action_construction/technique.txt | 6 - .../action_extraction/examples/example.txt | 149 ----- .../action_extraction/examples/example1.txt | 198 +++++++ .../prompts/action_extraction/feedback.txt | 20 +- .../prompts/action_extraction/role.txt | 14 +- .../prompts/action_extraction/task.txt | 9 +- .../prompts/action_extraction/technique.txt | 6 - .../nl2plan/prompts/blocksworld.txt | 6 - .../nl2plan/prompts/blocksworld_p1.txt | 1 - .../examples/{example.txt => example1.txt} | 71 ++- .../hierarchy_construction/feedback.txt | 18 +- .../prompts/hierarchy_construction/role.txt | 22 +- .../prompts/hierarchy_construction/task.txt | 3 +- .../hierarchy_construction/technique.txt | 7 - .../nl2plan/prompts/task_extraction/error.txt | 7 + .../examples/{example.txt => example1.txt} | 118 ++-- .../prompts/task_extraction/feedback.txt | 27 +- .../nl2plan/prompts/task_extraction/role.txt | 36 +- .../nl2plan/prompts/task_extraction/task.txt | 6 +- .../prompts/task_extraction/technique.txt | 8 - .../type_extraction/examples/example.txt | 94 ---- .../type_extraction/examples/example1.txt | 91 +++ .../prompts/type_extraction/feedback.txt | 29 +- .../nl2plan/prompts/type_extraction/role.txt | 13 +- .../nl2plan/prompts/type_extraction/task.txt | 5 +- .../prompts/type_extraction/technique.txt | 6 - .../nl2plan/results/blocksworld/domain.pddl | 98 ++++ .../nl2plan/results/blocksworld/problem.pddl | 34 ++ .../nl2plan/results/domain.pddl | 115 ---- .../nl2plan/results/problem.pddl | 31 -- paper_reconstructions/proc2pddl/main.py | 4 +- 71 files changed, 2014 insertions(+), 1079 deletions(-) delete mode 100644 paper_reconstructions/nl2plan/domains/logistics/task2.txt delete mode 100644 paper_reconstructions/nl2plan/domains/logistics/task3.txt create mode 100644 paper_reconstructions/nl2plan/nl2plan/action_construction.py create mode 100644 paper_reconstructions/nl2plan/nl2plan/action_extraction.py create mode 100644 paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py create mode 100644 paper_reconstructions/nl2plan/nl2plan/task_extraction.py create mode 100644 paper_reconstructions/nl2plan/nl2plan/type_extraction.py rename paper_reconstructions/nl2plan/prompts/action_construction/examples/{example.txt => example1.txt} (83%) delete mode 100644 paper_reconstructions/nl2plan/prompts/action_construction/technique.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt create mode 100644 paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/blocksworld.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt rename paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/{example.txt => example1.txt} (70%) delete mode 100644 paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt create mode 100644 paper_reconstructions/nl2plan/prompts/task_extraction/error.txt rename paper_reconstructions/nl2plan/prompts/task_extraction/examples/{example.txt => example1.txt} (59%) delete mode 100644 paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt create mode 100644 paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt delete mode 100644 paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/problem.pddl delete mode 100644 paper_reconstructions/nl2plan/results/domain.pddl delete mode 100644 paper_reconstructions/nl2plan/results/problem.pddl diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index d1d1016..67400bb 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -81,9 +81,9 @@ def extract_type( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract types.") @@ -134,9 +134,9 @@ def extract_type_hierarchy( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract type hierarchy.") @@ -197,9 +197,9 @@ def extract_nl_actions( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract NL actions.") @@ -211,11 +211,12 @@ def extract_pddl_action( prompt_template: str, action_name: str, action_desc: str = None, - action_list: dict[str, str] = None, + action_list: str = None, predicates: list[Predicate] = None, types: dict[str, str] = None, + syntax_validator: SyntaxValidator = None, max_retries: int = 3, - ) -> tuple[Action, list[Predicate], str]: + ) -> tuple[Action, list[Predicate], str, tuple[bool, str]]: """ Extract an action and predicates from a given action description using LLM @@ -234,15 +235,16 @@ def extract_pddl_action( action (Action): constructed action class new_predicates (list[Predicate]): a list of new predicates llm_response (str): the raw string LLM response + validation_info (tuple[bool, str]): validation check information """ # replace prompt placeholders types_str = format_dict(types) if types else "No types provided." predicates_str = ( - format_predicates(predicates) if predicates else "No predicates provided." + "\n".join([f"- {pred['clean']}" for pred in predicates]) if predicates else "No predicates provided." ) action_list_str = ( - str(action_list) if action_list else "No other actions provided" + action_list if action_list else "No other actions provided" ) prompt_template = prompt_template.replace("{domain_desc}", domain_desc) @@ -267,16 +269,39 @@ def extract_pddl_action( llm_response=llm_response, action_name=action_name ) new_predicates = parse_new_predicates(llm_response) + + validation_info = [True, "All validations passed."] + if syntax_validator: + for e in syntax_validator.error_types: + if e == 'invalid_header': + validation_info = syntax_validator.validate_header(llm_response) + elif e == 'invalid_keyword_usage': + validation_info = syntax_validator.validate_keyword_usage(llm_response) + elif e == 'unsupported_keywords': + validation_info = syntax_validator.validate_unsupported_keywords(llm_response, syntax_validator.unsupported_keywords) + elif e == 'invalid_param_types': + validation_info = syntax_validator.validate_params(action['params'], types) + elif e == 'invalid_predicate_name': + validation_info = syntax_validator.validate_types_predicates(new_predicates, types) + elif e == 'invalid_predicate_format': + validation_info = syntax_validator.validate_format_predicates(predicates, types) + elif e == 'invalid_predicate_usage': + validation_info = syntax_validator.validate_usage_predicates(llm_response, predicates, types) + else: + raise NotImplementedError(f"Validation type '{e}' is not implemented.") + + if not validation_info[0]: + return action, new_predicates, llm_response, validation_info if action is not None and new_predicates is not None: - return action, new_predicates, llm_response + return action, new_predicates, llm_response, validation_info except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract PDDL action.") @@ -415,9 +440,9 @@ def extract_parameters( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract parameters.") @@ -485,9 +510,9 @@ def extract_preconditions( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract preconditions.") @@ -558,9 +583,9 @@ def extract_effects( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract effects.") @@ -623,9 +648,9 @@ def extract_predicates( except Exception as e: print( f"Error encountered during attempt {attempt + 1}/{max_retries}: {e}. " - f"LLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." + f"\nLLM Output: \n\n{llm_response if 'llm_response' in locals() else 'None'}\n\n Retrying..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract predicates.") diff --git a/l2p/feedback_builder.py b/l2p/feedback_builder.py index f9f6110..410fa4a 100644 --- a/l2p/feedback_builder.py +++ b/l2p/feedback_builder.py @@ -7,6 +7,7 @@ from .domain_builder import DomainBuilder from .task_builder import TaskBuilder from collections import OrderedDict +import textwrap domain_builder = DomainBuilder() task_builder = TaskBuilder() @@ -74,13 +75,25 @@ def type_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "type_1": "description", + "type_2": "description", + "type_3": "description", + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{type_str}" ) + + model.reset_tokens() types, llm_response = domain_builder.extract_type( - model, domain_desc, prompt + model, domain_desc, prompt, type_str ) return types, llm_response @@ -112,12 +125,32 @@ def type_hierarchy_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "parent_type_1": "description", + "children": [ + { + "child_type_1": "description", + "children": [ + {"child_child_type_1": "description", "children": []}, + {"child_child_type_2": "description", "children": []} + ] + } + ] + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{type_str}" ) + + model.reset_tokens() + type_hierarchy, llm_response = domain_builder.extract_type_hierarchy( - model, domain_desc, prompt + model, domain_desc, prompt, type_str ) return type_hierarchy, llm_response @@ -154,11 +187,23 @@ def nl_action_feedback( ) if not no_fb: + structure_prompt = textwrap.dedent(""" + ## OUTPUT + { + "action_name_1": "action_description", + "action_name_2": "action_description", + "action_name_3": "action_description" + } + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" + f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f"\n\nApply the suggestions to your original answer:\n{nl_action_str}" ) + model.reset_tokens() + nl_actions, llm_response = domain_builder.extract_type_hierarchy( model, domain_desc, prompt ) @@ -176,7 +221,7 @@ def pddl_action_feedback( action: Action = None, predicates: list[Predicate] = None, types: dict[str, str] = None, - ) -> tuple[Action, list[Predicate], str]: + ) -> tuple[Action, list[Predicate], str, tuple[bool,str], bool]: """Makes LLM call using feedback prompt, then parses it into action format""" model.reset_tokens() @@ -186,7 +231,7 @@ def pddl_action_feedback( format_predicates(predicates) if predicates else "No predicates provided." ) param_str = ( - ", ".join([f"{name} - {type}" for name, type in action["params"].items()]) + "\n".join([f"{name} - {type}" for name, type in action["params"].items()]) if action else "No parameters provided" ) @@ -201,7 +246,7 @@ def pddl_action_feedback( feedback_template = feedback_template.replace("{types}", type_str) feedback_template = feedback_template.replace("{predicates}", predicate_str) feedback_template = feedback_template.replace("{action_name}", action_name) - feedback_template = feedback_template.replace("{parameters}", param_str) + feedback_template = feedback_template.replace("{action_params}", param_str) feedback_template = feedback_template.replace( "{action_preconditions}", preconditions_str ) @@ -211,16 +256,51 @@ def pddl_action_feedback( model, feedback_template, feedback_type, llm_response ) + validation_info = [True, "All validations passed."] if not no_fb: + + structure_prompt = textwrap.dedent(""" + End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL as so: + + ### Action Parameters + ``` + - ?t - type: 'parameter_description' + ``` + + ### Action Preconditions + ``` + (and + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION + ) + ``` + + ### Action Effects + ``` + (and + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION + ) + ``` + + ### New Predicates + ``` + - (predicate_name ?t1 - type_1 ?t2 - type_2): 'predicate_description' + ``` + + If there are no new predicates created, keep an empty space enclosed ``` ``` with the '### New Predicates' header. + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" + f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() - action, predicates, llm_response = domain_builder.extract_pddl_action( + action, predicates, llm_response, validation_info = domain_builder.extract_pddl_action( model, domain_desc, prompt, action_name ) - return action, predicates, llm_response + return action, predicates, llm_response, validation_info, no_fb @require_llm def parameter_feedback( @@ -264,6 +344,8 @@ def parameter_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() param, param_raw, llm_response = domain_builder.extract_parameters( model, domain_desc, prompt, action_name, action_desc, types @@ -324,6 +406,8 @@ def precondition_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() preconditions, new_predicates, llm_response = ( domain_builder.extract_preconditions( @@ -389,6 +473,8 @@ def effect_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() effects, new_predicates, llm_response = domain_builder.extract_effects( model, domain_desc, prompt, action_name, action_desc @@ -434,6 +520,8 @@ def predicate_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() new_predicates, llm_response = domain_builder.extract_predicates( model, domain_desc, prompt @@ -482,19 +570,50 @@ def task_feedback( feedback_template = feedback_template.replace("{predicates}", predicate_str) feedback_template = feedback_template.replace("{objects}", objects_str) feedback_template = feedback_template.replace( - "{initial_state}", initial_state_str + "{initial_states}", initial_state_str ) - feedback_template = feedback_template.replace("{goal_state}", goal_state_str) + feedback_template = feedback_template.replace("{goal_states}", goal_state_str) no_fb, fb_msg = self.get_feedback( model, feedback_template, feedback_type, llm_response ) if not no_fb: + + structure_prompt = textwrap.dedent(""" + End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: + + ### OBJECTS + ``` + object1 - type_1 + object2 - type_2 + object3 - type_1 + ``` + + ### INITIAL + ``` + (predicate_name object1 object2) ; comment for initial state predicate 1 + (predicate_name object3 object4) ; comment for initial state predicate 2 + (predicate_name object5) ; comment for initial state predicate 3 + ``` + + ### GOAL + ``` + (and + (predicate_name object) ; comment + ) + ``` + + Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. + """) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" + f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() objects, initial, goal, _ = task_builder.extract_task( model, problem_desc, prompt @@ -545,6 +664,8 @@ def objects_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() objects, llm_response = task_builder.extract_objects( model, problem_desc, prompt @@ -604,6 +725,8 @@ def initial_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() initial, llm_response = task_builder.extract_initial_state( model, problem_desc, prompt @@ -668,6 +791,8 @@ def goal_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) + + model.reset_tokens() goal, llm_response = task_builder.extract_goal_state( model, problem_desc, prompt diff --git a/l2p/task_builder.py b/l2p/task_builder.py index 4686031..77cbc30 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -58,7 +58,7 @@ def extract_objects( # replace prompt placeholders predicate_str = ( - format_predicates(predicates) if predicates else "No predicates provided." + "\n".join([f"- {pred['name']}: {pred['desc']}" for pred in predicates]) if predicates else "No predicates provided." ) types_str = "\n".join(types) if types else "No types provided." @@ -82,7 +82,7 @@ def extract_objects( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract objects.") @@ -155,7 +155,7 @@ def extract_initial_state( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract initial states.") @@ -228,7 +228,7 @@ def extract_goal_state( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract goal states.") @@ -297,7 +297,7 @@ def extract_task( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract task.") @@ -363,7 +363,7 @@ def extract_nl_conditions( print( f"Error encountered: {e}. Retrying {attempt + 1}/{max_retries}..." ) - time.sleep(1) # add a delay before retrying + time.sleep(2) # add a delay before retrying raise RuntimeError("Max retries exceeded. Failed to extract NL task states.") diff --git a/l2p/utils/pddl_parser.py b/l2p/utils/pddl_parser.py index b36609a..45721fa 100644 --- a/l2p/utils/pddl_parser.py +++ b/l2p/utils/pddl_parser.py @@ -9,13 +9,22 @@ from copy import deepcopy import re, ast, json, sys, os -def load_file(file_path): +def load_file(file_path: str): _, ext = os.path.splitext(file_path) with open(file_path, "r") as file: if ext == ".json": return json.load(file) else: return file.read().strip() + +def load_files(folder_path: str): + file_contents = [] + for filename in sorted(os.listdir(folder_path)): + file_path = os.path.join(folder_path, filename) + if os.path.isfile(file_path): + with open(file_path, 'r') as file: + file_contents.append(file.read()) + return file_contents def parse_params(llm_output): """ @@ -25,7 +34,7 @@ def parse_params(llm_output): LLM output header should contain '### Parameters' along with structured content. """ params_info = OrderedDict() - params_heading = llm_output.split("Parameters")[1].strip().split("###")[0] + params_heading = re.split(r"\n#+\s", llm_output.split("Parameters")[1].strip(), maxsplit=1)[0] params_str = combine_blocks(params_heading) params_raw = [] for line in params_str.split("\n"): diff --git a/l2p/utils/pddl_validator.py b/l2p/utils/pddl_validator.py index bd6f997..d20eb55 100644 --- a/l2p/utils/pddl_validator.py +++ b/l2p/utils/pddl_validator.py @@ -8,6 +8,25 @@ class SyntaxValidator: + def __init__( + self, + error_types=None, + unsupported_keywords = None + ): + + default_error_types = [ + 'invalid_header', + 'invalid_keyword_usage', + 'unsupported_keywords', + 'invalid_param_types', + 'invalid_predicate_name', + 'invalid_predicate_format', + 'invalid_predicate_usage' + ] + + default_unsupported = ['forall', 'when', 'exists', 'implies'] + self.error_types = default_error_types if error_types is None else error_types + self.unsupported_keywords = default_unsupported if unsupported_keywords is None else unsupported_keywords # PARAMETER CHECKS @@ -296,6 +315,7 @@ def validate_task_objects( obj_type_found = False for type_key in types.keys(): + current_type, parent_type = type_key.split(" - ") # checks if obj_type is found in types diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt b/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt index e69de29..0c2ad46 100644 --- a/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt +++ b/paper_reconstructions/nl2plan/domains/blocksworld/desc.txt @@ -0,0 +1 @@ +The AI agent here is a mechanical robot arm that can pick and place the blocks. Only one block may be moved at a time: it may either be placed on the table or placed atop another block. Because of this, any blocks that are, at a given time, under another block cannot be moved. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt index e69de29..ee1d196 100644 --- a/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt +++ b/paper_reconstructions/nl2plan/domains/blocksworld/task1.txt @@ -0,0 +1 @@ +There are four blocks currently. The blue block is on the red which is on the yellow. The yellow and the green are on the table. I want the red on top of the green. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt index e69de29..ac747b5 100644 --- a/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt +++ b/paper_reconstructions/nl2plan/domains/blocksworld/task2.txt @@ -0,0 +1 @@ +There are four blocks in two piles. The first has blue on red and the second has green on yellow. I want a single stack ordered (lowest first): red, green, blue, yellow. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt b/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt index e69de29..fdab06f 100644 --- a/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt +++ b/paper_reconstructions/nl2plan/domains/blocksworld/task3.txt @@ -0,0 +1 @@ +I've got five blocks of three colours and want to stack them in a single pile such that the red blocks are at the bottom, the blue are on those and the green are on top. Currently they're in two stacks, (red, blue, green) and (green, red) ordered from the bottom up. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/desc.txt b/paper_reconstructions/nl2plan/domains/household/desc.txt index e69de29..4861b0b 100644 --- a/paper_reconstructions/nl2plan/domains/household/desc.txt +++ b/paper_reconstructions/nl2plan/domains/household/desc.txt @@ -0,0 +1 @@ +The AI agent here is a household robot that can navigate to various large and normally immovable furniture pieces or appliances in the house to carry out household tasks. Note that the robot has only one gripper, so (a) it can only hold one object; (b) it shouldn't hold any other irrelevant objects in its gripper while performing some manipulation tasks (e.g., opening a drawer or closing a window); (c) operations on small household items should be carried out on furniture with a flat surface to get enough space for manipulation. In this domain, the locations of the robot and small household items (e.g., apples, oranges, bowls, lunch boxes or lamps) are determined by large and normally immovable furniture pieces or appliances. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task1.txt b/paper_reconstructions/nl2plan/domains/household/task1.txt index e69de29..a0b2359 100644 --- a/paper_reconstructions/nl2plan/domains/household/task1.txt +++ b/paper_reconstructions/nl2plan/domains/household/task1.txt @@ -0,0 +1,23 @@ +Please toggle lamp_1 on and humidifier_1 off starting from the following state: + +- drawer_1 is opened +- drawer_2 is opened +- fridge_1 is opened +- cabinet_1 is not opened +- cabinet_2 is opened +- cup_1 in/on cabinet_2 +- plate_1 in/on drawer_2 +- cutting_board_1 in/on countertop_1 +- cutting_board_1 is pickupable +- blender_1 in/on dining_table_1 +- blender_1 is not pickupable +- blender_1 is turned off +- lamp_1 in/on side_table_1 +- lamp_1 is turned off +- humidifier_1 in/on side_table_1 +- humidifier_1 is turned on +- apple_1 in/on cabinet_2 +- book_1 in/on dining_table_1 +- book_2 in/on dining_table_1 +- robot at cabinet_1 +- robot is holding mug_1 \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task2.txt b/paper_reconstructions/nl2plan/domains/household/task2.txt index e69de29..76f04ee 100644 --- a/paper_reconstructions/nl2plan/domains/household/task2.txt +++ b/paper_reconstructions/nl2plan/domains/household/task2.txt @@ -0,0 +1,34 @@ +Your task is to transfer potato_1 from a lunch box to plate_1 and close the fridge after yourself. + +This is the current state: +- drawer_1 is not opened +- fridge_1 is opened +- cabinet_1 is not opened +- bowl_1 in/on cabinet_2 +- bowl_2 in/on drawer_2 +- plate_1 in/on dining_table_1 +- plate_2 in/on dish_washer_1 +- pan_1 in/on cabinet_3 +- pan_2 in/on cabinet_4 +- lunch_box_1 in/on fridge_1 +- lunch_box_1 is not opened +- lunch_box_2 in/on fridge_1 +- lunch_box_2 is not opened +- pizza_box_1 in/on drawer_4 +- pizza_box_1 is not opened +- cutting_board_1 in/on drawer_1 +- cutting_board_1 is pickupable +- apple_1 in/on cabinet_1 +- apple_1 is not sliced +- apple_2 in/on fridge_1 +- apple_2 is not sliced +- pizza_1 in/on lunch_box_1 +- pizza_1 is not pickupable +- toast_1 in/on lunch_box_1 +- toast_1 is not sliced +- banana_1 in/on cabinet_2 +- banana_1 is not sliced +- potato_1 in/on lunch_box_2 +- potato_1 is not sliced +- robot at cabinet_2 +- robot is not holding anything \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/household/task3.txt b/paper_reconstructions/nl2plan/domains/household/task3.txt index e69de29..18b33e0 100644 --- a/paper_reconstructions/nl2plan/domains/household/task3.txt +++ b/paper_reconstructions/nl2plan/domains/household/task3.txt @@ -0,0 +1,74 @@ +I want you to heat pizza_1 with pan_2. + +The following are the current objects and their state: +- drawer_1 is opened +- drawer_2 is not opened +- drawer_3 is opened +- drawer_4 is not opened +- fridge_1 is not opened +- cabinet_1 is opened +- cabinet_2 is not opened +- cabinet_3 is not opened +- cabinet_4 is opened +- microwave_1 is not opened +- carpet_1 is not clean +- carpet_2 is not clean +- dish_washer_1 is opened +- garbage_can_1 is not opened +- cup_1 in/on drawer_3 +- bowl_1 in/on dish_washer_1 +- bowl_2 in/on cabinet_4 +- plate_1 in/on dining_table_1 +- plate_2 in/on cabinet_3 +- pan_1 in/on stove_burner_1 +- pan_2 in/on dining_table_1 +- lunch_box_1 in/on fridge_1 +- lunch_box_1 is not opened +- lunch_box_2 in/on cabinet_3 +- lunch_box_2 is not opened +- pizza_box_1 in/on cabinet_2 +- pizza_box_1 is not opened +- cutting_board_1 in/on countertop_2 +- cutting_board_1 is pickupable +- toaster_1 in/on countertop_2 +- toaster_1 is not pickupable +- toaster_1 is turned off +- blender_1 in/on dining_table_1 +- blender_1 is not pickupable +- blender_1 is turned off +- lamp_1 in/on side_table_2 +- lamp_1 is turned on +- lamp_1 is not pickupable +- humidifier_1 in/on side_table_2 +- humidifier_1 is turned on +- humidifier_1 is not pickupable +- apple_1 in/on lunch_box_2 +- apple_1 is not sliced +- apple_2 in/on drawer_2 +- apple_2 is not sliced +- pizza_1 in/on pizza_box_1 +- pizza_1 is not pickupable +- toast_1 in/on lunch_box_1 +- toast_1 is not sliced +- orange_1 in/on lunch_box_1 +- orange_1 is not sliced +- orange_2 in/on drawer_1 +- orange_2 is not sliced +- banana_1 in/on cabinet_3 +- banana_1 is not sliced +- potato_1 in/on cabinet_1 +- potato_1 is not sliced +- fork_1 in/on cabinet_4 +- spoon_1 in/on drawer_4 +- knife_1 in/on cabinet_2 +- book_1 in/on dining_table_1 +- book_2 in/on side_table_2 +- book_3 in/on side_table_2 +- book_4 in/on side_table_1 +- book_5 in/on side_table_1 +- cloth_1 in/on cabinet_3 +- cloth_1 is clean +- handheld_vacuum_1 in/on shelf_1 +- handheld_vacuum_1 has an empty dust bin +- robot at drawer_1 +- robot is holding mug_1 \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt index e69de29..8084c5f 100644 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt +++ b/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt @@ -0,0 +1 @@ +An independent set of a graph is a subset of its vertices such that no two vertices of the subset share an edge. Reconfiguring an independent set means replacing one vertex in the subset with another one such that the new subset is still an independent set. The ISR problem is to find a sequence of such reconfiguration steps to reach a given target configuration from a given start configuration. Model the reconfiguration with two actions, "remove" and "add". "remove" cannot be taken if the last action taken was a "remove" action, and conversly "add" can only be taken if the last action taken was a "remove". \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt index e69de29..0a95207 100644 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt +++ b/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt @@ -0,0 +1,12 @@ +The current graph has the following neighbors: +- (1,2) +- (2,3) +- (3,4) +- (4,5) +- (5,6) +- (6,7) +- (7,8) +- (7,9) +- (9,5) + +And the initial independent set is (6,4,9). Transform it to (7,5,3) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt index e69de29..67fc22b 100644 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt +++ b/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt @@ -0,0 +1,22 @@ +So, I want to go from the set (C,E,G,K,M,O,Q) to (D,F,H,J,L,N,P) in a graph with the following neighbors: +- (A,B) +- (B,C) +- (C,D) +- (C,H) +- (C,J) +- (D,E) +- (F,G) +- (F,M) +- (G,H) +- (G,N) +- (H,I) +- (I,J) +- (I,O) +- (J,K) +- (K,L) +- (K,P) +- (L,Q) +- (M,N) +- (N,O) +- (O,P) +- (P,Q) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt index e69de29..4025ba0 100644 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt +++ b/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt @@ -0,0 +1,33 @@ +The graph has the following neighbors: +(A, E) +(B, C) +(B, F) +(C, D) +(D, G) +(E, H) +(F, J) +(G, L) +(H, I) +(H, M) +(I, J) +(I, N) +(J, K) +(K, L) +(K, P) +(L, Q) +(M, N) +(M, R) +(N, O) +(O, P) +(O, S) +(P, Q) +(Q, T) +(R, U) +(S, W) +(T, X) +(U, V) +(V, W) +(X, Y) +(Y, Z) + +And I'm starting with the set (A,C,F,H,L,N,P,R,S,T,V) and want to end with the set (B,D,E,I,K,M,O,Q,U,X,Z). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/desc.txt b/paper_reconstructions/nl2plan/domains/isr/desc.txt index e69de29..05474db 100644 --- a/paper_reconstructions/nl2plan/domains/isr/desc.txt +++ b/paper_reconstructions/nl2plan/domains/isr/desc.txt @@ -0,0 +1 @@ +An independent set of a graph is a subset of its vertices such that no two vertices of the subset share an edge. Reconfiguring an independent set means replacing one vertex in the subset with another one such that the new subset is still an independent set. The ISR problem is to find a sequence of such reconfiguration steps to reach a given target configuration from a given start configuration \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task1.txt b/paper_reconstructions/nl2plan/domains/isr/task1.txt index e69de29..0cade54 100644 --- a/paper_reconstructions/nl2plan/domains/isr/task1.txt +++ b/paper_reconstructions/nl2plan/domains/isr/task1.txt @@ -0,0 +1,12 @@ +The current graph has the following neighbors: +- (1,2) +- (2,3) +- (3,4) +- (4,5) +- (5,6) +- (6,7) +- (7,8) +- (7,9) +- (9,5) + +And the initial independent set is (4,6,9). Transform it to (3,5,7) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task2.txt b/paper_reconstructions/nl2plan/domains/isr/task2.txt index e69de29..67fc22b 100644 --- a/paper_reconstructions/nl2plan/domains/isr/task2.txt +++ b/paper_reconstructions/nl2plan/domains/isr/task2.txt @@ -0,0 +1,22 @@ +So, I want to go from the set (C,E,G,K,M,O,Q) to (D,F,H,J,L,N,P) in a graph with the following neighbors: +- (A,B) +- (B,C) +- (C,D) +- (C,H) +- (C,J) +- (D,E) +- (F,G) +- (F,M) +- (G,H) +- (G,N) +- (H,I) +- (I,J) +- (I,O) +- (J,K) +- (K,L) +- (K,P) +- (L,Q) +- (M,N) +- (N,O) +- (O,P) +- (P,Q) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task3.txt b/paper_reconstructions/nl2plan/domains/isr/task3.txt index e69de29..4025ba0 100644 --- a/paper_reconstructions/nl2plan/domains/isr/task3.txt +++ b/paper_reconstructions/nl2plan/domains/isr/task3.txt @@ -0,0 +1,33 @@ +The graph has the following neighbors: +(A, E) +(B, C) +(B, F) +(C, D) +(D, G) +(E, H) +(F, J) +(G, L) +(H, I) +(H, M) +(I, J) +(I, N) +(J, K) +(K, L) +(K, P) +(L, Q) +(M, N) +(M, R) +(N, O) +(O, P) +(O, S) +(P, Q) +(Q, T) +(R, U) +(S, W) +(T, X) +(U, V) +(V, W) +(X, Y) +(Y, Z) + +And I'm starting with the set (A,C,F,H,L,N,P,R,S,T,V) and want to end with the set (B,D,E,I,K,M,O,Q,U,X,Z). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/desc.txt b/paper_reconstructions/nl2plan/domains/logistics/desc.txt index e69de29..00f75d0 100644 --- a/paper_reconstructions/nl2plan/domains/logistics/desc.txt +++ b/paper_reconstructions/nl2plan/domains/logistics/desc.txt @@ -0,0 +1 @@ +The AI agent here is a logistics planner that has to plan to transport packages within the locations in a city through a truck and between cities through an airplane. Within a city, the locations are directly linked, allowing trucks to travel between any two of these locations. Similarly, cities are directly connected to each other allowing airplanes to travel between any two cities. Also, there is no limit to how many packages a truck or plane can carry (so in theory a truck or plane can carry an infinite number of packages). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/task1.txt b/paper_reconstructions/nl2plan/domains/logistics/task1.txt index e69de29..3029f3f 100644 --- a/paper_reconstructions/nl2plan/domains/logistics/task1.txt +++ b/paper_reconstructions/nl2plan/domains/logistics/task1.txt @@ -0,0 +1 @@ +Currently I've got five packages to ship, 3 in a storage in Ado and the rest in Betar's storage. Those from Ado should be sent 1 to Bal Street in Betar, 2 to Cli Promenade in Colin. Those from Betar should be moved to the Ado storage. The only plane is currently in Duran's airport, but each city has it's own truck and airport. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/task2.txt b/paper_reconstructions/nl2plan/domains/logistics/task2.txt deleted file mode 100644 index e69de29..0000000 diff --git a/paper_reconstructions/nl2plan/domains/logistics/task3.txt b/paper_reconstructions/nl2plan/domains/logistics/task3.txt deleted file mode 100644 index e69de29..0000000 diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt b/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt index e69de29..40e066b 100644 --- a/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt +++ b/paper_reconstructions/nl2plan/domains/tyreworld/desc.txt @@ -0,0 +1 @@ +The AI agent here is a robot that has to replace a flat tyre with a spare one. This involves fetching the tools (wrench, jack, pump) from the boot, undoing the nuts on the flat tyre, jacking up the (appropriate) hub(s), removing the tyre, doing up the spare one, etc. Note that there is no restriction on how many objects the AI agent (i.e., the robot) can carry. Also note that each hub has only one nut. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt index e69de29..80103c0 100644 --- a/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task1.txt @@ -0,0 +1 @@ +The robot is already holding all the tools and has a whole, but uninflated, wheel. The flat tire is already loosened and jacked up, but still left on the hub. Safely replace the flat tire with the whole one and prepare it. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt index e69de29..1f5a498 100644 --- a/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task2.txt @@ -0,0 +1 @@ +The robot currently only has a wrench, but the other tools and a spare (already inflated) tyre are in the open boot. The back left wheel is flat, and still attached. It should be safely replaced. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt b/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt index e69de29..1e22e9a 100644 --- a/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt +++ b/paper_reconstructions/nl2plan/domains/tyreworld/task3.txt @@ -0,0 +1 @@ +The car is already in the process of having wheels changed, so the front left hub is raised with the jack and its wheel removed. I want you to remove and replace the back left tyre. You'll find an uninflated tyre, the wrench and a pump in the closed trunk. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py index abe85ce..b3f1ad9 100644 --- a/paper_reconstructions/nl2plan/main.py +++ b/paper_reconstructions/nl2plan/main.py @@ -4,404 +4,202 @@ Run: python3 -m paper_reconstructions.nl2plan.main """ -import os, json +import argparse from l2p import * +from .nl2plan.type_extraction import TypeExtraction +from .nl2plan.hierarchy_construction import HierarchyConstruction +from .nl2plan.action_extraction import ActionExtraction +from .nl2plan.action_construction import ActionConstruction +from .nl2plan.task_extraction import TaskExtraction + +DOMAINS = [ + "blocksworld", + "household", + "isr", + "isr-assisted", + "logistics", + "tyreworld" +] + +REQUIREMENTS = [ + ":strips", + ":typing", + ":equality", + ":negative-preconditions", + ":disjunctive-preconditions", + ":universal-preconditions", + ":conditional-effects", + ] -def format_json_output(data): - return json.dumps(data, indent=4) - - -engine = "gpt-4o-mini" -api_key = os.environ.get("OPENAI_API_KEY") -openai_llm = OPENAI(model=engine, api_key=api_key) - -domain_desc = load_file("paper_reconstructions/nl2plan/prompts/blocksworld.txt") -problem_desc = load_file("paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt") - -# open and create type extraction prompt builder class -role_desc = load_file("paper_reconstructions/nl2plan/prompts/type_extraction/role.txt") -tech_desc = load_file( - "paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt" -) -task_desc = load_file("paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") -type_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create type hierarchy prompt builder class -role_desc = load_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt" -) -tech_desc = load_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt" -) -task_desc = load_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt" -) -type_hierarchy_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create NL action prompt builder class -role_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/role.txt" -) -tech_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt" -) -task_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/task.txt" -) -action_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create PDDL action prompt builder class -role_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_construction/role.txt" -) -tech_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_construction/technique.txt" -) -task_desc = load_file( - "paper_reconstructions/nl2plan/prompts/action_construction/task.txt" -) -action_construction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -# open and create compact action prompt builder class -role_desc = load_file("paper_reconstructions/nl2plan/prompts/task_extraction/role.txt") -tech_desc = load_file( - "paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt" -) -task_desc = load_file("paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") -task_extraction_prompt = PromptBuilder( - role=role_desc, technique=tech_desc, task=task_desc -) - -domain_builder = DomainBuilder() -task_builder = TaskBuilder() -syntax_validator = SyntaxValidator() -planner = FastDownward(planner_path="downward/fast-downward.py") -feedback_builder = FeedbackBuilder() - -unsupported_keywords = ["object", "pddl", "lisp"] - - -def type_extraction( - model: LLM, domain_desc: str, type_extraction_prompt: PromptBuilder -) -> dict[str, str]: - # STEP ONE: type extraction - types, response = domain_builder.extract_type( - model, domain_desc, type_extraction_prompt.generate_prompt() - ) +UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] - feedback_template = load_file( - "paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt" - ) - types, _ = feedback_builder.type_feedback( - model=model, - domain_desc=domain_desc, - feedback_template=feedback_template, - feedback_type="llm", - types=types, - llm_response=response, - ) +def run_nl2plan(args): + # create necessary classes + domain_builder = DomainBuilder() # L2P domain builder + task_builder = TaskBuilder() # L2P task builder + planner = FastDownward(planner_path=args.planner) # FastDownward planner - return types - - -def hierarchy_construction( - model, domain_desc, type_hierarchy_prompt, types -) -> dict[str, str]: - # STEP TWO: type hierarchy extraction - type_hierarchy, response = domain_builder.extract_type_hierarchy( - model=model, - domain_desc=domain_desc, - prompt_template=type_hierarchy_prompt.generate_prompt(), + # initialize OpenAI engine + api_key = os.environ.get("OPENAI_API_KEY") + model = OPENAI(model=args.model, api_key=api_key) + + + # A. Type Extraction + type_extraction = TypeExtraction() + type_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") + + types = type_extraction.type_extraction( + model=model, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_extraction_prompt=type_extraction.prompt_template, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) + + print("TYPES:\n", types) + model.reset_tokens() + + # B. Hierarchy Construction + hierarchy_construction = HierarchyConstruction() + hierarchy_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") + + type_hierarchy = hierarchy_construction.hierarchy_construction( + model=model, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_hierarchy_prompt=hierarchy_construction.prompt_template, types=types, - ) - - feedback_template = load_file( - "paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt" - ) - type_hierarchy, _ = feedback_builder.type_hierarchy_feedback( - model=model, - domain_desc=domain_desc, - feedback_template=feedback_template, - feedback_type="llm", + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) + + print("\n\nTYPE HIERARCHY:\n", type_hierarchy) + model.reset_tokens() + + # C. Action Extraction + action_extraction = ActionExtraction() + action_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") + + nl_actions = action_extraction.action_extraction( + model=model, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + action_extraction_prompt=action_extraction.prompt_template, type_hierarchy=type_hierarchy, - llm_response=response, - ) - - return type_hierarchy - - -def action_extraction( - model, domain_desc, action_extraction_prompt, type_hierarchy -) -> dict[str, str]: - # STEP THREE: action extraction - nl_actions, response = domain_builder.extract_nl_actions( - model=model, - domain_desc=domain_desc, - prompt_template=action_extraction_prompt.generate_prompt(), - types=type_hierarchy, - ) - - feedback_template = load_file( - "paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt" - ) - nl_actions, _ = feedback_builder.nl_action_feedback( - model=model, - domain_desc=domain_desc, - llm_response=response, - feedback_template=feedback_template, - feedback_type="llm", + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) + + print("\n\nNL ACTIONS:\n", nl_actions) + model.reset_tokens() + + # D. Action Construction + action_construction = ActionConstruction() + action_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") + + actions, predicates, = action_construction.action_construction( + model=model, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + act_constr_prompt=action_construction.prompt_template, nl_actions=nl_actions, type_hierarchy=type_hierarchy, - ) - - return nl_actions - - -def action_construction( - model, domain_desc, action_construction_prompt, nl_actions, type_hierarchy -) -> tuple[list[Action], list[Predicate]]: - # STEP FOUR: action construction - - predicates = [] - max_iters = 2 - for _ in range(max_iters): - - actions = [] - current_preds = len(predicates) - - for action_name, action_desc in nl_actions.items(): - - feedback_template = load_file( - "paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt" - ) - - # retrieve rest of list - action_list = { - a_name: a_desc - for a_name, a_desc in nl_actions.items() - if a_name != action_name - } - - action, new_predicates, llm_response = domain_builder.extract_pddl_action( - model=model, - domain_desc=domain_desc, - prompt_template=action_construction_prompt.generate_prompt(), - action_name=action_name, - action_desc=action_desc, - action_list=action_list, - predicates=predicates, - types=type_hierarchy, - ) - - # perform syntax check on action model - is_valid, feedback_msg = syntax_validator.validate_usage_predicates( - llm_response, predicates, type_hierarchy - ) - # if there is syntax error, run through feedback mechanism to retrieve new action model - if is_valid == False: - feedback_template += ( - "\n\nThe following is a syntax error with your response:\n" - + feedback_msg - ) - - # TODO: currently buggy - run feedback at the end of the pipline - - # RUN FEEDBACK - # action, new_predicates, _ = feedback_builder.pddl_action_feedback( - # model=model, - # domain_desc=domain_desc, - # llm_response=llm_response, - # feedback_template=feedback_template, - # feedback_type="llm", - # action=action, - # predicates=predicates, - # types=types, - # ) - - actions.append(action) - predicates.extend(new_predicates) - - if len(predicates) == current_preds: - print("No new predicates created. Stopping action construction.") - break - - # discard predicates not found in action models + duplicates - predicates = prune_predicates(predicates=predicates, actions=actions) - - return actions, predicates - - -def task_extraction( - model, problem_desc, task_extraction_prompt, types, predicates, actions -) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: - # STEP FIVE: task extraction - feedback_template = load_file( - "paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt" - ) - - objects, initial, goal, llm_response = task_builder.extract_task( - model=model, - problem_desc=problem_desc, - prompt_template=task_extraction_prompt.generate_prompt(), - types=types, - predicates=predicates, - actions=actions, - ) - - feedback_msgs = [] - all_valid = True - - # List of validation checks - validation_checks = [ - (syntax_validator.validate_task_objects, (objects, types)), - ( - syntax_validator.validate_task_states, - (initial, objects, predicates, "initial"), - ), - (syntax_validator.validate_task_states, (goal, objects, predicates, "goal")), - ] - - # Perform each validation check - for validator, args in validation_checks: - is_valid, feedback_msg = validator(*args) - if not is_valid: - all_valid = False - feedback_msgs.append(feedback_msg) - - # If any check fails, append feedback messages - if not all_valid: - feedback_template += ( - "\n\nThe following is a syntax error with your response:" - + "\n".join(feedback_msgs) + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), + max_attempts=1 ) - - objects, initial, goal, _ = feedback_builder.task_feedback( - model=model, - problem_desc=problem_desc, - llm_response=llm_response, - feedback_template=feedback_template, - feedback_type="llm", - predicates=predicates, - types=types, - objects=objects, - initial=initial, - goal=goal, - ) - - objects = task_builder.format_objects(objects) - initial = task_builder.format_initial(initial) - goal = task_builder.format_goal(goal) - - return objects, initial, goal - - -if __name__ == "__main__": - - # STEP ONE: type extraction - types = type_extraction(openai_llm, domain_desc, type_extraction_prompt) - - print("Types:", format_json_output(types)) - print("END OF STEP ONE") - - # STEP TWO: hierarchy construction - type_hierarchy = hierarchy_construction( - openai_llm, domain_desc, type_hierarchy_prompt, types - ) - - print("Type Hierarchy", format_json_output(type_hierarchy)) - print("END OF STEP TWO") - - # STEP THREE: action extraction - nl_actions = action_extraction( - openai_llm, domain_desc, action_extraction_prompt, type_hierarchy - ) - - print("Natural Language Actions") - for i in nl_actions: - print(i) - print("END OF STEP THREE") - - # STEP FOUR: action construction - actions, predicates = action_construction( - openai_llm, domain_desc, action_construction_prompt, nl_actions, type_hierarchy - ) - - print("PDDL Actions") + + print("\n\nACTIONS:") for i in actions: print(i) - print("--------------------") - print("PDDL Predicates") + + print("\n\nPREDICATES:") for i in predicates: print(i) - print("END OF STEP FOUR") - + + model.reset_tokens() + + # E. Task Extraction + task_extraction = TaskExtraction() + task_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") + + objects, initial, goal = task_extraction.task_extraction( + model=model, + problem_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/task1.txt"), + task_extraction_prompt=task_extraction.prompt_template, + types=type_hierarchy, + predicates=predicates, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), + error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") + ) + + print("\n\nOBJECTS:\n", objects) + print("\n\nINITIAL STATES:\n", initial) + print("\n\nGOAL STATES:\n", goal) + + predicate_str = "\n".join( + [pred["clean"].replace(":", " ; ") for pred in predicates] + ) + types = format_types(type_hierarchy) # retrieve types - types = prune_types( - types=types, predicates=predicates, actions=actions - ) # discard types not in predicates / actions + duplicates - types = { + pruned_types = { name: description for name, description in types.items() - if name not in unsupported_keywords + if name not in UNSUPPORTED_KEYWORDS } # remove unsupported words - # STEP FIVE: task extraction - objects, initial, goal = task_extraction( - openai_llm, problem_desc, task_extraction_prompt, types, predicates, actions - ) - - print("Objects:\n", objects) - print("Initial States:\n", initial) - print("Goal States:\n", goal) - print("END OF STEP FIVE") - # format strings - predicate_str = "\n".join( - [pred["clean"].replace(":", " ; ") for pred in predicates] - ) - types_str = "\n".join(types) - - requirements = [ - ":strips", - ":typing", - ":equality", - ":negative-preconditions", - ":disjunctive-preconditions", - ":universal-preconditions", - ":conditional-effects", - ] - + types_str = "\n".join(pruned_types) + # generate PDDL specifications pddl_domain = domain_builder.generate_domain( - domain="test_domain", - requirements=requirements, + domain=args.domain, + requirements=args.requirements, types=types_str, predicates=predicate_str, actions=actions, ) + + print("\n\nPDDL DOMAIN:\n", pddl_domain) + + problem_name = args.domain + "_problem" pddl_problem = task_builder.generate_task( - domain="test_domain", - problem="test_problem", + domain=args.domain, + problem=problem_name, objects=objects, initial=initial, goal=goal, ) + + print("\n\nPDDL PROBLEM:\n", pddl_problem) # write files - domain_file = "paper_reconstructions/nl2plan/results/domain.pddl" + domain_file = "paper_reconstructions/nl2plan/results/blocksworld/domain.pddl" with open(domain_file, "w") as f: f.write(pddl_domain) - problem_file = "paper_reconstructions/nl2plan/results/problem.pddl" + problem_file = "paper_reconstructions/nl2plan/results/blocksworld/problem.pddl" with open(problem_file, "w") as f: f.write(pddl_problem) # run planner planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) + + + +if __name__ == "__main__": + + # load in arguments to run program + parser = argparse.ArgumentParser(description="LLM+P") + parser.add_argument('--model', type=str, default="gpt-4o-mini") + parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) + parser.add_argument('--planner', type=str, default="/Users/marcustantakoun/Downloads/downward/fast-downward.py") + args = parser.parse_args() + + # run LLM+P method + run_nl2plan(args=args) diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py new file mode 100644 index 0000000..125c269 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -0,0 +1,255 @@ +import os +from l2p import * + +class ActionConstruction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.syntax_validator = SyntaxValidator() + self.pddl_actions = list[Action] + self.pddl_predicates = list[Predicate] + + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + + def set_actions(self, actions: list[Action]): + self.pddl_actions = actions + + + def set_predicates(self, predicates: list[Predicate]): + self.pddl_predicates = predicates + + + def construct_action( + self, + model: LLM, + domain_desc: str, + act_constr_prompt: PromptBuilder, + action_list: str, + action_name: str, + action_desc: str, + predicates: list[Predicate], + type_hierarchy: dict[str,str], + syntax_validator: SyntaxValidator, + feedback_prompt: str = None, + max_attempts = 2, + feedback = True + ) -> tuple[Action, list[Predicate]]: + """ + Construct a single action from a given action description using LLM language model. + + Args: + model (LLM): The LLM language model connection. + act_constr_prompt (PromptBuilder): action construction prompt. + action_name (str): The name of the action. + action_desc (str): The action description. + predicates (list[Predicate]): A list of predicates. + syntax_validator (SyntaxValidator): The PDDL syntax validator. + feedback_prompt (str): Feedback template. + max_iters (int): Maximum number of iterations to construct action. Defaults to 8. + feedback (bool): Whether to request feedback from LLM. Defaults to True. + + Returns: + Action: The constructed action. + new_predicates (list[Predicate]): A list of new predicates + """ + + # fill in action construction prompt placeholders + action_prompt = act_constr_prompt.generate_prompt() + action_prompt = action_prompt.replace('{action_desc}', action_desc) + action_prompt = action_prompt.replace('{action_name}', action_name) + + if len(predicates) == 0: + predicate_str = "No predicate has been defined yet" + else: + predicate_str = "" + predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) + action_prompt = action_prompt.replace('{predicates}', predicate_str) + + # replace specific feedback template + if feedback_prompt is not None: + feedback_prompt = feedback_prompt.replace('{action_desc}', action_desc) + feedback_prompt = feedback_prompt.replace('{action_name}', action_name) + elif feedback: + raise ValueError("Feedback template is required when feedback is enabled.") + + for iter in range(1, max_attempts + 1 + (feedback is not None)): + print(f"Generating PDDL of action: `{action_name}`") + + try: + action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + model=model, + domain_desc=domain_desc, + prompt_template=action_prompt, + action_name=action_name, + action_desc=action_desc, + action_list=action_list, + predicates=predicates, + types=format_types(type_hierarchy), + syntax_validator=syntax_validator + ) + + no_error, error_msg = validation_info + + except Exception as e: + no_error = False + error_msg = str(e) + + if no_error: + if feedback is not None: + + action, new_predicates, response_fb, _, no_fb = self.feedback_builder.pddl_action_feedback( + model=model, + domain_desc=domain_desc, + llm_response=llm_response, + feedback_template=feedback_prompt, + feedback_type="llm", + action=action, + predicates=predicates, + types=type_hierarchy + ) + + if no_fb == True: + break + + else: + with open("paper_reconstructions/nl2plan/prompts/action_construction/error.txt") as f: + error_template = f.read().strip() + error_prompt = error_template.replace('{action_name}', action_name) + error_prompt = error_prompt.replace('{action_desc}', action_desc) + error_prompt = error_prompt.replace('{predicate_list}', predicate_str) + error_prompt = error_prompt.replace('{error_msg}', error_msg) + error_prompt = error_prompt.replace('{llm_response}', llm_response) + + action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + model=model, + domain_desc=domain_desc, + prompt_template=error_prompt, + action_name=action_name, + action_desc=action_desc, + action_list=action_list, + predicates=predicates, + types=type_hierarchy, + syntax_validator=syntax_validator + ) + + return action, new_predicates + + + def action_construction( + self, + model: LLM, + domain_desc: str, + act_constr_prompt: PromptBuilder, + nl_actions: dict[str,str], + type_hierarchy: dict[str,str], + feedback_prompt: str | None = None, + max_attempts: int = 2, + max_iters: int = 2 + ) -> tuple[list[Action], list[Predicate]]: + + action_list = "\n".join([f"- {name}: {desc}" for name, desc in nl_actions.items()]) + + syntax_validator = SyntaxValidator() + + predicates = [] + for iter in range(max_iters): + actions = [] + print(f"Starting iteration {iter + 1} of action construction") + curr_preds = len(predicates) + + for action_name, action_desc in nl_actions.items(): + action, new_predicates = self.construct_action( + model=model, + domain_desc=domain_desc, + act_constr_prompt=act_constr_prompt, + action_list=action_list, + action_name=action_name, + action_desc=action_desc, + predicates=predicates, + type_hierarchy=type_hierarchy, + syntax_validator=syntax_validator, + feedback_prompt=feedback_prompt, + max_attempts=max_attempts, + feedback=True + ) + actions.append(action) + predicates.extend(new_predicates) + predicates = prune_predicates(predicates, actions) + + if len(predicates) == curr_preds: + print("No new predicates created. Stopping action construction.") + break + else: + print("Reached maximum iterations. Stopping action construction.") + + return actions, predicates + + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + # nl_actions = { + # "pick_block": "The robot arm picks up a block from a surface. Requires the block to be on a surface and not currently held by the arm. Example: robot_arm picks up block_1 from table_1.", + # "place_on_table": "The robot arm places a block on a table. Requires the block to be held by the arm and the table to be clear of other blocks. Example: robot_arm places block_1 on table_1.", + # "place_on_block": "The robot arm places a block on top of another block. Requires the block to be held by the arm and the target block to be clear (not currently held or covered by another block). Example: robot_arm places block_1 on block_2.", + # "release_block": "The robot arm releases a block it is currently holding. Requires the block to be held by the arm. Example: robot_arm releases block_1." + # } + + nl_actions = {'pick_block': 'The robot arm picks up a block from the table or from on top of another block. The block must be accessible and not currently under another block. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block onto the table. The block must be held by the robot arm and the table must be clear of any other blocks in that position. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. The block being placed must be held by the robot arm, and the block it is being placed on must be stable and not currently under another block. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases the currently held block without placing it on the table or another block. This action is used to drop the block. The block is no longer held by the robot arm after this action is performed. Example: robot_arm releases block_1.', 'check_accessibility': 'The robot arm checks if a block is accessible for picking. Example: robot_arm checks if block_1 is accessible.'} + + + action_construction = ActionConstruction() + action_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") + + actions, predicates, = action_construction.action_construction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + act_constr_prompt=action_construction.prompt_template, + nl_actions=nl_actions, + type_hierarchy=hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), + max_attempts=1 + ) + + for i in actions: + print(i) + + print() + + for i in predicates: + print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py new file mode 100644 index 0000000..4d86487 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py @@ -0,0 +1,94 @@ +import os +from l2p import LLM, OPENAI +from l2p import PromptBuilder +from l2p import DomainBuilder +from l2p import FeedbackBuilder +from l2p import load_file, load_files + +class ActionExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.nl_actions = dict[str,str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_nl_actions(self, nl_actions: dict[str,str]): + self.nl_actions = nl_actions + + def action_extraction( + self, + model: LLM, + domain_desc: str, + action_extraction_prompt: PromptBuilder, + type_hierarchy: dict[str,str], + feedback_prompt: str + ) -> dict[str, str]: + + nl_actions, response = self.domain_builder.extract_nl_actions( + model=model, + domain_desc=domain_desc, + prompt_template=action_extraction_prompt.generate_prompt(), + types=type_hierarchy, + ) + + nl_actions, response_fb = self.feedback_builder.nl_action_feedback( + model=model, + domain_desc=domain_desc, + llm_response=response, + feedback_template=feedback_prompt, + feedback_type="llm", + nl_actions=nl_actions, + type_hierarchy=type_hierarchy, + ) + + return nl_actions + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + action_extraction = ActionExtraction() + action_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") + + nl_actions = action_extraction.action_extraction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + action_extraction_prompt=action_extraction.prompt_template, + type_hierarchy=hierarchy, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) + + for i in nl_actions: + print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py new file mode 100644 index 0000000..ca21e54 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py @@ -0,0 +1,77 @@ +import os +from l2p import * + +class HierarchyConstruction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.type_hierarchy = dict[str, str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_types(self, types: dict[str,str]): + self.type_hierarchy = types + + def hierarchy_construction( + self, + model: LLM, + domain_desc: str, + type_hierarchy_prompt: PromptBuilder, + types: dict[str,str], + feedback_prompt: str + ) -> dict[str, str]: + + type_hierarchy, _ = self.domain_builder.extract_type_hierarchy( + model=model, + domain_desc=domain_desc, + prompt_template=type_hierarchy_prompt.generate_prompt(), + types=types, + ) + + type_hierarchy, _ = self.feedback_builder.type_hierarchy_feedback( + model=model, + domain_desc=domain_desc, + feedback_template=feedback_prompt, + feedback_type="llm", + type_hierarchy=type_hierarchy, + llm_response="", + ) + + return type_hierarchy + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + types = { + 'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', + 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', + 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} + + hierarchy_construction = HierarchyConstruction() + hierarchy_construction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") + + type_hierarchy = hierarchy_construction.hierarchy_construction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_hierarchy_prompt=hierarchy_construction.prompt_template, + types=types, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) + + print(type_hierarchy) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py new file mode 100644 index 0000000..eb6a240 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py @@ -0,0 +1,151 @@ +import os +from l2p import * + +class TaskExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.task_builder = TaskBuilder() + self.feedback_builder = FeedbackBuilder() + self.syntax_validator = SyntaxValidator() + self.pddl_predicates = list[Predicate] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_predicates(self, predicates: list[Predicate]): + self.pddl_predicates = predicates + + def task_extraction( + self, + model: LLM, + problem_desc: str, + task_extraction_prompt: PromptBuilder, + types: dict[str,str], + predicates: list[Predicate], + feedback_prompt: str, + error_prompt: str, + max_attempts: int = 8 + ) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: + + objects, initial, goal, llm_response = self.task_builder.extract_task( + model=model, + problem_desc=problem_desc, + prompt_template=task_extraction_prompt.generate_prompt(), + types=format_types(types), + predicates=predicates + ) + + all_valid = True + for _ in range(max_attempts): + + feedback_msgs = [] + all_valid = True + types_list = format_types(types) + types_list = {k: types_list[k] for i, k in enumerate(types_list) if i != 0} + + # list of validation checks + validation_checks = [ + self.syntax_validator.validate_task_objects(objects, types_list), + self.syntax_validator.validate_task_states(initial, objects, predicates, "initial"), + self.syntax_validator.validate_task_states(goal, objects, predicates, "goal"), + ] + + # Perform each validation check + for validator, args in validation_checks: + is_valid, feedback_msg = validator, args + if not is_valid: + all_valid = False + feedback_msgs.append(feedback_msg) + + # If any check fails, append feedback messages + if not all_valid: + error_prompt = error_prompt.replace("{error_msg}", str(feedback_msgs)) + error_prompt = error_prompt.replace("{task}", "goal and state extraction") + objects, initial, goal, _ = self.feedback_builder.task_feedback( + model=model, + problem_desc=problem_desc, + llm_response=llm_response, + feedback_template=error_prompt, + feedback_type="llm" + ) + + else: break + + if not all_valid: + raise ValueError(f"Validation failed: {feedback_msgs}") + + objects, initial, goal, _ = self.feedback_builder.task_feedback( + model=model, + problem_desc=problem_desc, + llm_response=llm_response, + feedback_template=feedback_prompt, + feedback_type="llm", + predicates=predicates, + types=types, + objects=objects, + initial=initial, + goal=goal, + ) + + objects = self.task_builder.format_objects(objects) + initial = self.task_builder.format_initial(initial) + goal = self.task_builder.format_goal(goal) + + return objects, initial, goal + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + hierarchy = { + 'object': 'Object is always root, everything is an object', + 'children': [ + {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', + 'children': [ + {'block': 'A type of movable_object.', 'children': []} + ] + }, + {'surface': 'A parent type for all surfaces, including tables.', + 'children': [ + {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} + ] + } + ] + } + + + predicates = [{'name': 'on_surface', 'desc': 'true if the block ?b is on the surface ?s', 'raw': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s', 'params': OrderedDict([('?b', 'block'), ('?s', 'surface')]), 'clean': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s'}, + {'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm'}, + {'name': 'movable', 'desc': "'The block is movable (not under another block)'", 'raw': "(movable ?b - block): 'The block is movable (not under another block)'", 'params': OrderedDict([('?b', 'block')]), 'clean': "(movable ?b - block): 'The block is movable (not under another block)'"}, + {'name': 'on_block', 'desc': "'Indicates that block ?b is placed on top of block ?b2'", 'raw': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'", 'params': OrderedDict([('?b', 'block'), ('?b2', 'block')]), 'clean': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'"}] + + task_extraction = TaskExtraction() + task_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") + + object, initial, goal = task_extraction.task_extraction( + model=openai_llm, + problem_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/task1.txt"), + task_extraction_prompt=task_extraction.prompt_template, + types=hierarchy, + predicates=predicates, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), + error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") + ) + + print(object) + print(initial) + print(goal) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py new file mode 100644 index 0000000..53055e5 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py @@ -0,0 +1,73 @@ +import os +from l2p import LLM, OPENAI +from l2p import PromptBuilder +from l2p import DomainBuilder +from l2p import FeedbackBuilder +from l2p import load_file, load_files + +class TypeExtraction: + def __init__(self): + self.prompt_template = PromptBuilder() + self.domain_builder = DomainBuilder() + self.feedback_builder = FeedbackBuilder() + self.types = dict[str, str] + + def set_prompt(self, role_path: str, examples_path: str, task_path: str): + + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + self.prompt_template.set_role(role=role) + for ex in examples: + self.prompt_template.set_examples(example=ex) + self.prompt_template.set_task(task=task) + + def set_types(self, types: dict[str,str]): + self.types = types + + def type_extraction( + self, + model: LLM, + domain_desc: str, + type_extraction_prompt: PromptBuilder, + feedback_prompt: str + ) -> tuple[dict[str, str], str]: + + types, _ = self.domain_builder.extract_type( + model=model, + domain_desc=domain_desc, + prompt_template=type_extraction_prompt.generate_prompt() + ) + + types, _ = self.feedback_builder.type_feedback( + model=model, + domain_desc=domain_desc, + feedback_template=feedback_prompt, + feedback_type="llm", + types=types, + llm_response="", + ) + + return types + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + + openai_llm = OPENAI(model=engine, api_key=api_key) + + type_extraction = TypeExtraction() + type_extraction.set_prompt( + role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") + + types = type_extraction.type_extraction( + model=openai_llm, + domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + type_extraction_prompt=type_extraction.prompt_template, + feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) + + print(types) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt index dce1b5c..ec6fc09 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt @@ -1,5 +1,5 @@ ## Error -There was an issue with or feedback for generating the specified action. Correct the following error and regenerate the action, using the exact same headers. Remember that you MUST reuse all the headers ("Action Parameters", "Action Preconditions", "Action Effects" and "New Predicates") +There was an issue with or feedback for generating the specified action. Correct the following error and regenerate the action, using the exact same headers. Remember that you MUST reuse all the headers ("### Action Parameters", "### Action Preconditions", "### Action Effects" and "### New Predicates") {error_msg} @@ -13,4 +13,5 @@ Make sure to reply with all four parts of the action: parameters, preconditions, ### Available Predicates {predicate_list} -### Response \ No newline at end of file +### Original Response +{llm_response} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt similarity index 83% rename from paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt index fc0c88a..4445a1e 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/examples/example1.txt @@ -1,38 +1,26 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. - -Given type hierarchy: -{ - "object": "Object is always root, everything is an object", - "children": [ - { - "worker": "A type of object consisting of humans who do things.", - "children": [ - {"administrator": "A type of worker.", "children": []}, - {"general_worker": "A type of worker.", "children": []} - ] - }, - {"vehicle": "A type of object consisting of vehicles.", "children": []}, - { - "location": "A type of object consisting of places which can be visited.", - "children": [ - {"house": "A type of location.", "children": []} - ] - } - ] -} - -Given action: description -drive: A vehicle drives from a location to another. Requires that the vehicle is at the starting location and that the two locations are connected. Example: truck1 drives from loc1 to house1. +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport workers. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +- object: Everything is an object + - worker: Human workers which do things + - administrator: Workers who can create orders for other workers + - general_worker: Workers who can perform a variety of tasks, if there is an order for it + - vehicle: Used to transport workers + - location: Places where workers and machines can be + - house: What is constructed. + +## Action +drive + +A vehicle drives from a location to another. Requires that the vehicle is at the starting location and that the two locations are connected. Example: truck1 drives from loc1 to house1. ### Available Predicates No predicate has been defined yet ------------------------------------------------------ - -Get predicates: +### Action Parameters Well, first we need to know which vehicle is travelling. ``` - ?v - vehicle: The vehicle travelling @@ -44,7 +32,7 @@ Then, we need to know where it's travelling to and from. Any type of location (b - ?to - location: The location travelling to ``` -Get preconditions: +### Action Preconditions To be able to drive from ?from to ?to it's specified that: 1: The truck has to be at the starting location. 2: The two locations have to be connected. @@ -67,7 +55,7 @@ Let's specify this in PDDL: ) ``` -Get effects: +### Action Effects So, what happens when the action is performed? - The vehicle is no longer at ?from. - The vehicle is now at ?to. @@ -82,7 +70,7 @@ Let's write the PDDL: ) ``` -State new predicates: +### New Predicates We used several new predicates. Those have to be specified formally here. The first predicate we created is "at" which shows where something is. To make it compatible for both vehicles and workers, we use the general object type. @@ -169,7 +157,6 @@ These are the exact same as above, but they need to be reiterated: ``` ### New Predicates -These are the same as before: ``` - (at ?o - object ?l - location): true if the object ?o (a vehicle or a worker) is at the location ?l - (connected ?l1 - location ?l2 - location): true if a road exists between ?l1 and ?l2 allowing vehicle travel between them. diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt b/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt index 2d938d3..c5b1933 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt @@ -1,7 +1,7 @@ # Role -You are a PDDL expert and will be given a set of PDDL actions to correct and give feedback and advice on. Consider not only if the actions are technically correct, but also whether they are defined following good standards such as flexibility and clarity. Overly specifying types by use of "is-type" predicates should generally be avoided. Remember that the preconditions should make sure that only valid objects are passed to the action, we can't assume anything except the provided types. Don't assume any restrictions beyond those specified by the domain itself. Don't unnecessarily overcomplicate the actions. Note that creating new options isn't possible. If the action is well defined, respond with "No feedback". +You are a PDDL expert and will be given a set of PDDL actions to correct and give feedback and advice on. Consider not only if the actions are technically correct, but also whether they are defined following good standards such as flexibility and clarity. Overly specifying types by use of "is-type" predicates should generally be avoided. Remember that the preconditions should make sure that only valid objects are passed to the action, we can't assume anything except the provided types. Don't assume any restrictions beyond those specified by the domain itself. Don't unnecessarily overcomplicate the actions. Note that creating new options isn't possible. If the action is well defined, respond with "No feedback" under header '# JUDGEMENT'. -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +IMPORTANT: Duplicate predicates are acceptable and should not be considered as a suggestion/judge to fix. Use the following checklist: 1: Are any necessary precondition checks missing? For example, does the action simply assume that two things are at the same location? @@ -41,6 +41,7 @@ A ranger guards a location from poachers. The ranger has to be at the location. - ?l - location: The location to guard. ``` + #### Action Preconditions ``` (and @@ -78,6 +79,7 @@ A ranger guards a location from poachers. The ranger has to be at the location. 6: Should any predicate be used in a symmetrical manner? None of the predicates are symmetrical. Therefore: No. +# JUDGEMENT My concrete suggestions are: - Remove the check for "(at ?l ?l)" from the preconditions. - Remove "(not (at ?r ?l))" from the effect. @@ -139,7 +141,6 @@ A truck driver from point A to point B. They need to be connected by a road and ) ``` - ### Feedback 1: Are any necessary precondition checks missing? The action explicitly states the truck has to be at the starting location, which also makes sense, but this is never checked. Thereby: Yes. @@ -159,6 +160,7 @@ A truck driver from point A to point B. They need to be connected by a road and 6: Should any predicate be used in a symmetrical manner? Since roads are undirected, we need to check if there is a road from ?from to ?to or vice versa. Not doing so creates brittle PDDL. This should always be done under symmetry. As such: Yes. +# JUDGEMENT You should take the following concrete steps: - Check that the truck is actually at the starting location by adding "(at ?t ?from)" to the precondition. - Make sure that both directions are checked for a road by replacing "(road_between ?from ?to)" with "(or (road_between ?from ?to) (road_between ?to ?from))" @@ -232,16 +234,14 @@ An elevator picks up a person at a floor where they both are. Example: elevator_ 6: Should any predicate be used in a symmetrical manner? None of the predicates have symmetries of that sort. The answer is: No. +# JUDGEMENT Therefore: No feedback. ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Available types +## Available Types {types} ## Available Predicates @@ -250,21 +250,24 @@ The following are the predicates which could be used: You can also suggest new predicates to add. -## Action name +## Action {action_name} -### Action Parameters you gave -{parameters} +{action_desc} + +### Action Parameters +``` +{action_params} +``` -### Action Preconditions you gave +### Action Preconditions ``` {action_preconditions} ``` -### Action Effects you gave +### Action Effects ``` {action_effects} ``` -## Original LLM response -{llm_response} \ No newline at end of file +### Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt index c579e32..025af9a 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt @@ -1,31 +1,36 @@ -You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in a simple, intuitive and readable way as well as to avoid symmetrical constraints, so (same_room ?b1 - block ?b2 - block2 ?r - room) should instead be modelled with two predicates, (in_room ?b1 - block ?r - room) and (in_room ?b2 - block ?r - room). Note that creating new actions is not an option. Your end response should not contain random words/characters not found in a PDDL file. +You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in a simple, intuitive and readable way as well as to avoid symmetrical constraints, so (same_room ?b1 - block ?b2 - block2 ?r - room) should instead be modelled with two predicates, (in_room ?b1 - block ?r - room) and (in_room ?b2 - block ?r - room). Note that creating new actions is not an option. -No generated types should be of 'object' but their respective types +Think through your choices and comment on them as you go. -Every action given must be defined. Think through your choices and comment on them as you go. There should not be any unnecessary words in the final output such as "pddl" or "lisp" - -End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. Follow the exact example syntax as the following: +End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. There must be 3 hastags (#) being used `###`. Here is an example: ### Action Parameters ``` -- ?v - vehicle: The vehicle travelling +- ?t - type: 'parameter_description' ``` ### Action Preconditions ``` (and - (at ?v ?from) ; The vehicle is at the starting location + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION ) ``` ### Action Effects ``` (and - (not (at ?v ?from)) ; ?v is no longer at ?from + (predicate_name ?t1 ?t2) ; COMMENT DESCRIPTION ) ``` ### New Predicates ``` -- (at ?o - object ?l - location): true if the object ?o (a vehicle or a worker) is at the location ?l +- (predicate_name ?t1 - type_1 ?t2 - type_2): 'predicate_description' +``` + +IMPORTANT: If there are no new predicates created, keep an empty space enclosed ``` ``` with the '### New Predicates' header like so: + +### New Predicates +``` + ``` \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/task.txt b/paper_reconstructions/nl2plan/prompts/action_construction/task.txt index 3c05c8e..d7696d9 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/task.txt @@ -1,17 +1,17 @@ -## Domain +## Domain {domain_desc} -## Available types +## Types {types} -## Future actions to be implemented later +## Future Actions +The following actions will be defined later and together they make up the entire domain: {action_list} -## Action name +## Action {action_name} -## Action description {action_desc} -## Available predicates +### Available Predicates {predicates} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt b/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt deleted file mode 100644 index 800b1e7..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_construction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for constructing a PDDL action: - -1. Construct action parameters and create necessary predicates to produce action preconditions in PDDL -2. Construct necessary predicates to produce action effects in PDDL -3. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -4. Re-iterate parameters, preconditions, effects, and predicates \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt deleted file mode 100644 index 12454d5..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example.txt +++ /dev/null @@ -1,149 +0,0 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport the workers. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. - -Given types: -- object: Everything is an object - - worker: Human workers which do things - - administrator: Workers who can create orders for other workers - - general_worker: Workers who can perform a variety of tasks, if there is an order for it - - order: Instructions to general_workers to perform something. Created by administrators - - vehicle: Used to transport workers. - - location: Places where workers and machines can be - - house: What is constructed. Can be finalised when all components are built - - depot: Where material is stored and vehicles can be loaded - -Given actions: -No actions available. - ------------------------------------------------------ - -1. Iterate over parent types and extract actions: -### Worker related actions -There are two general types of workers, administrators and general_workers. - -The adminstrators have one task, to create orders. -``` -create_order: An administrator creates a new order for something. Example: administrator_1 creates a build_floor_order for house_0. -``` - -The other workers can perform a wide array of construction work, given an order. - -They can build floors. -``` -build_floor: A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. -``` - -They can build walls. -``` -build_wall: A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. -``` - -They can build roofs. -``` -build_roof: A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. -``` - -Those are all the actions the workers can perform directly. - -### Order related actions -The orders don't have any other actions. - -### Vehicle related actions -There are probably a lot of types of vehicles, but to transport things they all have to be able to move. -``` -move_vehicle: A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. -``` - -This lets the vehicles move. - -### Material related actions -The materials don't have any other actions assosiated with them. - -### House component related actions -The components can't do anything by themselves. - -### Location related actions -The depot don't have any actions, however the house can be finalised. -``` -finalise_house: The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. -``` - -2. Feedback - 1: Are there any more actions needed for this domain? Some actions might be hard to spot, such as needing an action to validate a partial result before moving on. - Yes. For the vehicles to be able to transport workers we need to add actions to allow workers to step on and off the vehicles, "enter_vehicle" and "exit_vehicle". Definitions are given below. - - 2: Should any of the actions be split or combined? To model actions in PDDL its sometimes required to split it into three parts, one which initiates the action, one which performs a part of the action and is usually repeated, and lastly an action ending the action. - Yes. In PDDL it's not functional to have a single "create_order" action for all parts of the house (floor, walls, roof and finalisation). The results of applying the action have to be simple, so we'll split it into "order_floor" and so on. - - 3: Should any of the actions be removed? For example, actions which model irrelevant details. - Yes. The "build_floor" action should be removed since building floors isn't needed. - - 4: Should the actions and constraints be clarified or the examples modified? Are they currently unclear or missing objects? - No. The action descriptions and constraints are stated. - - 5: Should any preconditions be changed? For example, are any preconditions such as object states or action ordering missing? Are any unnecessary preconditions included? - 6: Should any effects be changed? For example, is some effect forgotten? Is any any incorrect effect included? - -3. My concrete suggestions are the following: - - Add the following two vehicle-related actions: - - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. - - exit_vehicle: A worker exits a vehicle at the vehicle's location. Example: worker_8 exits truck_5 at house_7. - - Remove the "build_floor" action. - - Remove the "create_order" action. - - Replace the "create_order" action with the following four actions: - - create_floor_order: An administrator creates an order to build a floor at a house. The administrator doesn't have to be there. Example: administrator_2 creates an order the floor at house_8. - - create_wall_order: An administrator creates an order to build walls at a house. The administrator doesn't have to be there. Example: administrator_3 creates an order to build walls at house_9. - - create_roof_order: An administrator creates an order to build a roof at a house. The administrator doesn't have to be there. Example: administrator_4 creates an order to build roofs at house_10. - - create_finalize_order: An administrator creates an order to finalize a house. The administrator doesn't have to be there. Example: administrator_5 creates an order to finalizes house_11. - -Response: the feedback raises some valid points, but not all are correct. Splitting the "create_order" action is indeed better PDDL modelling. Similarly, the "enter_vehicle" and "exit_vehicle" do have to be provided. However, the build_floor action is needed for the domain and should be kept. - -### New Actions -We also create the new actions to allow for workers to travel within vehicles. - -``` -enter_vehicle: A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3. -``` - -``` -exit_vehicle: A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5. -``` - -Lastly, we split the "create_order" action into four pieces, one per order type. - -``` -create_floor_order: An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12. -``` - -``` -create_wall_order: An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12. -``` - -``` -create_roof_order: An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13. -``` - -``` -create_finalize_order: An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14. -``` - -These are all the actions needed for the domain. - -4. Re-Iterated actions into Python dictionary: - -## OUTPUT -{ - 'build_floor: 'A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists.', - 'build_wall': 'A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists.', - 'build_roof': 'A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists.', - 'move_vehicle': 'A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1.', - 'finalise_house': 'The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9.', - 'enter_vehicle': 'A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3.', - 'exit_vehicle': 'A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5.', - 'create_floor_order': 'An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12.', - 'create_wall_order': 'An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12.', - 'create_roof_order': 'An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13.', - 'create_finalize_order': An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14.', -} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt new file mode 100644 index 0000000..88c0536 --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/examples/example1.txt @@ -0,0 +1,198 @@ +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport the workers. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +- object: Everything is an object + - worker: Human workers which do things + - administrator: Workers who can create orders for other workers + - general_worker: Workers who can perform a variety of tasks, if there is an order for it + - order: Instructions to general_workers to perform something. Created by administrators + - vehicle: Used to transport workers. + - location: Places where workers and machines can be + - house: What is constructed. Can be finalised when all components are built + - depot: Where material is stored and vehicles can be loaded + +## Actions: +### Worker related actions +There are two general types of workers, administrators and general_workers. + +The adminstrators have one task, to create orders. +``` +create_order + +An administrator creates a new order for something. Example: administrator_1 creates a build_floor_order for house_0. +``` + +The other workers can perform a wide array of construction work, given an order. + +They can build floors. +``` +build_floor + +A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. +``` + +They can build walls. +``` +build_wall + +A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. +``` + + +They can build roofs. +``` +build_roof + +A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. +``` + +Those are all the actions the workers can perform directly. + +### Order related actions +The orders don't have any other actions. + +### Vehicle related actions +There are probably a lot of types of vehicles, but to transport things they all have to be able to move. +``` +move_vehicle + +A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. +``` + +This lets the vehicles move. + +### Material related actions +The materials don't have any other actions assosiated with them. + +### House component related actions +The components can't do anything by themselves. + +### Location related actions +The depot don't have any actions, however the house can be finalised. +``` +finalise_house + +The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. +``` + +## Feedback +1: Are there any more actions needed for this domain? + Yes. For the vehicles to be able to transport workers we need to add actions to allow workers to step on and off the vehicles, "enter_vehicle" and "exit_vehicle". Definitions are given below. + +2: Should any of the actions be split or combined? + Yes. In PDDL it's not functional to have a single "create_order" action for all parts of the house (floor, walls, roof and finalisation). The results of applying the action have to be simple, so we'll split it into "order_floor" and so on. + +3: Should any of the actions be removed? + Yes. The "build_floor" action should be removed since building floors isn't needed. + +4: Should the actions and constraints be clarified or the examples modified? + No. The action descriptions and constraints are stated. + +My concrete suggestions are the following: + - Add the following two vehicle-related actions: + - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. + - exit_vehicle: A worker exits a vehicle at the vehicle's location. Example: worker_8 exits truck_5 at house_7. + - Remove the "build_floor" action. + - Remove the "create_order" action. + - Replace the "create_order" action with the following four actions: + - create_floor_order: An administrator creates an order to build a floor at a house. The administrator doesn't have to be there. Example: administrator_2 creates an order the floor at house_8. + - create_wall_order: An administrator creates an order to build walls at a house. The administrator doesn't have to be there. Example: administrator_3 creates an order to build walls at house_9. + - create_roof_order: An administrator creates an order to build a roof at a house. The administrator doesn't have to be there. Example: administrator_4 creates an order to build roofs at house_10. + - create_finalize_order: An administrator creates an order to finalize a house. The administrator doesn't have to be there. Example: administrator_5 creates an order to finalizes house_11. + +## Response +The feedback raises some valid points, but not all are correct. Splitting the "create_order" action is indeed better PDDL modelling. Similarly, the "enter_vehicle" and "exit_vehicle" do have to be provided. However, the build_floor action is needed for the domain and should be kept. + +## Actions + +### Re-Iterated Actions +These are the actions which are kept unchanged from before. + +``` +build_floor + +A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists. +``` + +``` +build_wall + +A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists. +``` + +``` +build_roof + +A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists. +``` + +``` +move_vehicle + +A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1. +``` + +``` +finalise_house + +The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9. +``` + +### New Actions +We also create the new actions to allow for workers to travel within vehicles. + +``` +enter_vehicle + +A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3. +``` + +``` +exit_vehicle + +A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5. +``` + +Lastly, we split the "create_order" action into four pieces, one per order type. + +``` +create_floor_order + +An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12. +``` + +``` +create_wall_order + +An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12. +``` + +``` +create_roof_order + +An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13. +``` + +``` +create_finalize_order + +An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14. +``` + +## OUTPUT +{ + "build_floor": "A worker performs an order to build a floor. Requires the worker to be there and for a build_floor_order for the house to exist. Example: worker_1 builds a floor at house_1 given that a build_floor_order for it exists.", + "build_wall": "A worker performs an order to build a wall. Requires the worker to be there and for a build_wall_order for the house to exist. Example: worker_2 builds a wall at house_2 given that a build_wall_order for it exists.", + "build_roof": "A worker performs an order to build a roof. Requires the worker to be there and for a build_roof_order for the house to exist. Example: worker_3 builds a roof at house_3 given that a build_roof_order for it exists." + "move_vehicle": "A vehicle moves from point A to point B. Example: truck_1 moves from house_1 to depot_1.", + "finalise_house": "The house is finalised (walls painted, interior prepared and so on). Requires all the house_components (floor, wall and roof) to be built there already, a corresponding order and a worker on site. Example: house_4 is finalised by worker_9.", + "enter_vehicle": "A worker enters a vehicle, allowing them to travel with it. They both need to be at the same location. Example: worker_4 enters truck_3 at depot_3.", + "exit_vehicle": "A worker exits a vehicle at that vehicle's location. Example: worker_5 exits lorry_2 at house_5.", + "create_floor_order": "An administrator creates an order to build the floor at a location. Example: administrator_6 creates a build_floor_order for house_12.", + "create_wall_order": "An administrator creates an order to build the wall at a location. Example: administrator_7 creates a build_wall_order for house_12.", + "create_roof_order": "An administrator creates an order to build the roof at a location. Example: administrator_8 creates a build_roof_order for house_13.", + "create_finalize_order": "An administrator creates an order to build the finalize at a location. Example: administrator_9 creates a finalize_order for house_14.", +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt index 77efba9..79689d3 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt @@ -1,7 +1,5 @@ # Role -You will be given a set of which are used for a PDDL domain. You should evaluate if they make up all the actions necessary for the given domain, or if any new actions have to be created or existing actions removed. Describe your thought process and comments your suggestions. Focus only on the actions currently, predicates will be specified at a later date. Be careful not to over complicate any domains, adding actions simply for complexity/completeness when they're not needed for the domain should be avoided, we're making a simplified model. Keep the essentials. If the actions are well defined, simply respond with "No feedback". - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +You will be given a set of which are used for a PDDL domain. You should evaluate if they make up all the actions necessary for the given domain, or if any new actions have to be created or existing actions removed. Describe your thought process and comments your suggestions. Focus only on the actions currently, predicates will be specified at a later date. Be careful not to over complicate any domains, adding actions simply for complexity/completeness when they're not needed for the domain should be avoided, we're making a simplified model. Keep the essentials. If the actions are well defined, simply respond with "No feedback" under header '# JUDGEMENT'. Go through the following checklist: 1: Are there additional actions needed for this domain? Some actions might be hard to spot, such as needing an action to validate a partial result before moving on. @@ -55,6 +53,7 @@ Currently, there are a couple of trucks at the Chicago depot and we're trying to 6: Should any action examples be modified? In the "move_vehicle" action, the example only illustrates where the vehicle is movin from. It should also include where it is moving to. Hence: Yes. +# JUDGEMENT My concrete suggestions are the following: - Add the following two vehicle-related actions: - enter_vehicle: A worker enters a vehicle while at the vehicle's location. Example: worker_7 enters truck_4 at house_6. @@ -103,6 +102,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo 6: Should any action examples be modified? The examples are all good. Therefore: No. +# JUDGEMENT I'd advice you change the following: - Remove the "generate_relocation_strategy" action. - Change the description of the following: @@ -142,20 +142,18 @@ I've got a building with five floors and two elevators, and I want you to plan t 6: Should any action examples be modified? All examples involve the relevant objects and clearly specify what happens. Thereby: No. -As such: No feedback. - ----------------------------------------- +# JUDGEMENT +No feedback. -Here is the original output: +# Task ## Domain {domain_desc} -## Available types +## Available Types {types} -## Actions you gave +## Actions {nl_actions} -## Original LLM response -{llm_response} \ No newline at end of file +### Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt index 1eb6e1d..a403249 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/role.txt @@ -1,6 +1,12 @@ -Your role is to identify what actions an AI Agent would have available in a domain. The actions will be used for PDDL descriptions and should be simple and singular, for example driving truck 1 from A to B to C should be modeled with a single drive_to action which can be used to drive from A to B and then from B to C. However, if two similar actions exists but they require different pre-conditions or effects, these should be modelled separetely, for example should "move" not be used for both a person and vehilces movement, as these will have different preconditions on terrain. Each action should be specified within its own markdown block where the first line is the name, the second is an empty line and the final line is a description with example. Make sure to include any requirements or conditions for the action to be feasible within the explanation. Be concrete and explain your thoughts as you go. Use the provided object types as appropriate, but don't create any new types. Any actions involving 'checking' should not be considered an action, because that is a predicate in PDDL. Only suggest actions that cannot be described by a predicate. +Your task is to identify what actions an AI Agent would have available in a domain. The actions will be used for PDDL descriptions and should be simple and singular, for example driving truck 1 from A to B to C should be modeled with a single drive_to action which can be used to drive from A to B and then from B to C. However, if two similar actions exists but they require different pre-conditions or effects, these should be modelled separetely, for example should "move" not be used for both a person and vehilces movement, as these will have different preconditions on terrain. Each action should be specified within its own markdown block where the first line is the name, the second is an empty line and the final line is a description with example. Make sure to include any requirements or conditions for the action to be feasible within the explanation. Be concrete and explain your thoughts as you go. Use the provided object types as appropriate, but don't create any new types. -Do not attempt to solve the task, even if instructed to do so. Only define the actions. -If there are available actions, do not alter them. Add those to the final answer. +Reply only within the "Actions" heading. Do not attempt to solve the task, even if instructed to do so. -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'action_name':'action_description'}' +End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'action_name':'action_description'}' as so: + +## OUTPUT +{ + "action_name_1": "action_description", + "action_name_2": "action_description", + "action_name_3": "action_description" +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt index 0958549..ff0c18f 100644 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/action_extraction/task.txt @@ -1,5 +1,8 @@ -{domain_desc} +These are all the actions needed for the domain. -{types} +# Task +## Domain +{domain_desc} -{nl_actions} \ No newline at end of file +## Types +{types} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt deleted file mode 100644 index 33e5405..0000000 --- a/paper_reconstructions/nl2plan/prompts/action_extraction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for extracting PDDL actions in natural language: - -1. Iterate over each parent type. Within each parent type, elaborate further descrptions of the subtypes and assign possible related actions in domain. Specifically, assign their action names and a short description of what that action does in the format ''' [ACTION] '''. -2. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -3. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding actions) -4. Re-iterate over the actions and put them into a Python dictionary pair '{'action_name':'action_description'}'. Keep the actions the same if they do not need to be modified. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/blocksworld.txt b/paper_reconstructions/nl2plan/prompts/blocksworld.txt deleted file mode 100644 index e4b544f..0000000 --- a/paper_reconstructions/nl2plan/prompts/blocksworld.txt +++ /dev/null @@ -1,6 +0,0 @@ -The robot has four actions: pickup, putdown, stack, and unstack. The domain assumes a world where there are a set of blocks that can be stacked on top of each other, an arm that can hold one block at a time, and a table where blocks can be placed. -The actions defined in this domain include: -pickup: allows the arm to pick up a block from the table if it is clear and the arm is empty. After the pickup action, the arm will be holding the block, and the block will no longer be on the table or clear. -putdown: allows the arm to put down a block on the table if it is holding a block. After the putdown action, the arm will be empty, and the block will be on the table and clear. -stack: allows the arm to stack a block on top of another block if the arm is holding the top block and the bottom block is clear. After the stack action, the arm will be empty, the top block will be on top of the bottom block, and the bottom block will no longer be clear. -unstack: allows the arm to unstack a block from on top of another block if the arm is empty and the top block is clear. After the unstack action, the arm will be holding the top block, the top block will no longer be on top of the bottom block, and the bottom block will be clear. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt b/paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt deleted file mode 100644 index ee1d196..0000000 --- a/paper_reconstructions/nl2plan/prompts/blocksworld_p1.txt +++ /dev/null @@ -1 +0,0 @@ -There are four blocks currently. The blue block is on the red which is on the yellow. The yellow and the green are on the table. I want the red on top of the green. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt similarity index 70% rename from paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt index 3cb1ab9..f5981bb 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples/example1.txt @@ -1,9 +1,8 @@ -The following is an in-context example following the CoT technique. - -Given domain: +## Domain The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. -Given types: +## Types +The types are: - administrator: Workers who can create orders for other workers - wall: The exterior of a house. Requires a floor to be built first - order: Instructions to general_workers to perform something. Created by administrators @@ -18,18 +17,20 @@ Given types: - mansion: A large type of house - library: A building filled with books ------------------------------------------------------ - -1. Reasoning +## Reasoning The "administrator" and "general_worker" are both types of human workers, so we should probably create a "worker" meta-type class for those. + Furthermore, there are several different types of "house_component": "floor", "roof", and "wall". However, these aren't a subtype of "house" since a "floor" is not a "house" for example. + On the other hand, there are actually two subtypes of "house": "mansion" and "library". Both of these are types of houses. + Additionally, "house" and "depot" are both types of locations which can be visited. So, they're subtypes of "location". + "vehicle" is not a subtype or meta-type to any of the others. Same thing holds for "order". -2. Hierarchy +## Hierarchy So, all in all the hierarchy becomes: - +``` - object: Object is always root, everything is an object - worker: A type of object consisting of humans who do things. - administrator: A type of worker. @@ -44,26 +45,30 @@ So, all in all the hierarchy becomes: - house: A type of location. - mansion: A type of house. - library: A type of house. - - depot: A type of location. + - depot: A type of location. +``` + +## Feedback +1: Is any child NOT a subtype of its parent? + No. This is correct. -3. Feedback - 1: Is any child NOT a subtype of its parent? - No. This is correct. +2: Is any subtype NOT a child of its meta-type? + Yes. Depot is a type of location, and as such it should be a subtype and child of location. This has to be corrected. - 2: Is any subtype NOT a child of its meta-type? - Yes. Depot is a type of location, and as such it should be a subtype and child of location. This has to be corrected. +3: Are any new types needed for organisation? + Yes. There should be a meta-type called "construction_equipment" which includes both "house_component" and "vehicle" since these are used to build with. - 3: Are any new types needed for organisation? - Yes. There should be a meta-type called "construction_equipment" which includes both "house_component" and "vehicle" since these are used to build with. +My advice is that you perform the following concrete changes: + - Move the "depot" type to be a subtype of "location". + - Add a "construction_equipment" meta-type with "house_component" and "vehicle" as subtypes. - My advice is that you perform the following concrete changes: - - Move the "depot" type to be a subtype of "location". - - Add a "construction_equipment" meta-type with "house_component" and "vehicle" as subtypes. +Start with a "## Response" header, then re-iterate an updated version of the "## Hierarchy" header. -4. Response: +## Response The feedback is partially correct. Moving the "depot" type is valid and should be done. However, adding "construction_equipment" would group objects which behave too differently. -5. Re-iterate and convert to nested Python dictionary: +## Hierarchy +As such, the corrected hierarchy becomes: ``` - object: Object is always root, everything is an object - worker: A type of object consisting of humans who do things. @@ -82,6 +87,10 @@ The feedback is partially correct. Moving the "depot" type is valid and should b - depot: A type of location. ``` +Organize a dependency tree for the class hierarchy between different objects within a PDDL domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. You shouldn't create any new types except those needed for organisation of the provided types. + +End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: + ## OUTPUT { "object": "Object is always root, everything is an object", @@ -93,8 +102,12 @@ The feedback is partially correct. Moving the "depot" type is valid and should b {"general_worker": "A type of worker.", "children": []} ] }, - {"order": "A type of object consisting of instructions.", "children": []}, - {"vehicle": "A type of object consisting of vehicles.", "children": []}, + { + "order": "A type of object consisting of instructions.", "children": [] + }, + { + "vehicle": "A type of object consisting of vehicles.", "children": [] + }, { "house_component": "A type of object consisting of the components of a house.", "children": [ @@ -107,14 +120,16 @@ The feedback is partially correct. Moving the "depot" type is valid and should b "location": "A type of object consisting of places which can be visited.", "children": [ { - "house": "A type of location. ", + "house": "A type of location.", "children": [ {"mansion": "A type of house.", "children": []}, - {"library": "A type of house.", "children": []} + {"library": "A type of house.", "children": []}, ] }, - {"depot": "A type of location.", "children": []} + { + "depot": "A type of location.", "children": [] + } ] } ] -} +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt index 1620fca..8307947 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt @@ -1,6 +1,5 @@ -Your task is to evaluate if a type hierarchy is defined in the best way. You can suggest changing of the structure or adding types. Note that everything is always supposed to be a subtype of the 'object' class. You shouldn't suggest any new types except those needed for organisation of the provided types. - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +# Role +Your task is to evaluate if a type hierarchy is defined in the best way. You can suggest changing of the structure or adding types. If the hierarchy is optimal, respond with "No feedback" under header '# JUDGEMENT'. Note that everything is always supposed to be a subtype of the "object" class. You shouldn't suggest any new types except those needed for organisation of the provided types. Go through the following checklist: 1: Is any child not a subtype of its parent? For example, "house" is defined as a subtype of "city". Often this is due to the child being physically inside the parent. @@ -28,6 +27,7 @@ I've got a building with five floors and two elevators, and I want you to plan t 3: Are any new types needed for organisation? The types are all distinct, and as such no organisation type is needed. Due to this: No. +# JUDGEMENT Therefore: No feedback. ## Example 2 @@ -56,6 +56,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo 3: Are any new types needed for organisation? Both "ranger" and "veterinarian" are mentioned to be workers, but the worker class isn't included. It should be included as a parent type and parent of both "ranger" and "veterinarian". Due to this: Yes. +# JUDGEMENT My advice is that you perform the following concrete changes: - Move the "fish" type and all its subtypes to be subtypes and children of "animal". - Add a "worker" parent type as a parent of both "ranger" and "veterinarian". @@ -81,18 +82,15 @@ The AI agent is here a scheduling system for a house construction company. 3: Are any new types needed for organisation? Since there are no subtypes, we don't need any organisational types. As such: No. +# JUDGEMENT My advice is that you perform the following concrete change: - Move the "house" type away from the "city" type. "house" should not be a subtype of "city". ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Types you gave +## Types {types} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt index 0be8846..62a1210 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt @@ -1,21 +1,5 @@ -Your role is to organize a dependency tree for the class hierarchy between different objects within a PDDL domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. You shouldn't create any new types except those needed for organisation of the provided types. A location and object should not be the same types. +Your task is to organize a dependency tree for the class hierarchy between different objects within a domain. Do not expand on your reasoning, except as short comments. Each object should appear only once, even if it could belong to several types. Note, that every child should be a subtype of its parent, not physically contained within the parent. Respond with the tree in the "## Hierarchy" header within "```". Start the tree with "object", everything is a subtype of object. You shouldn't create any new types except those needed for organisation of the provided types. -Think through the types and their relationships. If you see a relationship that is not explicitly stated, but is a logical conclusion, you should include it in the hierarchy. +Do not attempt to solve the task, even if instructed to do so. Only extract the types. -It is extremely crucial that an action term is not considered a type, so it should not be considered in the type hierarchy. - -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: - -## OUTPUT (example) -{ - "object": "Object is always root, everything is an object", - "children": [ - { - "worker": "A type of object consisting of humans who do things.", - "children": [ - {"administrator": "A type of worker.", "children": []}, - {"general_worker": "A type of worker.", "children": []} - ] - } - ] -} +Think through the types and their relationships. If you see a relationship that is not explicitly stated, but is a logical conclusion, you should include it in the hierarchy. Write your considerations in the "## Reasoning" section. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt index 01358a8..4db8335 100644 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt @@ -1,5 +1,6 @@ ## Domain {domain_desc} -## Types to use +## Types +The types are: {types} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt b/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt deleted file mode 100644 index 43ba5c5..0000000 --- a/paper_reconstructions/nl2plan/prompts/hierarchy_construction/technique.txt +++ /dev/null @@ -1,7 +0,0 @@ -Chain of Thought for organizing types: - -1. Compare the relationships of each type descriptions with the rest of the types in the list dictionary. If they are tightly close (i.e. belong in same category), but are not sub classes of each other, add them to their parent class. If there are no meta-type class for those relationships, create one. -2. Assemble a hierarchy with the formed relationships in the previous step -3. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -4. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -5. Re-iterate over the type hierarchy and convert it to a nested Python dictionary format with the type-description as key-value pairing. Keep the types the same if they do not need to be modified. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt new file mode 100644 index 0000000..a46b459 --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/error.txt @@ -0,0 +1,7 @@ +## Error +There was a at least one error during {task}. Address the following errors and regenerate your entire response: +{error_msg} + +Regenerate an entire response correcting the above error. Make sure to use the exact same headers as requested before, but start with a "## Response" header to analyze the error. + +## Response \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt similarity index 59% rename from paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt rename to paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt index fc99551..361943b 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/examples/example1.txt @@ -1,10 +1,9 @@ -The following is an in-context example following the CoT technique. +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport workers. -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. -Given types: -""" +## Types - object: Everything is an object - worker: Human workers which do things - administrator: Workers who can create orders for other workers @@ -12,10 +11,8 @@ Given types: - vehicle: Used to transport workers - location: Places where workers and machines can be - house: What is constructed. -""" -Given predicates: -""" +## Predicates - (at ?o - object ?l - location): true if the object ?o (which should be a worker or vehicle) is at location ?l - (inside ?w - worker ?v - vehicle): true if the worker ?w is in the vehicle ?v - (wall_order ?h - house): true if there is an order to build a wall at house ?h @@ -26,11 +23,8 @@ Given predicates: - (roof_built ?h - house): true if a roof has been built for house ?h - (finalized ?h - house): true if the house ?h has been completed. - (connected ?l1 - location ?l2 - location): true if there is a road between l1 and l2 allowing travel between them. -""" ------------------------------------------------------ - -1. State object instances, identify the cardinality of each object types: +## Object Instances We assume that there are two trucks since the description said "a couple". ``` truck1 - the first truck at the Chicago depot @@ -52,7 +46,7 @@ emma - general_worker: The first worker, Emma bob - general_worker: The second worker, Bob ``` -2. Identify initial states: +## State Let's start by specifying where everyone is. It's a reasonable assumption that everyone starts at the Chicago depot. ``` (at truck1 chicago_depot): truck1 is at the chicago_depot @@ -77,7 +71,7 @@ Finally, the "connected" predicate states that two locations are connected if th (connected chicago_depot house3): chicago_depot is connected to house3 ``` -3. Identify goal states +## Goal ``` (AND ; all the following should be done (finalised house1) ; house 1 is done @@ -87,34 +81,34 @@ Finally, the "connected" predicate states that two locations are connected if th ) ``` -4. Feedback - 1. Are any necessary objects forgotten? Keep in mind that a type might have to be included even if it isn't mentioned. - The description states that there are "a couple of trucks". This entails that many trucks exist, but only two are defined. Add some more. Therefore: Yes. +## Error +1. Are any necessary objects forgotten? + The description states that there are "a couple of trucks". This entails that many trucks exist, but only two are defined. Add some more. Therefore: Yes. - 2. Are any un-necessary objects included? If things are irrelevant they shouldn't be included. - All the objects which are included are actually described and needed. So: No. +2. Are any un-necessary objects included? + All the objects which are included are actually described and needed. So: No. - 3. Are any objects defined as the wrong type? The objects should of course be defined correctly. - The "house" type is supposed to be used for what is being constructed, the houses built. However, "chicago_depot" is cleraly not being built by us, but is defined as a "house". It should be just a general location. Thereby: Yes. +3. Are any objects defined as the wrong type? + The "house" type is supposed to be used for what is being constructed, the houses built. However, "chicago_depot" is cleraly not being built by us, but is defined as a "house". It should be just a general location. Thereby: Yes. - 4. Are any needed or expected predicates missing from the initalization? Everything has to be defined in the problem file, nothing is assumed. - Naturally, everything needs a starting location and most of the objects are assumed to start at the chicago_depot, which makes sense. However, "bob" lacks a starting position. Hence: Yes. +4. Are any needed or expected predicates missing from the initalization? + Naturally, everything needs a starting location and most of the objects are assumed to start at the chicago_depot, which makes sense. However, "bob" lacks a starting position. Hence: Yes. - 5. Are any unnecessary or incorrect predicates initialised? We should only initialize that which is actually true. - All the predicates which are initiated are valid and needed. As such: No. +5. Are any unnecessary or incorrect predicates initialised? + All the predicates which are initiated are valid and needed. As such: No. - 6. Is anything forgotten from the goal state? Everything we wish to require should be checked. - What is requested is, implicitly, that all the houses be finalized. This is checked, so: No. +6. Is anything forgotten from the goal state? + What is requested is, implicitly, that all the houses be finalized. This is checked, so: No. - 7. Is anything superflous included in the goal? We shouldn't check more things than needed. - The wanted position of the truck is not specified and isn't needed for the task to be considered to be completed. This should be removed. Hence: Yes. +7. Is anything superflous included in the goal? + The wanted position of the truck is not specified and isn't needed for the task to be considered to be completed. This should be removed. Hence: Yes. - 8. Should any predicate be used in a symmetrical manner? For example, if we want to build a road between A and B, the goal should allow either "(road_between A B)" or "(road_between B A)" to make the PDDL robust. This should ALWAYS be done even if this could also be handled in the action. - The "connected" predicate clearly specifies that travel is possible in both directions, which means that (connected A B) should entail (connected B A). - Therefore, each "connected" predicate should be mirrored to clarify that they're connected in both directions. This makes the PDDL more robust. - However, this is already done. As such: No. +8. Should any predicate be used in a symmetrical manner? + The "connected" predicate clearly specifies that travel is possible in both directions, which means that (connected A B) should entail (connected B A). + Therefore, each "connected" predicate should be mirrored to clarify that they're connected in both directions. This makes the PDDL more robust. + However, this is already done. As such: No. -5. My concrete suggestions are the following: +My concrete suggestions are the following: - Add more trucks to the domain. Initialize them to chicago_depot: - (at truck3 chicago_depot) - (at truck4 chicago_depot) @@ -127,12 +121,17 @@ Finally, the "connected" predicate states that two locations are connected if th (finalized house2) ; house 2 is done (finalized house3) ; house 3 is done ) - ``` - Response: the feedback is not entirely correct. Adding more trucks would be too large of an assumption, since the domain task only states "A couple". As such, we leave it with only two trucks. Adding the starting location for Bob as well as removing the goal condition for truck1 is both correct however. I'll make those changes. + ``` +Regenerate an entire response correcting the above error. Make sure to use the exact same headers as requested before, but start with a "## Response" header to analyze the error. + +## Response +The feedback is not entirely correct. Adding more trucks would be too large of an assumption, since the domain task only states "A couple". As such, we leave it with only two trucks. -6. Now I'll reiterate the corrected initialization with the following headers. +Adding the starting location for Bob as well as removing the goal condition for truck1 is both correct however. I'll make those changes. -## OBJECTS +Now I'll reiterate the corrected initialization with the exact same headers. + +## Object Instances The feedback suggested to use more trucks, but this would be wrong since the domain only specifies "A couple". So, we stick with the two trucks. ``` truck1 - the first truck at the Chicago depot @@ -154,7 +153,7 @@ emma - general_worker: The first worker, Emma bob - general_worker: The second worker, Bob ``` -## INITIAL +## State Let's start by specifying where everyone is again. This time, we make sure to include Bob. ``` (at truck1 chicago_depot): truck1 is at the chicago_depot @@ -176,7 +175,7 @@ The connections between the locations are the same bi-directional connections as (connected chicago_depot house3): chicago_depot is connected to house3 ``` -## GOAL +## Goal For the goal, we remove the "truck1" location predicate, but still check that all the houses are finalised. ``` (AND ; all the following should be done @@ -186,4 +185,41 @@ For the goal, we remove the "truck1" location predicate, but still check that al ) ``` -[END OF EXAMPLE] \ No newline at end of file +Thus, we get: + +### OBJECTS +``` +truck1 - the first truck at the Chicago depot +truck2 - the second truck at the Chicago depot +chicago_depot - location: The Chicago depot +house1 - The first house to build +house2 - The second house to build +house3 - The third house to build +jamie - administrator: The administrator Jamie +emma - general_worker: The first worker, Emma +bob - general_worker: The second worker, Bob +``` + +### INITIAL +``` +(at truck1 chicago_depot): truck1 is at the chicago_depot +(at truck2 chicago_depot): truck2 is at the chicago_depot +(at jamie chicago_depot): Jamie is at the depot +(at emma chicago_depot): Emma is at the depot +(at bob chicago_depot): Bob is at the depot +(connected house1 chicago_depot): house1 is connected to the chicago_depot +(connected house2 chicago_depot): house2 is connected to the chicago_depot +(connected house3 chicago_depot): house3 is connected to the chicago_depot +(connected chicago_depot house1): chicago_depot is connected to house1 +(connected chicago_depot house2): chicago_depot is connected to house2 +(connected chicago_depot house3): chicago_depot is connected to house3 +``` + +### GOAL +``` +(AND ; all the following should be done + (finalised house1) ; house 1 is done + (finalised house2) ; house 2 is done + (finalised house3) ; house 3 is done +) +``` \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt index 0894956..a55e9ab 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt @@ -1,7 +1,6 @@ # Role -You are a PDDL expert and will be given the parts of a PDDL problem file to give feedback on. Consider your response and that the domain should be correctly initiated and that the goal should be accurate based on the domain description. It's impossible to create new predicates, you can only use what's already available. Think through your feedback step by step. If the action is well defined, respond with "No feedback". -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +You are a PDDL expert and will be given the parts of a PDDL problem file to give feedback on. Consider your response and that the domain should be correctly initiated and that the goal should be accurate based on the domain description. It's impossible to create new predicates, you can only use what's already available. Think through your feedback step by step. If the action is well defined, respond with "No feedback" under header '# JUDGEMENT'. Use the following checklist: 1. Are any necessary objects missing? Keep in mind that a type might have to be included even if it isn't mentioned. @@ -103,6 +102,7 @@ bob - general_worker: The second worker, Bob Even though this could have been handled by the actions, we can't guarantee that it is and as such we have to mirror all these predicates. Thereby: Yes. +# JUDGEMENT My concrete suggestions are the following: - Add a second truck ("truck2"). Initialize it with the following: - (at truck2 chicago_depot) @@ -217,6 +217,7 @@ ranger2 - ranger: One of the available rangers 8. Should any predicate be used in a symmetrical manner? While the "at" predicate could accept two locations, this is clearly not the intent. Hence: No. +# JUDGEMENT My concrete suggestions are the following: - Remove the "deer4" and "outer4" objects from the domain entirely. They're incorrectly included. - Add at least one more ranger object. For example, "ranger3" could be added an initalized like this: @@ -304,14 +305,13 @@ elevator_2 - elevator: The second elevator in the building. 8. Should any predicate be used in a symmetrical manner? All the predicates are clearly intended to be one-directional, and that is how they're used. So: No. +# JUDGEMENT Based on this, the response is: No feedback. ----------------------------------------- +# Task -Here is the original output: - -## Problem -{problem_desc} +## Domain +{domain_desc} ## Available Types {types} @@ -323,14 +323,13 @@ The following are the available predicates which can be used: ## State This is the state to give feedback on based on the domain and predicates above. -## Objects +### Objects {objects} -## Initial State -{initial_state} +### Initial State +{initial_states} -## Goal State -{goal_state} +### Goal State +{goal_states} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt index 7d7355c..a297162 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/role.txt @@ -1,30 +1,26 @@ -Your task is to extract the initial state and the goal state for a PDDL problem based on a domain description and the available predicates. Consider that if a predicate is checked by an action for an object, it should probably somehow be possible to make true or start true. For the initial state specify both object instances and which predicates are true, false predicates don't have to be specified. For the goal, specify the states which need to have specific values regardless if those are true or false. Do it step-by-step and explain your thoughts. Respond with the exact headings provided. You can't assume that any object, regardless of type, already exists. Everything you wish to use should be defined here. Also, remember that any symmetrical predicates likely should be defined both ways. Even if there is one goal state, it must contain the PDDL 'AND' syntax +Your task is to estimate the initial state and the goal state for a PDDL problem based on a domain description and the available actions. Consider that if a predicate is checked by an action for an object, it should probably somehow be possible to make true or start true. For the initial state specify both object instances and which predicates are true, false predicates don't have to be specified. For the goal, specify the states which need to have specific values regardless if those are true or false. Do it step-by-step and explain your thoughts. Respond with the exact headings provided. You can't assume that any object, regardless of type, already exists. Everything you wish to use should be defined here. Also, remember that any symmetrical predicates likely should be defined both ways. -No object types should be of 'object' but their respective types +End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: -The problem you are to extract from is under the header '## Problem description' - -Also it is crucial you follow these checks: - - objects types should be found in types list - - objects name should not be the same as a type name - - object name should not be the same as a predicate name - - objects should only be appointed by its respective type - - all predicates used must have the same parameters stated in its domain file - -Do not, under any circumstance, output the answers in PDDL format. Final answer must be in the following format at the end: -## OBJECTS +### OBJECTS ``` -truck1 - truck +object1 - type_1 +object2 - type_2 +object3 - type_1 ``` -## INITIAL +### INITIAL ``` -(at truck1 chicago_depot): truck1 is at the chicago_depot +(predicate_name object1 object2) ; comment for initial state predicate 1 +(predicate_name object3 object4) ; comment for initial state predicate 2 +(predicate_name object5) ; comment for initial state predicate 3 ``` -## GOAL +### GOAL ``` -(AND ; all the following should be done - (finalised house1) ; house 1 is done +(and + (predicate_name object) ; comment ) -``` \ No newline at end of file +``` + +Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt index acb4184..b38e4cf 100644 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/task_extraction/task.txt @@ -1,8 +1,12 @@ ## Types +``` {types} +``` ## Predicates +``` {predicates} +``` -## Problem description +## Problem {problem_desc} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt deleted file mode 100644 index ec019ce..0000000 --- a/paper_reconstructions/nl2plan/prompts/task_extraction/technique.txt +++ /dev/null @@ -1,8 +0,0 @@ -Chain of Thought for extracting PDDL problem file: - -1. Using the given domain description and types, identify object instances and their respective cardinalities -2. Using the given domain description, predicates and extracted object instances, identify the initial states -3. Using the given domain description, objects, and implications of the initial states, identify the goal states -4. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -5. If there are errors, generate a suggestion response -6. Re-iterate over the objects, initial, and goal states. At this point, define them under the capitalized headers as final inputs: '## OBJECTS', '## INITIAL', and '## GOAL' respectively. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt deleted file mode 100644 index 28d0838..0000000 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example.txt +++ /dev/null @@ -1,94 +0,0 @@ -The following is an in-context example following the CoT technique. - -Given domain: -The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. - -Given types: -There are no available types. - ------------------------------------------------------ - -1. First, we'll need types for the houses that are built and the depot. We'll also add a general location type to organize this. -``` -- location: Can be visited and travelled between. -- house: Constructed by the company. Are a type of location. -- depot: Contains trucks and likely material for the construction. -``` - -Next, we need to model the vehicles itself. General "vehicles" are mentioned, as are trucks. We'll model both for safety. -``` -- vehicle: Can transport things, such as material or personell, between locattions. -- truck: A type of vehicle for ground transport. -``` - -After that, the workers need to be included. These are: -``` -- jamie: An administrator. -- emma: A worker. -- bob: A worker. -``` - -Lastly, I've repeatedly assumed the existence of construction materials. This is likely needed and useful, so I'll add it in. -``` -- material: Assorted material for constructing houses. Transported by vehicles. -``` - -2. Feedback: - 1: Are there any more types which are needed to model the domain? - No. There is no need to include any more types. - - 2: Are any more types needed for organisation? For example, if both "carbonara" and "sushi" are both included, a "food" meta-type should likely be included as well. - Yes. Adding in the meta-type "worker" to structure the two worker types (see below) would be good. - - 3: Are any of the supposed types actually objects? For example, is a name listed as a type? If so, it should be replaced with the general type. - Yes. Jamie, Emma and Bob are all individual objects (or in this case people). They should be replaced with their types, administrator and general_worker. - - 4: Are any of the types actually actions? If so, they should be removed. - No. Beyond the people mentioned above the types are reasonable. - - 5: Are any of the types actually properties? If so, they should later be modelled with predicates instead and thereby removed. - 6: Is the acting agent itself or the resulting plans included? If only one instance of the agent exists, such as the entire problem modelling behaviour for one robot, it should be removed. - 7: Will any of the included types only ever be used once? If so, it should be removed and modelled implicitly. - 8: Is the acting agent itself or the resulting plans included? The domain might be better modelled in PDDL if some parts are modelled not as objects and types, even if they technically are. - - -3. I'd suggest the following: -- Remove "jamie", "emma" and "bob". -- Add the following: - - worker: A meta-type structuring the specific workers. - - general_worker: A type of worker who can perform a variety of jobs based on orders. - - administrator: A type of worker who can create orders. - -The feedback raises some valid points, but not all are correct. I agree that exchanging "jamie", "emma" and "bob" with "administrator" and "general_worker" is correct. However, modelling "helicopter" and "excavator" would be too much. We shouldn't include more types than is actually needed and useful for the task at hand, and since no helicopters or excavators exist we'll skip those. - -4. Extract types in Python dictionary format - -First, I have to re-iterate all the types I want to keep: -``` -- location: Locations can be visited and travelled between. -- house: Constructed by the company. Are a type of location. -- depot: Contains trucks and likely material for the construction. -- vehicle: Vehicles can transport things, such as material or personel, between locations. -- truck: A type of vehicle for ground transport. -- material: Assorted material for constructing houses. Transported by vehicles. -``` - -Then, I also want to add the new general worker types: -``` -- general_worker: A type of worker who can perform a variety of jobs based on orders. -- administrator: A type of worker who can create orders. -``` - -I will now output all the types that were not found in the given types description. - -## OUTPUT -{ - "location": "Locations can be visited and travelled between.", - "house": "Constructed by the company. Are a type of location.", - "depot": "Contains trucks and likely material for the construction.", - "vehicle": "Vehicles can transport things, such as material or personel, between locations.", - "truck": "A type of vehicle for ground transport.", - "material": "Assorted material for constructing houses. Transported by vehicles.", - "general_worker": "A type of worker who can perform a variety of jobs based on orders.", - "administrator": "A type of worker who can create orders." -} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt new file mode 100644 index 0000000..ac5365b --- /dev/null +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/examples/example1.txt @@ -0,0 +1,91 @@ +## Domain +The AI agent is here a scheduling system for a house construction company with administrators who can create orders, workers who perform them and vehicles to transport things. + +Currently, there are a couple of trucks at the Chicago depot and we're trying to build three houses in the area. Jamie is the only administrator, but we've got Emma and Bob available for general work. + +## Types +First, we'll need types for the houses that are built and the depot. We'll also add a general location type to organize this. +``` +- location: Locations can be visited and travelled between. +- house: Constructed by the company. Are a type of location. +- depot: Contains trucks and likely material for the construction. +``` + +Next, we need to model the vehicles itself. General "vehicles" are mentioned, as are trucks. We'll model both for safety. +``` +- vehicle: Vehicles can transport things, such as material or personell, between locattions. +- truck: A type of vehicle for ground transport. +``` + +After that, the workers need to be included. These are: +``` +- jamie: An administrator. +- emma: A worker. +- bob: A worker. +``` + +Lastly, I've repeatedly assumed the existence of construction materials. This is likely needed and useful, so I'll add it in. +``` +- material: Assorted material for constructing houses. Transported by vehicles. +``` + +## Feedback +1: Are there any more types which are needed to model the domain? + No. There is no need to include any more types. + +2: Are any more types needed for organisation? + Yes. Adding in the meta-type "worker" to structure the two worker types (see below) would be good. + +3: Are any of the supposed types actually objects? + Yes. Jamie, Emma and Bob are all individual objects (or in this case people). They should be replaced with their types, administrator and general_worker. + +4: Should any of the types be removed? + No. Beyond the people mentioned above the types are reasonable. + +I'd suggest the following: +- Remove "jamie", "emma" and "bob". +- Add the following: + - worker: A meta-type structuring the specific workers. + - general_worker: A type of worker who can perform a variety of jobs based on orders. + - administrator: A type of worker who can create orders. + + +Start with a "## Response" header, then re-iterate an updated version of the "## Types" header. + +## Response +The feedback raises some valid points, but not all are correct. + +I agree that exchanging "jamie", "emma" and "bob" with "administrator" and "general_worker" is correct. + +However, modelling "helicopter" and "excavator" would be too much. We shouldn't include more types than is actually needed and useful for the task at hand, and since no helicopters or excavators exist we'll skip those. + +## Types +First, I have to re-iterate all the types I want to keep: +``` +- location: Locations can be visited and travelled between. +- house: Constructed by the company. Are a type of location. +- depot: Contains trucks and likely material for the construction. +- vehicle: Vehicles can transport things, such as material or personell, between locattions. +- truck: A type of vehicle for ground transport. +- material: Assorted material for constructing houses. Transported by vehicles. +``` + +Then, I also want to add the new general worker types: +``` +- general_worker: A type of worker who can perform a variety of jobs based on orders. +- administrator: A type of worker who can create orders. +``` + +End your final answer starting with "## OUTPUT" and then re-iterate an updated version the Python dictionary pair '{'name':'description'}' as so: + +## OUTPUT +{ + "location": "Locations can be visited and travelled between.", + "house": "Constructed by the company. Are a type of location.", + "depot": "Contains trucks and likely material for the construction.", + "vehicle": "Vehicles can transport things, such as material or personell, between locattions.", + "truck": "A type of vehicle for ground transport.", + "material": "Assorted material for constructing houses. Transported by vehicles.", + "general_worker": "A type of worker who can perform a variety of jobs based on orders.", + "administrator": "A type of worker who can create orders." +} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt index b0ce911..8b49aeb 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt @@ -1,8 +1,5 @@ -You are a PDDL expert and your task is to evaluate if a set of types are correct and sufficent for modelling a given domain. - -Make suggestions / changes if there are any checks that you deem are insufficient, if not, respond with 'no feedback' (once) at the end of your whole response. You either return a suggestion/feedback or you respond with 'no feedback' not both. Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. - -Do not respond with 'no feedback' in between each check. Do not add anything new other than what is focused on the specific PDDL aspect at hand. +# Role +Your are a PDDL expert and your task is to evaluate if a set of types are correct and sufficent for modelling a given domain. If it is, respond with "no feedback" under header '# JUDGEMENT'. If it isn't, provide your thoughts on how to correct the types. Don't model the available actions, but just the types of objects to be used. Go through the following checklist: 1: Are there additional types which are needed to model the domain? @@ -14,6 +11,15 @@ Go through the following checklist: 7: Will any of the included types only ever be used once? If so, it should be removed and modelled implicitly. 8: Is the acting agent itself or the resulting plans included? The domain might be better modelled in PDDL if some parts are modelled not as objects and types, even if they technically are. +End your final answer starting with "## OUTPUT" and then re-iterate an updated version the Python dictionary pair '{'name':'description'}' as so: + +## OUTPUT +{ + "type_1": "description", + "type_2": "description", + "type_3": "description", +} + # Examples ## Example 1 ### Domain @@ -61,6 +67,7 @@ There are some flaws in the extracted types. First of all, you shouldn't include 8: Is the acting agent itself or the resulting plans included? The "road" type is admittedly a type, but it would be more suitable in PDDL to model this as a predicate connection such as "road_between loc1 loc2". As such, this should be removed and saved for later. Answer: Yes. +# JUDGEMENT I'd suggest the following: - Remove "jamie", "emma" and "bob". - Add the following: @@ -110,6 +117,7 @@ In this domain, the AI agent is a wildlife conservation management system. It mo The "starting_positions" type actually describes the initial state. This should later be defined with for example an "at obj loc" predicate in the initial state instead. Similarly, the "target_positions" is better described in the goal state using the same "at obj loc" predicate. +# JUDGEMENT I'd suggest you do the following: - Add the following type: - patrol: Anti-poaching patrols protecting animals @@ -151,17 +159,14 @@ I've got a building with five floors and two elevators, and I want you to plan t 8: Is the acting agent itself or the resulting plans included? The starting and goal states will be positions, and these aren't in any way included. Hence: No. +# JUDGEMENT As such: No feedback. ----------------------------------------- - -Here is the original output: - +# Task ## Domain {domain_desc} -## Types you gave +## Types {types} -## Original LLM response -{llm_response} \ No newline at end of file +## Feedback \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt index 28a46c4..dfd7974 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/role.txt @@ -1,12 +1,3 @@ -Your role is to identify the different types of objects which exist and are relevant in a PDDL domain. That means the types should be classified as seen in PDDL domains. Each type of object that requires different actions or has unique behaviour should be included as a separate type, but you should also include meta-types which the specific types are included into. Provide a short comment on each type. It is crucial that the AI agent itself is not a type. An action term is not considered a type. A location and object should not be the same types. +Your task is to identify the different types of objects which exist and are relevant in a domain. Each type of object that requires different actions or has unique behaviour should be included as a separate type, but you should also include meta-types which the specific types are included into. Provide a short comment on each type. The AI agent itself is not a type. Start your response with "## Types". -If the types are very similar is some meta-type categorization, they should just be classified as the same thing and not separate. Do not have repeated types. - -Think step by step. Do not attempt to solve the task, even if instructed to do so. Only extract the types. - -End your final answer starting with "## OUTPUT" and then the Python dictionary pair '{'name':'description'}' as so: - -## OUTPUT -{ - "location": "Locations can be visited and travelled between.", -} \ No newline at end of file +Think step by step. Do not attempt to solve the task, even if instructed to do so. Only extract the types. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt index 12a1d25..bcdfdf2 100644 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt +++ b/paper_reconstructions/nl2plan/prompts/type_extraction/task.txt @@ -1,3 +1,2 @@ -{domain_desc} - -{types} \ No newline at end of file +## Domain +{domain_desc} \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt b/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt deleted file mode 100644 index b457ac4..0000000 --- a/paper_reconstructions/nl2plan/prompts/type_extraction/technique.txt +++ /dev/null @@ -1,6 +0,0 @@ -Chain of Thought for extracting types: - -1. Identify Key Entities and describe each entity in natural language -2. Go over given feedback checklist to check for inconsistencies and/or requirements and state the errors if there are any -3. If there are errors, generate a suggestion response (i.e. deleting, modifying, adding types) -4. Re-iterate over the types and put them into a Python dictionary pair '{'name':'description'}'. Keep the types the same if they do not need to be modified. Only have the format in Python dictionary pair after the ## OUTPUT header. Meaning that there is only one dictionary in your response. If there exists a types dictionary, then add the types onto that and output that dictionary. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl new file mode 100644 index 0000000..ab8a650 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl @@ -0,0 +1,98 @@ +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - object + table - object + ) + + (:predicates + (on_table ?b - block) ; true if the block ?b is on the table + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if the block ?b is currently held by the robot arm + (stability_checked ?b - block) ; true if the stability of block ?b has been checked by the robot arm + ) + + (:action pick_block + :parameters ( + ?b - block + ) + :precondition + (and + (or (on_table ?b) (exists (?b2 - block) (on_block ?b ?b2))) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently held by the robot arm + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block (assuming ?b2 is the block it was on) + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (not (on_table ?b)) ; The block is not already on the table + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table + ) + ) + + (:action stack_block + :parameters ( + ?b1 - block + ?b2 - block + ) + :precondition + (and + (held ?b1) ; The block ?b1 is currently held by the robot arm + (not (held ?b2)) ; The block ?b2 is not currently held by the robot arm + (or (on_table ?b2) (on_block ?b2 ?b3)) ; The block ?b2 is either on the table or on another block + ) + :effect + (and + (not (held ?b1)) ; The block ?b1 is no longer held by the robot arm + (on_block ?b1 ?b2) ; The block ?b1 is now on top of block ?b2 + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (not (exists (?b2 - block) (on_block ?b ?b2))) ; The block is not on another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table after being released + ) + ) + + (:action check_stability + :parameters ( + ?b - block + ) + :precondition + (and + (not (held ?b)) ; The block is not currently held by the robot arm + (or (on_table ?b) (on_block ?b ?b1)) ; The block is either on the table or on top of another block + ) + :effect + (and + (stability_checked ?b) ; The stability of the block has been checked + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/problem.pddl new file mode 100644 index 0000000..aa6ef19 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/problem.pddl @@ -0,0 +1,34 @@ +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + blue_block - block + red_block - block + yellow_block - block + green_block - block + table1 - table + ) + + (:init + (on_block red_block yellow_block) + (on_block blue_block red_block) + (on_table yellow_block) + (on_table green_block) + (held blue_block) + (stability_checked blue_block) + (stability_checked red_block) + (stability_checked yellow_block) + (stability_checked green_block) + ) + + (:goal + (and + (on_block red_block green_block) + (on_table green_block) + (on_table yellow_block) + (on_block blue_block red_block) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/domain.pddl b/paper_reconstructions/nl2plan/results/domain.pddl deleted file mode 100644 index 1497ce6..0000000 --- a/paper_reconstructions/nl2plan/results/domain.pddl +++ /dev/null @@ -1,115 +0,0 @@ -(define (domain test_domain) - (:requirements - :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) - - (:types - block - physical_object - table - physical_object - arm - tool - ) - - (:predicates - (at ?b - block ?t - table) ; true if the block ?b is at the table ?t - (clear ?b - block) ; true if the block ?b is clear (not covered by another block) - (empty ?a - arm) ; true if the arm ?a is empty (not holding any block) - (holding ?a - arm ?b - block) ; true if the arm ?a is holding the block ?b - (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 - ) - - (:action pickup - :parameters ( - ?a - arm - ?b - block - ?t - table - ) - :precondition - (and - (at ?b ?t) ; The block is at the table - (clear ?b) ; The block is clear (not covered by another block) - (empty ?a) ; The arm is empty (not holding any block) - ) - :effect - (and - (not (at ?b ?t)) ; The block is no longer at the table - (not (clear ?b)) ; The block is no longer clear - (holding ?a ?b) ; The arm is now holding the block - ) - ) - - (:action putdown - :parameters ( - ?a - arm - ?b - block - ?t - table - ) - :precondition - (and - (holding ?a ?b) ; The arm is holding the block - (clear ?t) ; The location on the table is clear - ) - :effect - (and - (not (holding ?a ?b)) ; The arm is no longer holding the block - (at ?b ?t) ; The block is now on the table - (clear ?b) ; The block is now clear - ) - ) - - (:action stack - :parameters ( - ?a - arm - ?b1 - block - ?b2 - block - ) - :precondition - (and - (holding ?a ?b1) ; The arm is holding the top block - (clear ?b2) ; The bottom block is clear - (not (on ?b1 ?b2)) ; The top block is not already on the bottom block - ) - :effect - (and - (not (holding ?a ?b1)) ; The arm is no longer holding the top block - (on ?b1 ?b2) ; The top block is now on the bottom block - (not (clear ?b2)) ; The bottom block is no longer clear - (empty ?a) ; The arm is now empty - ) - ) - - (:action unstack - :parameters ( - ?a - arm - ?b1 - block - ?b2 - block - ) - :precondition - (and - (empty ?a) ; The arm is empty - (clear ?b1) ; The top block is clear - (on ?b1 ?b2) ; The top block is on the bottom block - ) - :effect - (and - (holding ?a ?b1) ; The arm is now holding the top block - (not (on ?b1 ?b2)) ; The top block is no longer on the bottom block - (clear ?b2) ; The bottom block is now clear - (not (clear ?b1)) ; The top block is no longer clear - ) - ) - - (:action check_clear - :parameters ( - ?b - block - ?a - arm - ) - :precondition - (and - (at ?b ?t) ; The block is at the table - (empty ?a) ; The arm is empty - ) - :effect - (and - (clear ?b) ; The block is confirmed to be clear - ) - ) -) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/problem.pddl b/paper_reconstructions/nl2plan/results/problem.pddl deleted file mode 100644 index 47173ab..0000000 --- a/paper_reconstructions/nl2plan/results/problem.pddl +++ /dev/null @@ -1,31 +0,0 @@ -(define - (problem test_problem) - (:domain test_domain) - - (:objects - blue_block - block - red_block - block - yellow_block - block - green_block - block - table1 - table - ) - - (:init - (on blue_block red_block) - (on red_block yellow_block) - (at yellow_block table1) - (at green_block table1) - (clear blue_block) - (clear green_block) - (clear red_block) - (and ) - (on red_block green_block) - ) - - (:goal - (and - (on red_block green_block) - ) - ) - -) \ No newline at end of file diff --git a/paper_reconstructions/proc2pddl/main.py b/paper_reconstructions/proc2pddl/main.py index ca39bbd..263403f 100644 --- a/paper_reconstructions/proc2pddl/main.py +++ b/paper_reconstructions/proc2pddl/main.py @@ -25,7 +25,7 @@ if __name__ == "__main__": - unsupported_keywords = ["object", "pddl", "lisp"] + UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] # retrieve wikihow text domain_desc = load_file("paper_reconstructions/proc2pddl/prompts/wikihow.txt") @@ -80,7 +80,7 @@ pruned_types = { name: description for name, description in types.items() - if name not in unsupported_keywords + if name not in UNSUPPORTED_KEYWORDS } # remove unsupported words # format strings From 69cbd18bec859858bbab3930843b46286335b5bc Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Mon, 6 Jan 2025 00:23:21 -0500 Subject: [PATCH 07/15] cleaned nl2plan code + tests --- paper_reconstructions/nl2plan/nl2plan/action_extraction.py | 6 +----- paper_reconstructions/nl2plan/nl2plan/type_extraction.py | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py index 4d86487..cc2b3ee 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py @@ -1,9 +1,5 @@ import os -from l2p import LLM, OPENAI -from l2p import PromptBuilder -from l2p import DomainBuilder -from l2p import FeedbackBuilder -from l2p import load_file, load_files +from l2p import * class ActionExtraction: def __init__(self): diff --git a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py index 53055e5..db6b005 100644 --- a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py @@ -1,9 +1,5 @@ import os -from l2p import LLM, OPENAI -from l2p import PromptBuilder -from l2p import DomainBuilder -from l2p import FeedbackBuilder -from l2p import load_file, load_files +from l2p import * class TypeExtraction: def __init__(self): From 54cc1aec9a35d23f0cfaca63cdb9c19ab140cdd1 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Tue, 7 Jan 2025 09:10:17 -0500 Subject: [PATCH 08/15] fixed planner code --- l2p/utils/pddl_planner.py | 38 +++++++++++++------ l2p/utils/pddl_validator.py | 3 +- .../nl2plan/nl2plan/action_construction.py | 15 +++----- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/l2p/utils/pddl_planner.py b/l2p/utils/pddl_planner.py index 45dfc20..c4ead0f 100644 --- a/l2p/utils/pddl_planner.py +++ b/l2p/utils/pddl_planner.py @@ -1,4 +1,12 @@ -import subprocess, os, re +""" +L2P comes pre-packaged with FastDownward: https://www.fast-downward.org + +For usage, users must clone or download the submodule /downward separately and direct the +`planner_path` to the folder. This module is not necessary to use L2P, but for ease of use +to produce plans from generated domain and problem PDDL specifications via LLMs. +""" + +import subprocess, re # Define the exit codes SUCCESS = 0 @@ -29,16 +37,26 @@ class FastDownward: def __init__(self, planner_path: str): - self.planner_path = planner_path - - def run_fast_downward(self, domain_file, problem_file, plan_file="sas_plan"): + self.planner_path = planner_path # directory of FastDownward planner + + def run_fast_downward(self, domain_file: str, problem_file: str, search_alg: str="lama-first"): + """ + Main function to run planner. + + Args: + - domain_file (str): PDDL domain file path + - problem_file (str): PDDL problem file path + - search_alg (str): search algorithm/heuristic to use + + refer to: https://www.fast-downward.org/PlannerUsage + + Returns: + - success (bool): if a plan was found, otherwise False for incomplete. + - plan_output (str): plan output information. + + """ try: - - print(self.planner_path) - - # lmcut() = landmark-cut heuristic - refer to: https://www.fast-downward.org/PlannerUsage result = subprocess.run( - [self.planner_path, "--alias", "lama-first", domain_file, problem_file], + [self.planner_path, "--alias", search_alg, domain_file, problem_file], capture_output=True, text=True, ) @@ -47,8 +65,6 @@ def run_fast_downward(self, domain_file, problem_file, plan_file="sas_plan"): if result.returncode == SUCCESS: # Planning succeeded - with open(plan_file, "w") as f: - f.write(result.stdout) print("Planning succeeded!") print( "All run components successfully terminated (translator: completed, search: found a plan, validate: validated a plan)" diff --git a/l2p/utils/pddl_validator.py b/l2p/utils/pddl_validator.py index d20eb55..0d97b42 100644 --- a/l2p/utils/pddl_validator.py +++ b/l2p/utils/pddl_validator.py @@ -14,6 +14,7 @@ def __init__( unsupported_keywords = None ): + # current error types available default_error_types = [ 'invalid_header', 'invalid_keyword_usage', @@ -24,7 +25,7 @@ def __init__( 'invalid_predicate_usage' ] - default_unsupported = ['forall', 'when', 'exists', 'implies'] + default_unsupported = ['forall', 'when', 'exists', 'implies'] # current unsupported usage of PDDL self.error_types = default_error_types if error_types is None else error_types self.unsupported_keywords = default_unsupported if unsupported_keywords is None else unsupported_keywords diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py index 125c269..0ef0cf5 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -220,15 +220,12 @@ def action_construction( ] } - # nl_actions = { - # "pick_block": "The robot arm picks up a block from a surface. Requires the block to be on a surface and not currently held by the arm. Example: robot_arm picks up block_1 from table_1.", - # "place_on_table": "The robot arm places a block on a table. Requires the block to be held by the arm and the table to be clear of other blocks. Example: robot_arm places block_1 on table_1.", - # "place_on_block": "The robot arm places a block on top of another block. Requires the block to be held by the arm and the target block to be clear (not currently held or covered by another block). Example: robot_arm places block_1 on block_2.", - # "release_block": "The robot arm releases a block it is currently holding. Requires the block to be held by the arm. Example: robot_arm releases block_1." - # } - - nl_actions = {'pick_block': 'The robot arm picks up a block from the table or from on top of another block. The block must be accessible and not currently under another block. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block onto the table. The block must be held by the robot arm and the table must be clear of any other blocks in that position. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. The block being placed must be held by the robot arm, and the block it is being placed on must be stable and not currently under another block. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases the currently held block without placing it on the table or another block. This action is used to drop the block. The block is no longer held by the robot arm after this action is performed. Example: robot_arm releases block_1.', 'check_accessibility': 'The robot arm checks if a block is accessible for picking. Example: robot_arm checks if block_1 is accessible.'} - + nl_actions = { + "pick_block": "The robot arm picks up a block from a surface. Requires the block to be on a surface and not currently held by the arm. Example: robot_arm picks up block_1 from table_1.", + "place_on_table": "The robot arm places a block on a table. Requires the block to be held by the arm and the table to be clear of other blocks. Example: robot_arm places block_1 on table_1.", + "place_on_block": "The robot arm places a block on top of another block. Requires the block to be held by the arm and the target block to be clear (not currently held or covered by another block). Example: robot_arm places block_1 on block_2.", + "release_block": "The robot arm releases a block it is currently holding. Requires the block to be held by the arm. Example: robot_arm releases block_1." + } action_construction = ActionConstruction() action_construction.set_prompt( From d649f24fe1b71c36d138b4652bb0ee84624083f0 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Tue, 7 Jan 2025 10:37:51 -0500 Subject: [PATCH 09/15] cleaned Nl2Plan code --- .../nl2plan/domains/isr-assisted/desc.txt | 1 - .../nl2plan/domains/isr-assisted/task1.txt | 12 -- .../nl2plan/domains/isr-assisted/task2.txt | 22 --- .../nl2plan/domains/isr-assisted/task3.txt | 33 ---- .../nl2plan/domains/isr/desc.txt | 1 - .../nl2plan/domains/isr/task1.txt | 12 -- .../nl2plan/domains/isr/task2.txt | 22 --- .../nl2plan/domains/isr/task3.txt | 33 ---- paper_reconstructions/nl2plan/main.py | 89 ++++++---- .../nl2plan/nl2plan/__init__.py | 5 + .../nl2plan/results/blocksworld/domain.pddl | 98 ---------- .../results/blocksworld/task1/domain.pddl | 88 +++++++++ .../nl2plan/results/blocksworld/task1/log.txt | 167 ++++++++++++++++++ .../results/blocksworld/task1/plan.txt | 1 + .../blocksworld/{ => task1}/problem.pddl | 15 +- 15 files changed, 316 insertions(+), 283 deletions(-) delete mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr/desc.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr/task1.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr/task2.txt delete mode 100644 paper_reconstructions/nl2plan/domains/isr/task3.txt create mode 100644 paper_reconstructions/nl2plan/nl2plan/__init__.py delete mode 100644 paper_reconstructions/nl2plan/results/blocksworld/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt rename paper_reconstructions/nl2plan/results/blocksworld/{ => task1}/problem.pddl (52%) diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt deleted file mode 100644 index 8084c5f..0000000 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/desc.txt +++ /dev/null @@ -1 +0,0 @@ -An independent set of a graph is a subset of its vertices such that no two vertices of the subset share an edge. Reconfiguring an independent set means replacing one vertex in the subset with another one such that the new subset is still an independent set. The ISR problem is to find a sequence of such reconfiguration steps to reach a given target configuration from a given start configuration. Model the reconfiguration with two actions, "remove" and "add". "remove" cannot be taken if the last action taken was a "remove" action, and conversly "add" can only be taken if the last action taken was a "remove". \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt deleted file mode 100644 index 0a95207..0000000 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task1.txt +++ /dev/null @@ -1,12 +0,0 @@ -The current graph has the following neighbors: -- (1,2) -- (2,3) -- (3,4) -- (4,5) -- (5,6) -- (6,7) -- (7,8) -- (7,9) -- (9,5) - -And the initial independent set is (6,4,9). Transform it to (7,5,3) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt deleted file mode 100644 index 67fc22b..0000000 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task2.txt +++ /dev/null @@ -1,22 +0,0 @@ -So, I want to go from the set (C,E,G,K,M,O,Q) to (D,F,H,J,L,N,P) in a graph with the following neighbors: -- (A,B) -- (B,C) -- (C,D) -- (C,H) -- (C,J) -- (D,E) -- (F,G) -- (F,M) -- (G,H) -- (G,N) -- (H,I) -- (I,J) -- (I,O) -- (J,K) -- (K,L) -- (K,P) -- (L,Q) -- (M,N) -- (N,O) -- (O,P) -- (P,Q) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt b/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt deleted file mode 100644 index 4025ba0..0000000 --- a/paper_reconstructions/nl2plan/domains/isr-assisted/task3.txt +++ /dev/null @@ -1,33 +0,0 @@ -The graph has the following neighbors: -(A, E) -(B, C) -(B, F) -(C, D) -(D, G) -(E, H) -(F, J) -(G, L) -(H, I) -(H, M) -(I, J) -(I, N) -(J, K) -(K, L) -(K, P) -(L, Q) -(M, N) -(M, R) -(N, O) -(O, P) -(O, S) -(P, Q) -(Q, T) -(R, U) -(S, W) -(T, X) -(U, V) -(V, W) -(X, Y) -(Y, Z) - -And I'm starting with the set (A,C,F,H,L,N,P,R,S,T,V) and want to end with the set (B,D,E,I,K,M,O,Q,U,X,Z). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/desc.txt b/paper_reconstructions/nl2plan/domains/isr/desc.txt deleted file mode 100644 index 05474db..0000000 --- a/paper_reconstructions/nl2plan/domains/isr/desc.txt +++ /dev/null @@ -1 +0,0 @@ -An independent set of a graph is a subset of its vertices such that no two vertices of the subset share an edge. Reconfiguring an independent set means replacing one vertex in the subset with another one such that the new subset is still an independent set. The ISR problem is to find a sequence of such reconfiguration steps to reach a given target configuration from a given start configuration \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task1.txt b/paper_reconstructions/nl2plan/domains/isr/task1.txt deleted file mode 100644 index 0cade54..0000000 --- a/paper_reconstructions/nl2plan/domains/isr/task1.txt +++ /dev/null @@ -1,12 +0,0 @@ -The current graph has the following neighbors: -- (1,2) -- (2,3) -- (3,4) -- (4,5) -- (5,6) -- (6,7) -- (7,8) -- (7,9) -- (9,5) - -And the initial independent set is (4,6,9). Transform it to (3,5,7) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task2.txt b/paper_reconstructions/nl2plan/domains/isr/task2.txt deleted file mode 100644 index 67fc22b..0000000 --- a/paper_reconstructions/nl2plan/domains/isr/task2.txt +++ /dev/null @@ -1,22 +0,0 @@ -So, I want to go from the set (C,E,G,K,M,O,Q) to (D,F,H,J,L,N,P) in a graph with the following neighbors: -- (A,B) -- (B,C) -- (C,D) -- (C,H) -- (C,J) -- (D,E) -- (F,G) -- (F,M) -- (G,H) -- (G,N) -- (H,I) -- (I,J) -- (I,O) -- (J,K) -- (K,L) -- (K,P) -- (L,Q) -- (M,N) -- (N,O) -- (O,P) -- (P,Q) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/isr/task3.txt b/paper_reconstructions/nl2plan/domains/isr/task3.txt deleted file mode 100644 index 4025ba0..0000000 --- a/paper_reconstructions/nl2plan/domains/isr/task3.txt +++ /dev/null @@ -1,33 +0,0 @@ -The graph has the following neighbors: -(A, E) -(B, C) -(B, F) -(C, D) -(D, G) -(E, H) -(F, J) -(G, L) -(H, I) -(H, M) -(I, J) -(I, N) -(J, K) -(K, L) -(K, P) -(L, Q) -(M, N) -(M, R) -(N, O) -(O, P) -(O, S) -(P, Q) -(Q, T) -(R, U) -(S, W) -(T, X) -(U, V) -(V, W) -(X, Y) -(Y, Z) - -And I'm starting with the set (A,C,F,H,L,N,P,R,S,T,V) and want to end with the set (B,D,E,I,K,M,O,Q,U,X,Z). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py index b3f1ad9..29472d7 100644 --- a/paper_reconstructions/nl2plan/main.py +++ b/paper_reconstructions/nl2plan/main.py @@ -6,17 +6,13 @@ import argparse from l2p import * -from .nl2plan.type_extraction import TypeExtraction -from .nl2plan.hierarchy_construction import HierarchyConstruction -from .nl2plan.action_extraction import ActionExtraction -from .nl2plan.action_construction import ActionConstruction -from .nl2plan.task_extraction import TaskExtraction +from .nl2plan import * DOMAINS = [ "blocksworld", "household", - "isr", - "isr-assisted", + "isr", # currently unsupported + "isr-assisted", # currently unsupported "logistics", "tyreworld" ] @@ -33,11 +29,14 @@ UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] -def run_nl2plan(args): +separator = "-" * 20 + +def run_nl2plan(args, domain: str, problem: str): # create necessary classes domain_builder = DomainBuilder() # L2P domain builder task_builder = TaskBuilder() # L2P task builder planner = FastDownward(planner_path=args.planner) # FastDownward planner + log = "" # string to log all step output # initialize OpenAI engine api_key = os.environ.get("OPENAI_API_KEY") @@ -53,11 +52,11 @@ def run_nl2plan(args): types = type_extraction.type_extraction( model=model, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), type_extraction_prompt=type_extraction.prompt_template, feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) - print("TYPES:\n", types) + log += f"STEP ONE: TYPE EXTRACTION\n\n{types}\n\n" model.reset_tokens() # B. Hierarchy Construction @@ -69,12 +68,12 @@ def run_nl2plan(args): type_hierarchy = hierarchy_construction.hierarchy_construction( model=model, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), type_hierarchy_prompt=hierarchy_construction.prompt_template, types=types, feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) - - print("\n\nTYPE HIERARCHY:\n", type_hierarchy) + + log += f"{separator}\nSTEP TWO: HIERARCHY CONSTRUCTION\n\n{type_hierarchy}\n\n" model.reset_tokens() # C. Action Extraction @@ -86,12 +85,12 @@ def run_nl2plan(args): nl_actions = action_extraction.action_extraction( model=model, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), action_extraction_prompt=action_extraction.prompt_template, type_hierarchy=type_hierarchy, feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) - - print("\n\nNL ACTIONS:\n", nl_actions) + + log += f"{separator}\nSTEP THREE: ACTION EXTRACTION\n\n{nl_actions}\n\n" model.reset_tokens() # D. Action Construction @@ -103,7 +102,7 @@ def run_nl2plan(args): actions, predicates, = action_construction.action_construction( model=model, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), + domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), act_constr_prompt=action_construction.prompt_template, nl_actions=nl_actions, type_hierarchy=type_hierarchy, @@ -111,14 +110,12 @@ def run_nl2plan(args): max_attempts=1 ) - print("\n\nACTIONS:") - for i in actions: - print(i) - - print("\n\nPREDICATES:") - for i in predicates: - print(i) - + log += f"{separator}\n" + log += "STEP FOUR: ACTION CONSTRUCTION\n\n" + log += "ACTIONS:\n" + log += '\n'.join([str(action) for action in actions]) + "\n\n" + log += "PREDICATES:\n" + log += '\n'.join([str(predicate) for predicate in predicates]) + "\n\n" model.reset_tokens() # E. Task Extraction @@ -130,7 +127,7 @@ def run_nl2plan(args): objects, initial, goal = task_extraction.task_extraction( model=model, - problem_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/task1.txt"), + problem_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/{problem}.txt"), task_extraction_prompt=task_extraction.prompt_template, types=type_hierarchy, predicates=predicates, @@ -138,9 +135,10 @@ def run_nl2plan(args): error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") ) - print("\n\nOBJECTS:\n", objects) - print("\n\nINITIAL STATES:\n", initial) - print("\n\nGOAL STATES:\n", goal) + log += f"{separator}\nSTEP FIVE: TASK EXTRACTION\n\n" + log += f"OBJECTS:\n{objects}\n" + log += f"INITIAL STATES:\n{initial}\n" + log += f"GOAL STATES:\n{goal}\n" predicate_str = "\n".join( [pred["clean"].replace(":", " ; ") for pred in predicates] @@ -165,7 +163,7 @@ def run_nl2plan(args): actions=actions, ) - print("\n\nPDDL DOMAIN:\n", pddl_domain) + log += f"\n\nPDDL DOMAIN:\n{pddl_domain}" problem_name = args.domain + "_problem" pddl_problem = task_builder.generate_task( @@ -176,25 +174,40 @@ def run_nl2plan(args): goal=goal, ) - print("\n\nPDDL PROBLEM:\n", pddl_problem) + log += f"\n\nPDDL PROBLEM:\n{pddl_problem}" + + # Ensure that the directories exist + main_directory = f"paper_reconstructions/nl2plan/results/{domain}/{problem}" + os.makedirs(main_directory, exist_ok=True) # Creates the directory, if it doesn't exist + + # Write log file + log_file = f"{main_directory}/log.txt" + with open(log_file, "w") as f: + f.write(log) - # write files - domain_file = "paper_reconstructions/nl2plan/results/blocksworld/domain.pddl" + # Write domain and problem files + domain_file = f"{main_directory}/domain.pddl" with open(domain_file, "w") as f: f.write(pddl_domain) - problem_file = "paper_reconstructions/nl2plan/results/blocksworld/problem.pddl" + problem_file = f"{main_directory}/problem.pddl" with open(problem_file, "w") as f: f.write(pddl_problem) - # run planner - planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) + # Run planner + _, plan = planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) + + # Write plan file + plan_file = f"{main_directory}/plan.txt" + with open(plan_file, "w") as f: + f.write(plan) + if __name__ == "__main__": # load in arguments to run program - parser = argparse.ArgumentParser(description="LLM+P") + parser = argparse.ArgumentParser(description="NL2Plan") parser.add_argument('--model', type=str, default="gpt-4o-mini") parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) @@ -202,4 +215,4 @@ def run_nl2plan(args): args = parser.parse_args() # run LLM+P method - run_nl2plan(args=args) + run_nl2plan(args=args, domain="blocksworld", problem="task1") diff --git a/paper_reconstructions/nl2plan/nl2plan/__init__.py b/paper_reconstructions/nl2plan/nl2plan/__init__.py new file mode 100644 index 0000000..5c1fe55 --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/__init__.py @@ -0,0 +1,5 @@ +from .type_extraction import TypeExtraction +from .hierarchy_construction import HierarchyConstruction +from .action_extraction import ActionExtraction +from .action_construction import ActionConstruction +from .task_extraction import TaskExtraction \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl deleted file mode 100644 index ab8a650..0000000 --- a/paper_reconstructions/nl2plan/results/blocksworld/domain.pddl +++ /dev/null @@ -1,98 +0,0 @@ -(define (domain blocksworld) - (:requirements - :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) - - (:types - block - object - table - object - ) - - (:predicates - (on_table ?b - block) ; true if the block ?b is on the table - (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 - (held ?b - block) ; true if the block ?b is currently held by the robot arm - (stability_checked ?b - block) ; true if the stability of block ?b has been checked by the robot arm - ) - - (:action pick_block - :parameters ( - ?b - block - ) - :precondition - (and - (or (on_table ?b) (exists (?b2 - block) (on_block ?b ?b2))) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently held by the robot arm - ) - :effect - (and - (held ?b) ; The block is now held by the robot arm - (not (on_table ?b)) ; The block is no longer on the table - (not (on_block ?b ?b2)) ; The block is no longer on top of another block (assuming ?b2 is the block it was on) - ) - ) - - (:action place_on_table - :parameters ( - ?b - block - ) - :precondition - (and - (held ?b) ; The block is currently held by the robot arm - (not (on_table ?b)) ; The block is not already on the table - ) - :effect - (and - (not (held ?b)) ; The block is no longer held by the robot arm - (on_table ?b) ; The block is now on the table - ) - ) - - (:action stack_block - :parameters ( - ?b1 - block - ?b2 - block - ) - :precondition - (and - (held ?b1) ; The block ?b1 is currently held by the robot arm - (not (held ?b2)) ; The block ?b2 is not currently held by the robot arm - (or (on_table ?b2) (on_block ?b2 ?b3)) ; The block ?b2 is either on the table or on another block - ) - :effect - (and - (not (held ?b1)) ; The block ?b1 is no longer held by the robot arm - (on_block ?b1 ?b2) ; The block ?b1 is now on top of block ?b2 - ) - ) - - (:action release_block - :parameters ( - ?b - block - ) - :precondition - (and - (held ?b) ; The block is currently held by the robot arm - (not (exists (?b2 - block) (on_block ?b ?b2))) ; The block is not on another block - ) - :effect - (and - (not (held ?b)) ; The block is no longer held by the robot arm - (on_table ?b) ; The block is now on the table after being released - ) - ) - - (:action check_stability - :parameters ( - ?b - block - ) - :precondition - (and - (not (held ?b)) ; The block is not currently held by the robot arm - (or (on_table ?b) (on_block ?b ?b1)) ; The block is either on the table or on top of another block - ) - :effect - (and - (stability_checked ?b) ; The stability of the block has been checked - ) - ) -) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl new file mode 100644 index 0000000..132401d --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl @@ -0,0 +1,88 @@ +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - object + table - object + ) + + (:predicates + (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if block ?b is currently being held by the robot arm + ) + + (:action pick_block + :parameters ( + ?b - block + ?t - table + ?b2 - block + ) + :precondition + (and + (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently being held + ) + :effect + (and + (held ?b) ; The block is now being held by the robot arm + (not (on_table ?b ?t)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ?t - table + ) + :precondition + (and + (held ?b) ; The block is currently being held + (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed + (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + ) + :effect + (and + (on_table ?b ?t) ; The block is now on the table + (not (held ?b)) ; The block is no longer being held + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?t - table + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held + (not (held ?b2)) ; The block being placed on is not currently held + (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it + (not (on_table ?b2 ?t)) ; The block being placed on is not on the table + ) + :effect + (and + (on_block ?b1 ?b2) ; The block being placed is now on top of the other block + (not (held ?b1)) ; The block being placed is no longer held + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently being held + (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt new file mode 100644 index 0000000..d498594 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt @@ -0,0 +1,167 @@ +STEP ONE: TYPE EXTRACTION + +{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'children': []}, {'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'children': []}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block and not currently being held. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block down on the table. Requires the block to be held and the table to be clear of any blocks directly beneath the block being placed. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be held and the block being placed on to be clear of any blocks directly beneath it. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block it is holding. Requires the block to be held. Example: robot_arm releases block_1.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'pick_block', 'params': OrderedDict([('?b', 'block'), ('?t', 'table'), ('?b2', 'block')]), 'preconditions': '(and\n (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently being held\n)', 'effects': '(and\n (held ?b) ; The block is now being held by the robot arm\n (not (on_table ?b ?t)) ; The block is no longer on the table\n (not (on_block ?b ?b2)) ; The block is no longer on top of another block\n)'} +{'name': 'place_on_table', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed\n (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed\n)', 'effects': '(and\n (on_table ?b ?t) ; The block is now on the table\n (not (held ?b)) ; The block is no longer being held\n)'} +{'name': 'place_on_block', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b1) ; The block being placed is currently held\n (not (held ?b2)) ; The block being placed on is not currently held\n (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it\n (not (on_table ?b2 ?t)) ; The block being placed on is not on the table\n)', 'effects': '(and\n (on_block ?b1 ?b2) ; The block being placed is now on top of the other block\n (not (held ?b1)) ; The block being placed is no longer held\n)'} +{'name': 'release_block', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held\n (on_table ?b) ; The block is placed on the table after being released\n)'} + +PREDICATES: +{'name': 'on_table', 'desc': 'true if block ?b is on the table ?t', 'raw': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'clean': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t'} +{'name': 'on_block', 'desc': 'true if block ?b1 is on top of block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2'} +{'name': 'held', 'desc': 'true if block ?b is currently being held by the robot arm', 'raw': '(held ?b - block): true if block ?b is currently being held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if block ?b is currently being held by the robot arm'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +blue_block - block +red_block - block +yellow_block - block +green_block - block +table1 - table +INITIAL STATES: +(on_block blue_block red_block) +(on_block red_block yellow_block) +(on_table yellow_block table1) +(on_table green_block table1) +(clear green_block) +GOAL STATES: +(AND + (on_block red_block green_block) +) + + +PDDL DOMAIN: +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + block - object + table - object + ) + + (:predicates + (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if block ?b is currently being held by the robot arm + ) + + (:action pick_block + :parameters ( + ?b - block + ?t - table + ?b2 - block + ) + :precondition + (and + (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently being held + ) + :effect + (and + (held ?b) ; The block is now being held by the robot arm + (not (on_table ?b ?t)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ?t - table + ) + :precondition + (and + (held ?b) ; The block is currently being held + (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed + (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + ) + :effect + (and + (on_table ?b ?t) ; The block is now on the table + (not (held ?b)) ; The block is no longer being held + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?t - table + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held + (not (held ?b2)) ; The block being placed on is not currently held + (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it + (not (on_table ?b2 ?t)) ; The block being placed on is not on the table + ) + :effect + (and + (on_block ?b1 ?b2) ; The block being placed is now on top of the other block + (not (held ?b1)) ; The block being placed is no longer held + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently being held + (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) + +PDDL PROBLEM: +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + blue_block - block + red_block - block + yellow_block - block + green_block - block + table1 - table + ) + + (:init + (on_block blue_block red_block) + (on_block red_block yellow_block) + (on_table yellow_block table1) + (on_table green_block table1) + (clear green_block) + ) + + (:goal + (and + (on_block red_block green_block) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt new file mode 100644 index 0000000..746607c --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt @@ -0,0 +1 @@ +Input error in translate phase. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl similarity index 52% rename from paper_reconstructions/nl2plan/results/blocksworld/problem.pddl rename to paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl index aa6ef19..d138670 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/problem.pddl +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl @@ -11,23 +11,16 @@ ) (:init - (on_block red_block yellow_block) (on_block blue_block red_block) - (on_table yellow_block) - (on_table green_block) - (held blue_block) - (stability_checked blue_block) - (stability_checked red_block) - (stability_checked yellow_block) - (stability_checked green_block) + (on_block red_block yellow_block) + (on_table yellow_block table1) + (on_table green_block table1) + (clear green_block) ) (:goal (and (on_block red_block green_block) - (on_table green_block) - (on_table yellow_block) - (on_block blue_block red_block) ) ) From 2e477a709ac0529f591a4249d0afc59eab652706 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Tue, 7 Jan 2025 14:02:10 -0500 Subject: [PATCH 10/15] cleaned nl2plan --- paper_reconstructions/nl2plan/main.py | 52 +++-- .../nl2plan/nl2plan/__init__.py | 5 - .../nl2plan/nl2plan/action_construction.py | 27 +-- .../nl2plan/nl2plan/action_extraction.py | 20 +- .../nl2plan/nl2plan/hierarchy_construction.py | 20 +- .../nl2plan/nl2plan/task_extraction.py | 21 +- .../nl2plan/nl2plan/type_extraction.py | 19 +- .../nl2plan/nl2plan/utils.py | 22 ++ .../results/blocksworld/task2/domain.pddl | 121 ++++++++++ .../nl2plan/results/blocksworld/task2/log.txt | 206 ++++++++++++++++++ .../results/blocksworld/task2/plan.txt | 1 + .../results/blocksworld/task2/problem.pddl | 29 +++ 12 files changed, 439 insertions(+), 104 deletions(-) delete mode 100644 paper_reconstructions/nl2plan/nl2plan/__init__.py create mode 100644 paper_reconstructions/nl2plan/nl2plan/utils.py create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py index 29472d7..b78b3fa 100644 --- a/paper_reconstructions/nl2plan/main.py +++ b/paper_reconstructions/nl2plan/main.py @@ -6,7 +6,12 @@ import argparse from l2p import * -from .nl2plan import * +from .nl2plan.type_extraction import TypeExtraction +from .nl2plan.hierarchy_construction import HierarchyConstruction +from .nl2plan.action_extraction import ActionExtraction +from .nl2plan.action_construction import ActionConstruction +from .nl2plan.task_extraction import TaskExtraction +from .nl2plan.utils import set_prompt DOMAINS = [ "blocksworld", @@ -45,7 +50,8 @@ def run_nl2plan(args, domain: str, problem: str): # A. Type Extraction type_extraction = TypeExtraction() - type_extraction.set_prompt( + type_extraction.prompt_template = set_prompt( + type_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") @@ -61,7 +67,8 @@ def run_nl2plan(args, domain: str, problem: str): # B. Hierarchy Construction hierarchy_construction = HierarchyConstruction() - hierarchy_construction.set_prompt( + hierarchy_construction.prompt_template = set_prompt( + hierarchy_construction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") @@ -78,7 +85,8 @@ def run_nl2plan(args, domain: str, problem: str): # C. Action Extraction action_extraction = ActionExtraction() - action_extraction.set_prompt( + action_extraction.prompt_template = set_prompt( + action_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") @@ -95,7 +103,8 @@ def run_nl2plan(args, domain: str, problem: str): # D. Action Construction action_construction = ActionConstruction() - action_construction.set_prompt( + action_construction.prompt_template = set_prompt( + action_construction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") @@ -120,7 +129,8 @@ def run_nl2plan(args, domain: str, problem: str): # E. Task Extraction task_extraction = TaskExtraction() - task_extraction.set_prompt( + task_extraction.prompt_template = set_prompt( + task_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") @@ -206,13 +216,25 @@ def run_nl2plan(args, domain: str, problem: str): if __name__ == "__main__": - # load in arguments to run program - parser = argparse.ArgumentParser(description="NL2Plan") - parser.add_argument('--model', type=str, default="gpt-4o-mini") - parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") - parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) - parser.add_argument('--planner', type=str, default="/Users/marcustantakoun/Downloads/downward/fast-downward.py") - args = parser.parse_args() + # # load in arguments to run program + # parser = argparse.ArgumentParser(description="NL2Plan") + # parser.add_argument('--model', type=str, default="gpt-4o-mini") + # parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") + # parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) + # parser.add_argument('--planner', type=str, default="/Users/marcustantakoun/Downloads/downward/fast-downward.py") + # args = parser.parse_args() - # run LLM+P method - run_nl2plan(args=args, domain="blocksworld", problem="task1") + # # run LLM+P method + # run_nl2plan(args=args, domain="blocksworld", problem="task2") + + planner = FastDownward(planner_path="/Users/marcustantakoun/Downloads/downward/fast-downward.py") + domain_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl" + problem_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl" + + # Run planner + _, plan = planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) + + # Write plan file + plan_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt" + with open(plan_file, "w") as f: + f.write(plan) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/__init__.py b/paper_reconstructions/nl2plan/nl2plan/__init__.py deleted file mode 100644 index 5c1fe55..0000000 --- a/paper_reconstructions/nl2plan/nl2plan/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .type_extraction import TypeExtraction -from .hierarchy_construction import HierarchyConstruction -from .action_extraction import ActionExtraction -from .action_construction import ActionConstruction -from .task_extraction import TaskExtraction \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py index 0ef0cf5..c981920 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -1,5 +1,6 @@ import os from l2p import * +from .utils import set_prompt class ActionConstruction: def __init__(self): @@ -7,28 +8,6 @@ def __init__(self): self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() self.syntax_validator = SyntaxValidator() - self.pddl_actions = list[Action] - self.pddl_predicates = list[Predicate] - - - def set_prompt(self, role_path: str, examples_path: str, task_path: str): - - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - - self.prompt_template.set_role(role=role) - for ex in examples: - self.prompt_template.set_examples(example=ex) - self.prompt_template.set_task(task=task) - - - def set_actions(self, actions: list[Action]): - self.pddl_actions = actions - - - def set_predicates(self, predicates: list[Predicate]): - self.pddl_predicates = predicates def construct_action( @@ -228,7 +207,9 @@ def action_construction( } action_construction = ActionConstruction() - action_construction.set_prompt( + + action_construction.prompt_template = set_prompt( + action_construction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") diff --git a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py index cc2b3ee..abf7b81 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py @@ -1,5 +1,6 @@ import os from l2p import * +from .utils import set_prompt class ActionExtraction: def __init__(self): @@ -8,20 +9,7 @@ def __init__(self): self.feedback_builder = FeedbackBuilder() self.nl_actions = dict[str,str] - def set_prompt(self, role_path: str, examples_path: str, task_path: str): - - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - - self.prompt_template.set_role(role=role) - for ex in examples: - self.prompt_template.set_examples(example=ex) - self.prompt_template.set_task(task=task) - - def set_nl_actions(self, nl_actions: dict[str,str]): - self.nl_actions = nl_actions - + def action_extraction( self, model: LLM, @@ -74,7 +62,9 @@ def action_extraction( } action_extraction = ActionExtraction() - action_extraction.set_prompt( + + action_extraction.prompt_template = set_prompt( + action_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") diff --git a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py index ca21e54..50ce82e 100644 --- a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py @@ -1,5 +1,6 @@ import os from l2p import * +from .utils import set_prompt class HierarchyConstruction: def __init__(self): @@ -7,20 +8,7 @@ def __init__(self): self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() self.type_hierarchy = dict[str, str] - - def set_prompt(self, role_path: str, examples_path: str, task_path: str): - - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - - self.prompt_template.set_role(role=role) - for ex in examples: - self.prompt_template.set_examples(example=ex) - self.prompt_template.set_task(task=task) - - def set_types(self, types: dict[str,str]): - self.type_hierarchy = types + def hierarchy_construction( self, @@ -62,7 +50,9 @@ def hierarchy_construction( 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} hierarchy_construction = HierarchyConstruction() - hierarchy_construction.set_prompt( + + hierarchy_construction.prompt_template = set_prompt( + hierarchy_construction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") diff --git a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py index eb6a240..dedbe45 100644 --- a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py @@ -1,5 +1,6 @@ import os from l2p import * +from .utils import set_prompt class TaskExtraction: def __init__(self): @@ -7,21 +8,7 @@ def __init__(self): self.task_builder = TaskBuilder() self.feedback_builder = FeedbackBuilder() self.syntax_validator = SyntaxValidator() - self.pddl_predicates = list[Predicate] - - def set_prompt(self, role_path: str, examples_path: str, task_path: str): - - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - - self.prompt_template.set_role(role=role) - for ex in examples: - self.prompt_template.set_examples(example=ex) - self.prompt_template.set_task(task=task) - - def set_predicates(self, predicates: list[Predicate]): - self.pddl_predicates = predicates + def task_extraction( self, @@ -131,7 +118,9 @@ def task_extraction( {'name': 'on_block', 'desc': "'Indicates that block ?b is placed on top of block ?b2'", 'raw': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'", 'params': OrderedDict([('?b', 'block'), ('?b2', 'block')]), 'clean': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'"}] task_extraction = TaskExtraction() - task_extraction.set_prompt( + + task_extraction.prompt_template = set_prompt( + task_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") diff --git a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py index db6b005..859cb7a 100644 --- a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py @@ -1,26 +1,13 @@ import os from l2p import * +from .utils import set_prompt class TypeExtraction: def __init__(self): self.prompt_template = PromptBuilder() self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() - self.types = dict[str, str] - - def set_prompt(self, role_path: str, examples_path: str, task_path: str): - - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - self.prompt_template.set_role(role=role) - for ex in examples: - self.prompt_template.set_examples(example=ex) - self.prompt_template.set_task(task=task) - - def set_types(self, types: dict[str,str]): - self.types = types def type_extraction( self, @@ -55,7 +42,9 @@ def type_extraction( openai_llm = OPENAI(model=engine, api_key=api_key) type_extraction = TypeExtraction() - type_extraction.set_prompt( + + type_extraction.prompt_template = set_prompt( + type_extraction.prompt_template, role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") diff --git a/paper_reconstructions/nl2plan/nl2plan/utils.py b/paper_reconstructions/nl2plan/nl2plan/utils.py new file mode 100644 index 0000000..cc7df7b --- /dev/null +++ b/paper_reconstructions/nl2plan/nl2plan/utils.py @@ -0,0 +1,22 @@ +from l2p import PromptBuilder +from l2p import load_file, load_files + +def set_prompt( + prompt_builder: PromptBuilder, + role_path: str, + examples_path: str, + task_path: str + ) -> PromptBuilder: + + # load in files + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + # set prompts to prompt builder class + prompt_builder.set_role(role=role) + for ex in examples: + prompt_builder.set_examples(example=ex) + prompt_builder.set_task(task=task) + + return prompt_builder \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl new file mode 100644 index 0000000..61315df --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl @@ -0,0 +1,121 @@ +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + movable_object - object + block - movable_object + table - object + ) + + (:predicates + (on_table ?b - block) ; true if the block ?b is on the table. + (held ?b - block) ; true if the block ?b is currently held by the robot arm. + (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2. + ) + + (:action pick_block + :parameters ( + ?b - block + ) + :precondition + (and + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently held by the arm + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2) + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?b3 - block + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held by the robot arm. + (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked. + (not (held ?b2)) ; The target block must not be held by the arm. + ) + :effect + (and + (not (held ?b1)) ; The block being placed is no longer held by the robot arm. + (on ?b1 ?b2) ; The block being placed is now on top of the target block. + ) + ) + + (:action release_block + :parameters ( + ?b - block + ?b2 - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block + ) + ) + + (:action pick_and_place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently held by the robot arm + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was) + ) + ) + + (:action pick_and_place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?b3 - block + ) + :precondition + (and + (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block + (not (held ?b1)) ; ?b1 must not be currently held by the robot arm + (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block + ) + :effect + (and + (held ?b1) ; ?b1 is now held by the robot arm + (not (on_table ?b1)) ; ?b1 is no longer on the table + (on ?b1 ?b2) ; ?b1 is now on top of ?b2 + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt new file mode 100644 index 0000000..e55c0bf --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt @@ -0,0 +1,206 @@ +STEP ONE: TYPE EXTRACTION + +{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm.', 'children': []}]}, {'table': 'A flat surface where blocks can be placed.', 'children': []}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table.', 'place_on_table': 'The robot arm places a block onto the table. Requires the block to be currently held by the arm. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be currently held by the arm and the target block to be on the table or already stacked, and the target block must not be held by the arm. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block that is currently held. Example: robot_arm releases block_1.', 'pick_and_place_on_table': 'The robot arm picks a block and places it on the table. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table and places it on the table.', 'pick_and_place_on_block': 'The robot arm picks a block and places it on top of another block. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table and places it on block_2.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'pick_block', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently held by the arm\n)', 'effects': '(and\n (held ?b) ; The block is now held by the robot arm\n (not (on_table ?b)) ; The block is no longer on the table\n (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2)\n)'} +{'name': 'place_on_table', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (on_table ?b) ; The block is now on the table\n)'} +{'name': 'place_on_block', 'params': OrderedDict({'?b1': 'block', '?b2': 'block', '?b3': 'block'}), 'preconditions': '(and\n (held ?b1) ; The block being placed is currently held by the robot arm.\n (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked.\n (not (held ?b2)) ; The target block must not be held by the arm.\n)', 'effects': '(and\n (not (held ?b1)) ; The block being placed is no longer held by the robot arm.\n (on ?b1 ?b2) ; The block being placed is now on top of the target block.\n)'} +{'name': 'release_block', 'params': OrderedDict({'?b': 'block', '?b2': 'block'}), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block\n)'} +{'name': 'pick_and_place_on_table', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently held by the robot arm\n)', 'effects': '(and\n (held ?b) ; The block is now held by the robot arm\n (not (on_table ?b)) ; The block is no longer on the table\n (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was)\n)'} +{'name': 'pick_and_place_on_block', 'params': OrderedDict({'?b1': 'block', '?b2': 'block', '?b3': 'block'}), 'preconditions': '(and\n (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block\n (not (held ?b1)) ; ?b1 must not be currently held by the robot arm\n (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block\n)', 'effects': '(and\n (held ?b1) ; ?b1 is now held by the robot arm\n (not (on_table ?b1)) ; ?b1 is no longer on the table\n (on ?b1 ?b2) ; ?b1 is now on top of ?b2\n)'} + +PREDICATES: +{'name': 'on_table', 'desc': 'true if the block ?b is on the table.', 'raw': '(on_table ?b - block): true if the block ?b is on the table', 'params': OrderedDict({'?b': 'block'}), 'clean': '(on_table ?b - block): true if the block ?b is on the table.'} +{'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm.', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict({'?b': 'block'}), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm.'} +{'name': 'on', 'desc': 'true if block ?b1 is on top of block ?b2.', 'raw': '(on ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict({'?b1': 'block', '?b2': 'block'}), 'clean': '(on ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2.'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +block1 - block +block2 - block +block3 - block +block4 - block +table1 - table +INITIAL STATES: +(on block1 table1) +(on block2 block1) +(on block3 table1) +(on block4 block3) +GOAL STATES: +(AND + (on block1 table1) + (on block3 block1) + (on block2 block3) + (on block4 block2) +) + + +PDDL DOMAIN: +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + movable_object - object + block - movable_object + table - object + ) + + (:predicates + (on_table ?b - block) ; true if the block ?b is on the table. + (held ?b - block) ; true if the block ?b is currently held by the robot arm. + (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2. + ) + + (:action pick_block + :parameters ( + ?b - block + ) + :precondition + (and + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently held by the arm + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2) + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?b3 - block + ) + :precondition + (and + (held ?b1) ; The block being placed is currently held by the robot arm. + (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked. + (not (held ?b2)) ; The target block must not be held by the arm. + ) + :effect + (and + (not (held ?b1)) ; The block being placed is no longer held by the robot arm. + (on ?b1 ?b2) ; The block being placed is now on top of the target block. + ) + ) + + (:action release_block + :parameters ( + ?b - block + ?b2 - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block + ) + ) + + (:action pick_and_place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block + (not (held ?b)) ; The block is not currently held by the robot arm + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was) + ) + ) + + (:action pick_and_place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ?b3 - block + ) + :precondition + (and + (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block + (not (held ?b1)) ; ?b1 must not be currently held by the robot arm + (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block + ) + :effect + (and + (held ?b1) ; ?b1 is now held by the robot arm + (not (on_table ?b1)) ; ?b1 is no longer on the table + (on ?b1 ?b2) ; ?b1 is now on top of ?b2 + ) + ) +) + +PDDL PROBLEM: +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + block1 - block + block2 - block + block3 - block + block4 - block + table1 - table + ) + + (:init + (on block1 table1) + (on block2 block1) + (on block3 table1) + (on block4 block3) + ) + + (:goal + (and + (on block1 table1) + (on block3 block1) + (on block2 block3) + (on block4 block2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt new file mode 100644 index 0000000..2995509 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt @@ -0,0 +1 @@ +Input error in the driver. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl new file mode 100644 index 0000000..cd4abfa --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl @@ -0,0 +1,29 @@ +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + block1 - block + block2 - block + block3 - block + block4 - block + table1 - table + ) + + (:init + (on block1 table1) + (on block2 block1) + (on block3 table1) + (on block4 block3) + ) + + (:goal + (and + (on block1 table1) + (on block3 block1) + (on block2 block3) + (on block4 block2) + ) + ) + +) \ No newline at end of file From 38e4fa207f095d3ed3b6ae3b641e30e26da47e81 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Wed, 8 Jan 2025 12:08:18 -0500 Subject: [PATCH 11/15] completed Nl2Plan recreation --- l2p/domain_builder.py | 75 ++- l2p/feedback_builder.py | 86 ++-- l2p/prompt_builder.py | 1 + l2p/task_builder.py | 8 +- l2p/utils/pddl_parser.py | 13 +- l2p/utils/pddl_planner.py | 16 +- l2p/utils/pddl_validator.py | 39 +- .../llm+dm/construct_action_models.py | 3 + .../llm+dm/correct_action_models.py | 0 paper_reconstructions/llm+dm/main.py | 4 + paper_reconstructions/llm+p/domain.py | 53 +- paper_reconstructions/llm+p/main.py | 98 ++-- .../nl2plan/domains/logistics/desc.txt | 1 - .../nl2plan/domains/logistics/task1.txt | 1 - paper_reconstructions/nl2plan/main.py | 482 ++++++++++-------- .../nl2plan/nl2plan/action_construction.py | 238 +++++---- .../nl2plan/nl2plan/action_extraction.py | 76 +-- .../nl2plan/nl2plan/hierarchy_construction.py | 67 +-- .../nl2plan/nl2plan/task_extraction.py | 137 +++-- .../nl2plan/nl2plan/type_extraction.py | 70 ++- .../nl2plan/nl2plan/utils.py | 22 - .../prompts/action_construction/role.txt | 2 + .../results/blocksworld/task1/domain.pddl | 80 ++- .../nl2plan/results/blocksworld/task1/log.txt | 159 +++--- .../results/blocksworld/task1/plan.txt | 4 +- .../results/blocksworld/task1/problem.pddl | 28 +- .../results/blocksworld/task2/domain.pddl | 112 ++-- .../nl2plan/results/blocksworld/task2/log.txt | 195 +++---- .../results/blocksworld/task2/plan.txt | 2 +- .../results/blocksworld/task2/problem.pddl | 29 +- .../results/blocksworld/task3/domain.pddl | 87 ++++ .../nl2plan/results/blocksworld/task3/log.txt | 193 +++++++ .../results/blocksworld/task3/plan.txt | 1 + .../results/blocksworld/task3/problem.pddl | 40 ++ .../results/household/task1/domain.pddl | 205 ++++++++ .../nl2plan/results/household/task1/log.txt | 357 +++++++++++++ .../nl2plan/results/household/task1/plan.txt | 1 + .../results/household/task1/problem.pddl | 56 ++ .../results/tyreworld/task1/domain.pddl | 187 +++++++ .../nl2plan/results/tyreworld/task1/log.txt | 306 +++++++++++ .../nl2plan/results/tyreworld/task1/plan.txt | 4 + .../results/tyreworld/task1/problem.pddl | 40 ++ paper_reconstructions/p+s/main.py | 174 ++++--- tests/test_domain_builder.py | 65 ++- 44 files changed, 2677 insertions(+), 1140 deletions(-) create mode 100644 paper_reconstructions/llm+dm/construct_action_models.py create mode 100644 paper_reconstructions/llm+dm/correct_action_models.py delete mode 100644 paper_reconstructions/nl2plan/domains/logistics/desc.txt delete mode 100644 paper_reconstructions/nl2plan/domains/logistics/task1.txt delete mode 100644 paper_reconstructions/nl2plan/nl2plan/utils.py create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task3/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task3/log.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task3/plan.txt create mode 100644 paper_reconstructions/nl2plan/results/blocksworld/task3/problem.pddl create mode 100644 paper_reconstructions/nl2plan/results/household/task1/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/household/task1/log.txt create mode 100644 paper_reconstructions/nl2plan/results/household/task1/plan.txt create mode 100644 paper_reconstructions/nl2plan/results/household/task1/problem.pddl create mode 100644 paper_reconstructions/nl2plan/results/tyreworld/task1/domain.pddl create mode 100644 paper_reconstructions/nl2plan/results/tyreworld/task1/log.txt create mode 100644 paper_reconstructions/nl2plan/results/tyreworld/task1/plan.txt create mode 100644 paper_reconstructions/nl2plan/results/tyreworld/task1/problem.pddl diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index 67400bb..c9b9b6c 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -241,11 +241,11 @@ def extract_pddl_action( # replace prompt placeholders types_str = format_dict(types) if types else "No types provided." predicates_str = ( - "\n".join([f"- {pred['clean']}" for pred in predicates]) if predicates else "No predicates provided." - ) - action_list_str = ( - action_list if action_list else "No other actions provided" + "\n".join([f"- {pred['clean']}" for pred in predicates]) + if predicates + else "No predicates provided." ) + action_list_str = action_list if action_list else "No other actions provided" prompt_template = prompt_template.replace("{domain_desc}", domain_desc) prompt_template = prompt_template.replace("{action_list}", action_list_str) @@ -269,27 +269,51 @@ def extract_pddl_action( llm_response=llm_response, action_name=action_name ) new_predicates = parse_new_predicates(llm_response) - + validation_info = [True, "All validations passed."] if syntax_validator: for e in syntax_validator.error_types: - if e == 'invalid_header': - validation_info = syntax_validator.validate_header(llm_response) - elif e == 'invalid_keyword_usage': - validation_info = syntax_validator.validate_keyword_usage(llm_response) - elif e == 'unsupported_keywords': - validation_info = syntax_validator.validate_unsupported_keywords(llm_response, syntax_validator.unsupported_keywords) - elif e == 'invalid_param_types': - validation_info = syntax_validator.validate_params(action['params'], types) - elif e == 'invalid_predicate_name': - validation_info = syntax_validator.validate_types_predicates(new_predicates, types) - elif e == 'invalid_predicate_format': - validation_info = syntax_validator.validate_format_predicates(predicates, types) - elif e == 'invalid_predicate_usage': - validation_info = syntax_validator.validate_usage_predicates(llm_response, predicates, types) + if e == "invalid_header": + validation_info = syntax_validator.validate_header( + llm_response + ) + elif e == "invalid_keyword_usage": + validation_info = syntax_validator.validate_keyword_usage( + llm_response + ) + elif e == "unsupported_keywords": + validation_info = ( + syntax_validator.validate_unsupported_keywords( + llm_response, syntax_validator.unsupported_keywords + ) + ) + elif e == "invalid_param_types": + validation_info = syntax_validator.validate_params( + action["params"], types + ) + elif e == "invalid_predicate_name": + validation_info = ( + syntax_validator.validate_types_predicates( + new_predicates, types + ) + ) + elif e == "invalid_predicate_format": + validation_info = ( + syntax_validator.validate_format_predicates( + predicates, types + ) + ) + elif e == "invalid_predicate_usage": + validation_info = ( + syntax_validator.validate_usage_predicates( + llm_response, predicates, types + ) + ) else: - raise NotImplementedError(f"Validation type '{e}' is not implemented.") - + raise NotImplementedError( + f"Validation type '{e}' is not implemented." + ) + if not validation_info[0]: return action, new_predicates, llm_response, validation_info @@ -753,14 +777,15 @@ def generate_domain( """ desc = "" desc += f"(define (domain {domain})\n" - desc += indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + "\n\n" + desc += ( + indent(string=f"(:requirements\n {' '.join(requirements)})", level=1) + + "\n\n" + ) desc += f" (:types \n{indent(string=types, level=2)}\n )\n\n" desc += f" (:predicates \n{indent(string=predicates, level=2)}\n )" desc += self.action_descs(actions) desc += "\n)" - desc = desc.replace("AND", "and").replace( - "OR", "or" - ) + desc = desc.replace("AND", "and").replace("OR", "or") return desc def action_desc(self, action: Action) -> str: diff --git a/l2p/feedback_builder.py b/l2p/feedback_builder.py index 410fa4a..a5e3815 100644 --- a/l2p/feedback_builder.py +++ b/l2p/feedback_builder.py @@ -75,21 +75,23 @@ def type_feedback( ) if not no_fb: - structure_prompt = textwrap.dedent(""" + structure_prompt = textwrap.dedent( + """ ## OUTPUT { "type_1": "description", "type_2": "description", "type_3": "description", } - """) - + """ + ) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f'\nEnd your final answer starting with "## OUTPUT" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}' f"\n\nApply the suggestions to your original answer:\n{type_str}" ) - + model.reset_tokens() types, llm_response = domain_builder.extract_type( @@ -125,7 +127,8 @@ def type_hierarchy_feedback( ) if not no_fb: - structure_prompt = textwrap.dedent(""" + structure_prompt = textwrap.dedent( + """ ## OUTPUT { "parent_type_1": "description", @@ -139,16 +142,17 @@ def type_hierarchy_feedback( } ] } - """) - + """ + ) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f'\nEnd your final answer starting with "## OUTPUT" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}' f"\n\nApply the suggestions to your original answer:\n{type_str}" ) - + model.reset_tokens() - + type_hierarchy, llm_response = domain_builder.extract_type_hierarchy( model, domain_desc, prompt, type_str ) @@ -187,23 +191,25 @@ def nl_action_feedback( ) if not no_fb: - structure_prompt = textwrap.dedent(""" + structure_prompt = textwrap.dedent( + """ ## OUTPUT { "action_name_1": "action_description", "action_name_2": "action_description", "action_name_3": "action_description" } - """) - + """ + ) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" - f"\nEnd your final answer starting with \"## OUTPUT\" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}" + f'\nEnd your final answer starting with "## OUTPUT" and then re-iterate an updated version of the Python dictionary pair like so:\n{structure_prompt}' f"\n\nApply the suggestions to your original answer:\n{nl_action_str}" ) - + model.reset_tokens() - + nl_actions, llm_response = domain_builder.extract_type_hierarchy( model, domain_desc, prompt ) @@ -221,7 +227,7 @@ def pddl_action_feedback( action: Action = None, predicates: list[Predicate] = None, types: dict[str, str] = None, - ) -> tuple[Action, list[Predicate], str, tuple[bool,str], bool]: + ) -> tuple[Action, list[Predicate], str, tuple[bool, str], bool]: """Makes LLM call using feedback prompt, then parses it into action format""" model.reset_tokens() @@ -258,8 +264,9 @@ def pddl_action_feedback( validation_info = [True, "All validations passed."] if not no_fb: - - structure_prompt = textwrap.dedent(""" + + structure_prompt = textwrap.dedent( + """ End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL as so: ### Action Parameters @@ -287,18 +294,21 @@ def pddl_action_feedback( ``` If there are no new predicates created, keep an empty space enclosed ``` ``` with the '### New Predicates' header. - """) - + """ + ) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() - action, predicates, llm_response, validation_info = domain_builder.extract_pddl_action( - model, domain_desc, prompt, action_name + action, predicates, llm_response, validation_info = ( + domain_builder.extract_pddl_action( + model, domain_desc, prompt, action_name + ) ) return action, predicates, llm_response, validation_info, no_fb @@ -344,7 +354,7 @@ def parameter_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() param, param_raw, llm_response = domain_builder.extract_parameters( @@ -406,7 +416,7 @@ def precondition_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() preconditions, new_predicates, llm_response = ( @@ -473,7 +483,7 @@ def effect_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() effects, new_predicates, llm_response = domain_builder.extract_effects( @@ -520,7 +530,7 @@ def predicate_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() new_predicates, llm_response = domain_builder.extract_predicates( @@ -579,8 +589,9 @@ def task_feedback( ) if not no_fb: - - structure_prompt = textwrap.dedent(""" + + structure_prompt = textwrap.dedent( + """ End your final answer starting with headers (in order) "### OBJECTS" (with no brackets) "### INITIAL" and "### GOAL" containg respective content with ''' ''' comment blocks in PDDL as so: ### OBJECTS @@ -605,14 +616,15 @@ def task_feedback( ``` Even if there is one goal state, it must contain the PDDL 'and' syntax. Each object must be declared separately with their type and not grouped - even if objects share the same type. - """) - + """ + ) + prompt = ( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\n{structure_prompt}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() objects, initial, goal, _ = task_builder.extract_task( @@ -664,7 +676,7 @@ def objects_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() objects, llm_response = task_builder.extract_objects( @@ -725,7 +737,7 @@ def initial_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() initial, llm_response = task_builder.extract_initial_state( @@ -791,7 +803,7 @@ def goal_state_feedback( f"\n\nYou now are revising your answer using feedback. Here is the feedback you outputted:\n{fb_msg}" f"\n\nFollow the same syntax format as the original output in your answer:\n{llm_response}" ) - + model.reset_tokens() goal, llm_response = task_builder.extract_goal_state( diff --git a/l2p/prompt_builder.py b/l2p/prompt_builder.py index 5bb8e87..4727cf1 100644 --- a/l2p/prompt_builder.py +++ b/l2p/prompt_builder.py @@ -3,6 +3,7 @@ have to use this class, but it is generally advisable for ease of use. """ + class PromptBuilder: def __init__( self, diff --git a/l2p/task_builder.py b/l2p/task_builder.py index 77cbc30..03746b0 100644 --- a/l2p/task_builder.py +++ b/l2p/task_builder.py @@ -58,7 +58,9 @@ def extract_objects( # replace prompt placeholders predicate_str = ( - "\n".join([f"- {pred['name']}: {pred['desc']}" for pred in predicates]) if predicates else "No predicates provided." + "\n".join([f"- {pred['name']}: {pred['desc']}" for pred in predicates]) + if predicates + else "No predicates provided." ) types_str = "\n".join(types) if types else "No types provided." @@ -433,7 +435,9 @@ def format_action(self, actions: list[Action]) -> str: return desc def format_objects(self, objects: dict[str, str]) -> str: - objects = "\n".join([f"{obj} - {type}" if type else f"{obj}" for obj, type in objects.items()]) + objects = "\n".join( + [f"{obj} - {type}" if type else f"{obj}" for obj, type in objects.items()] + ) return objects def format_initial(self, initial_states: list[dict[str, str]]) -> str: diff --git a/l2p/utils/pddl_parser.py b/l2p/utils/pddl_parser.py index 45721fa..a31426e 100644 --- a/l2p/utils/pddl_parser.py +++ b/l2p/utils/pddl_parser.py @@ -9,6 +9,7 @@ from copy import deepcopy import re, ast, json, sys, os + def load_file(file_path: str): _, ext = os.path.splitext(file_path) with open(file_path, "r") as file: @@ -16,16 +17,18 @@ def load_file(file_path: str): return json.load(file) else: return file.read().strip() - + + def load_files(folder_path: str): file_contents = [] for filename in sorted(os.listdir(folder_path)): file_path = os.path.join(folder_path, filename) if os.path.isfile(file_path): - with open(file_path, 'r') as file: + with open(file_path, "r") as file: file_contents.append(file.read()) return file_contents + def parse_params(llm_output): """ Parses parameters from LLM into Python format (refer to example templates to see @@ -34,7 +37,9 @@ def parse_params(llm_output): LLM output header should contain '### Parameters' along with structured content. """ params_info = OrderedDict() - params_heading = re.split(r"\n#+\s", llm_output.split("Parameters")[1].strip(), maxsplit=1)[0] + params_heading = re.split( + r"\n#+\s", llm_output.split("Parameters")[1].strip(), maxsplit=1 + )[0] params_str = combine_blocks(params_heading) params_raw = [] for line in params_str.split("\n"): @@ -226,7 +231,7 @@ def parse_objects(llm_response: str) -> dict[str, str]: objects_head = extract_heading(llm_response, "OBJECTS") objects_raw = combine_blocks(objects_head) - + objects_clean = clear_comments( text=objects_raw, comments=[":", "//", "#", ";", "(", ")"] ) # Remove comments diff --git a/l2p/utils/pddl_planner.py b/l2p/utils/pddl_planner.py index c4ead0f..baed7aa 100644 --- a/l2p/utils/pddl_planner.py +++ b/l2p/utils/pddl_planner.py @@ -35,24 +35,26 @@ class FastDownward: - + def __init__(self, planner_path: str): - self.planner_path = planner_path # directory of FastDownward planner + self.planner_path = planner_path # directory of FastDownward planner - def run_fast_downward(self, domain_file: str, problem_file: str, search_alg: str="lama-first"): + def run_fast_downward( + self, domain_file: str, problem_file: str, search_alg: str = "lama-first" + ): """ Main function to run planner. - + Args: - domain_file (str): PDDL domain file path - problem_file (str): PDDL problem file path - - search_alg (str): search algorithm/heuristic to use + - search_alg (str): search algorithm/heuristic to use + refer to: https://www.fast-downward.org/PlannerUsage - + Returns: - success (bool): if a plan was found, otherwise False for incomplete. - plan_output (str): plan output information. - + """ try: result = subprocess.run( diff --git a/l2p/utils/pddl_validator.py b/l2p/utils/pddl_validator.py index 0d97b42..b8257fc 100644 --- a/l2p/utils/pddl_validator.py +++ b/l2p/utils/pddl_validator.py @@ -8,26 +8,31 @@ class SyntaxValidator: - def __init__( - self, - error_types=None, - unsupported_keywords = None - ): - + def __init__(self, error_types=None, unsupported_keywords=None): + # current error types available default_error_types = [ - 'invalid_header', - 'invalid_keyword_usage', - 'unsupported_keywords', - 'invalid_param_types', - 'invalid_predicate_name', - 'invalid_predicate_format', - 'invalid_predicate_usage' + "invalid_header", + "invalid_keyword_usage", + "unsupported_keywords", + "invalid_param_types", + "invalid_predicate_name", + "invalid_predicate_format", + "invalid_predicate_usage", ] - - default_unsupported = ['forall', 'when', 'exists', 'implies'] # current unsupported usage of PDDL + + default_unsupported = [ + "forall", + "when", + "exists", + "implies", + ] # current unsupported usage of PDDL self.error_types = default_error_types if error_types is None else error_types - self.unsupported_keywords = default_unsupported if unsupported_keywords is None else unsupported_keywords + self.unsupported_keywords = ( + default_unsupported + if unsupported_keywords is None + else unsupported_keywords + ) # PARAMETER CHECKS @@ -316,7 +321,7 @@ def validate_task_objects( obj_type_found = False for type_key in types.keys(): - + current_type, parent_type = type_key.split(" - ") # checks if obj_type is found in types diff --git a/paper_reconstructions/llm+dm/construct_action_models.py b/paper_reconstructions/llm+dm/construct_action_models.py new file mode 100644 index 0000000..8062daa --- /dev/null +++ b/paper_reconstructions/llm+dm/construct_action_models.py @@ -0,0 +1,3 @@ +""" + +""" diff --git a/paper_reconstructions/llm+dm/correct_action_models.py b/paper_reconstructions/llm+dm/correct_action_models.py new file mode 100644 index 0000000..e69de29 diff --git a/paper_reconstructions/llm+dm/main.py b/paper_reconstructions/llm+dm/main.py index cd6fc0c..277ee70 100644 --- a/paper_reconstructions/llm+dm/main.py +++ b/paper_reconstructions/llm+dm/main.py @@ -7,6 +7,10 @@ 1. NL descriptions of all the actions 2. A description of the domain 3. Information of the object types and hierarchy - fixed set of object types specified in prompt + +This file contains 2 main module components (Step 1+2 in LLM+DM): + 1. `construct_action_models.py` + 2. `correct_action_models.py` """ import os diff --git a/paper_reconstructions/llm+p/domain.py b/paper_reconstructions/llm+p/domain.py index 6d0474f..6cf014f 100644 --- a/paper_reconstructions/llm+p/domain.py +++ b/paper_reconstructions/llm+p/domain.py @@ -4,26 +4,28 @@ import glob + def postprocess(x): return x.strip() + class Domain: def __init__(self, name): self.name = name self.context = ("p_example.nl", "p_example.pddl", "p_example.sol") self.tasks = [] self.grab_tasks() - + def grab_tasks(self): path = f"paper_reconstructions/llm+p/domains/{self.name}/problems" nls = [] for fn in glob.glob(f"{path}/*.nl"): - + fn_ = fn.split("/")[-1] nls.append(fn_) self.tasks = sorted(nls) - + def get_task_name(self, i): name = self.tasks[i] name = name.replace("nl", "pddl") @@ -35,27 +37,27 @@ def get_task_file(self, i): def get_task(self, i): nl_f = self.get_task_file(i) - - with open(nl_f, 'r') as f: + + with open(nl_f, "r") as f: nl = f.read() return postprocess(nl) def get_context(self): - nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[0]}" + nl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[0]}" pddl_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[1]}" - sol_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[2]}" - with open(nl_f, 'r') as f: - nl = f.read() - with open(pddl_f, 'r') as f: + sol_f = f"paper_reconstructions/llm+p/domains/{self.name}/{self.context[2]}" + with open(nl_f, "r") as f: + nl = f.read() + with open(pddl_f, "r") as f: pddl = f.read() - with open(sol_f, 'r') as f: - sol = f.read() + with open(sol_f, "r") as f: + sol = f.read() return postprocess(nl), postprocess(pddl), postprocess(sol) def get_domain_pddl(self): domain_pddl_f = self.get_domain_pddl_file() - with open(domain_pddl_f, 'r') as f: + with open(domain_pddl_f, "r") as f: domain_pddl = f.read() return postprocess(domain_pddl) @@ -66,7 +68,7 @@ def get_domain_pddl_file(self): def get_domain_nl(self): domain_nl_f = self.get_domain_nl_file() try: - with open(domain_nl_f, 'r') as f: + with open(domain_nl_f, "r") as f: domain_nl = f.read() except: domain_nl = "Nothing" @@ -78,25 +80,32 @@ def get_domain_nl_file(self): class Barman(Domain): - name = "barman" + name = "barman" + class Floortile(Domain): - name = "floortile" + name = "floortile" + class Termes(Domain): - name = "termes" + name = "termes" + class Tyreworld(Domain): - name = "tyreworld" + name = "tyreworld" + class Grippers(Domain): - name = "grippers" + name = "grippers" + class Storage(Domain): - name = "storage" + name = "storage" + class Blocksworld(Domain): - name = "blocksworld" + name = "blocksworld" + class Manipulation(Domain): - name = "manipulation" \ No newline at end of file + name = "manipulation" diff --git a/paper_reconstructions/llm+p/main.py b/paper_reconstructions/llm+p/main.py index 7624497..054bb06 100644 --- a/paper_reconstructions/llm+p/main.py +++ b/paper_reconstructions/llm+p/main.py @@ -24,52 +24,57 @@ "storage", "termes", "tyreworld", - "manipulation" + "manipulation", ] + def create_llm_ic_pddl_prompt(task_nl, domain_pddl, context): - # (LM+P), create the problem PDDL given the context - - context_nl, context_pddl, context_sol = context - - prompt = f"I want you to solve planning problems. " + \ - f"An example planning problem is: \n{context_nl} \n" + \ - f"The problem PDDL file to this problem is: \n{context_pddl} \n" + \ - f"Now I have a new planning problem and its description is: \n{task_nl} \n" + \ - f"Provide me with the problem PDDL file that describes " + \ - f"the new planning problem directly without further explanations. Do not return anything else." - - # add in L2P default format prompt - prompt += "\n\n" + load_file("templates/task_templates/extract_task.txt") - return prompt - + # (LM+P), create the problem PDDL given the context + + context_nl, context_pddl, context_sol = context + + prompt = ( + f"I want you to solve planning problems. " + + f"An example planning problem is: \n{context_nl} \n" + + f"The problem PDDL file to this problem is: \n{context_pddl} \n" + + f"Now I have a new planning problem and its description is: \n{task_nl} \n" + + f"Provide me with the problem PDDL file that describes " + + f"the new planning problem directly without further explanations. Do not return anything else." + ) + + # add in L2P default format prompt + prompt += "\n\n" + load_file("templates/task_templates/extract_task.txt") + return prompt + def llm_ic_pddl_planner(args, problem_name): - + # create necessary classes - task_builder = TaskBuilder() # L2P task builder + task_builder = TaskBuilder() # L2P task builder domain = Domain(name=args.domain) - planner = FastDownward(planner_path=args.planner) # FastDownward planner - + planner = FastDownward(planner_path=args.planner) # FastDownward planner + # initialize OpenAI engine api_key = os.environ.get("OPENAI_API_KEY") model = OPENAI(model=args.model, api_key=api_key) - + # extract assumptions - context = domain.get_context() - domain_pddl = domain.get_domain_pddl() + context = domain.get_context() + domain_pddl = domain.get_domain_pddl() domain_pddl_file = domain.get_domain_pddl_file() - + # create the tmp / result folders - result_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/pddl" - plan_results_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/plan" - - task = args.task # extract task arguments - + result_folder = f"paper_reconstructions/llm+p/domains/{domain.name}/results/pddl" + plan_results_folder = ( + f"paper_reconstructions/llm+p/domains/{domain.name}/results/plan" + ) + + task = args.task # extract task arguments + # A. generate problem pddl file - task_nl = domain.get_task(task) - prompt = create_llm_ic_pddl_prompt(task_nl, domain_pddl, context) - + task_nl = domain.get_task(task) + prompt = create_llm_ic_pddl_prompt(task_nl, domain_pddl, context) + # query LLM using L2P objects, initial, goal, llm_response = task_builder.extract_task( model=model, @@ -90,34 +95,35 @@ def llm_ic_pddl_planner(args, problem_name): initial_state_str, goal_state_str, ) - + # write generated pddl into folder pddl_file_path = os.path.join(result_folder, domain.get_task_name(task)) os.makedirs(result_folder, exist_ok=True) - with open(pddl_file_path, 'w') as file: + with open(pddl_file_path, "w") as file: file.write(pddl_problem) - + # B. run planner plan_name = domain.get_task_name(task).replace("pddl", "txt") - _, output = planner.run_fast_downward(domain_file=domain_pddl_file, problem_file=pddl_file_path) - + _, output = planner.run_fast_downward( + domain_file=domain_pddl_file, problem_file=pddl_file_path + ) + # write generated plan into folder plan_file_path = os.path.join(plan_results_folder, plan_name) os.makedirs(plan_results_folder, exist_ok=True) - with open(plan_file_path, 'w') as file: + with open(plan_file_path, "w") as file: file.write(output) - - + if __name__ == "__main__": - + # load in arguments to run program parser = argparse.ArgumentParser(description="LLM+P") - parser.add_argument('--model', type=str, default="gpt-4o-mini") - parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") - parser.add_argument('--task', type=int, default=0) # task to run - parser.add_argument('--planner', type=str, default="downward/fast-downward.py") + parser.add_argument("--model", type=str, default="gpt-4o-mini") + parser.add_argument("--domain", type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument("--task", type=int, default=0) # task to run + parser.add_argument("--planner", type=str, default="downward/fast-downward.py") args = parser.parse_args() - + # run LLM+P method llm_ic_pddl_planner(args=args, problem_name="blocksworld_problem") diff --git a/paper_reconstructions/nl2plan/domains/logistics/desc.txt b/paper_reconstructions/nl2plan/domains/logistics/desc.txt deleted file mode 100644 index 00f75d0..0000000 --- a/paper_reconstructions/nl2plan/domains/logistics/desc.txt +++ /dev/null @@ -1 +0,0 @@ -The AI agent here is a logistics planner that has to plan to transport packages within the locations in a city through a truck and between cities through an airplane. Within a city, the locations are directly linked, allowing trucks to travel between any two of these locations. Similarly, cities are directly connected to each other allowing airplanes to travel between any two cities. Also, there is no limit to how many packages a truck or plane can carry (so in theory a truck or plane can carry an infinite number of packages). \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/domains/logistics/task1.txt b/paper_reconstructions/nl2plan/domains/logistics/task1.txt deleted file mode 100644 index 3029f3f..0000000 --- a/paper_reconstructions/nl2plan/domains/logistics/task1.txt +++ /dev/null @@ -1 +0,0 @@ -Currently I've got five packages to ship, 3 in a storage in Ado and the rest in Betar's storage. Those from Ado should be sent 1 to Bal Street in Betar, 2 to Cli Promenade in Colin. Those from Betar should be moved to the Ado storage. The only plane is currently in Duran's airport, but each city has it's own truck and airport. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py index b78b3fa..106de70 100644 --- a/paper_reconstructions/nl2plan/main.py +++ b/paper_reconstructions/nl2plan/main.py @@ -2,6 +2,19 @@ Paper: "NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions" Gestrin et al (2024) Source code: https://github.com/mrlab-ai/NL2Plan Run: python3 -m paper_reconstructions.nl2plan.main + +Each component of NL2Plan framework can be found in ./nl2plan. Specifically, this framework consists of: + 1. Type Extraction - build types + 2. Hierarchy Construction - organize types + 3. Action Extraction - high-level extraction of actions + descriptions + 4. Action Construction - coverted actions into PDDL format + 5. Task Extraction - build PDDL problem specification + +Step 1-4 is concerned with PDDL domain; step 5 involves PDDL problem. + +Each step contains a feedback mechanism (either LLM or human). In this case, we chose to do full +automation and let LLM run a feedback checklist on its outputs. There are also validators found +in step 4 (action construction) and step 5 (task extraction) for PDDL syntax. """ import argparse @@ -11,230 +24,283 @@ from .nl2plan.action_extraction import ActionExtraction from .nl2plan.action_construction import ActionConstruction from .nl2plan.task_extraction import TaskExtraction -from .nl2plan.utils import set_prompt DOMAINS = [ "blocksworld", "household", - "isr", # currently unsupported - "isr-assisted", # currently unsupported - "logistics", - "tyreworld" + "isr", # no experiments ran yet + "isr-assisted", # no experiments ran yet + "logistics", # no experiments ran yet + "tyreworld", ] REQUIREMENTS = [ - ":strips", - ":typing", - ":equality", - ":negative-preconditions", - ":disjunctive-preconditions", - ":universal-preconditions", - ":conditional-effects", - ] + ":strips", + ":typing", + ":equality", + ":negative-preconditions", + ":disjunctive-preconditions", + ":universal-preconditions", + ":conditional-effects", +] UNSUPPORTED_KEYWORDS = ["object", "pddl", "lisp"] separator = "-" * 20 + +# universal function to load in prompt templates into L2P PromptBuilder class. +def set_prompt( + prompt_builder: PromptBuilder, role_path: str, examples_path: str, task_path: str +) -> PromptBuilder: + + # load in files + role = load_file(role_path) + examples = load_files(examples_path) + task = load_file(task_path) + + # set prompts to prompt builder class + prompt_builder.set_role(role=role) + for ex in examples: + prompt_builder.set_examples(example=ex) + prompt_builder.set_task(task=task) + + return prompt_builder + + def run_nl2plan(args, domain: str, problem: str): + """ + This function runs the whole NL2Plan framework. + + Args: + - domain (str): domain name to direct files + - problem (str): specific problem case and create result + """ + # create necessary classes - domain_builder = DomainBuilder() # L2P domain builder - task_builder = TaskBuilder() # L2P task builder - planner = FastDownward(planner_path=args.planner) # FastDownward planner - log = "" # string to log all step output - - # initialize OpenAI engine - api_key = os.environ.get("OPENAI_API_KEY") - model = OPENAI(model=args.model, api_key=api_key) - - - # A. Type Extraction - type_extraction = TypeExtraction() - type_extraction.prompt_template = set_prompt( - type_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") - - types = type_extraction.type_extraction( - model=model, - domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), - type_extraction_prompt=type_extraction.prompt_template, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) - - log += f"STEP ONE: TYPE EXTRACTION\n\n{types}\n\n" - model.reset_tokens() - - # B. Hierarchy Construction - hierarchy_construction = HierarchyConstruction() - hierarchy_construction.prompt_template = set_prompt( - hierarchy_construction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", - task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") - - type_hierarchy = hierarchy_construction.hierarchy_construction( - model=model, - domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), - type_hierarchy_prompt=hierarchy_construction.prompt_template, - types=types, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) - - log += f"{separator}\nSTEP TWO: HIERARCHY CONSTRUCTION\n\n{type_hierarchy}\n\n" - model.reset_tokens() - - # C. Action Extraction - action_extraction = ActionExtraction() - action_extraction.prompt_template = set_prompt( - action_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") - - nl_actions = action_extraction.action_extraction( - model=model, - domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), - action_extraction_prompt=action_extraction.prompt_template, - type_hierarchy=type_hierarchy, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) - - log += f"{separator}\nSTEP THREE: ACTION EXTRACTION\n\n{nl_actions}\n\n" - model.reset_tokens() - - # D. Action Construction - action_construction = ActionConstruction() - action_construction.prompt_template = set_prompt( - action_construction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", - task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") - - actions, predicates, = action_construction.action_construction( - model=model, - domain_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt"), - act_constr_prompt=action_construction.prompt_template, - nl_actions=nl_actions, - type_hierarchy=type_hierarchy, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), - max_attempts=1 - ) - - log += f"{separator}\n" - log += "STEP FOUR: ACTION CONSTRUCTION\n\n" - log += "ACTIONS:\n" - log += '\n'.join([str(action) for action in actions]) + "\n\n" - log += "PREDICATES:\n" - log += '\n'.join([str(predicate) for predicate in predicates]) + "\n\n" - model.reset_tokens() - - # E. Task Extraction - task_extraction = TaskExtraction() - task_extraction.prompt_template = set_prompt( - task_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") - - objects, initial, goal = task_extraction.task_extraction( - model=model, - problem_desc=load_file(f"paper_reconstructions/nl2plan/domains/{domain}/{problem}.txt"), - task_extraction_prompt=task_extraction.prompt_template, - types=type_hierarchy, - predicates=predicates, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), - error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") - ) - - log += f"{separator}\nSTEP FIVE: TASK EXTRACTION\n\n" - log += f"OBJECTS:\n{objects}\n" - log += f"INITIAL STATES:\n{initial}\n" - log += f"GOAL STATES:\n{goal}\n" - - predicate_str = "\n".join( - [pred["clean"].replace(":", " ; ") for pred in predicates] - ) - - types = format_types(type_hierarchy) # retrieve types - pruned_types = { - name: description - for name, description in types.items() - if name not in UNSUPPORTED_KEYWORDS - } # remove unsupported words - - # format strings - types_str = "\n".join(pruned_types) - - # generate PDDL specifications - pddl_domain = domain_builder.generate_domain( - domain=args.domain, - requirements=args.requirements, - types=types_str, - predicates=predicate_str, - actions=actions, - ) - - log += f"\n\nPDDL DOMAIN:\n{pddl_domain}" - - problem_name = args.domain + "_problem" - pddl_problem = task_builder.generate_task( - domain=args.domain, - problem=problem_name, - objects=objects, - initial=initial, - goal=goal, - ) - - log += f"\n\nPDDL PROBLEM:\n{pddl_problem}" - - # Ensure that the directories exist + domain_builder = DomainBuilder() # L2P domain builder + task_builder = TaskBuilder() # L2P task builder + planner = FastDownward(planner_path=args.planner) # FastDownward planner + log = "" # string to log all step output + + # ensure that the directories exist main_directory = f"paper_reconstructions/nl2plan/results/{domain}/{problem}" - os.makedirs(main_directory, exist_ok=True) # Creates the directory, if it doesn't exist + os.makedirs( + main_directory, exist_ok=True + ) # Creates the directory, if it doesn't exist - # Write log file + # write log file (in case of run-time failure) log_file = f"{main_directory}/log.txt" - with open(log_file, "w") as f: - f.write(log) - - # Write domain and problem files - domain_file = f"{main_directory}/domain.pddl" - with open(domain_file, "w") as f: - f.write(pddl_domain) - problem_file = f"{main_directory}/problem.pddl" - with open(problem_file, "w") as f: - f.write(pddl_problem) - - # Run planner - _, plan = planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) - - # Write plan file - plan_file = f"{main_directory}/plan.txt" - with open(plan_file, "w") as f: - f.write(plan) - - - + + try: + # initialize OpenAI engine + api_key = os.environ.get("OPENAI_API_KEY") + model = OPENAI(model=args.model, api_key=api_key) + + # A. Type Extraction + type_extraction = TypeExtraction() + type_extraction.prompt_template = set_prompt( + type_extraction.prompt_template, + role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt", + ) + + types = type_extraction.type_extraction( + model=model, + domain_desc=load_file( + f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt" + ), + type_extraction_prompt=type_extraction.prompt_template, + feedback_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt" + ), + ) + + log += f"STEP ONE: TYPE EXTRACTION\n\n{types}\n\n" + + # B. Hierarchy Construction + hierarchy_construction = HierarchyConstruction() + hierarchy_construction.prompt_template = set_prompt( + hierarchy_construction.prompt_template, + role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt", + ) + + type_hierarchy = hierarchy_construction.hierarchy_construction( + model=model, + domain_desc=load_file( + f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt" + ), + type_hierarchy_prompt=hierarchy_construction.prompt_template, + types=types, + feedback_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt" + ), + ) + + log += f"{separator}\nSTEP TWO: HIERARCHY CONSTRUCTION\n\n{type_hierarchy}\n\n" + + # C. Action Extraction + action_extraction = ActionExtraction() + action_extraction.prompt_template = set_prompt( + action_extraction.prompt_template, + role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt", + ) + + nl_actions = action_extraction.action_extraction( + model=model, + domain_desc=load_file( + f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt" + ), + action_extraction_prompt=action_extraction.prompt_template, + type_hierarchy=type_hierarchy, + feedback_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt" + ), + ) + + log += f"{separator}\nSTEP THREE: ACTION EXTRACTION\n\n{nl_actions}\n\n" + + # D. Action Construction + action_construction = ActionConstruction() + action_construction.prompt_template = set_prompt( + action_construction.prompt_template, + role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", + task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt", + ) + + ( + actions, + predicates, + ) = action_construction.action_construction( + model=model, + domain_desc=load_file( + f"paper_reconstructions/nl2plan/domains/{domain}/desc.txt" + ), + act_constr_prompt=action_construction.prompt_template, + nl_actions=nl_actions, + type_hierarchy=type_hierarchy, + feedback_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt" + ), + max_attempts=2, + ) + + log += f"{separator}\n" + log += "STEP FOUR: ACTION CONSTRUCTION\n\n" + log += "ACTIONS:\n" + log += "\n".join([str(action) for action in actions]) + "\n\n" + log += "PREDICATES:\n" + log += "\n".join([str(predicate) for predicate in predicates]) + "\n\n" + + # E. Task Extraction + task_extraction = TaskExtraction() + task_extraction.prompt_template = set_prompt( + task_extraction.prompt_template, + role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", + examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", + task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt", + ) + + objects, initial, goal = task_extraction.task_extraction( + model=model, + problem_desc=load_file( + f"paper_reconstructions/nl2plan/domains/{domain}/{problem}.txt" + ), + task_extraction_prompt=task_extraction.prompt_template, + types=type_hierarchy, + predicates=predicates, + feedback_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt" + ), + error_prompt=load_file( + "paper_reconstructions/nl2plan/prompts/task_extraction/error.txt" + ), + ) + + log += f"{separator}\nSTEP FIVE: TASK EXTRACTION\n\n" + log += f"OBJECTS:\n{objects}\n" + log += f"INITIAL STATES:\n{initial}\n" + log += f"GOAL STATES:\n{goal}\n" + + predicate_str = "\n".join( + [pred["clean"].replace(":", " ; ") for pred in predicates] + ) + + types = format_types(type_hierarchy) # retrieve types + pruned_types = { + name: description + for name, description in types.items() + if name not in UNSUPPORTED_KEYWORDS + } # remove unsupported words + + # format strings + types_str = "\n".join(pruned_types) + + # generate PDDL domain and problem file + pddl_domain = domain_builder.generate_domain( + domain=args.domain, + requirements=args.requirements, + types=types_str, + predicates=predicate_str, + actions=actions, + ) + + problem_name = args.domain + "_problem" + pddl_problem = task_builder.generate_task( + domain=args.domain, + problem=problem_name, + objects=objects, + initial=initial, + goal=goal, + ) + + log += f"\n\nPDDL DOMAIN:\n{pddl_domain}" + log += f"\n\nPDDL PROBLEM:\n{pddl_problem}" + + # write domain and problem files + domain_file = f"{main_directory}/domain.pddl" + problem_file = f"{main_directory}/problem.pddl" + + with open(domain_file, "w") as f: + f.write(pddl_domain) + with open(problem_file, "w") as f: + f.write(pddl_problem) + + # run planner + _, plan = planner.run_fast_downward( + domain_file=domain_file, problem_file=problem_file + ) + + # record plan results + plan_file = f"{main_directory}/plan.txt" + with open(plan_file, "w") as f: + f.write(plan) + + except Exception as e: + with open(log_file, "w") as f: + f.write(log) + raise e # re-raise the exception after logging + else: + # write the log file if everything succeeds + with open(log_file, "w") as f: + f.write(log) + if __name__ == "__main__": - - # # load in arguments to run program - # parser = argparse.ArgumentParser(description="NL2Plan") - # parser.add_argument('--model', type=str, default="gpt-4o-mini") - # parser.add_argument('--domain', type=str, choices=DOMAINS, default="blocksworld") - # parser.add_argument('--requirements', type=list[str], default=REQUIREMENTS) - # parser.add_argument('--planner', type=str, default="/Users/marcustantakoun/Downloads/downward/fast-downward.py") - # args = parser.parse_args() - - # # run LLM+P method - # run_nl2plan(args=args, domain="blocksworld", problem="task2") - - planner = FastDownward(planner_path="/Users/marcustantakoun/Downloads/downward/fast-downward.py") - domain_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl" - problem_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl" - - # Run planner - _, plan = planner.run_fast_downward(domain_file=domain_file, problem_file=problem_file) - - # Write plan file - plan_file = "paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt" - with open(plan_file, "w") as f: - f.write(plan) \ No newline at end of file + + # load in arguments to run program + parser = argparse.ArgumentParser(description="NL2Plan") + parser.add_argument("--model", type=str, default="gpt-4o-mini") + parser.add_argument("--domain", type=str, choices=DOMAINS, default="blocksworld") + parser.add_argument("--requirements", type=list[str], default=REQUIREMENTS) + parser.add_argument("--planner", type=str, default="downward/fast-downward.py") + args = parser.parse_args() + + # run LLM+P method + run_nl2plan(args=args, domain="blocksworld", problem="task1") diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py index c981920..911ac97 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -1,15 +1,26 @@ -import os +""" +Step 4 (Action Construction) of NL2Plan + +This class queries the LLM to construct the actions (from NL to PDDL) for given domain in +class data type `Action`. + +This is the main algorithm (inspired by LLM+DM) that follows an action-by-action generation that +builds a dynamic predicate list. Each action is generated one by one to create the actions and +predicate list, then the process loops again, recreating new actions with the current predicate list. + +This consists of two main steps: (i) creating a single action (running through feedback + validation check) +and (ii) looping through each of these actions from the NL actions found in the previous step. +""" + from l2p import * -from .utils import set_prompt + class ActionConstruction: def __init__(self): self.prompt_template = PromptBuilder() self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() - self.syntax_validator = SyntaxValidator() - - + def construct_action( self, model: LLM, @@ -19,15 +30,17 @@ def construct_action( action_name: str, action_desc: str, predicates: list[Predicate], - type_hierarchy: dict[str,str], + type_hierarchy: dict[str, str], syntax_validator: SyntaxValidator, feedback_prompt: str = None, - max_attempts = 2, - feedback = True - ) -> tuple[Action, list[Predicate]]: + max_attempts=2, + feedback=True, + ) -> tuple[Action, list[Predicate]]: """ Construct a single action from a given action description using LLM language model. - + NL2Plan defaults to 8 attempts to construct the action; in this case, we did 2 to reduce + token usage (but could drastically affect results). + Args: model (LLM): The LLM language model connection. act_constr_prompt (PromptBuilder): action construction prompt. @@ -38,36 +51,39 @@ def construct_action( feedback_prompt (str): Feedback template. max_iters (int): Maximum number of iterations to construct action. Defaults to 8. feedback (bool): Whether to request feedback from LLM. Defaults to True. - + Returns: - Action: The constructed action. + action (Action): The constructed action. new_predicates (list[Predicate]): A list of new predicates """ - + # fill in action construction prompt placeholders action_prompt = act_constr_prompt.generate_prompt() - action_prompt = action_prompt.replace('{action_desc}', action_desc) - action_prompt = action_prompt.replace('{action_name}', action_name) - + action_prompt = action_prompt.replace("{action_desc}", action_desc) + action_prompt = action_prompt.replace("{action_name}", action_name) + if len(predicates) == 0: predicate_str = "No predicate has been defined yet" - else: + else: predicate_str = "" predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) - action_prompt = action_prompt.replace('{predicates}', predicate_str) - + action_prompt = action_prompt.replace("{predicates}", predicate_str) + # replace specific feedback template if feedback_prompt is not None: - feedback_prompt = feedback_prompt.replace('{action_desc}', action_desc) - feedback_prompt = feedback_prompt.replace('{action_name}', action_name) + feedback_prompt = feedback_prompt.replace("{action_desc}", action_desc) + feedback_prompt = feedback_prompt.replace("{action_name}", action_name) elif feedback: raise ValueError("Feedback template is required when feedback is enabled.") - + + # run through single action creation + feedback and validation check for iter in range(1, max_attempts + 1 + (feedback is not None)): print(f"Generating PDDL of action: `{action_name}`") - - try: - action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + + # syntax check runs directly inside L2P extraction function + try: + action, new_predicates, llm_response, validation_info = ( + self.domain_builder.extract_pddl_action( model=model, domain_desc=domain_desc, prompt_template=action_prompt, @@ -76,42 +92,51 @@ def construct_action( action_list=action_list, predicates=predicates, types=format_types(type_hierarchy), - syntax_validator=syntax_validator + syntax_validator=syntax_validator, ) - + ) + no_error, error_msg = validation_info - + except Exception as e: no_error = False error_msg = str(e) - + + # if validation passes, go through feedback checklist if no_error: if feedback is not None: - - action, new_predicates, response_fb, _, no_fb = self.feedback_builder.pddl_action_feedback( - model=model, - domain_desc=domain_desc, - llm_response=llm_response, - feedback_template=feedback_prompt, - feedback_type="llm", - action=action, - predicates=predicates, - types=type_hierarchy + + action, new_predicates, response_fb, _, no_fb = ( + self.feedback_builder.pddl_action_feedback( + model=model, + domain_desc=domain_desc, + llm_response=llm_response, + feedback_template=feedback_prompt, + feedback_type="llm", + action=action, + predicates=predicates, + types=type_hierarchy, + ) ) - + + # if no feedback, then action is complete if no_fb == True: break - + + # if validation does not pass, then generate error messages to run through LLM else: - with open("paper_reconstructions/nl2plan/prompts/action_construction/error.txt") as f: + with open( + "paper_reconstructions/nl2plan/prompts/action_construction/error.txt" + ) as f: error_template = f.read().strip() - error_prompt = error_template.replace('{action_name}', action_name) - error_prompt = error_prompt.replace('{action_desc}', action_desc) - error_prompt = error_prompt.replace('{predicate_list}', predicate_str) - error_prompt = error_prompt.replace('{error_msg}', error_msg) - error_prompt = error_prompt.replace('{llm_response}', llm_response) - - action, new_predicates, llm_response, validation_info = self.domain_builder.extract_pddl_action( + error_prompt = error_template.replace("{action_name}", action_name) + error_prompt = error_prompt.replace("{action_desc}", action_desc) + error_prompt = error_prompt.replace("{predicate_list}", predicate_str) + error_prompt = error_prompt.replace("{error_msg}", error_msg) + error_prompt = error_prompt.replace("{llm_response}", llm_response) + + action, new_predicates, llm_response, validation_info = ( + self.domain_builder.extract_pddl_action( model=model, domain_desc=domain_desc, prompt_template=error_prompt, @@ -120,34 +145,56 @@ def construct_action( action_list=action_list, predicates=predicates, types=type_hierarchy, - syntax_validator=syntax_validator + syntax_validator=syntax_validator, ) - + ) + return action, new_predicates - - + def action_construction( self, model: LLM, domain_desc: str, act_constr_prompt: PromptBuilder, - nl_actions: dict[str,str], - type_hierarchy: dict[str,str], + nl_actions: dict[str, str], + type_hierarchy: dict[str, str], feedback_prompt: str | None = None, max_attempts: int = 2, - max_iters: int = 2 - ) -> tuple[list[Action], list[Predicate]]: - - action_list = "\n".join([f"- {name}: {desc}" for name, desc in nl_actions.items()]) - - syntax_validator = SyntaxValidator() - + max_iters: int = 2, + ) -> tuple[list[Action], list[Predicate]]: + """ + This function loops through all the natural language actions found in the + previous step. The number of loops determines how many overall cycles that all actions + will be generated on the current predicate list. + + Args: + - model (LLM): The LLM language model connection. + - domain_desc (str): description of domain + - act_constr_prompt (PromptBuilder): action prompt extraction + - nl_actions (dict[str,str]): list of actions in natural language + - type_hierarchy (dict[str,str]): dictionary of organized types + - feedback_prompt (str): feedback prompt to check LLM output + - max_attempts (int): attempts of creating a single action + - max_iters (int): # of overall loops to construct full list of actions + + Returns: + - actions (list[Action]): list of actions + - predicates (list[Predicates]): list of predicates + """ + + action_list = "\n".join( + [f"- {name}: {desc}" for name, desc in nl_actions.items()] + ) + + syntax_validator = SyntaxValidator() # create syntax validator to run checks on + + # run through main loop over each action predicates = [] for iter in range(max_iters): actions = [] print(f"Starting iteration {iter + 1} of action construction") curr_preds = len(predicates) - + for action_name, action_desc in nl_actions.items(): action, new_predicates = self.construct_action( model=model, @@ -161,73 +208,16 @@ def action_construction( syntax_validator=syntax_validator, feedback_prompt=feedback_prompt, max_attempts=max_attempts, - feedback=True - ) + feedback=True, + ) actions.append(action) predicates.extend(new_predicates) predicates = prune_predicates(predicates, actions) - + if len(predicates) == curr_preds: print("No new predicates created. Stopping action construction.") break else: print("Reached maximum iterations. Stopping action construction.") - + return actions, predicates - - -if __name__ == "__main__": - - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - - openai_llm = OPENAI(model=engine, api_key=api_key) - - hierarchy = { - 'object': 'Object is always root, everything is an object', - 'children': [ - {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', - 'children': [ - {'block': 'A type of movable_object.', 'children': []} - ] - }, - {'surface': 'A parent type for all surfaces, including tables.', - 'children': [ - {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} - ] - } - ] - } - - nl_actions = { - "pick_block": "The robot arm picks up a block from a surface. Requires the block to be on a surface and not currently held by the arm. Example: robot_arm picks up block_1 from table_1.", - "place_on_table": "The robot arm places a block on a table. Requires the block to be held by the arm and the table to be clear of other blocks. Example: robot_arm places block_1 on table_1.", - "place_on_block": "The robot arm places a block on top of another block. Requires the block to be held by the arm and the target block to be clear (not currently held or covered by another block). Example: robot_arm places block_1 on block_2.", - "release_block": "The robot arm releases a block it is currently holding. Requires the block to be held by the arm. Example: robot_arm releases block_1." - } - - action_construction = ActionConstruction() - - action_construction.prompt_template = set_prompt( - action_construction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/action_construction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/action_construction/examples", - task_path="paper_reconstructions/nl2plan/prompts/action_construction/task.txt") - - actions, predicates, = action_construction.action_construction( - model=openai_llm, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), - act_constr_prompt=action_construction.prompt_template, - nl_actions=nl_actions, - type_hierarchy=hierarchy, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_construction/feedback.txt"), - max_attempts=1 - ) - - for i in actions: - print(i) - - print() - - for i in predicates: - print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py index abf7b81..28f4ee9 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_extraction.py @@ -1,24 +1,39 @@ -import os +""" +Step 3 (Action Extraction) of NL2Plan + +This class queries the LLM to construct the actions (in natural language) for given domain in +Python dictionary format {'name':'description'}. +""" + from l2p import * -from .utils import set_prompt + class ActionExtraction: def __init__(self): self.prompt_template = PromptBuilder() self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() - self.nl_actions = dict[str,str] - def action_extraction( self, - model: LLM, - domain_desc: str, + model: LLM, + domain_desc: str, action_extraction_prompt: PromptBuilder, - type_hierarchy: dict[str,str], - feedback_prompt: str - ) -> dict[str, str]: - + type_hierarchy: dict[str, str], + feedback_prompt: str, + ) -> dict[str, str]: + """ + Main function of the action extraction construction step. + + Args: + - model (LLM): LLM to inquire. + - domain_desc (str): specific domain description to work off. + - action_extraction_prompt (PromptBuilder): base prompt to extract actions. + - feedback_prompt (str): feedback template for LLM to correct output. + Returns: + - nl_actions (dict[str,str]): dictionary of extracted actions {'name':'desc'} + """ + nl_actions, response = self.domain_builder.extract_nl_actions( model=model, domain_desc=domain_desc, @@ -37,44 +52,3 @@ def action_extraction( ) return nl_actions - -if __name__ == "__main__": - - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - - openai_llm = OPENAI(model=engine, api_key=api_key) - - hierarchy = { - 'object': 'Object is always root, everything is an object', - 'children': [ - {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', - 'children': [ - {'block': 'A type of movable_object.', 'children': []} - ] - }, - {'surface': 'A parent type for all surfaces, including tables.', - 'children': [ - {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} - ] - } - ] - } - - action_extraction = ActionExtraction() - - action_extraction.prompt_template = set_prompt( - action_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/action_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/action_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/action_extraction/task.txt") - - nl_actions = action_extraction.action_extraction( - model=openai_llm, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), - action_extraction_prompt=action_extraction.prompt_template, - type_hierarchy=hierarchy, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/action_extraction/feedback.txt")) - - for i in nl_actions: - print(i) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py index 50ce82e..1034981 100644 --- a/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/hierarchy_construction.py @@ -1,24 +1,39 @@ -import os +""" +Step 2 (Hierarchy Construction) of NL2Plan + +This class queries the LLM to organize the types for given domain in a nested Python dictionary format. +""" + from l2p import * -from .utils import set_prompt + class HierarchyConstruction: def __init__(self): self.prompt_template = PromptBuilder() self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() - self.type_hierarchy = dict[str, str] - def hierarchy_construction( - self, - model: LLM, - domain_desc: str, - type_hierarchy_prompt: PromptBuilder, - types: dict[str,str], - feedback_prompt: str - ) -> dict[str, str]: + self, + model: LLM, + domain_desc: str, + type_hierarchy_prompt: PromptBuilder, + types: dict[str, str], + feedback_prompt: str, + ) -> dict[str, str]: + """ + Main function of the hierarchy construction step. + + Args: + - model (LLM): LLM to inquire. + - domain_desc (str): specific domain description to work off. + - type_hierarchy_prompt (PromptBuilder): base prompt to organize types. + - feedback_prompt (str): feedback template for LLM to correct output. + Returns: + - type_hierarchy (dict[str,str]): organized hierarchy type dictionary + """ + # prompt LLM to extract type hierarchy (using L2P) type_hierarchy, _ = self.domain_builder.extract_type_hierarchy( model=model, domain_desc=domain_desc, @@ -26,6 +41,7 @@ def hierarchy_construction( types=types, ) + # feedback mechanism type_hierarchy, _ = self.feedback_builder.type_hierarchy_feedback( model=model, domain_desc=domain_desc, @@ -36,32 +52,3 @@ def hierarchy_construction( ) return type_hierarchy - -if __name__ == "__main__": - - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - - openai_llm = OPENAI(model=engine, api_key=api_key) - - types = { - 'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', - 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', - 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} - - hierarchy_construction = HierarchyConstruction() - - hierarchy_construction.prompt_template = set_prompt( - hierarchy_construction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/examples", - task_path="paper_reconstructions/nl2plan/prompts/hierarchy_construction/task.txt") - - type_hierarchy = hierarchy_construction.hierarchy_construction( - model=openai_llm, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), - type_hierarchy_prompt=hierarchy_construction.prompt_template, - types=types, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/hierarchy_construction/feedback.txt")) - - print(type_hierarchy) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py index dedbe45..bb2758b 100644 --- a/paper_reconstructions/nl2plan/nl2plan/task_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/task_extraction.py @@ -1,6 +1,13 @@ -import os +""" +Step 5 (Task Extraction) of NL2Plan + +This class queries the LLM to construct the PDDL task components (objects, initial, goal states). +Specifically, it takes in the predicates (and types for validation) to construct the +problem file given task description. +""" + from l2p import * -from .utils import set_prompt + class TaskExtraction: def __init__(self): @@ -9,66 +16,96 @@ def __init__(self): self.feedback_builder = FeedbackBuilder() self.syntax_validator = SyntaxValidator() - def task_extraction( - self, - model: LLM, - problem_desc: str, - task_extraction_prompt: PromptBuilder, - types: dict[str,str], - predicates: list[Predicate], + self, + model: LLM, + problem_desc: str, + task_extraction_prompt: PromptBuilder, + types: dict[str, str], + predicates: list[Predicate], feedback_prompt: str, error_prompt: str, - max_attempts: int = 8 - ) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: + max_attempts: int = 8, + ) -> tuple[dict[str, str], list[dict[str, str]], list[dict[str, str]]]: + """ + Main function to run task extraction. Specifically, extracts objects, + initial state, and goal state as components to get PDDL problem. + + Args: + - model (LLM): The LLM language model connection. + - problem_desc (str): not domain, but just problem description + - task_extraction_prompt (PromptBuilder): task prompt extraction + - types (dict[str,str]): domain types + - predicates (list[Predicates]): predicates to work off of + - feedback_prompt (str): feedback checklist prompt + - error_prompt (str): error checklist prompt (via syntax validator) + - max_attempts (str): attempts to construct proper task extraction + Returns: + - objects (dict[str,str]): PDDL object types {'?name':'type'} + - initial (list[dict[str,str]]): initial state of problem + - goal (list[dict[str,str]]): desired state of problem + ex: state_1 = {'name': 'on_top', 'params': ['blue_block', 'red_block'], 'neg': False} + """ + + # initial extraction of task objects, initial, goal, llm_response = self.task_builder.extract_task( model=model, problem_desc=problem_desc, prompt_template=task_extraction_prompt.generate_prompt(), types=format_types(types), - predicates=predicates + predicates=predicates, ) - + + # keep iterating until output passes all syntax validation checks all_valid = True for _ in range(max_attempts): - + feedback_msgs = [] all_valid = True types_list = format_types(types) types_list = {k: types_list[k] for i, k in enumerate(types_list) if i != 0} - + # list of validation checks validation_checks = [ self.syntax_validator.validate_task_objects(objects, types_list), - self.syntax_validator.validate_task_states(initial, objects, predicates, "initial"), - self.syntax_validator.validate_task_states(goal, objects, predicates, "goal"), + self.syntax_validator.validate_task_states( + initial, objects, predicates, "initial" + ), + self.syntax_validator.validate_task_states( + goal, objects, predicates, "goal" + ), ] - # Perform each validation check + # perform each validation check for validator, args in validation_checks: is_valid, feedback_msg = validator, args if not is_valid: all_valid = False feedback_msgs.append(feedback_msg) - # If any check fails, append feedback messages + # if any check fails, append feedback messages if not all_valid: error_prompt = error_prompt.replace("{error_msg}", str(feedback_msgs)) - error_prompt = error_prompt.replace("{task}", "goal and state extraction") + error_prompt = error_prompt.replace( + "{task}", "goal and state extraction" + ) objects, initial, goal, _ = self.feedback_builder.task_feedback( model=model, problem_desc=problem_desc, llm_response=llm_response, feedback_template=error_prompt, - feedback_type="llm" + feedback_type="llm", ) - - else: break - + + # if valid, break attempt loop + else: + break + if not all_valid: raise ValueError(f"Validation failed: {feedback_msgs}") + # extract feedback objects, initial, goal, _ = self.feedback_builder.task_feedback( model=model, problem_desc=problem_desc, @@ -82,59 +119,9 @@ def task_extraction( goal=goal, ) + # format the inputs into proper Python structures objects = self.task_builder.format_objects(objects) initial = self.task_builder.format_initial(initial) goal = self.task_builder.format_goal(goal) return objects, initial, goal - -if __name__ == "__main__": - - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - - openai_llm = OPENAI(model=engine, api_key=api_key) - - hierarchy = { - 'object': 'Object is always root, everything is an object', - 'children': [ - {'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', - 'children': [ - {'block': 'A type of movable_object.', 'children': []} - ] - }, - {'surface': 'A parent type for all surfaces, including tables.', - 'children': [ - {'table': 'A type of surface that serves as a base for the blocks.', 'children': []} - ] - } - ] - } - - - predicates = [{'name': 'on_surface', 'desc': 'true if the block ?b is on the surface ?s', 'raw': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s', 'params': OrderedDict([('?b', 'block'), ('?s', 'surface')]), 'clean': '(on_surface ?b - block ?s - surface): true if the block ?b is on the surface ?s'}, - {'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm'}, - {'name': 'movable', 'desc': "'The block is movable (not under another block)'", 'raw': "(movable ?b - block): 'The block is movable (not under another block)'", 'params': OrderedDict([('?b', 'block')]), 'clean': "(movable ?b - block): 'The block is movable (not under another block)'"}, - {'name': 'on_block', 'desc': "'Indicates that block ?b is placed on top of block ?b2'", 'raw': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'", 'params': OrderedDict([('?b', 'block'), ('?b2', 'block')]), 'clean': "(on_block ?b - block ?b2 - block): 'Indicates that block ?b is placed on top of block ?b2'"}] - - task_extraction = TaskExtraction() - - task_extraction.prompt_template = set_prompt( - task_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/task_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/task_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/task_extraction/task.txt") - - object, initial, goal = task_extraction.task_extraction( - model=openai_llm, - problem_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/task1.txt"), - task_extraction_prompt=task_extraction.prompt_template, - types=hierarchy, - predicates=predicates, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/feedback.txt"), - error_prompt=load_file("paper_reconstructions/nl2plan/prompts/task_extraction/error.txt") - ) - - print(object) - print(initial) - print(goal) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py index 859cb7a..7af66c2 100644 --- a/paper_reconstructions/nl2plan/nl2plan/type_extraction.py +++ b/paper_reconstructions/nl2plan/nl2plan/type_extraction.py @@ -1,28 +1,45 @@ -import os +""" +Step 1 (Type Extraction) of NL2Plan + +This class queries the LLM to construct the types for given domain in Python dictionary format. +""" + from l2p import * -from .utils import set_prompt + class TypeExtraction: def __init__(self): self.prompt_template = PromptBuilder() self.domain_builder = DomainBuilder() self.feedback_builder = FeedbackBuilder() - - + def type_extraction( - self, - model: LLM, - domain_desc: str, - type_extraction_prompt: PromptBuilder, - feedback_prompt: str - ) -> tuple[dict[str, str], str]: + self, + model: LLM, + domain_desc: str, + type_extraction_prompt: PromptBuilder, + feedback_prompt: str, + ) -> dict[str, str]: + """ + Main function of the type extraction step. + + Args: + - model (LLM): LLM to inquire. + - domain_desc (str): specific domain description to work off. + - type_extraction_prompt (PromptBuilder): base prompt to extract types. + - feedback_prompt (str): feedback template for LLM to correct output. + Returns: + - types (dict[str,str]): type dictionary + """ + # prompt LLM to extract types types, _ = self.domain_builder.extract_type( - model=model, - domain_desc=domain_desc, - prompt_template=type_extraction_prompt.generate_prompt() + model=model, + domain_desc=domain_desc, + prompt_template=type_extraction_prompt.generate_prompt(), ) - + + # feedback mechanism - returns newly modified types (if needed) types, _ = self.feedback_builder.type_feedback( model=model, domain_desc=domain_desc, @@ -31,28 +48,5 @@ def type_extraction( types=types, llm_response="", ) - + return types - -if __name__ == "__main__": - - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - - openai_llm = OPENAI(model=engine, api_key=api_key) - - type_extraction = TypeExtraction() - - type_extraction.prompt_template = set_prompt( - type_extraction.prompt_template, - role_path="paper_reconstructions/nl2plan/prompts/type_extraction/role.txt", - examples_path="paper_reconstructions/nl2plan/prompts/type_extraction/examples", - task_path="paper_reconstructions/nl2plan/prompts/type_extraction/task.txt") - - types = type_extraction.type_extraction( - model=openai_llm, - domain_desc=load_file("paper_reconstructions/nl2plan/domains/blocksworld/desc.txt"), - type_extraction_prompt=type_extraction.prompt_template, - feedback_prompt=load_file("paper_reconstructions/nl2plan/prompts/type_extraction/feedback.txt")) - - print(types) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/nl2plan/utils.py b/paper_reconstructions/nl2plan/nl2plan/utils.py deleted file mode 100644 index cc7df7b..0000000 --- a/paper_reconstructions/nl2plan/nl2plan/utils.py +++ /dev/null @@ -1,22 +0,0 @@ -from l2p import PromptBuilder -from l2p import load_file, load_files - -def set_prompt( - prompt_builder: PromptBuilder, - role_path: str, - examples_path: str, - task_path: str - ) -> PromptBuilder: - - # load in files - role = load_file(role_path) - examples = load_files(examples_path) - task = load_file(task_path) - - # set prompts to prompt builder class - prompt_builder.set_role(role=role) - for ex in examples: - prompt_builder.set_examples(example=ex) - prompt_builder.set_task(task=task) - - return prompt_builder \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt index 025af9a..1519593 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/role.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/role.txt @@ -2,6 +2,8 @@ You are defining the preconditions and effects (represented in PDDL format) of a Think through your choices and comment on them as you go. +ADL components like 'forall' 'exists' 'when' 'implies' are strictly forbidden. Implementations should only use basic PDDL usage. + End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. There must be 3 hastags (#) being used `###`. Here is an example: ### Action Parameters diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl index 132401d..f3cbeff 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/domain.pddl @@ -5,84 +5,82 @@ (:types block - object table - object + robot_arm - object ) (:predicates - (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t - (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 - (held ?b - block) ; true if block ?b is currently being held by the robot arm + (clear ?b - block) ; true if no block is on top of block ?b + (on_table ?b - block) ; true if block ?b is on the table + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on block ?b2 + (arm_free ?r - robot_arm) ; true if the robot arm ?r is not holding any block + (holding ?r - robot_arm ?b - block) ; true if the robot arm ?r is holding block ?b + (is_robot_arm ?o - object) ; + (is_table ?o - object) ; ) - (:action pick_block + (:action pick_up_block :parameters ( + ?r - robot_arm ?b - block - ?t - table ?b2 - block ) :precondition (and - (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently being held + (arm_free ?r) ; The robot arm is not holding any block + (clear ?b) ; No block is on top of block ?b + (or + (on_table ?b) ; Block ?b is on the table + (exists (?b2 - block) (on_block ?b ?b2)) ; Block ?b is on another block ?b2 + ) ) :effect (and - (held ?b) ; The block is now being held by the robot arm - (not (on_table ?b ?t)) ; The block is no longer on the table - (not (on_block ?b ?b2)) ; The block is no longer on top of another block + (not (arm_free ?r)) ; The robot arm is now holding a block + (holding ?r ?b) ; The robot arm is holding block ?b + (not (on_table ?b)) ; Block ?b is no longer on the table + (forall (?b2 - block) (when (on_block ?b ?b2) (not (on_block ?b ?b2)))) ; If block ?b was on block ?b2, it is no longer on it ) ) - (:action place_on_table + (:action place_block_on_table :parameters ( + ?r - object ?b - block - ?t - table + ?t - object ) :precondition (and - (held ?b) ; The block is currently being held - (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed - (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + (holding ?r ?b) ; The robot arm is holding the block + (clear ?t) ; The table has space for the block + (is_robot_arm ?r) ; The object ?r is a robot arm + (is_table ?t) ; The object ?t is a table ) :effect (and - (on_table ?b ?t) ; The block is now on the table - (not (held ?b)) ; The block is no longer being held + (not (holding ?r ?b)) ; The robot arm is no longer holding the block + (on_table ?b) ; The block is now on the table + (arm_free ?r) ; The robot arm is now free ) ) - (:action place_on_block + (:action place_block_on_block :parameters ( + ?r - object ?b1 - block ?b2 - block - ?t - table ) :precondition (and - (held ?b1) ; The block being placed is currently held - (not (held ?b2)) ; The block being placed on is not currently held - (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it - (not (on_table ?b2 ?t)) ; The block being placed on is not on the table + (is_robot_arm ?r) ; ?r is a robot arm + (holding ?r ?b1) ; The robot arm is holding block ?b1 + (clear ?b2) ; Block ?b2 is clear, meaning no block is on top of it ) :effect (and - (on_block ?b1 ?b2) ; The block being placed is now on top of the other block - (not (held ?b1)) ; The block being placed is no longer held - ) - ) - - (:action release_block - :parameters ( - ?b - block - ) - :precondition - (and - (held ?b) ; The block is currently being held - (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block - ) - :effect - (and - (not (held ?b)) ; The block is no longer held - (on_table ?b) ; The block is placed on the table after being released + (not (holding ?r ?b1)) ; The robot arm is no longer holding block ?b1 + (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2 + (not (clear ?b2)) ; Block ?b2 is no longer clear + (arm_free ?r) ; The robot arm is now free ) ) ) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt index d498594..5861704 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/log.txt @@ -1,49 +1,60 @@ STEP ONE: TYPE EXTRACTION -{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.'} +{'block': 'The primary object that can be picked up and placed. Blocks can be stacked on top of each other or placed on the table.', 'table': 'The surface on which blocks can be placed. Acts as the base for block stacking.'} -------------------- STEP TWO: HIERARCHY CONSTRUCTION -{'object': 'Object is always root, everything is an object', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'children': []}, {'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'children': []}]} +{'object': 'Object is always root, everything is an object', 'children': [{'block': 'The primary object that can be picked up and placed.', 'children': []}, {'table': 'The surface on which blocks can be placed.', 'children': []}]} -------------------- STEP THREE: ACTION EXTRACTION -{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block and not currently being held. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block down on the table. Requires the block to be held and the table to be clear of any blocks directly beneath the block being placed. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be held and the block being placed on to be clear of any blocks directly beneath it. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block it is holding. Requires the block to be held. Example: robot_arm releases block_1.'} +{'pick_up_block': 'The robot arm picks up a block from the table or from atop another block. The block must not have any other block on top of it. Example: The robot arm picks up block_1 from the table.', 'place_block_on_table': 'The robot arm places a block onto the table. The block must be held by the robot arm and the table must have space for the block. Example: The robot arm places block_2 on the table.', 'place_block_on_block': 'The robot arm places a block onto another block. The block being placed must be held by the robot arm, and the block it is being placed on must not have any other block on top of it. Example: The robot arm places block_3 on top of block_4.'} -------------------- STEP FOUR: ACTION CONSTRUCTION ACTIONS: -{'name': 'pick_block', 'params': OrderedDict([('?b', 'block'), ('?t', 'table'), ('?b2', 'block')]), 'preconditions': '(and\n (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently being held\n)', 'effects': '(and\n (held ?b) ; The block is now being held by the robot arm\n (not (on_table ?b ?t)) ; The block is no longer on the table\n (not (on_block ?b ?b2)) ; The block is no longer on top of another block\n)'} -{'name': 'place_on_table', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed\n (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed\n)', 'effects': '(and\n (on_table ?b ?t) ; The block is now on the table\n (not (held ?b)) ; The block is no longer being held\n)'} -{'name': 'place_on_block', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (held ?b1) ; The block being placed is currently held\n (not (held ?b2)) ; The block being placed on is not currently held\n (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it\n (not (on_table ?b2 ?t)) ; The block being placed on is not on the table\n)', 'effects': '(and\n (on_block ?b1 ?b2) ; The block being placed is now on top of the other block\n (not (held ?b1)) ; The block being placed is no longer held\n)'} -{'name': 'release_block', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (held ?b) ; The block is currently being held\n (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held\n (on_table ?b) ; The block is placed on the table after being released\n)'} +{'name': 'pick_up_block', 'params': OrderedDict([('?r', 'robot_arm'), ('?b', 'block')]), 'preconditions': '(and\n (arm_free ?r) ; The robot arm is not holding any block\n (clear ?b) ; No block is on top of block ?b\n (or\n (on_table ?b) ; Block ?b is on the table\n (exists (?b2 - block) (on_block ?b ?b2)) ; Block ?b is on another block ?b2\n )\n)', 'effects': '(and\n (not (arm_free ?r)) ; The robot arm is now holding a block\n (holding ?r ?b) ; The robot arm is holding block ?b\n (not (on_table ?b)) ; Block ?b is no longer on the table\n (forall (?b2 - block) (when (on_block ?b ?b2) (not (on_block ?b ?b2)))) ; If block ?b was on block ?b2, it is no longer on it\n)'} +{'name': 'place_block_on_table', 'params': OrderedDict([('?r', 'object'), ('?b', 'block'), ('?t', 'object')]), 'preconditions': '(and\n (holding ?r ?b) ; The robot arm is holding the block\n (clear ?t) ; The table has space for the block\n (is_robot_arm ?r) ; The object ?r is a robot arm\n (is_table ?t) ; The object ?t is a table\n)', 'effects': '(and\n (not (holding ?r ?b)) ; The robot arm is no longer holding the block\n (on_table ?b) ; The block is now on the table\n (arm_free ?r) ; The robot arm is now free\n)'} +{'name': 'place_block_on_block', 'params': OrderedDict([('?r', 'object'), ('?b1', 'block'), ('?b2', 'block')]), 'preconditions': '(and\n (is_robot_arm ?r) ; ?r is a robot arm\n (holding ?r ?b1) ; The robot arm is holding block ?b1\n (clear ?b2) ; Block ?b2 is clear, meaning no block is on top of it\n)', 'effects': '(and\n (not (holding ?r ?b1)) ; The robot arm is no longer holding block ?b1\n (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2\n (not (clear ?b2)) ; Block ?b2 is no longer clear\n (arm_free ?r) ; The robot arm is now free\n)'} PREDICATES: -{'name': 'on_table', 'desc': 'true if block ?b is on the table ?t', 'raw': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t', 'params': OrderedDict([('?b', 'block'), ('?t', 'table')]), 'clean': '(on_table ?b - block ?t - table): true if block ?b is on the table ?t'} -{'name': 'on_block', 'desc': 'true if block ?b1 is on top of block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2'} -{'name': 'held', 'desc': 'true if block ?b is currently being held by the robot arm', 'raw': '(held ?b - block): true if block ?b is currently being held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if block ?b is currently being held by the robot arm'} +{'name': 'clear', 'desc': 'true if no block is on top of block ?b', 'raw': '(clear ?b - block): true if no block is on top of block ?b', 'params': OrderedDict([('?b', 'block')]), 'clean': '(clear ?b - block): true if no block is on top of block ?b'} +{'name': 'on_table', 'desc': 'true if block ?b is on the table', 'raw': '(on_table ?b - block): true if block ?b is on the table', 'params': OrderedDict([('?b', 'block')]), 'clean': '(on_table ?b - block): true if block ?b is on the table'} +{'name': 'on_block', 'desc': 'true if block ?b1 is on block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on block ?b2'} +{'name': 'arm_free', 'desc': 'true if the robot arm ?r is not holding any block', 'raw': '(arm_free ?r - robot_arm): true if the robot arm ?r is not holding any block', 'params': OrderedDict([('?r', 'robot_arm')]), 'clean': '(arm_free ?r - robot_arm): true if the robot arm ?r is not holding any block'} +{'name': 'holding', 'desc': 'true if the robot arm ?r is holding block ?b', 'raw': '(holding ?r - robot_arm ?b - block): true if the robot arm ?r is holding block ?b', 'params': OrderedDict([('?r', 'robot_arm'), ('?b', 'block')]), 'clean': '(holding ?r - robot_arm ?b - block): true if the robot arm ?r is holding block ?b'} +{'name': 'is_robot_arm', 'desc': '', 'raw': '(is_robot_arm ?o - object) ; True if the object is a robot arm', 'params': OrderedDict([('?o', 'object')]), 'clean': '(is_robot_arm ?o - object): '} +{'name': 'is_table', 'desc': '', 'raw': '(is_table ?o - object) ; True if the object is a table', 'params': OrderedDict([('?o', 'object')]), 'clean': '(is_table ?o - object): '} -------------------- STEP FIVE: TASK EXTRACTION OBJECTS: -blue_block - block -red_block - block -yellow_block - block -green_block - block +blue - block +red - block +yellow - block +green - block table1 - table +robot_arm1 - object INITIAL STATES: -(on_block blue_block red_block) -(on_block red_block yellow_block) -(on_table yellow_block table1) -(on_table green_block table1) -(clear green_block) +(on_block blue red) +(on_block red yellow) +(on_table yellow table1) +(on_table green table1) +(clear blue) +(clear green) +(arm_free robot_arm1) +(is_robot_arm robot_arm1) +(is_table table1) GOAL STATES: (AND - (on_block red_block green_block) + (on_block red green) + (on_block blue red) + (on_table yellow table1) + (on_table green table1) ) @@ -58,81 +69,77 @@ PDDL DOMAIN: ) (:predicates - (on_table ?b - block ?t - table) ; true if block ?b is on the table ?t - (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 - (held ?b - block) ; true if block ?b is currently being held by the robot arm + (clear ?b - block) ; true if no block is on top of block ?b + (on_table ?b - block) ; true if block ?b is on the table + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on block ?b2 + (arm_free ?r - robot_arm) ; true if the robot arm ?r is not holding any block + (holding ?r - robot_arm ?b - block) ; true if the robot arm ?r is holding block ?b + (is_robot_arm ?o - object) ; + (is_table ?o - object) ; ) - (:action pick_block + (:action pick_up_block :parameters ( + ?r - robot_arm ?b - block - ?t - table - ?b2 - block ) :precondition (and - (or (on_table ?b ?t) (on_block ?b ?b2)) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently being held + (arm_free ?r) ; The robot arm is not holding any block + (clear ?b) ; No block is on top of block ?b + (or + (on_table ?b) ; Block ?b is on the table + (exists (?b2 - block) (on_block ?b ?b2)) ; Block ?b is on another block ?b2 + ) ) :effect (and - (held ?b) ; The block is now being held by the robot arm - (not (on_table ?b ?t)) ; The block is no longer on the table - (not (on_block ?b ?b2)) ; The block is no longer on top of another block + (not (arm_free ?r)) ; The robot arm is now holding a block + (holding ?r ?b) ; The robot arm is holding block ?b + (not (on_table ?b)) ; Block ?b is no longer on the table + (forall (?b2 - block) (when (on_block ?b ?b2) (not (on_block ?b ?b2)))) ; If block ?b was on block ?b2, it is no longer on it ) ) - (:action place_on_table + (:action place_block_on_table :parameters ( + ?r - object ?b - block - ?t - table + ?t - object ) :precondition (and - (held ?b) ; The block is currently being held - (not (on_block ?b ?t)) ; The table must be clear of any blocks directly beneath the block being placed - (not (on_block ?b1 ?t)) ; The table must not have any blocks directly beneath the block being placed + (holding ?r ?b) ; The robot arm is holding the block + (clear ?t) ; The table has space for the block + (is_robot_arm ?r) ; The object ?r is a robot arm + (is_table ?t) ; The object ?t is a table ) :effect (and - (on_table ?b ?t) ; The block is now on the table - (not (held ?b)) ; The block is no longer being held + (not (holding ?r ?b)) ; The robot arm is no longer holding the block + (on_table ?b) ; The block is now on the table + (arm_free ?r) ; The robot arm is now free ) ) - (:action place_on_block + (:action place_block_on_block :parameters ( + ?r - object ?b1 - block ?b2 - block - ?t - table - ) - :precondition - (and - (held ?b1) ; The block being placed is currently held - (not (held ?b2)) ; The block being placed on is not currently held - (not (on_block ?b1 ?b2)) ; The block being placed on is clear of any blocks directly beneath it - (not (on_table ?b2 ?t)) ; The block being placed on is not on the table - ) - :effect - (and - (on_block ?b1 ?b2) ; The block being placed is now on top of the other block - (not (held ?b1)) ; The block being placed is no longer held - ) - ) - - (:action release_block - :parameters ( - ?b - block ) :precondition (and - (held ?b) ; The block is currently being held - (or (on_table ?b) (not (exists (?b2 - block) (on_block ?b ?b2)))) ; The block is either on the table or not on top of another block + (is_robot_arm ?r) ; ?r is a robot arm + (holding ?r ?b1) ; The robot arm is holding block ?b1 + (clear ?b2) ; Block ?b2 is clear, meaning no block is on top of it ) :effect (and - (not (held ?b)) ; The block is no longer held - (on_table ?b) ; The block is placed on the table after being released + (not (holding ?r ?b1)) ; The robot arm is no longer holding block ?b1 + (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2 + (not (clear ?b2)) ; Block ?b2 is no longer clear + (arm_free ?r) ; The robot arm is now free ) ) ) @@ -143,24 +150,32 @@ PDDL PROBLEM: (:domain blocksworld) (:objects - blue_block - block - red_block - block - yellow_block - block - green_block - block + blue - block + red - block + yellow - block + green - block table1 - table + robot_arm1 - object ) (:init - (on_block blue_block red_block) - (on_block red_block yellow_block) - (on_table yellow_block table1) - (on_table green_block table1) - (clear green_block) + (on_block blue red) + (on_block red yellow) + (on_table yellow table1) + (on_table green table1) + (clear blue) + (clear green) + (arm_free robot_arm1) + (is_robot_arm robot_arm1) + (is_table table1) ) (:goal (and - (on_block red_block green_block) + (on_block red green) + (on_block blue red) + (on_table yellow table1) + (on_table green table1) ) ) diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt index 746607c..0db11dd 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/plan.txt @@ -1 +1,3 @@ -Input error in translate phase. \ No newline at end of file +Input error in translate phase. + +THIS PLAN FAILED BECAUSE OF THE ACTION EXTRACTION STEP: CONSTRUCTED ONLY 3 ACTIONS NOT SUFFICIENT TO MODEL PROBLEM \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl index d138670..bbc14be 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl +++ b/paper_reconstructions/nl2plan/results/blocksworld/task1/problem.pddl @@ -3,24 +3,32 @@ (:domain blocksworld) (:objects - blue_block - block - red_block - block - yellow_block - block - green_block - block + blue - block + red - block + yellow - block + green - block table1 - table + robot_arm1 - object ) (:init - (on_block blue_block red_block) - (on_block red_block yellow_block) - (on_table yellow_block table1) - (on_table green_block table1) - (clear green_block) + (on_block blue red) + (on_block red yellow) + (on_table yellow table1) + (on_table green table1) + (clear blue) + (clear green) + (arm_free robot_arm1) + (is_robot_arm robot_arm1) + (is_table table1) ) (:goal (and - (on_block red_block green_block) + (on_block red green) + (on_block blue red) + (on_table yellow table1) + (on_table green table1) ) ) diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl index 61315df..ea1d450 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/domain.pddl @@ -5,117 +5,79 @@ (:types movable_object - object block - movable_object - table - object + surface - object + table - surface ) (:predicates - (on_table ?b - block) ; true if the block ?b is on the table. - (held ?b - block) ; true if the block ?b is currently held by the robot arm. - (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2. + (is_robot_arm ?r - object) ; true if the object ?r is a robot arm + (clear ?b - block) ; true if no other block is on top of block ?b + (arm_free ?r - object) ; true if the robot arm ?r is not holding any block + (on ?b - block ?s - surface) ; true if block ?b is on surface ?s + (holding ?r - object ?b - block) ; true if the robot arm ?r is holding block ?b + (table_space_available ?t - table) ; true if the table ?t has space available for a block + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on block ?b2 ) - (:action pick_block + (:action pick_up_block :parameters ( + ?r - object ?b - block + ?s - surface ) :precondition (and - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently held by the arm + (is_robot_arm ?r) ; The object ?r is a robot arm + (clear ?b) ; The block ?b is clear (no block on top of it) + (arm_free ?r) ; The robot arm ?r is free (not holding any block) + (on ?b ?s) ; The block ?b is on the surface ?s ) :effect (and - (held ?b) ; The block is now held by the robot arm - (not (on_table ?b)) ; The block is no longer on the table - (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2) + (not (on ?b ?s)) ; The block ?b is no longer on the surface ?s + (holding ?r ?b) ; The robot arm ?r is now holding the block ?b + (not (arm_free ?r)) ; The robot arm ?r is no longer free ) ) - (:action place_on_table + (:action place_block_on_table :parameters ( + ?r - object ?b - block + ?t - table ) :precondition (and - (held ?b) ; The block is currently held by the robot arm + (is_robot_arm ?r) ; The object ?r is a robot arm + (holding ?r ?b) ; The robot arm ?r is holding the block ?b + (table_space_available ?t) ; The table ?t has space available for the block ) :effect (and - (not (held ?b)) ; The block is no longer held by the robot arm - (on_table ?b) ; The block is now on the table + (not (holding ?r ?b)) ; The robot arm ?r is no longer holding the block ?b + (on ?b ?t) ; The block ?b is now on the table ?t + (arm_free ?r) ; The robot arm ?r is now free ) ) - (:action place_on_block + (:action place_block_on_block :parameters ( + ?r - object ?b1 - block ?b2 - block - ?b3 - block ) :precondition (and - (held ?b1) ; The block being placed is currently held by the robot arm. - (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked. - (not (held ?b2)) ; The target block must not be held by the arm. + (is_robot_arm ?r) ; The object ?r is a robot arm + (holding ?r ?b1) ; The robot arm ?r is holding block ?b1 + (clear ?b2) ; The block ?b2 is clear, i.e., no other block is on top of it ) :effect (and - (not (held ?b1)) ; The block being placed is no longer held by the robot arm. - (on ?b1 ?b2) ; The block being placed is now on top of the target block. - ) - ) - - (:action release_block - :parameters ( - ?b - block - ?b2 - block - ) - :precondition - (and - (held ?b) ; The block is currently held by the robot arm - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block - ) - :effect - (and - (not (held ?b)) ; The block is no longer held by the robot arm - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block - ) - ) - - (:action pick_and_place_on_table - :parameters ( - ?b - block - ) - :precondition - (and - (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently held by the robot arm - ) - :effect - (and - (held ?b) ; The block is now held by the robot arm - (not (on_table ?b)) ; The block is no longer on the table - (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was) - ) - ) - - (:action pick_and_place_on_block - :parameters ( - ?b1 - block - ?b2 - block - ?b3 - block - ) - :precondition - (and - (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block - (not (held ?b1)) ; ?b1 must not be currently held by the robot arm - (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block - ) - :effect - (and - (held ?b1) ; ?b1 is now held by the robot arm - (not (on_table ?b1)) ; ?b1 is no longer on the table - (on ?b1 ?b2) ; ?b1 is now on top of ?b2 + (not (holding ?r ?b1)) ; The robot arm ?r is no longer holding block ?b1 + (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2 + (clear ?b1) ; Block ?b1 is clear after being placed + (not (clear ?b2)) ; Block ?b2 is no longer clear after ?b1 is placed on it ) ) ) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt index e55c0bf..0becdfb 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/log.txt @@ -1,53 +1,59 @@ STEP ONE: TYPE EXTRACTION -{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} +{'block': 'The primary object that the robot arm interacts with. Blocks can be moved, stacked, or placed on the table.', 'table': 'The surface on which blocks can be placed. It serves as the base level for stacking blocks.', 'movable_object': 'A meta-type that includes any object that can be moved by the robot arm. In this case, it includes blocks.', 'surface': 'A meta-type that includes any object that can serve as a base for placing other objects. In this case, it includes the table.'} -------------------- STEP TWO: HIERARCHY CONSTRUCTION -{'object': 'Object is always root, everything is an object', 'children': [{'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm.', 'children': []}]}, {'table': 'A flat surface where blocks can be placed.', 'children': []}]} +{'object': 'Object is always root, everything is an object', 'children': [{'movable_object': 'A type of object that can be moved.', 'children': [{'block': 'A type of movable_object.', 'children': []}]}, {'surface': 'A type of object that can serve as a base.', 'children': [{'table': 'A type of surface.', 'children': []}]}]} -------------------- STEP THREE: ACTION EXTRACTION -{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table.', 'place_on_table': 'The robot arm places a block onto the table. Requires the block to be currently held by the arm. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be currently held by the arm and the target block to be on the table or already stacked, and the target block must not be held by the arm. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block that is currently held. Example: robot_arm releases block_1.', 'pick_and_place_on_table': 'The robot arm picks a block and places it on the table. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table and places it on the table.', 'pick_and_place_on_block': 'The robot arm picks a block and places it on top of another block. Requires the block to be on the table or on another block and not currently held by the arm. Example: robot_arm picks block_1 from the table and places it on block_2.'} +{'pick_up_block': 'The robot arm picks up a block from a surface. The block must be clear (i.e., no other block is on top of it) and the robot arm must be free (not holding another block). Example: The robot arm picks up block_1 from the table.', 'place_block_on_table': 'The robot arm places a block onto the table. The robot arm must be holding the block, and the table must have space for the block. Example: The robot arm places block_2 on the table.', 'place_block_on_block': 'The robot arm places a block onto another block. The robot arm must be holding the block, and the target block must be clear (i.e., no other block is on top of it). Example: The robot arm places block_3 on block_4.'} -------------------- STEP FOUR: ACTION CONSTRUCTION ACTIONS: -{'name': 'pick_block', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently held by the arm\n)', 'effects': '(and\n (held ?b) ; The block is now held by the robot arm\n (not (on_table ?b)) ; The block is no longer on the table\n (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2)\n)'} -{'name': 'place_on_table', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (on_table ?b) ; The block is now on the table\n)'} -{'name': 'place_on_block', 'params': OrderedDict({'?b1': 'block', '?b2': 'block', '?b3': 'block'}), 'preconditions': '(and\n (held ?b1) ; The block being placed is currently held by the robot arm.\n (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked.\n (not (held ?b2)) ; The target block must not be held by the arm.\n)', 'effects': '(and\n (not (held ?b1)) ; The block being placed is no longer held by the robot arm.\n (on ?b1 ?b2) ; The block being placed is now on top of the target block.\n)'} -{'name': 'release_block', 'params': OrderedDict({'?b': 'block', '?b2': 'block'}), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block\n)'} -{'name': 'pick_and_place_on_table', 'params': OrderedDict({'?b': 'block'}), 'preconditions': '(and\n (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block\n (not (held ?b)) ; The block is not currently held by the robot arm\n)', 'effects': '(and\n (held ?b) ; The block is now held by the robot arm\n (not (on_table ?b)) ; The block is no longer on the table\n (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was)\n)'} -{'name': 'pick_and_place_on_block', 'params': OrderedDict({'?b1': 'block', '?b2': 'block', '?b3': 'block'}), 'preconditions': '(and\n (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block\n (not (held ?b1)) ; ?b1 must not be currently held by the robot arm\n (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block\n)', 'effects': '(and\n (held ?b1) ; ?b1 is now held by the robot arm\n (not (on_table ?b1)) ; ?b1 is no longer on the table\n (on ?b1 ?b2) ; ?b1 is now on top of ?b2\n)'} +{'name': 'pick_up_block', 'params': OrderedDict([('?r', 'object'), ('?b', 'block'), ('?s', 'surface')]), 'preconditions': '(and\n (is_robot_arm ?r) ; The object ?r is a robot arm\n (clear ?b) ; The block ?b is clear (no block on top of it)\n (arm_free ?r) ; The robot arm ?r is free (not holding any block)\n (on ?b ?s) ; The block ?b is on the surface ?s\n)', 'effects': '(and\n (not (on ?b ?s)) ; The block ?b is no longer on the surface ?s\n (holding ?r ?b) ; The robot arm ?r is now holding the block ?b\n (not (arm_free ?r)) ; The robot arm ?r is no longer free\n)'} +{'name': 'place_block_on_table', 'params': OrderedDict([('?r', 'object'), ('?b', 'block'), ('?t', 'table')]), 'preconditions': '(and\n (is_robot_arm ?r) ; The object ?r is a robot arm\n (holding ?r ?b) ; The robot arm ?r is holding the block ?b\n (table_space_available ?t) ; The table ?t has space available for the block\n)', 'effects': '(and\n (not (holding ?r ?b)) ; The robot arm ?r is no longer holding the block ?b\n (on ?b ?t) ; The block ?b is now on the table ?t\n (arm_free ?r) ; The robot arm ?r is now free\n)'} +{'name': 'place_block_on_block', 'params': OrderedDict([('?r', 'object'), ('?b1', 'block'), ('?b2', 'block')]), 'preconditions': '(and\n (is_robot_arm ?r) ; The object ?r is a robot arm\n (holding ?r ?b1) ; The robot arm ?r is holding block ?b1\n (clear ?b2) ; The block ?b2 is clear, i.e., no other block is on top of it\n)', 'effects': '(and\n (not (holding ?r ?b1)) ; The robot arm ?r is no longer holding block ?b1\n (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2\n (clear ?b1) ; Block ?b1 is clear after being placed\n (not (clear ?b2)) ; Block ?b2 is no longer clear after ?b1 is placed on it\n)'} PREDICATES: -{'name': 'on_table', 'desc': 'true if the block ?b is on the table.', 'raw': '(on_table ?b - block): true if the block ?b is on the table', 'params': OrderedDict({'?b': 'block'}), 'clean': '(on_table ?b - block): true if the block ?b is on the table.'} -{'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm.', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict({'?b': 'block'}), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm.'} -{'name': 'on', 'desc': 'true if block ?b1 is on top of block ?b2.', 'raw': '(on ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict({'?b1': 'block', '?b2': 'block'}), 'clean': '(on ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2.'} +{'name': 'is_robot_arm', 'desc': 'true if the object ?r is a robot arm', 'raw': '(is_robot_arm ?r - object): true if the object ?r is a robot arm', 'params': OrderedDict([('?r', 'object')]), 'clean': '(is_robot_arm ?r - object): true if the object ?r is a robot arm'} +{'name': 'clear', 'desc': 'true if no other block is on top of block ?b', 'raw': '(clear ?b - block): true if no other block is on top of block ?b', 'params': OrderedDict([('?b', 'block')]), 'clean': '(clear ?b - block): true if no other block is on top of block ?b'} +{'name': 'arm_free', 'desc': 'true if the robot arm ?r is not holding any block', 'raw': '(arm_free ?r - object): true if the robot arm ?r is not holding any block', 'params': OrderedDict([('?r', 'object')]), 'clean': '(arm_free ?r - object): true if the robot arm ?r is not holding any block'} +{'name': 'on', 'desc': 'true if block ?b is on surface ?s', 'raw': '(on ?b - block ?s - surface): true if block ?b is on surface ?s', 'params': OrderedDict([('?b', 'block'), ('?s', 'surface')]), 'clean': '(on ?b - block ?s - surface): true if block ?b is on surface ?s'} +{'name': 'holding', 'desc': 'true if the robot arm ?r is holding block ?b', 'raw': '(holding ?r - object ?b - block): true if the robot arm ?r is holding block ?b', 'params': OrderedDict([('?r', 'object'), ('?b', 'block')]), 'clean': '(holding ?r - object ?b - block): true if the robot arm ?r is holding block ?b'} +{'name': 'table_space_available', 'desc': 'true if the table ?t has space available for a block', 'raw': '(table_space_available ?t - table): true if the table ?t has space available for a block', 'params': OrderedDict([('?t', 'table')]), 'clean': '(table_space_available ?t - table): true if the table ?t has space available for a block'} +{'name': 'on_block', 'desc': 'true if block ?b1 is on block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on block ?b2'} -------------------- STEP FIVE: TASK EXTRACTION OBJECTS: -block1 - block -block2 - block -block3 - block -block4 - block +blue - block +red - block +green - block +yellow - block table1 - table +robot_arm1 - object INITIAL STATES: -(on block1 table1) -(on block2 block1) -(on block3 table1) -(on block4 block3) +(is_robot_arm robot_arm1) +(clear blue) +(clear green) +(arm_free robot_arm1) +(on blue red) +(on green yellow) +(on yellow table1) +(table_space_available table1) GOAL STATES: (AND - (on block1 table1) - (on block3 block1) - (on block2 block3) - (on block4 block2) + (on green red) + (on blue green) + (on yellow blue) + (clear yellow) ) @@ -59,117 +65,79 @@ PDDL DOMAIN: (:types movable_object - object block - movable_object - table - object + surface - object + table - surface ) (:predicates - (on_table ?b - block) ; true if the block ?b is on the table. - (held ?b - block) ; true if the block ?b is currently held by the robot arm. - (on ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2. + (is_robot_arm ?r - object) ; true if the object ?r is a robot arm + (clear ?b - block) ; true if no other block is on top of block ?b + (arm_free ?r - object) ; true if the robot arm ?r is not holding any block + (on ?b - block ?s - surface) ; true if block ?b is on surface ?s + (holding ?r - object ?b - block) ; true if the robot arm ?r is holding block ?b + (table_space_available ?t - table) ; true if the table ?t has space available for a block + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on block ?b2 ) - (:action pick_block + (:action pick_up_block :parameters ( + ?r - object ?b - block + ?s - surface ) :precondition (and - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently held by the arm + (is_robot_arm ?r) ; The object ?r is a robot arm + (clear ?b) ; The block ?b is clear (no block on top of it) + (arm_free ?r) ; The robot arm ?r is free (not holding any block) + (on ?b ?s) ; The block ?b is on the surface ?s ) :effect (and - (held ?b) ; The block is now held by the robot arm - (not (on_table ?b)) ; The block is no longer on the table - (not (on ?b ?b2)) ; The block is no longer on top of another block (for all blocks ?b2) + (not (on ?b ?s)) ; The block ?b is no longer on the surface ?s + (holding ?r ?b) ; The robot arm ?r is now holding the block ?b + (not (arm_free ?r)) ; The robot arm ?r is no longer free ) ) - (:action place_on_table + (:action place_block_on_table :parameters ( + ?r - object ?b - block + ?t - table ) :precondition (and - (held ?b) ; The block is currently held by the robot arm + (is_robot_arm ?r) ; The object ?r is a robot arm + (holding ?r ?b) ; The robot arm ?r is holding the block ?b + (table_space_available ?t) ; The table ?t has space available for the block ) :effect (and - (not (held ?b)) ; The block is no longer held by the robot arm - (on_table ?b) ; The block is now on the table + (not (holding ?r ?b)) ; The robot arm ?r is no longer holding the block ?b + (on ?b ?t) ; The block ?b is now on the table ?t + (arm_free ?r) ; The robot arm ?r is now free ) ) - (:action place_on_block + (:action place_block_on_block :parameters ( + ?r - object ?b1 - block ?b2 - block - ?b3 - block ) :precondition (and - (held ?b1) ; The block being placed is currently held by the robot arm. - (or (on_table ?b2) (on ?b2 ?b3)) ; The target block must be on the table or already stacked. - (not (held ?b2)) ; The target block must not be held by the arm. + (is_robot_arm ?r) ; The object ?r is a robot arm + (holding ?r ?b1) ; The robot arm ?r is holding block ?b1 + (clear ?b2) ; The block ?b2 is clear, i.e., no other block is on top of it ) :effect (and - (not (held ?b1)) ; The block being placed is no longer held by the robot arm. - (on ?b1 ?b2) ; The block being placed is now on top of the target block. - ) - ) - - (:action release_block - :parameters ( - ?b - block - ?b2 - block - ) - :precondition - (and - (held ?b) ; The block is currently held by the robot arm - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is being released onto the table or onto another block - ) - :effect - (and - (not (held ?b)) ; The block is no longer held by the robot arm - (or (on_table ?b) (exists (?b2 - block) (on ?b ?b2))) ; The block is now on the table or on another block - ) - ) - - (:action pick_and_place_on_table - :parameters ( - ?b - block - ) - :precondition - (and - (or (on_table ?b) (on ?b ?b2)) ; The block is either on the table or on another block - (not (held ?b)) ; The block is not currently held by the robot arm - ) - :effect - (and - (held ?b) ; The block is now held by the robot arm - (not (on_table ?b)) ; The block is no longer on the table - (not (on ?b ?b2)) ; The block is no longer on top of another block (if it was) - ) - ) - - (:action pick_and_place_on_block - :parameters ( - ?b1 - block - ?b2 - block - ?b3 - block - ) - :precondition - (and - (or (on_table ?b1) (on ?b1 ?b2)) ; ?b1 must be on the table or on another block - (not (held ?b1)) ; ?b1 must not be currently held by the robot arm - (or (on_table ?b2) (on ?b2 ?b3)) ; ?b2 must be on the table or on another block - ) - :effect - (and - (held ?b1) ; ?b1 is now held by the robot arm - (not (on_table ?b1)) ; ?b1 is no longer on the table - (on ?b1 ?b2) ; ?b1 is now on top of ?b2 + (not (holding ?r ?b1)) ; The robot arm ?r is no longer holding block ?b1 + (on_block ?b1 ?b2) ; Block ?b1 is now on block ?b2 + (clear ?b1) ; Block ?b1 is clear after being placed + (not (clear ?b2)) ; Block ?b2 is no longer clear after ?b1 is placed on it ) ) ) @@ -180,26 +148,31 @@ PDDL PROBLEM: (:domain blocksworld) (:objects - block1 - block - block2 - block - block3 - block - block4 - block + blue - block + red - block + green - block + yellow - block table1 - table + robot_arm1 - object ) (:init - (on block1 table1) - (on block2 block1) - (on block3 table1) - (on block4 block3) + (is_robot_arm robot_arm1) + (clear blue) + (clear green) + (arm_free robot_arm1) + (on blue red) + (on green yellow) + (on yellow table1) + (table_space_available table1) ) (:goal (and - (on block1 table1) - (on block3 block1) - (on block2 block3) - (on block4 block2) + (on green red) + (on blue green) + (on yellow blue) + (clear yellow) ) ) diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt index 2995509..a7ffa51 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/plan.txt @@ -1 +1 @@ -Input error in the driver. \ No newline at end of file +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl index cd4abfa..1b3f72f 100644 --- a/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl +++ b/paper_reconstructions/nl2plan/results/blocksworld/task2/problem.pddl @@ -3,26 +3,31 @@ (:domain blocksworld) (:objects - block1 - block - block2 - block - block3 - block - block4 - block + blue - block + red - block + green - block + yellow - block table1 - table + robot_arm1 - object ) (:init - (on block1 table1) - (on block2 block1) - (on block3 table1) - (on block4 block3) + (is_robot_arm robot_arm1) + (clear blue) + (clear green) + (arm_free robot_arm1) + (on blue red) + (on green yellow) + (on yellow table1) + (table_space_available table1) ) (:goal (and - (on block1 table1) - (on block3 block1) - (on block2 block3) - (on block4 block2) + (on green red) + (on blue green) + (on yellow blue) + (clear yellow) ) ) diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task3/domain.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task3/domain.pddl new file mode 100644 index 0000000..4f8d61b --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task3/domain.pddl @@ -0,0 +1,87 @@ +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + movable_object - object + block - movable_object + table - object + ) + + (:predicates + (on_table ?b - block) ; true if the block ?b is on the table + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if the block ?b is currently held by the robot arm + (stable ?b - block) ; true if the block ?b is stable and can support another block on top of it. + ) + + (:action pick_block + :parameters ( + ?b - block + ) + :precondition + (and + (or + (on_table ?b) ; The block is on the table + (exists (?b2 - block) (on_block ?b ?b2)) ; The block is on top of another block + ) + (not (held ?b)) ; The block is not currently held + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ) + :precondition + (and + (held ?b1) ; The block ?b1 is currently held by the robot arm + (not (held ?b2)) ; The block ?b2 is not currently held + (stable ?b1) ; The block ?b1 must also be stable + (stable ?b2) ; The block ?b2 is stable + ) + :effect + (and + (not (held ?b1)) ; The block ?b1 is no longer held by the robot arm + (on_block ?b1 ?b2) ; The block ?b1 is now on top of block ?b2 + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (stable ?b) ; The block is stable and can be safely placed + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task3/log.txt b/paper_reconstructions/nl2plan/results/blocksworld/task3/log.txt new file mode 100644 index 0000000..501c2d1 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task3/log.txt @@ -0,0 +1,193 @@ +STEP ONE: TYPE EXTRACTION + +{'block': 'The individual units that can be picked and placed by the robot arm. They can be stacked or placed on a table.', 'table': 'A flat surface where blocks can be placed. It serves as a base for the blocks.', 'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm, specifically blocks in this case.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'movable_object': 'A meta-type that includes all objects that can be moved by the robot arm.', 'children': [{'block': 'The individual units that can be picked and placed by the robot arm.', 'children': []}]}, {'table': 'A flat surface where blocks can be placed.', 'children': []}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'pick_block': 'The robot arm picks up a block from the table or from on top of another block. Requires the block to be on the table or on another block. Example: robot_arm picks up block_1 from the table.', 'place_on_table': 'The robot arm places a block onto the table. Requires the block to be currently held by the robot arm. Example: robot_arm places block_1 on the table.', 'place_on_block': 'The robot arm places a block on top of another block. Requires the block to be currently held by the robot arm and the target block to be stable and not currently held. Example: robot_arm places block_1 on block_2.', 'release_block': 'The robot arm releases a block that it is currently holding. Example: robot_arm releases block_1.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'pick_block', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (or \n (on_table ?b) ; The block is on the table\n (exists (?b2 - block) (on_block ?b ?b2)) ; The block is on top of another block\n )\n (not (held ?b)) ; The block is not currently held\n)', 'effects': '(and\n (held ?b) ; The block is now held by the robot arm\n (not (on_table ?b)) ; The block is no longer on the table\n (not (on_block ?b ?b2)) ; The block is no longer on top of another block\n)'} +{'name': 'place_on_table', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (on_table ?b) ; The block is now on the table\n)'} +{'name': 'place_on_block', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'preconditions': '(and\n (held ?b1) ; The block ?b1 is currently held by the robot arm\n (not (held ?b2)) ; The block ?b2 is not currently held\n (stable ?b1) ; The block ?b1 must also be stable\n (stable ?b2) ; The block ?b2 is stable\n)', 'effects': '(and\n (not (held ?b1)) ; The block ?b1 is no longer held by the robot arm\n (on_block ?b1 ?b2) ; The block ?b1 is now on top of block ?b2\n)'} +{'name': 'release_block', 'params': OrderedDict([('?b', 'block')]), 'preconditions': '(and\n (held ?b) ; The block is currently held by the robot arm\n (stable ?b) ; The block is stable and can be safely placed\n)', 'effects': '(and\n (not (held ?b)) ; The block is no longer held by the robot arm\n (on_table ?b) ; The block is placed on the table after being released\n)'} + +PREDICATES: +{'name': 'on_table', 'desc': 'true if the block ?b is on the table', 'raw': '(on_table ?b - block): true if the block ?b is on the table', 'params': OrderedDict([('?b', 'block')]), 'clean': '(on_table ?b - block): true if the block ?b is on the table'} +{'name': 'on_block', 'desc': 'true if block ?b1 is on top of block ?b2', 'raw': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b', 'params': OrderedDict([('?b1', 'block'), ('?b2', 'block')]), 'clean': '(on_block ?b1 - block ?b2 - block): true if block ?b1 is on top of block ?b2'} +{'name': 'held', 'desc': 'true if the block ?b is currently held by the robot arm', 'raw': '(held ?b - block): true if the block ?b is currently held by the robot arm', 'params': OrderedDict([('?b', 'block')]), 'clean': '(held ?b - block): true if the block ?b is currently held by the robot arm'} +{'name': 'stable', 'desc': 'true if the block ?b is stable and can support another block on top of it.', 'raw': '(stable ?b - block): true if the block ?b is stable and can support another block on top of it', 'params': OrderedDict([('?b', 'block')]), 'clean': '(stable ?b - block): true if the block ?b is stable and can support another block on top of it.'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +red1 - block +red2 - block +blue1 - block +green1 - block +green2 - block +INITIAL STATES: +(on_block red1 green1) +(on_block red2 green2) +(on_block blue1 green1) +(on_block green1 green2) +(stable red1) +(stable red2) +(stable blue1) +(stable green1) +(stable green2) +(held red1) +GOAL STATES: +(AND + (on_block green1 red1) + (on_block green2 red2) + (on_block green1 blue1) + (on_block green2 green1) + (stable red1) + (stable red2) + (stable blue1) + (stable green1) + (stable green2) +) + + +PDDL DOMAIN: +(define (domain blocksworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + movable_object - object + block - movable_object + table - object + ) + + (:predicates + (on_table ?b - block) ; true if the block ?b is on the table + (on_block ?b1 - block ?b2 - block) ; true if block ?b1 is on top of block ?b2 + (held ?b - block) ; true if the block ?b is currently held by the robot arm + (stable ?b - block) ; true if the block ?b is stable and can support another block on top of it. + ) + + (:action pick_block + :parameters ( + ?b - block + ) + :precondition + (and + (or + (on_table ?b) ; The block is on the table + (exists (?b2 - block) (on_block ?b ?b2)) ; The block is on top of another block + ) + (not (held ?b)) ; The block is not currently held + ) + :effect + (and + (held ?b) ; The block is now held by the robot arm + (not (on_table ?b)) ; The block is no longer on the table + (not (on_block ?b ?b2)) ; The block is no longer on top of another block + ) + ) + + (:action place_on_table + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is now on the table + ) + ) + + (:action place_on_block + :parameters ( + ?b1 - block + ?b2 - block + ) + :precondition + (and + (held ?b1) ; The block ?b1 is currently held by the robot arm + (not (held ?b2)) ; The block ?b2 is not currently held + (stable ?b1) ; The block ?b1 must also be stable + (stable ?b2) ; The block ?b2 is stable + ) + :effect + (and + (not (held ?b1)) ; The block ?b1 is no longer held by the robot arm + (on_block ?b1 ?b2) ; The block ?b1 is now on top of block ?b2 + ) + ) + + (:action release_block + :parameters ( + ?b - block + ) + :precondition + (and + (held ?b) ; The block is currently held by the robot arm + (stable ?b) ; The block is stable and can be safely placed + ) + :effect + (and + (not (held ?b)) ; The block is no longer held by the robot arm + (on_table ?b) ; The block is placed on the table after being released + ) + ) +) + +PDDL PROBLEM: +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + red1 - block + red2 - block + blue1 - block + green1 - block + green2 - block + ) + + (:init + (on_block red1 green1) + (on_block red2 green2) + (on_block blue1 green1) + (on_block green1 green2) + (stable red1) + (stable red2) + (stable blue1) + (stable green1) + (stable green2) + (held red1) + ) + + (:goal + (and + (on_block green1 red1) + (on_block green2 red2) + (on_block green1 blue1) + (on_block green2 green1) + (stable red1) + (stable red2) + (stable blue1) + (stable green1) + (stable green2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task3/plan.txt b/paper_reconstructions/nl2plan/results/blocksworld/task3/plan.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task3/plan.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/blocksworld/task3/problem.pddl b/paper_reconstructions/nl2plan/results/blocksworld/task3/problem.pddl new file mode 100644 index 0000000..821947c --- /dev/null +++ b/paper_reconstructions/nl2plan/results/blocksworld/task3/problem.pddl @@ -0,0 +1,40 @@ +(define + (problem blocksworld_problem) + (:domain blocksworld) + + (:objects + red1 - block + red2 - block + blue1 - block + green1 - block + green2 - block + ) + + (:init + (on_block red1 green1) + (on_block red2 green2) + (on_block blue1 green1) + (on_block green1 green2) + (stable red1) + (stable red2) + (stable blue1) + (stable green1) + (stable green2) + (held red1) + ) + + (:goal + (and + (on_block green1 red1) + (on_block green2 red2) + (on_block green1 blue1) + (on_block green2 green1) + (stable red1) + (stable red2) + (stable blue1) + (stable green1) + (stable green2) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/household/task1/domain.pddl b/paper_reconstructions/nl2plan/results/household/task1/domain.pddl new file mode 100644 index 0000000..ea3ec58 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/household/task1/domain.pddl @@ -0,0 +1,205 @@ +(define (domain household) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + robot - object + furniture - object + flat_surface - furniture + appliance - object + small_item - object + ) + + (:predicates + (at ?r - robot ?loc - object) ; true if the robot ?r is at the location ?loc + (is_furniture ?loc - object) ; true if the location ?loc is a piece of furniture + (is_appliance ?loc - object) ; true if the location ?loc is an appliance + (on ?item - small_item ?surface - flat_surface) ; true if the item is on the flat surface + (gripper_empty ?r - robot) ; true if the robot's gripper is empty + (holding ?r - robot ?item - small_item) ; true if the robot is holding the item + (appliance_open ?a - appliance) ; true if the appliance ?a is open + (appliance_closed ?a - appliance) ; true if the appliance ?a is closed + (drawer_open ?f - furniture) ; true if the drawer on the furniture ?f is open + (drawer_closed ?f - furniture) ; true if the drawer on the furniture ?f is closed + (appliance_on ?a - appliance) ; true if the appliance ?a is on + (appliance_off ?a - appliance) ; true if the appliance ?a is off + ) + + (:action navigate_to + :parameters ( + + ) + :precondition + (and + (at ?r ?current_loc) ; The robot is at its current location + (or (is_furniture ?loc) (is_appliance ?loc)) ; The target location is either furniture or an appliance + ) + :effect + (and + (not (at ?r ?current_loc)) ; The robot is no longer at the current location + (at ?r ?loc) ; The robot is now at the target location + ) + ) + + (:action pick_up + :parameters ( + ?r - robot + ?item - small_item + ?surface - flat_surface + ) + :precondition + (and + (at ?r ?surface) ; The robot is at the location of the flat surface + (on ?item ?surface) ; The item is on the flat surface + (gripper_empty ?r) ; The robot's gripper is empty + ) + :effect + (and + (not (on ?item ?surface)) ; The item is no longer on the flat surface + (not (gripper_empty ?r)) ; The robot's gripper is no longer empty + (holding ?r ?item) ; The robot is now holding the item + ) + ) + + (:action put_down + :parameters ( + ?r - robot + ?item - small_item + ?surface - flat_surface + ) + :precondition + (and + (at ?r ?surface) ; The robot is at the location of the flat surface + (holding ?r ?item) ; The robot is holding the item + (is_furniture ?surface) ; Ensure the surface is a flat surface + ) + :effect + (and + (on ?item ?surface) ; The item is now on the flat surface + (not (holding ?r ?item)) ; The robot is no longer holding the item + (gripper_empty ?r) ; The robot's gripper is now empty + ) + ) + + (:action open_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (is_appliance ?a) ; The location is an appliance + (gripper_empty ?r) ; The robot's gripper is empty + (appliance_closed ?a) ; The appliance is currently closed + ) + :effect + (and + (not (appliance_closed ?a)) ; The appliance is no longer closed + (appliance_open ?a) ; The appliance is now open + ) + ) + + (:action close_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (gripper_empty ?r) ; The robot's gripper is empty + (appliance_open ?a) ; The appliance is open + ) + :effect + (and + (not (appliance_open ?a)) ; The appliance is no longer open + (appliance_closed ?a) ; The appliance is now closed + ) + ) + + (:action open_drawer + :parameters ( + ?r - robot + ?f - furniture + ) + :precondition + (and + (at ?r ?f) ; The robot is at the location of the furniture + (gripper_empty ?r) ; The robot's gripper is empty + (not (drawer_open ?f)) ; The drawer is not already open + ) + :effect + (and + (drawer_open ?f) ; The drawer on the furniture is now open + ) + ) + + (:action close_drawer + :parameters ( + ?r - robot + ?f - furniture + ) + :precondition + (and + (at ?r ?f) ; The robot is at the location of the furniture + (gripper_empty ?r) ; The robot's gripper is empty + (drawer_open ?f) ; The drawer on the furniture is open + ) + :effect + (and + (not (drawer_open ?f)) ; The drawer on the furniture is no longer open + (drawer_closed ?f) ; The drawer on the furniture is now closed + ) + ) + + (:action turn_on_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (appliance_off ?a) ; The appliance is currently off + ) + :effect + (and + (not (appliance_off ?a)) ; The appliance is no longer off + (appliance_on ?a) ; The appliance is now on + ) + ) + + (:action turn_off_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (appliance_on ?a) ; The appliance is currently on + ) + :effect + (and + (not (appliance_on ?a)) ; The appliance is no longer on + (appliance_off ?a) ; The appliance is now off + ) + ) + + (:action check_state + :parameters ( + ?r - robot + ?loc - object + ) + :precondition + (and + (at ?r ?loc) ; The robot is at the location of the object + (or (is_furniture ?loc) (is_appliance ?loc)) ; The object is either furniture or an appliance + ) + :effect + (and + ; No effects as checking state is a non-modifying action + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/household/task1/log.txt b/paper_reconstructions/nl2plan/results/household/task1/log.txt new file mode 100644 index 0000000..b0b27a0 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/household/task1/log.txt @@ -0,0 +1,357 @@ +STEP ONE: TYPE EXTRACTION + +{'robot': 'The household robot that performs tasks and navigates the environment.', 'furniture': 'Large and normally immovable objects that define locations for the robot and small items.', 'appliance': 'Large and normally immovable devices that may require interaction from the robot.', 'small_item': 'Objects like apples, oranges, bowls, lunch boxes, or lamps that the robot can hold or manipulate.', 'flat_surface': 'A surface on furniture where small items can be placed for manipulation.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'robot': 'The household robot that performs tasks and navigates the environment.', 'children': []}, {'furniture': 'Large and normally immovable objects that define locations for the robot and small items.', 'children': [{'flat_surface': 'A surface on furniture where small items can be placed for manipulation.', 'children': []}]}, {'appliance': 'Large and normally immovable devices that may require interaction from the robot.', 'children': []}, {'small_item': 'Objects like apples, oranges, bowls, lunch boxes, or lamps that the robot can hold or manipulate.', 'children': []}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'navigate_to': 'The robot moves from its current location to a specified piece of furniture or appliance. Example: The robot navigates to the kitchen table.', 'pick_up': 'The robot picks up a small item from a flat surface. Requires the robot to be at the location of the item and the gripper to be empty. Example: The robot picks up an apple from the dining table.', 'put_down': 'The robot places a small item it is holding onto a flat surface. Requires the robot to be at the location of the flat surface. Example: The robot puts down an orange on the kitchen counter.', 'open_appliance': "The robot opens an appliance, such as a refrigerator or oven. Requires the robot to be at the location of the appliance and the gripper to be empty. The appliance's state changes to open. Example: The robot opens the refrigerator.", 'close_appliance': "The robot closes an appliance, such as a refrigerator or oven. Requires the robot to be at the location of the appliance and the gripper to be empty. The appliance's state changes to closed. Example: The robot closes the oven.", 'open_drawer': 'The robot opens a drawer on a piece of furniture. Requires the robot to be at the location of the furniture and the gripper to be empty. Example: The robot opens the drawer of the bedside table.', 'close_drawer': 'The robot closes a drawer on a piece of furniture. Requires the robot to be at the location of the furniture and the gripper to be empty. Example: The robot closes the drawer of the desk.', 'turn_on_appliance': 'The robot turns on an appliance, such as a lamp or a fan. Requires the robot to be at the location of the appliance and the appliance to be in a state that allows it to be turned on (e.g., plugged in). Example: The robot turns on the living room lamp.', 'turn_off_appliance': 'The robot turns off an appliance, such as a lamp or a fan. Requires the robot to be at the location of the appliance and the appliance to be in a state that allows it to be turned off. Example: The robot turns off the bedroom fan.', 'check_state': 'The robot checks the state of an appliance or furniture to determine if it is open, closed, on, or off. Example: The robot checks if the refrigerator is open.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'navigate_to', 'params': OrderedDict(), 'preconditions': '(and\n (at ?r ?current_loc) ; The robot is at its current location\n (or (is_furniture ?loc) (is_appliance ?loc)) ; The target location is either furniture or an appliance\n)', 'effects': '(and\n (not (at ?r ?current_loc)) ; The robot is no longer at the current location\n (at ?r ?loc) ; The robot is now at the target location\n)'} +{'name': 'pick_up', 'params': OrderedDict([('?r', 'robot'), ('?item', 'small_item'), ('?surface', 'flat_surface')]), 'preconditions': "(and\n (at ?r ?surface) ; The robot is at the location of the flat surface\n (on ?item ?surface) ; The item is on the flat surface\n (gripper_empty ?r) ; The robot's gripper is empty\n)", 'effects': "(and\n (not (on ?item ?surface)) ; The item is no longer on the flat surface\n (not (gripper_empty ?r)) ; The robot's gripper is no longer empty\n (holding ?r ?item) ; The robot is now holding the item\n)"} +{'name': 'put_down', 'params': OrderedDict([('?r', 'robot'), ('?item', 'small_item'), ('?surface', 'flat_surface')]), 'preconditions': '(and\n (at ?r ?surface) ; The robot is at the location of the flat surface\n (holding ?r ?item) ; The robot is holding the item\n (is_furniture ?surface) ; Ensure the surface is a flat surface\n)', 'effects': "(and\n (on ?item ?surface) ; The item is now on the flat surface\n (not (holding ?r ?item)) ; The robot is no longer holding the item\n (gripper_empty ?r) ; The robot's gripper is now empty\n)"} +{'name': 'open_appliance', 'params': OrderedDict([('?r', 'robot'), ('?a', 'appliance')]), 'preconditions': "(and\n (at ?r ?a) ; The robot is at the location of the appliance\n (is_appliance ?a) ; The location is an appliance\n (gripper_empty ?r) ; The robot's gripper is empty\n (appliance_closed ?a) ; The appliance is currently closed\n)", 'effects': '(and\n (not (appliance_closed ?a)) ; The appliance is no longer closed\n (appliance_open ?a) ; The appliance is now open\n)'} +{'name': 'close_appliance', 'params': OrderedDict([('?r', 'robot'), ('?a', 'appliance')]), 'preconditions': "(and\n (at ?r ?a) ; The robot is at the location of the appliance\n (gripper_empty ?r) ; The robot's gripper is empty\n (appliance_open ?a) ; The appliance is open\n)", 'effects': '(and\n (not (appliance_open ?a)) ; The appliance is no longer open\n (appliance_closed ?a) ; The appliance is now closed\n)'} +{'name': 'open_drawer', 'params': OrderedDict([('?r', 'robot'), ('?f', 'furniture')]), 'preconditions': "(and\n (at ?r ?f) ; The robot is at the location of the furniture\n (gripper_empty ?r) ; The robot's gripper is empty\n (not (drawer_open ?f)) ; The drawer is not already open\n)", 'effects': '(and\n (drawer_open ?f) ; The drawer on the furniture is now open\n)'} +{'name': 'close_drawer', 'params': OrderedDict([('?r', 'robot'), ('?f', 'furniture')]), 'preconditions': "(and\n (at ?r ?f) ; The robot is at the location of the furniture\n (gripper_empty ?r) ; The robot's gripper is empty\n (drawer_open ?f) ; The drawer on the furniture is open\n)", 'effects': '(and\n (not (drawer_open ?f)) ; The drawer on the furniture is no longer open\n (drawer_closed ?f) ; The drawer on the furniture is now closed\n)'} +{'name': 'turn_on_appliance', 'params': OrderedDict([('?r', 'robot'), ('?a', 'appliance')]), 'preconditions': '(and\n (at ?r ?a) ; The robot is at the location of the appliance\n (appliance_off ?a) ; The appliance is currently off\n)', 'effects': '(and\n (not (appliance_off ?a)) ; The appliance is no longer off\n (appliance_on ?a) ; The appliance is now on\n)'} +{'name': 'turn_off_appliance', 'params': OrderedDict([('?r', 'robot'), ('?a', 'appliance')]), 'preconditions': '(and\n (at ?r ?a) ; The robot is at the location of the appliance\n (appliance_on ?a) ; The appliance is currently on\n)', 'effects': '(and\n (not (appliance_on ?a)) ; The appliance is no longer on\n (appliance_off ?a) ; The appliance is now off\n)'} +{'name': 'check_state', 'params': OrderedDict([('?r', 'robot'), ('?loc', 'object')]), 'preconditions': '(and\n (at ?r ?loc) ; The robot is at the location of the object\n (or (is_furniture ?loc) (is_appliance ?loc)) ; The object is either furniture or an appliance\n)', 'effects': '(and\n ; No effects as checking state is a non-modifying action\n)'} + +PREDICATES: +{'name': 'at', 'desc': 'true if the robot ?r is at the location ?loc', 'raw': '(at ?r - robot ?loc - object): true if the robot ?r is at the location ?loc', 'params': OrderedDict([('?r', 'robot'), ('?loc', 'object')]), 'clean': '(at ?r - robot ?loc - object): true if the robot ?r is at the location ?loc'} +{'name': 'is_furniture', 'desc': 'true if the location ?loc is a piece of furniture', 'raw': '(is_furniture ?loc - object): true if the location ?loc is a piece of furniture', 'params': OrderedDict([('?loc', 'object')]), 'clean': '(is_furniture ?loc - object): true if the location ?loc is a piece of furniture'} +{'name': 'is_appliance', 'desc': 'true if the location ?loc is an appliance', 'raw': '(is_appliance ?loc - object): true if the location ?loc is an appliance', 'params': OrderedDict([('?loc', 'object')]), 'clean': '(is_appliance ?loc - object): true if the location ?loc is an appliance'} +{'name': 'on', 'desc': 'true if the item is on the flat surface', 'raw': '(on ?item - small_item ?surface - flat_surface): true if the item is on the flat surface', 'params': OrderedDict([('?item', 'small_item'), ('?surface', 'flat_surface')]), 'clean': '(on ?item - small_item ?surface - flat_surface): true if the item is on the flat surface'} +{'name': 'gripper_empty', 'desc': "true if the robot's gripper is empty", 'raw': "(gripper_empty ?r - robot): true if the robot's gripper is empty", 'params': OrderedDict([('?r', 'robot')]), 'clean': "(gripper_empty ?r - robot): true if the robot's gripper is empty"} +{'name': 'holding', 'desc': 'true if the robot is holding the item', 'raw': '(holding ?r - robot ?item - small_item): true if the robot is holding the item', 'params': OrderedDict([('?r', 'robot'), ('?item', 'small_item')]), 'clean': '(holding ?r - robot ?item - small_item): true if the robot is holding the item'} +{'name': 'appliance_open', 'desc': 'true if the appliance ?a is open', 'raw': '(appliance_open ?a - appliance): true if the appliance ?a is open', 'params': OrderedDict([('?a', 'appliance')]), 'clean': '(appliance_open ?a - appliance): true if the appliance ?a is open'} +{'name': 'appliance_closed', 'desc': 'true if the appliance ?a is closed', 'raw': '(appliance_closed ?a - appliance): true if the appliance ?a is closed', 'params': OrderedDict([('?a', 'appliance')]), 'clean': '(appliance_closed ?a - appliance): true if the appliance ?a is closed'} +{'name': 'drawer_open', 'desc': 'true if the drawer on the furniture ?f is open', 'raw': '(drawer_open ?f - furniture): true if the drawer on the furniture ?f is open', 'params': OrderedDict([('?f', 'furniture')]), 'clean': '(drawer_open ?f - furniture): true if the drawer on the furniture ?f is open'} +{'name': 'drawer_closed', 'desc': 'true if the drawer on the furniture ?f is closed', 'raw': '(drawer_closed ?f - furniture): true if the drawer on the furniture ?f is closed', 'params': OrderedDict([('?f', 'furniture')]), 'clean': '(drawer_closed ?f - furniture): true if the drawer on the furniture ?f is closed'} +{'name': 'appliance_on', 'desc': 'true if the appliance ?a is on', 'raw': '(appliance_on ?a - appliance): true if the appliance ?a is on', 'params': OrderedDict([('?a', 'appliance')]), 'clean': '(appliance_on ?a - appliance): true if the appliance ?a is on'} +{'name': 'appliance_off', 'desc': 'true if the appliance ?a is off', 'raw': '(appliance_off ?a - appliance): true if the appliance ?a is off', 'params': OrderedDict([('?a', 'appliance')]), 'clean': '(appliance_off ?a - appliance): true if the appliance ?a is off'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +robot1 - robot +cabinet_1 - furniture +cabinet_2 - furniture +drawer_1 - furniture +drawer_2 - furniture +countertop_1 - flat_surface +dining_table_1 - flat_surface +side_table_1 - flat_surface +fridge_1 - appliance +blender_1 - appliance +lamp_1 - appliance +humidifier_1 - appliance +cup_1 - small_item +plate_1 - small_item +cutting_board_1 - small_item +apple_1 - small_item +book_1 - small_item +book_2 - small_item +mug_1 - small_item +INITIAL STATES: +(at robot1 cabinet_1) +(holding robot1 mug_1) +(drawer_open drawer_1) +(drawer_open drawer_2) +(appliance_open fridge_1) +(drawer_closed cabinet_1) +(drawer_open cabinet_2) +(on cup_1 cabinet_2) +(on plate_1 drawer_2) +(on cutting_board_1 countertop_1) +(on blender_1 dining_table_1) +(appliance_off blender_1) +(on lamp_1 side_table_1) +(appliance_off lamp_1) +(on humidifier_1 side_table_1) +(appliance_on humidifier_1) +(on apple_1 cabinet_2) +(on book_1 dining_table_1) +(on book_2 dining_table_1) +GOAL STATES: +(AND + (appliance_on lamp_1) + (appliance_off humidifier_1) +) + + +PDDL DOMAIN: +(define (domain household) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + robot - object + furniture - object + flat_surface - furniture + appliance - object + small_item - object + ) + + (:predicates + (at ?r - robot ?loc - object) ; true if the robot ?r is at the location ?loc + (is_furniture ?loc - object) ; true if the location ?loc is a piece of furniture + (is_appliance ?loc - object) ; true if the location ?loc is an appliance + (on ?item - small_item ?surface - flat_surface) ; true if the item is on the flat surface + (gripper_empty ?r - robot) ; true if the robot's gripper is empty + (holding ?r - robot ?item - small_item) ; true if the robot is holding the item + (appliance_open ?a - appliance) ; true if the appliance ?a is open + (appliance_closed ?a - appliance) ; true if the appliance ?a is closed + (drawer_open ?f - furniture) ; true if the drawer on the furniture ?f is open + (drawer_closed ?f - furniture) ; true if the drawer on the furniture ?f is closed + (appliance_on ?a - appliance) ; true if the appliance ?a is on + (appliance_off ?a - appliance) ; true if the appliance ?a is off + ) + + (:action navigate_to + :parameters ( + + ) + :precondition + (and + (at ?r ?current_loc) ; The robot is at its current location + (or (is_furniture ?loc) (is_appliance ?loc)) ; The target location is either furniture or an appliance + ) + :effect + (and + (not (at ?r ?current_loc)) ; The robot is no longer at the current location + (at ?r ?loc) ; The robot is now at the target location + ) + ) + + (:action pick_up + :parameters ( + ?r - robot + ?item - small_item + ?surface - flat_surface + ) + :precondition + (and + (at ?r ?surface) ; The robot is at the location of the flat surface + (on ?item ?surface) ; The item is on the flat surface + (gripper_empty ?r) ; The robot's gripper is empty + ) + :effect + (and + (not (on ?item ?surface)) ; The item is no longer on the flat surface + (not (gripper_empty ?r)) ; The robot's gripper is no longer empty + (holding ?r ?item) ; The robot is now holding the item + ) + ) + + (:action put_down + :parameters ( + ?r - robot + ?item - small_item + ?surface - flat_surface + ) + :precondition + (and + (at ?r ?surface) ; The robot is at the location of the flat surface + (holding ?r ?item) ; The robot is holding the item + (is_furniture ?surface) ; Ensure the surface is a flat surface + ) + :effect + (and + (on ?item ?surface) ; The item is now on the flat surface + (not (holding ?r ?item)) ; The robot is no longer holding the item + (gripper_empty ?r) ; The robot's gripper is now empty + ) + ) + + (:action open_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (is_appliance ?a) ; The location is an appliance + (gripper_empty ?r) ; The robot's gripper is empty + (appliance_closed ?a) ; The appliance is currently closed + ) + :effect + (and + (not (appliance_closed ?a)) ; The appliance is no longer closed + (appliance_open ?a) ; The appliance is now open + ) + ) + + (:action close_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (gripper_empty ?r) ; The robot's gripper is empty + (appliance_open ?a) ; The appliance is open + ) + :effect + (and + (not (appliance_open ?a)) ; The appliance is no longer open + (appliance_closed ?a) ; The appliance is now closed + ) + ) + + (:action open_drawer + :parameters ( + ?r - robot + ?f - furniture + ) + :precondition + (and + (at ?r ?f) ; The robot is at the location of the furniture + (gripper_empty ?r) ; The robot's gripper is empty + (not (drawer_open ?f)) ; The drawer is not already open + ) + :effect + (and + (drawer_open ?f) ; The drawer on the furniture is now open + ) + ) + + (:action close_drawer + :parameters ( + ?r - robot + ?f - furniture + ) + :precondition + (and + (at ?r ?f) ; The robot is at the location of the furniture + (gripper_empty ?r) ; The robot's gripper is empty + (drawer_open ?f) ; The drawer on the furniture is open + ) + :effect + (and + (not (drawer_open ?f)) ; The drawer on the furniture is no longer open + (drawer_closed ?f) ; The drawer on the furniture is now closed + ) + ) + + (:action turn_on_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (appliance_off ?a) ; The appliance is currently off + ) + :effect + (and + (not (appliance_off ?a)) ; The appliance is no longer off + (appliance_on ?a) ; The appliance is now on + ) + ) + + (:action turn_off_appliance + :parameters ( + ?r - robot + ?a - appliance + ) + :precondition + (and + (at ?r ?a) ; The robot is at the location of the appliance + (appliance_on ?a) ; The appliance is currently on + ) + :effect + (and + (not (appliance_on ?a)) ; The appliance is no longer on + (appliance_off ?a) ; The appliance is now off + ) + ) + + (:action check_state + :parameters ( + ?r - robot + ?loc - object + ) + :precondition + (and + (at ?r ?loc) ; The robot is at the location of the object + (or (is_furniture ?loc) (is_appliance ?loc)) ; The object is either furniture or an appliance + ) + :effect + (and + ; No effects as checking state is a non-modifying action + ) + ) +) + +PDDL PROBLEM: +(define + (problem household_problem) + (:domain household) + + (:objects + robot1 - robot + cabinet_1 - furniture + cabinet_2 - furniture + drawer_1 - furniture + drawer_2 - furniture + countertop_1 - flat_surface + dining_table_1 - flat_surface + side_table_1 - flat_surface + fridge_1 - appliance + blender_1 - appliance + lamp_1 - appliance + humidifier_1 - appliance + cup_1 - small_item + plate_1 - small_item + cutting_board_1 - small_item + apple_1 - small_item + book_1 - small_item + book_2 - small_item + mug_1 - small_item + ) + + (:init + (at robot1 cabinet_1) + (holding robot1 mug_1) + (drawer_open drawer_1) + (drawer_open drawer_2) + (appliance_open fridge_1) + (drawer_closed cabinet_1) + (drawer_open cabinet_2) + (on cup_1 cabinet_2) + (on plate_1 drawer_2) + (on cutting_board_1 countertop_1) + (on blender_1 dining_table_1) + (appliance_off blender_1) + (on lamp_1 side_table_1) + (appliance_off lamp_1) + (on humidifier_1 side_table_1) + (appliance_on humidifier_1) + (on apple_1 cabinet_2) + (on book_1 dining_table_1) + (on book_2 dining_table_1) + ) + + (:goal + (and + (appliance_on lamp_1) + (appliance_off humidifier_1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/household/task1/plan.txt b/paper_reconstructions/nl2plan/results/household/task1/plan.txt new file mode 100644 index 0000000..a7ffa51 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/household/task1/plan.txt @@ -0,0 +1 @@ +Search phase was incomplete and did not solve the problem. \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/household/task1/problem.pddl b/paper_reconstructions/nl2plan/results/household/task1/problem.pddl new file mode 100644 index 0000000..1256c05 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/household/task1/problem.pddl @@ -0,0 +1,56 @@ +(define + (problem household_problem) + (:domain household) + + (:objects + robot1 - robot + cabinet_1 - furniture + cabinet_2 - furniture + drawer_1 - furniture + drawer_2 - furniture + countertop_1 - flat_surface + dining_table_1 - flat_surface + side_table_1 - flat_surface + fridge_1 - appliance + blender_1 - appliance + lamp_1 - appliance + humidifier_1 - appliance + cup_1 - small_item + plate_1 - small_item + cutting_board_1 - small_item + apple_1 - small_item + book_1 - small_item + book_2 - small_item + mug_1 - small_item + ) + + (:init + (at robot1 cabinet_1) + (holding robot1 mug_1) + (drawer_open drawer_1) + (drawer_open drawer_2) + (appliance_open fridge_1) + (drawer_closed cabinet_1) + (drawer_open cabinet_2) + (on cup_1 cabinet_2) + (on plate_1 drawer_2) + (on cutting_board_1 countertop_1) + (on blender_1 dining_table_1) + (appliance_off blender_1) + (on lamp_1 side_table_1) + (appliance_off lamp_1) + (on humidifier_1 side_table_1) + (appliance_on humidifier_1) + (on apple_1 cabinet_2) + (on book_1 dining_table_1) + (on book_2 dining_table_1) + ) + + (:goal + (and + (appliance_on lamp_1) + (appliance_off humidifier_1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/tyreworld/task1/domain.pddl b/paper_reconstructions/nl2plan/results/tyreworld/task1/domain.pddl new file mode 100644 index 0000000..b51ac6b --- /dev/null +++ b/paper_reconstructions/nl2plan/results/tyreworld/task1/domain.pddl @@ -0,0 +1,187 @@ +(define (domain tyreworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + vehicle - object + hub - vehicle + tyre - object + flat_tyre - tyre + spare_tyre - tyre + tool - object + wrench - tool + jack - tool + pump - tool + ) + + (:predicates + (is_robot ?r - object) ; true if the object ?r is a robot + (in_boot ?t - tool ?v - vehicle) ; true if the tool ?t is in the boot of the vehicle ?v + (at_vehicle ?r - object ?v - vehicle) ; true if the robot ?r is at the vehicle ?v + (has_tool ?r - object ?t - tool) ; true if the robot ?r has the tool ?t + (accessible_hub ?h - hub) ; true if the hub ?h is accessible for the robot to work on + (nut_undone ?h - hub) ; true if the nut on the hub ?h is undone + (jacked_up ?v - vehicle) ; true if the vehicle ?v is jacked up + (stable_position ?v - vehicle) ; true if the vehicle ?v is in a stable position + (on_hub ?t - tyre ?h - hub) ; true if the tyre ?t is on the hub ?h + (available ?t - tyre) ; true if the tyre ?t is available for handling + (available_for_disposal ?t - tyre) ; true if the tyre ?t is available for disposal + (nut_done_up ?h - hub) ; true if the nut on the hub ?h is done up + (inflated ?t - spare_tyre) ; true if the spare tyre ?t is inflated + ) + + (:action fetch_tool + :parameters ( + ?r - object + ?t - tool + ?v - vehicle + ) + :precondition + (and + (is_robot ?r) ; The object ?r is a robot + (at_vehicle ?r ?v) ; The robot is at the vehicle + (in_boot ?t ?v) ; The tool is in the boot of the vehicle + ) + :effect + (and + (not (in_boot ?t ?v)) ; The tool is no longer in the boot + (has_tool ?r ?t) ; The robot now has the tool + ) + ) + + (:action undo_nut + :parameters ( + ?r - object + ?w - wrench + ?h - hub + ) + :precondition + (and + (is_robot ?r) ; The object is a robot + (has_tool ?r ?w) ; The robot has the wrench + (accessible_hub ?h) ; The hub is accessible + ) + :effect + (and + (nut_undone ?h) ; The nut on the hub is now undone + ) + ) + + (:action jack_up_vehicle + :parameters ( + ?r - object + ?j - jack + ?v - vehicle + ) + :precondition + (and + (has_tool ?r ?j) ; The robot has the jack + (at_vehicle ?r ?v) ; The robot is at the vehicle + (stable_position ?v) ; The vehicle is in a stable position + ) + :effect + (and + (not (stable_position ?v)) ; The vehicle is no longer in a stable position + (jacked_up ?v) ; The vehicle is now jacked up + ) + ) + + (:action remove_flat_tyre + :parameters ( + ?r - object + ?h - hub + ?ft - flat_tyre + ?v - vehicle + ) + :precondition + (and + (nut_undone ?h) ; The nut on the hub is undone + (jacked_up ?v) ; The vehicle is jacked up + (accessible_hub ?h) ; The hub is accessible + (at_vehicle ?r ?v) ; The robot is at the vehicle + ) + :effect + (and + (not (on_hub ?ft ?h)) ; The flat tyre is no longer on the hub + (available_for_disposal ?ft) ; The flat tyre is available for disposal + ) + ) + + (:action install_spare_tyre + :parameters ( + ?r - object + ?s - spare_tyre + ?h - hub + ?f - flat_tyre + ) + :precondition + (and + (not (on_hub ?f ?h)) ; The flat tyre is not on the hub + (available ?s) ; The spare tyre is available for installation + ) + :effect + (and + (on_hub ?s ?h) ; The spare tyre is now on the hub + (not (available ?s)) ; The spare tyre is no longer available for handling + ) + ) + + (:action do_up_nut + :parameters ( + ?r - object + ?w - wrench + ?h - hub + ?s - spare_tyre + ?v - vehicle + ) + :precondition + (and + (is_robot ?r) ; The object is a robot + (has_tool ?r ?w) ; The robot has the wrench + (on_hub ?s ?h) ; The spare tyre is installed on the hub + (accessible_hub ?h) ; The hub is accessible + (stable_position ?v) ; The vehicle is in a stable position + ) + :effect + (and + (not (nut_undone ?h)) ; The nut is no longer undone + (nut_done_up ?h) ; The nut is done up on the hub + ) + ) + + (:action lower_vehicle + :parameters ( + ?r - object + ?j - jack + ?v - vehicle + ) + :precondition + (and + (jacked_up ?v) ; The vehicle is currently jacked up + (has_tool ?r ?j) ; The robot has the jack in its possession + ) + :effect + (and + (not (jacked_up ?v)) ; The vehicle is no longer jacked up + (stable_position ?v) ; The vehicle is now in a stable position + ) + ) + + (:action inflate_tyre + :parameters ( + ?r - object + ?p - pump + ?t - spare_tyre + ?h - hub + ) + :precondition + (and + (has_tool ?r ?p) ; The robot has the pump + (on_hub ?t ?h) ; The spare tyre is installed on the hub + ) + :effect + (and + (inflated ?t) ; The spare tyre is now inflated + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/tyreworld/task1/log.txt b/paper_reconstructions/nl2plan/results/tyreworld/task1/log.txt new file mode 100644 index 0000000..3a45d7e --- /dev/null +++ b/paper_reconstructions/nl2plan/results/tyreworld/task1/log.txt @@ -0,0 +1,306 @@ +STEP ONE: TYPE EXTRACTION + +{'vehicle': 'The object on which the tyre replacement is being performed. It has hubs and tyres.', 'hub': 'Part of the vehicle where the tyre is mounted. Each hub has one nut.', 'tyre': 'A meta-type for flat and spare tyres.', 'flat_tyre': 'The tyre that is currently flat and needs to be removed.', 'spare_tyre': 'The replacement tyre that will be installed.', 'tool': 'A meta-type for tools used to perform the tyre replacement.', 'wrench': 'A tool used to undo and do up the nuts on the hub.', 'jack': 'A tool used to lift the vehicle to remove and replace the tyre.', 'pump': 'A tool used to inflate the spare tyre if necessary.'} + +-------------------- +STEP TWO: HIERARCHY CONSTRUCTION + +{'object': 'Object is always root, everything is an object', 'children': [{'vehicle': 'The object on which the tyre replacement is being performed.', 'children': [{'hub': 'Part of the vehicle where the tyre is mounted.', 'children': []}]}, {'tyre': 'A meta-type for tyres.', 'children': [{'flat_tyre': 'The tyre that is currently flat and needs to be removed.', 'children': []}, {'spare_tyre': 'The replacement tyre that will be installed.', 'children': []}]}, {'tool': 'A meta-type for tools used to perform the tyre replacement.', 'children': [{'wrench': 'A tool used to undo and do up the nuts on the hub.', 'children': []}, {'jack': 'A tool used to lift the vehicle to remove and replace the tyre.', 'children': []}, {'pump': 'A tool used to inflate the spare tyre if necessary.', 'children': []}]}]} + +-------------------- +STEP THREE: ACTION EXTRACTION + +{'fetch_tool': 'The robot fetches a tool from the boot of the vehicle. Example: The robot fetches the wrench from the boot.', 'undo_nut': 'The robot uses the wrench to undo the nut on the hub. Requires the wrench to be in possession of the robot and the hub to be accessible. Example: The robot undoes the nut on hub_1.', 'jack_up_vehicle': 'The robot uses the jack to lift the vehicle. Requires the jack to be in possession of the robot and the vehicle to be in a stable position. Example: The robot jacks up the vehicle.', 'remove_flat_tyre': 'The robot removes the flat tyre from the hub. Requires the nut to be undone and the vehicle to be jacked up. Example: The robot removes the flat tyre from hub_1.', 'install_spare_tyre': 'The robot installs the spare tyre onto the hub. Requires the flat tyre to be removed and the spare tyre to be available. Example: The robot installs the spare tyre on hub_1.', 'do_up_nut': 'The robot uses the wrench to do up the nut on the hub. Requires the spare tyre to be installed and the wrench to be in possession of the robot. Example: The robot does up the nut on hub_1.', 'lower_vehicle': 'The robot uses the jack to lower the vehicle back to the ground. Requires the vehicle to be jacked up. Example: The robot lowers the vehicle.', 'inflate_tyre': 'The robot uses the pump to inflate the spare tyre if necessary. Requires the pump to be in possession of the robot and the spare tyre to be installed. Example: The robot inflates the spare tyre on hub_1.'} + +-------------------- +STEP FOUR: ACTION CONSTRUCTION + +ACTIONS: +{'name': 'fetch_tool', 'params': OrderedDict([('?r', 'object'), ('?t', 'tool'), ('?v', 'vehicle')]), 'preconditions': '(and\n (is_robot ?r) ; The object ?r is a robot\n (at_vehicle ?r ?v) ; The robot is at the vehicle\n (in_boot ?t ?v) ; The tool is in the boot of the vehicle\n)', 'effects': '(and\n (not (in_boot ?t ?v)) ; The tool is no longer in the boot\n (has_tool ?r ?t) ; The robot now has the tool\n)'} +{'name': 'undo_nut', 'params': OrderedDict([('?r', 'object'), ('?w', 'wrench'), ('?h', 'hub')]), 'preconditions': '(and\n (is_robot ?r) ; The object is a robot\n (has_tool ?r ?w) ; The robot has the wrench\n (accessible_hub ?h) ; The hub is accessible\n)', 'effects': '(and\n (nut_undone ?h) ; The nut on the hub is now undone\n)'} +{'name': 'jack_up_vehicle', 'params': OrderedDict([('?r', 'object'), ('?j', 'jack'), ('?v', 'vehicle')]), 'preconditions': '(and\n (has_tool ?r ?j) ; The robot has the jack\n (at_vehicle ?r ?v) ; The robot is at the vehicle\n (stable_position ?v) ; The vehicle is in a stable position\n)', 'effects': '(and\n (not (stable_position ?v)) ; The vehicle is no longer in a stable position\n (jacked_up ?v) ; The vehicle is now jacked up\n)'} +{'name': 'remove_flat_tyre', 'params': OrderedDict([('?r', 'object'), ('?h', 'hub'), ('?ft', 'flat_tyre'), ('?v', 'vehicle')]), 'preconditions': '(and\n (nut_undone ?h) ; The nut on the hub is undone\n (jacked_up ?v) ; The vehicle is jacked up\n (accessible_hub ?h) ; The hub is accessible\n (at_vehicle ?r ?v) ; The robot is at the vehicle\n)', 'effects': '(and\n (not (on_hub ?ft ?h)) ; The flat tyre is no longer on the hub\n (available_for_disposal ?ft) ; The flat tyre is available for disposal\n)'} +{'name': 'install_spare_tyre', 'params': OrderedDict([('?r', 'object'), ('?s', 'spare_tyre'), ('?h', 'hub'), ('?f', 'flat_tyre')]), 'preconditions': '(and\n (not (on_hub ?f ?h)) ; The flat tyre is not on the hub\n (available ?s) ; The spare tyre is available for installation\n)', 'effects': '(and\n (on_hub ?s ?h) ; The spare tyre is now on the hub\n (not (available ?s)) ; The spare tyre is no longer available for handling\n)'} +{'name': 'do_up_nut', 'params': OrderedDict([('?r', 'object'), ('?w', 'wrench'), ('?h', 'hub'), ('?s', 'spare_tyre'), ('?v', 'vehicle')]), 'preconditions': '(and\n (is_robot ?r) ; The object is a robot\n (has_tool ?r ?w) ; The robot has the wrench\n (on_hub ?s ?h) ; The spare tyre is installed on the hub\n (accessible_hub ?h) ; The hub is accessible\n (stable_position ?v) ; The vehicle is in a stable position\n)', 'effects': '(and\n (not (nut_undone ?h)) ; The nut is no longer undone\n (nut_done_up ?h) ; The nut is done up on the hub\n)'} +{'name': 'lower_vehicle', 'params': OrderedDict([('?r', 'object'), ('?j', 'jack'), ('?v', 'vehicle')]), 'preconditions': '(and\n (jacked_up ?v) ; The vehicle is currently jacked up\n (has_tool ?r ?j) ; The robot has the jack in its possession\n)', 'effects': '(and\n (not (jacked_up ?v)) ; The vehicle is no longer jacked up\n (stable_position ?v) ; The vehicle is now in a stable position\n)'} +{'name': 'inflate_tyre', 'params': OrderedDict([('?r', 'object'), ('?p', 'pump'), ('?t', 'spare_tyre'), ('?h', 'hub')]), 'preconditions': '(and\n (has_tool ?r ?p) ; The robot has the pump\n (on_hub ?t ?h) ; The spare tyre is installed on the hub\n)', 'effects': '(and\n (inflated ?t) ; The spare tyre is now inflated\n)'} + +PREDICATES: +{'name': 'is_robot', 'desc': 'true if the object ?r is a robot', 'raw': '(is_robot ?r - object): true if the object ?r is a robot', 'params': OrderedDict([('?r', 'object')]), 'clean': '(is_robot ?r - object): true if the object ?r is a robot'} +{'name': 'in_boot', 'desc': 'true if the tool ?t is in the boot of the vehicle ?v', 'raw': '(in_boot ?t - tool ?v - vehicle): true if the tool ?t is in the boot of the vehicle ?v', 'params': OrderedDict([('?t', 'tool'), ('?v', 'vehicle')]), 'clean': '(in_boot ?t - tool ?v - vehicle): true if the tool ?t is in the boot of the vehicle ?v'} +{'name': 'at_vehicle', 'desc': 'true if the robot ?r is at the vehicle ?v', 'raw': '(at_vehicle ?r - object ?v - vehicle): true if the robot ?r is at the vehicle ?v', 'params': OrderedDict([('?r', 'object'), ('?v', 'vehicle')]), 'clean': '(at_vehicle ?r - object ?v - vehicle): true if the robot ?r is at the vehicle ?v'} +{'name': 'has_tool', 'desc': 'true if the robot ?r has the tool ?t', 'raw': '(has_tool ?r - object ?t - tool): true if the robot ?r has the tool ?t', 'params': OrderedDict([('?r', 'object'), ('?t', 'tool')]), 'clean': '(has_tool ?r - object ?t - tool): true if the robot ?r has the tool ?t'} +{'name': 'accessible_hub', 'desc': 'true if the hub ?h is accessible for the robot to work on', 'raw': '(accessible_hub ?h - hub): true if the hub ?h is accessible for the robot to work on', 'params': OrderedDict([('?h', 'hub')]), 'clean': '(accessible_hub ?h - hub): true if the hub ?h is accessible for the robot to work on'} +{'name': 'nut_undone', 'desc': 'true if the nut on the hub ?h is undone', 'raw': '(nut_undone ?h - hub): true if the nut on the hub ?h is undone', 'params': OrderedDict([('?h', 'hub')]), 'clean': '(nut_undone ?h - hub): true if the nut on the hub ?h is undone'} +{'name': 'jacked_up', 'desc': 'true if the vehicle ?v is jacked up', 'raw': '(jacked_up ?v - vehicle): true if the vehicle ?v is jacked up', 'params': OrderedDict([('?v', 'vehicle')]), 'clean': '(jacked_up ?v - vehicle): true if the vehicle ?v is jacked up'} +{'name': 'stable_position', 'desc': 'true if the vehicle ?v is in a stable position', 'raw': '(stable_position ?v - vehicle): true if the vehicle ?v is in a stable position', 'params': OrderedDict([('?v', 'vehicle')]), 'clean': '(stable_position ?v - vehicle): true if the vehicle ?v is in a stable position'} +{'name': 'on_hub', 'desc': 'true if the tyre ?t is on the hub ?h', 'raw': '(on_hub ?t - tyre ?h - hub): true if the tyre ?t is on the hub ?h', 'params': OrderedDict([('?t', 'tyre'), ('?h', 'hub')]), 'clean': '(on_hub ?t - tyre ?h - hub): true if the tyre ?t is on the hub ?h'} +{'name': 'available', 'desc': 'true if the tyre ?t is available for handling', 'raw': '(available ?t - tyre): true if the tyre ?t is available for handling', 'params': OrderedDict([('?t', 'tyre')]), 'clean': '(available ?t - tyre): true if the tyre ?t is available for handling'} +{'name': 'available_for_disposal', 'desc': 'true if the tyre ?t is available for disposal', 'raw': '(available_for_disposal ?t - tyre): true if the tyre ?t is available for disposal', 'params': OrderedDict([('?t', 'tyre')]), 'clean': '(available_for_disposal ?t - tyre): true if the tyre ?t is available for disposal'} +{'name': 'nut_done_up', 'desc': 'true if the nut on the hub ?h is done up', 'raw': '(nut_done_up ?h - hub): true if the nut on the hub ?h is done up', 'params': OrderedDict([('?h', 'hub')]), 'clean': '(nut_done_up ?h - hub): true if the nut on the hub ?h is done up'} +{'name': 'inflated', 'desc': 'true if the spare tyre ?t is inflated', 'raw': '(inflated ?t - spare_tyre): true if the spare tyre ?t is inflated', 'params': OrderedDict([('?t', 'spare_tyre')]), 'clean': '(inflated ?t - spare_tyre): true if the spare tyre ?t is inflated'} + +-------------------- +STEP FIVE: TASK EXTRACTION + +OBJECTS: +robot1 - object +vehicle1 - vehicle +hub1 - hub +flat_tyre1 - flat_tyre +spare_tyre1 - spare_tyre +wrench1 - wrench +jack1 - jack +pump1 - pump +INITIAL STATES: +(is_robot robot1) +(at_vehicle robot1 vehicle1) +(has_tool robot1 wrench1) +(has_tool robot1 jack1) +(has_tool robot1 pump1) +(accessible_hub hub1) +(nut_undone hub1) +(jacked_up vehicle1) +(stable_position vehicle1) +(on_hub flat_tyre1 hub1) +(available spare_tyre1) +GOAL STATES: +(AND + (available_for_disposal flat_tyre1) + (on_hub spare_tyre1 hub1) + (nut_done_up hub1) + (inflated spare_tyre1) + (stable_position vehicle1) +) + + +PDDL DOMAIN: +(define (domain tyreworld) + (:requirements + :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects) + + (:types + vehicle - object + hub - vehicle + tyre - object + flat_tyre - tyre + spare_tyre - tyre + tool - object + wrench - tool + jack - tool + pump - tool + ) + + (:predicates + (is_robot ?r - object) ; true if the object ?r is a robot + (in_boot ?t - tool ?v - vehicle) ; true if the tool ?t is in the boot of the vehicle ?v + (at_vehicle ?r - object ?v - vehicle) ; true if the robot ?r is at the vehicle ?v + (has_tool ?r - object ?t - tool) ; true if the robot ?r has the tool ?t + (accessible_hub ?h - hub) ; true if the hub ?h is accessible for the robot to work on + (nut_undone ?h - hub) ; true if the nut on the hub ?h is undone + (jacked_up ?v - vehicle) ; true if the vehicle ?v is jacked up + (stable_position ?v - vehicle) ; true if the vehicle ?v is in a stable position + (on_hub ?t - tyre ?h - hub) ; true if the tyre ?t is on the hub ?h + (available ?t - tyre) ; true if the tyre ?t is available for handling + (available_for_disposal ?t - tyre) ; true if the tyre ?t is available for disposal + (nut_done_up ?h - hub) ; true if the nut on the hub ?h is done up + (inflated ?t - spare_tyre) ; true if the spare tyre ?t is inflated + ) + + (:action fetch_tool + :parameters ( + ?r - object + ?t - tool + ?v - vehicle + ) + :precondition + (and + (is_robot ?r) ; The object ?r is a robot + (at_vehicle ?r ?v) ; The robot is at the vehicle + (in_boot ?t ?v) ; The tool is in the boot of the vehicle + ) + :effect + (and + (not (in_boot ?t ?v)) ; The tool is no longer in the boot + (has_tool ?r ?t) ; The robot now has the tool + ) + ) + + (:action undo_nut + :parameters ( + ?r - object + ?w - wrench + ?h - hub + ) + :precondition + (and + (is_robot ?r) ; The object is a robot + (has_tool ?r ?w) ; The robot has the wrench + (accessible_hub ?h) ; The hub is accessible + ) + :effect + (and + (nut_undone ?h) ; The nut on the hub is now undone + ) + ) + + (:action jack_up_vehicle + :parameters ( + ?r - object + ?j - jack + ?v - vehicle + ) + :precondition + (and + (has_tool ?r ?j) ; The robot has the jack + (at_vehicle ?r ?v) ; The robot is at the vehicle + (stable_position ?v) ; The vehicle is in a stable position + ) + :effect + (and + (not (stable_position ?v)) ; The vehicle is no longer in a stable position + (jacked_up ?v) ; The vehicle is now jacked up + ) + ) + + (:action remove_flat_tyre + :parameters ( + ?r - object + ?h - hub + ?ft - flat_tyre + ?v - vehicle + ) + :precondition + (and + (nut_undone ?h) ; The nut on the hub is undone + (jacked_up ?v) ; The vehicle is jacked up + (accessible_hub ?h) ; The hub is accessible + (at_vehicle ?r ?v) ; The robot is at the vehicle + ) + :effect + (and + (not (on_hub ?ft ?h)) ; The flat tyre is no longer on the hub + (available_for_disposal ?ft) ; The flat tyre is available for disposal + ) + ) + + (:action install_spare_tyre + :parameters ( + ?r - object + ?s - spare_tyre + ?h - hub + ?f - flat_tyre + ) + :precondition + (and + (not (on_hub ?f ?h)) ; The flat tyre is not on the hub + (available ?s) ; The spare tyre is available for installation + ) + :effect + (and + (on_hub ?s ?h) ; The spare tyre is now on the hub + (not (available ?s)) ; The spare tyre is no longer available for handling + ) + ) + + (:action do_up_nut + :parameters ( + ?r - object + ?w - wrench + ?h - hub + ?s - spare_tyre + ?v - vehicle + ) + :precondition + (and + (is_robot ?r) ; The object is a robot + (has_tool ?r ?w) ; The robot has the wrench + (on_hub ?s ?h) ; The spare tyre is installed on the hub + (accessible_hub ?h) ; The hub is accessible + (stable_position ?v) ; The vehicle is in a stable position + ) + :effect + (and + (not (nut_undone ?h)) ; The nut is no longer undone + (nut_done_up ?h) ; The nut is done up on the hub + ) + ) + + (:action lower_vehicle + :parameters ( + ?r - object + ?j - jack + ?v - vehicle + ) + :precondition + (and + (jacked_up ?v) ; The vehicle is currently jacked up + (has_tool ?r ?j) ; The robot has the jack in its possession + ) + :effect + (and + (not (jacked_up ?v)) ; The vehicle is no longer jacked up + (stable_position ?v) ; The vehicle is now in a stable position + ) + ) + + (:action inflate_tyre + :parameters ( + ?r - object + ?p - pump + ?t - spare_tyre + ?h - hub + ) + :precondition + (and + (has_tool ?r ?p) ; The robot has the pump + (on_hub ?t ?h) ; The spare tyre is installed on the hub + ) + :effect + (and + (inflated ?t) ; The spare tyre is now inflated + ) + ) +) + +PDDL PROBLEM: +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + robot1 - object + vehicle1 - vehicle + hub1 - hub + flat_tyre1 - flat_tyre + spare_tyre1 - spare_tyre + wrench1 - wrench + jack1 - jack + pump1 - pump + ) + + (:init + (is_robot robot1) + (at_vehicle robot1 vehicle1) + (has_tool robot1 wrench1) + (has_tool robot1 jack1) + (has_tool robot1 pump1) + (accessible_hub hub1) + (nut_undone hub1) + (jacked_up vehicle1) + (stable_position vehicle1) + (on_hub flat_tyre1 hub1) + (available spare_tyre1) + ) + + (:goal + (and + (available_for_disposal flat_tyre1) + (on_hub spare_tyre1 hub1) + (nut_done_up hub1) + (inflated spare_tyre1) + (stable_position vehicle1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/tyreworld/task1/plan.txt b/paper_reconstructions/nl2plan/results/tyreworld/task1/plan.txt new file mode 100644 index 0000000..6b3420f --- /dev/null +++ b/paper_reconstructions/nl2plan/results/tyreworld/task1/plan.txt @@ -0,0 +1,4 @@ +remove_flat_tyre robot1 hub1 flat_tyre1 vehicle1 (1) +install_spare_tyre flat_tyre1 spare_tyre1 hub1 flat_tyre1 (1) +do_up_nut robot1 wrench1 hub1 spare_tyre1 vehicle1 (1) +inflate_tyre robot1 pump1 spare_tyre1 hub1 (1) \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/results/tyreworld/task1/problem.pddl b/paper_reconstructions/nl2plan/results/tyreworld/task1/problem.pddl new file mode 100644 index 0000000..d28fcf2 --- /dev/null +++ b/paper_reconstructions/nl2plan/results/tyreworld/task1/problem.pddl @@ -0,0 +1,40 @@ +(define + (problem tyreworld_problem) + (:domain tyreworld) + + (:objects + robot1 - object + vehicle1 - vehicle + hub1 - hub + flat_tyre1 - flat_tyre + spare_tyre1 - spare_tyre + wrench1 - wrench + jack1 - jack + pump1 - pump + ) + + (:init + (is_robot robot1) + (at_vehicle robot1 vehicle1) + (has_tool robot1 wrench1) + (has_tool robot1 jack1) + (has_tool robot1 pump1) + (accessible_hub hub1) + (nut_undone hub1) + (jacked_up vehicle1) + (stable_position vehicle1) + (on_hub flat_tyre1 hub1) + (available spare_tyre1) + ) + + (:goal + (and + (available_for_disposal flat_tyre1) + (on_hub spare_tyre1 hub1) + (nut_done_up hub1) + (inflated spare_tyre1) + (stable_position vehicle1) + ) + ) + +) \ No newline at end of file diff --git a/paper_reconstructions/p+s/main.py b/paper_reconstructions/p+s/main.py index a4889b1..c710cb3 100644 --- a/paper_reconstructions/p+s/main.py +++ b/paper_reconstructions/p+s/main.py @@ -13,13 +13,13 @@ def run_parse_and_solve( - model: LLM, - prompt_initial: str, - prompt_goal: str, - problem_path: str, - problem_name: str, - objects: dict[str,str] - ): + model: LLM, + prompt_initial: str, + prompt_goal: str, + problem_path: str, + problem_name: str, + objects: dict[str, str], +): """ Main framework of P+S - translate initial and goal states to PDDL from NL @@ -34,138 +34,147 @@ def run_parse_and_solve( # extract initial states initial_states, _ = task_builder.extract_initial_state( - model=model, - problem_desc="", - prompt_template=prompt_initial, - objects="") - + model=model, problem_desc="", prompt_template=prompt_initial, objects="" + ) + # extract goal states goal_states, _ = task_builder.extract_goal_state( - model=model, - problem_desc="", - prompt_template=prompt_goal, - objects="") - + model=model, problem_desc="", prompt_template=prompt_goal, objects="" + ) + # convert Python components to string objects_str = task_builder.format_objects(objects) initial_state_str = task_builder.format_initial(initial_states) goal_state_str = task_builder.format_goal(goal_states) - + # insert `(noteq)` predicate manually (due to domain from paper) objects = objects_str.split("\n") - for obj1, obj2 in combinations(objects, 2): # create all combinations + for obj1, obj2 in combinations(objects, 2): # create all combinations initial_state_str += f"\n(noteq {obj1} {obj2})" - + # take components and generate PDDL task format pddl_problem = task_builder.generate_task( - "simple-blocks", - problem_name, - objects=objects_str, - initial=initial_state_str, - goal=goal_state_str) - + "simple-blocks", + problem_name, + objects=objects_str, + initial=initial_state_str, + goal=goal_state_str, + ) + # write the problem file to respective directory problem_file = problem_path + f"/{problem_name}.pddl" with open(problem_file, "w") as f: f.write(pddl_problem) - + return problem_file def run_problem_01(init_examples, goal_examples): # PROBLEM 1 problem_path = "paper_reconstructions/p+s/results/problem_01" - objects_01 = {'sketchbook':'', 'sweatshirt':'', 'keyboard':'', 'novel':''} - + objects_01 = {"sketchbook": "", "sweatshirt": "", "keyboard": "", "novel": ""} + # assemble prompt template for initial and goal state extraction prompt_initial_01 = PromptBuilder( - role=ROLE_INITIAL, - examples=init_examples, - task=load_file("paper_reconstructions/p+s/problems/initial/000.txt")) - + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/000.txt"), + ) + prompt_goal_01 = PromptBuilder( - role=ROLE_GOAL, - examples=goal_examples, - task=load_file("paper_reconstructions/p+s/problems/goal/000.txt")) - + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/000.txt"), + ) + # run framework problem_file = run_parse_and_solve( - model=openai_llm, + model=openai_llm, prompt_initial=prompt_initial_01.generate_prompt(), prompt_goal=prompt_goal_01.generate_prompt(), problem_path=problem_path, problem_name="problem-01", - objects=objects_01) - + objects=objects_01, + ) + # run FastDownward planner _, result = planner.run_fast_downward( - domain_file="paper_reconstructions/p+s/results/domain.pddl", - problem_file=problem_file) - + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file, + ) + # write result of plan with open(problem_path + "/plan.txt", "w") as f: f.write(result) - - + + def run_problem_02(init_examples, goal_examples): # PROBLEM 2 problem_path = "paper_reconstructions/p+s/results/problem_02" - objects_02 = {'newspaper':'', 'accordion':'', 'saucepan':'', 'peacoat':''} + objects_02 = {"newspaper": "", "accordion": "", "saucepan": "", "peacoat": ""} prompt_initial_02 = PromptBuilder( - role=ROLE_INITIAL, - examples=init_examples, - task=load_file("paper_reconstructions/p+s/problems/initial/001.txt")) - + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/001.txt"), + ) + prompt_goal_02 = PromptBuilder( - role=ROLE_GOAL, - examples=goal_examples, - task=load_file("paper_reconstructions/p+s/problems/goal/001.txt")) - + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/001.txt"), + ) + problem_file = run_parse_and_solve( - model=openai_llm, + model=openai_llm, prompt_initial=prompt_initial_02.generate_prompt(), prompt_goal=prompt_goal_02.generate_prompt(), problem_path=problem_path, problem_name="problem-02", - objects=objects_02) - + objects=objects_02, + ) + _, result = planner.run_fast_downward( - domain_file="paper_reconstructions/p+s/results/domain.pddl", - problem_file=problem_file) - + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file, + ) + with open(problem_path + "/plan.txt", "w") as f: f.write(result) - - + + def run_problem_03(init_examples, goal_examples): # PROBLEM 3 problem_path = "paper_reconstructions/p+s/results/problem_03" - objects_03 = {'mouse-pad':'', 'hacksaw':'', 'saucepan':'', 'raincoat':''} - + objects_03 = {"mouse-pad": "", "hacksaw": "", "saucepan": "", "raincoat": ""} + # assemble prompt template for initial and goal state extraction prompt_initial_03 = PromptBuilder( - role=ROLE_INITIAL, - examples=init_examples, - task=load_file("paper_reconstructions/p+s/problems/initial/002.txt")) - + role=ROLE_INITIAL, + examples=init_examples, + task=load_file("paper_reconstructions/p+s/problems/initial/002.txt"), + ) + prompt_goal_03 = PromptBuilder( - role=ROLE_GOAL, - examples=goal_examples, - task=load_file("paper_reconstructions/p+s/problems/goal/002.txt")) - + role=ROLE_GOAL, + examples=goal_examples, + task=load_file("paper_reconstructions/p+s/problems/goal/002.txt"), + ) + problem_file = run_parse_and_solve( - model=openai_llm, + model=openai_llm, prompt_initial=prompt_initial_03.generate_prompt(), prompt_goal=prompt_goal_03.generate_prompt(), problem_path=problem_path, problem_name="problem-03", - objects=objects_03) - + objects=objects_03, + ) + _, result = planner.run_fast_downward( - domain_file="paper_reconstructions/p+s/results/domain.pddl", - problem_file=problem_file) - + domain_file="paper_reconstructions/p+s/results/domain.pddl", + problem_file=problem_file, + ) + with open(problem_path + "/plan.txt", "w") as f: f.write(result) @@ -177,7 +186,7 @@ def run_problem_03(init_examples, goal_examples): api_key = os.environ.get("OPENAI_API_KEY") openai_llm = OPENAI(model=engine, api_key=api_key) planner = FastDownward(planner_path="downward/fast-downward.py") - + # load in few shot examples folder_path = "paper_reconstructions/p+s/prompts/examples/initial" init_examples = [] @@ -187,7 +196,7 @@ def run_problem_03(init_examples, goal_examples): file_path = os.path.join(folder_path, filename) file_content = load_file(file_path) init_examples.append(file_content) - + folder_path = "paper_reconstructions/p+s/prompts/examples/goal" goal_examples = [] @@ -196,15 +205,14 @@ def run_problem_03(init_examples, goal_examples): file_path = os.path.join(folder_path, filename) file_content = load_file(file_path) goal_examples.append(file_content) - + # load in base templates ROLE = "Your task is to convert the natural language states into PDDL initial state predicates.\n\n" ROLE_INITIAL = ROLE + load_file("templates/task_templates/extract_initial.txt") ROLE_GOAL = ROLE + load_file("templates/task_templates/extract_goal.txt") DOMAIN_DIR = "paper_reconstructions/p+s/domain.pddl" - + # run problem sets run_problem_01(init_examples, goal_examples) run_problem_02(init_examples, goal_examples) run_problem_03(init_examples, goal_examples) - \ No newline at end of file diff --git a/tests/test_domain_builder.py b/tests/test_domain_builder.py index e761dd5..04f6cc5 100644 --- a/tests/test_domain_builder.py +++ b/tests/test_domain_builder.py @@ -9,9 +9,27 @@ def setUp(self): self.domain_builder = DomainBuilder() def test_extract_type(self): - mock_llm_1 = MockLLM([load_file("tests/test_prompts/test_domain_builder/test_extract_type/01.txt")]) - mock_llm_2 = MockLLM([load_file("tests/test_prompts/test_domain_builder/test_extract_type/02.txt")]) - mock_llm_3 = MockLLM([load_file("tests/test_prompts/test_domain_builder/test_extract_type/03.txt")]) + mock_llm_1 = MockLLM( + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type/01.txt" + ) + ] + ) + mock_llm_2 = MockLLM( + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type/02.txt" + ) + ] + ) + mock_llm_3 = MockLLM( + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type/03.txt" + ) + ] + ) types, _ = self.domain_builder.extract_type( model=mock_llm_1, @@ -48,15 +66,27 @@ def test_extract_type(self): self.assertIn("Max retries exceeded", str(context.exception)) def test_extract_type_hierarchy(self): - + mock_llm_1 = MockLLM( - [load_file("tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/01.txt")] + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/01.txt" + ) + ] ) mock_llm_2 = MockLLM( - [load_file("tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/02.txt")] + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/02.txt" + ) + ] ) mock_llm_3 = MockLLM( - [load_file("tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/03.txt")] + [ + load_file( + "tests/test_prompts/test_domain_builder/test_extract_type_hierarchy/03.txt" + ) + ] ) expected_hierarchy = { @@ -132,7 +162,7 @@ def test_extract_predicates(self): pass def test_generate_domain(self): - + domain = "test_domain" types = "robot location" predicates = "(at ?r - robot ?l - location)\n(connected ?l1 ?l2 - location)" @@ -151,8 +181,9 @@ def test_generate_domain(self): }, ] requirements = [":strips", ":typing"] - - expected_output = textwrap.dedent("""\ + + expected_output = textwrap.dedent( + """\ (define (domain test_domain) (:requirements :strips :typing) @@ -189,13 +220,19 @@ def test_generate_domain(self): (holding ?r) ) ) - """).strip() + """ + ).strip() + + result = self.domain_builder.generate_domain( + domain=domain, + types=types, + predicates=predicates, + actions=actions, + requirements=requirements, + ) - result = self.domain_builder.generate_domain(domain=domain, types=types, predicates=predicates, actions=actions, requirements=requirements) - self.assertEqual(result.strip(), expected_output.strip()) if __name__ == "__main__": unittest.main() - From 15a1fc460faa76f00a341bf2b9ff7e437a9531d3 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Thu, 9 Jan 2025 12:04:47 -0500 Subject: [PATCH 12/15] completed LLM+DM --- .../llm+dm/construct_action_models.py | 3 - .../llm+dm/correct_action_models.py | 0 .../llm+dm/domains/error_prompt.txt | 15 + .../domains/household/action_model.json | 159 +++ .../llm+dm/domains/household/domain_desc.txt | 1 + .../household/hierarchy_requirements.json | 17 + .../logistics}/action_model.json | 12 +- .../logistics}/domain_desc.txt | 0 .../logistics/hierarchy_requirements.json | 19 + .../{prompts => domains}/pddl_prompt.txt | 31 +- .../domains/tyreworld/action_model.json | 66 + .../llm+dm/domains/tyreworld/domain_desc.txt | 1 + .../tyreworld/hierarchy_requirements.json | 24 + paper_reconstructions/llm+dm/main.py | 417 +++--- .../prompts/hierarchy_requirements.json | 18 - .../llm+dm/results/domain.pddl | 142 --- .../llm+dm/results/household/domain.pddl | 494 ++++++++ .../results/household/gpt-4o-mini_0_0.txt | 1117 +++++++++++++++++ .../results/household/gpt-4o-mini_0_1.txt | 1067 ++++++++++++++++ .../llm+dm/results/logistics/domain.pddl | 137 ++ .../results/logistics/gpt-4o-mini_0_0.txt | 276 ++++ .../results/logistics/gpt-4o-mini_0_1.txt | 274 ++++ .../llm+dm/results/tyreworld/domain.pddl | 253 ++++ .../results/tyreworld/gpt-4o-mini_0_0.txt | 522 ++++++++ .../results/tyreworld/gpt-4o-mini_0_1.txt | 533 ++++++++ paper_reconstructions/nl2plan/main.py | 2 +- .../nl2plan/nl2plan/action_construction.py | 2 +- .../prompts/action_construction/error.txt | 2 +- 28 files changed, 5246 insertions(+), 358 deletions(-) delete mode 100644 paper_reconstructions/llm+dm/construct_action_models.py delete mode 100644 paper_reconstructions/llm+dm/correct_action_models.py create mode 100644 paper_reconstructions/llm+dm/domains/error_prompt.txt create mode 100644 paper_reconstructions/llm+dm/domains/household/action_model.json create mode 100644 paper_reconstructions/llm+dm/domains/household/domain_desc.txt create mode 100644 paper_reconstructions/llm+dm/domains/household/hierarchy_requirements.json rename paper_reconstructions/llm+dm/{prompts => domains/logistics}/action_model.json (80%) rename paper_reconstructions/llm+dm/{prompts => domains/logistics}/domain_desc.txt (100%) create mode 100644 paper_reconstructions/llm+dm/domains/logistics/hierarchy_requirements.json rename paper_reconstructions/llm+dm/{prompts => domains}/pddl_prompt.txt (84%) create mode 100644 paper_reconstructions/llm+dm/domains/tyreworld/action_model.json create mode 100644 paper_reconstructions/llm+dm/domains/tyreworld/domain_desc.txt create mode 100644 paper_reconstructions/llm+dm/domains/tyreworld/hierarchy_requirements.json delete mode 100644 paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json delete mode 100644 paper_reconstructions/llm+dm/results/domain.pddl create mode 100644 paper_reconstructions/llm+dm/results/household/domain.pddl create mode 100644 paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_0.txt create mode 100644 paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_1.txt create mode 100644 paper_reconstructions/llm+dm/results/logistics/domain.pddl create mode 100644 paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_0.txt create mode 100644 paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_1.txt create mode 100644 paper_reconstructions/llm+dm/results/tyreworld/domain.pddl create mode 100644 paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_0.txt create mode 100644 paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_1.txt diff --git a/paper_reconstructions/llm+dm/construct_action_models.py b/paper_reconstructions/llm+dm/construct_action_models.py deleted file mode 100644 index 8062daa..0000000 --- a/paper_reconstructions/llm+dm/construct_action_models.py +++ /dev/null @@ -1,3 +0,0 @@ -""" - -""" diff --git a/paper_reconstructions/llm+dm/correct_action_models.py b/paper_reconstructions/llm+dm/correct_action_models.py deleted file mode 100644 index e69de29..0000000 diff --git a/paper_reconstructions/llm+dm/domains/error_prompt.txt b/paper_reconstructions/llm+dm/domains/error_prompt.txt new file mode 100644 index 0000000..8a0e946 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/error_prompt.txt @@ -0,0 +1,15 @@ +## Error +There was an issue with or feedback for generating the specified action. Correct the following error and regenerate the action, using the exact same headers. Remember that you MUST reuse all the headers ("### Action Parameters", "### Action Preconditions", "### Action Effects" and "### New Predicates") + +{error_msg} + +Make sure to reply with all four parts of the action: parameters, preconditions, effects and new predicates. Also, start your response with a "### Response" header to give your thoughts about this error message. + +## Action +{action_name} + +### Available Predicates +{predicates} + +### Original Response +{llm_response} \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/household/action_model.json b/paper_reconstructions/llm+dm/domains/household/action_model.json new file mode 100644 index 0000000..86d0522 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/household/action_model.json @@ -0,0 +1,159 @@ +{ + "Go to a Furniture Piece or an Appliance": { + "desc": "This action enables the robot to navigate from one normally immovable piece of furniture to another (e.g., dining tables, side tables, cabinets, and sinks) or an appliance (e.g., refrigerators, coffee makers, microwaves, and washers).", + "extra_info": [] + }, + "Pick up an Object on or in a Furniture Piece or an Appliance": { + "desc": "This action enables the robot to pick up an object object_1 in/on a large piece of furniture (e.g., dining tables, drawers, cabinets) or an appliance (e.g., dishwashers and refrigerators). For example, the robot pick up coffee_mug_1 on dining_table_1, the robot pick up fork_1 in drawer_1, or the robot pick up apple_1 in refrigerator_1.", + "extra_info": [ + "This action is only applicable for objects that are pickupable by the robot.", + "The furniture piece or appliance should be opened if it is openable.", + "The object to pick up should not be stacked on top of other household items." + ] + }, + "Put an Object on or in a Furniture Piece or an Appliance": { + "desc": "This action enables the robot to put an object object_1 in/on a large piece of furniture (e.g., dining tables, drawers, cabinets) or an appliance (e.g., dishwashers and refrigerators). For example, the robot puts coffee_mug_1 on dining_table_1, the robot puts fork_1 in drawer_1, or the robot puts apple_1 in refrigerator_1.", + "extra_info": [ + "The furniture piece or appliance should be opened if it is openable." + ] + }, + "Stack Objects": { + "desc": "This action enables the robot to stack one object object_1 on top of another object object_2 that is on the same piece of furniture. For example, the robot stacks book_1 on top of book_2, or the robot stacks lunch_box_1 on top of lunch_box_2.", + "extra_info": [ + "The furniture piece has to have an open and flat surface.", + "Note that object_1 and object_2 both must be stackable objects.", + "You may assume the robot is holding object_1 at the beginning.", + "Also, there should be no other object on top of object_2." + ] + }, + "Unstack Objects": { + "desc": "This action enables the robot to unstack one object object_1 that is on top of another object object_2. For example, the robot stacks book_1 on top of book_2, or the robot stacks lunch_box_1 on top of lunch_box_2. The robot will hold the object after unstacking it.", + "extra_info": [] + }, + "Open a Furniture Piece or an Appliance": { + "desc": "This action enables the robot to open a large piece of furniture (e.g., cabinets and drawers) or an appliance (e.g., dishwashers and refrigerators) that is openable. For example, the robot opens cabinet_1, or the robot opens drawer_2.", + "extra_info": [] + }, + "Close a Furniture Piece or an Appliance": { + "desc": "This action enables the robot to close a large piece of furniture (e.g., cabinets and drawers) or an appliance (e.g., dishwashers and refrigerators) that is openable. For example, the robot closes cabinet_1, or the robot closes drawer_2.", + "extra_info": [] + }, + "Toggle a Small Appliance On": { + "desc": "This action enables the robot to toggle a small appliances (like humidifiers and light bulbs) to switch them on. For example, the robot toggles humidifier_2 on, or the robot toggle light_bulb_1 on.", + "extra_info": [] + }, + "Toggle a Small Appliance Off": { + "desc": "This action enables the robot to toggle a small appliances (like humidifiers and light bulbs) to switch them off. For example, the robot toggles humidifier_2 off, or the robot toggle light_bulb_1 off.", + "extra_info": [] + }, + "Slice Objects": { + "desc": "This action enables the robot to slice objects (like fruits and vegetables) with a knife. For example, the robot slices orange_1 with knife_2, the robot slices potato_3 with knife_1.", + "extra_info": [ + "Note that the object to slice needs to be placed on a cutting board. A cutting board can be viewed as a special kind of receptacle.", + "You may assume the robot is holding the knife in its gripper at the beginning.", + "The object to slice should be sliceable.", + "The furniture piece needs to have an open and flat surface to allow enough space for manipulation (e.g., countertops or tables)." + ] + }, + "Heat Food with a Microwave": { + "desc": "This action enables the robot to start a microwave and heat up the food inside. For example, the robot heats pizza_1 with microwave_2, the robot heats pasta_2 with microwave_1.", + "extra_info": [ + "The food to heat should be placed in a small receptacle (e.g., a plate or a bowl).", + "The robot also needs to close the door of the microwave before taking this action.", + "Note that the food is no longer pickupable after it has been heated." + ] + }, + "Heat Food with Pan": { + "desc": "This action enables the robot to heat food which is heatable with a pan. For example, the robot heats pizza_1 with pan_2, the robot heats pasta_2 with pan_1.", + "extra_info": [ + "Note that the food should be placed on the pan, and the pan needs to be placed on a stove burner before executing this action.", + "A stove burner can be viewed as an immovable appliance, and a pan can be viewed as a small receptacle.", + "Note that the food is no longer pickupable after it has been heated." + ] + }, + "Transfer Food from One Small Receptacle to Another": { + "desc": "This action enables the robot to transfer food food_1 from one small receptacle receptacle_1 to another small receptacle receptacle_2. This skill is usually used to transfer food that can not be easily picked up by the robot. For example, the robot can pour the milk from milk_box_1 to mug_1, or the robot can transfer heated pizza_1 from pan_2 to plate_1.", + "extra_info": [ + "The furniture piece needs to have an open and flat surface to allow enough space for manipulation (e.g., countertops or tables).", + "Both receptacles should be opened if it is openable.", + "Both receptacles should not be stacked on top of other objects if they are stackable." + ] + }, + "Puts an Object onto or into a Small Receptacle": { + "desc": "This action enables the robot to put an object object_1 into/onto a small receptacle receptacle_1 (e.g. storage boxes, bowls, plates, or pans). For example, the robot puts apple_1 into blow_1, or the robot puts apple_2 into lunch_box_2.", + "extra_info": [ + "The furniture piece needs to have an open and flat surface to allow enough space for manipulation (e.g., countertops or tables).", + "The receptacle should be opened if it is openable.", + "The receptacle should not be stacked on top of other objects if it is stackable." + ], + "short": "put an object ?x into/onto a small receptacle ?z at furniture piece ?y", + "prompt_example": "put apple_1 in/on plate_1 at dining_table_1", + "parameters": {}, + "preconditions": [], + "effects": [] + }, + "Pick up an Object on or in a Small Receptacle": { + "desc": "This action enables the robot to pick up an object object_1 in some small receptacle receptacle_1 (e.g. storage boxes, lunch boxes, bowls, plates). For example, the robot picks up apple_1 in blow_1, or the robot picks up apple_2 in lunch_box_2.", + "extra_info": [ + "The furniture piece needs to have an open and flat surface to allow enough space for manipulation (e.g., countertops or tables).", + "The receptacle should be opened if it is openable.", + "The receptacle should not be stacked on top of other objects if it is stackable." + ] + }, + "Open a Small Receptacle": { + "desc": "This action enables the robot to open a small receptacle receptacle_1 (e.g. small storage boxes or lunch boxes with lids). For example, the robot opens lunch_box_2, or the robot opens storage_box_1.", + "extra_info": [ + "This action is only applicable for receptacles that are openable.", + "The receptacle needs to be placed on a furniture piece that has an open and flat surface to allow enough space for manipulation (e.g., countertops or tables).", + "The receptacle should not be stacked on top of other objects if it is stackable." + ] + }, + "Close a Small Receptacle": { + "desc": "This action enables the robot to close a small receptacle receptacle_1 that is openable (e.g. small storage boxes or lunch boxes with lids). For example, the robot closes lunch_box_2, or the robot closes storage_box_1.", + "extra_info": [ + "This action is only applicable for receptacles that are openable.", + "The receptacle needs to be placed on a furniture piece that has an open and flat surface to allow enough space for manipulation (e.g., countertops or tables).", + "The receptacle should not be stacked on top of other objects if it is stackable." + ] + }, + "Mash Food with a Blender": { + "desc": "This action enables the robot to use a blender to mash some food in it. For example, the robot gets mashed apple_2 with blender_1, or the robot gets mashed banana_1 with blender_2. A blender can be viewed as a small receptacle.", + "extra_info": [ + "The food needs to be sliced beforehand and the food should be placed inside the blender.", + "Note that the food remains in the blender after this action is performed.", + "You may also assume the blender is turned off before and after mashing the food." + ] + }, + "Wash an Object": { + "desc": "This action enables the robot to wash an object (e.g., fruits and cloths) in a sink or basin. For example, the robot washed apple_1, or the robot washed romaine_lettuce_1.", + "extra_info": [ + "The object has to be something washable.", + "The robot should hold the object when washing it." + ] + }, + "Wipe a Surface": { + "desc": "This action enables the robot to wipe and clean the surface of a piece of furniture or an appliance, such as a dining table, a mirror, a sink, or a bathtub, with a cloth. For example, the robot wipes dining_table_1 with cloth_1, the robot wipes mirror_1 with cloth_2.", + "extra_info": [ + "You may assume the robot is holding the cloth before executing this action.", + "The cloth will be dirty after executing the action.", + "The robot should also use a clean cloth." + ] + }, + "Vacuum a Carpet": { + "desc": "This action enables the robot to vacuum a carpet with a handheld vacuum cleaner. For example, the robot uses vacuum_cleaner_1 to vacuum carpet_2, the robot uses vacuum_cleaner_2 to vacuum carpet_1. A vacuum can be viewed as a small household item and a carpet can be viewed as an immovable piece of furniture.", + "extra_info": [ + "You need to make sure the dust bin of the vacuum cleaner is not full before executing this action.", + "You may assume the robot is holding the vacuum cleaner at the beginning.", + "The dust bin of the vacuum cleaner will be full of dust if the carpet is not clean." + ] + }, + "Empty a Vacuum Cleaner": { + "desc": "This action enables the robot to empty a vacuum cleaner\u2019s dust bin by standing next to a trash can and dumping the dust into it. For example, the robot empties vacuum_cleaner_1 and dumps the dust into trash_can_2, or the robot empties vacuum_cleaner_2 and dumps the dust into trash_can 1. A trash can can be viewed as an immovable piece of furniture.", + "extra_info": [ + "Note that the robot should hold the vacuum cleaner and stand by the trash can before executing this action.", + "After executing this action, the robot is still holding the vacuum cleaner.", + "The trash can should be opened if it's openable.", + "The dust bin will be empty after executing this action." + ] + } + } \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/household/domain_desc.txt b/paper_reconstructions/llm+dm/domains/household/domain_desc.txt new file mode 100644 index 0000000..99c15ee --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/household/domain_desc.txt @@ -0,0 +1 @@ +The AI agent here is a household robot that can navigate to various large and normally immovable furniture pieces or appliances in the house to carry out household tasks. Note that the robot has only one gripper, so (a) it can only hold one object; (b) it shouldn't hold any other irrelevant objects in its gripper while performing some manipulation tasks (e.g., opening a drawer or closing a window); (c) operations on small household items should be carried out on furniture with a flat surface to get enough space for manipulation. There are three major types of objects in this domain: robot, furnitureAppliance, and householdObject. The object type furnitureAppliance covers large and normally immovable furniture pieces or appliances, such as stove burners, side tables, dining tables, drawer, cabinets, or microwaves. The object type householdObject covers all other small household items, such as handheld vacuum cleaners, cloth, apples, bananas, and small receptacles like bowls and lunch boxes. There is a subtype of householdObject called smallReceptacle that covers small receptacles like bowls, lunch boxes, plates etc. In this domain, the locations of the robot and small household items (e.g., apples, oranges, bowls, lunch boxes or lamps) are determined by large and normally immovable furniture pieces or appliances. \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/household/hierarchy_requirements.json b/paper_reconstructions/llm+dm/domains/household/hierarchy_requirements.json new file mode 100644 index 0000000..cbca059 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/household/hierarchy_requirements.json @@ -0,0 +1,17 @@ +{ + "hierarchy": { + "object": "", + "children": [ + {"furnitureAppliance": "", "children":[]}, + { + "householdObject": "", + "children": [ + {"smallReceptacle": "", "children":[]} + ] + } + ] + }, + "requirements": [ + "typing", "negative-preconditions", "disjunctive-preconditions", "conditional-effects", "equality" + ] +} \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/prompts/action_model.json b/paper_reconstructions/llm+dm/domains/logistics/action_model.json similarity index 80% rename from paper_reconstructions/llm+dm/prompts/action_model.json rename to paper_reconstructions/llm+dm/domains/logistics/action_model.json index 3122a1d..5a0da35 100644 --- a/paper_reconstructions/llm+dm/prompts/action_model.json +++ b/paper_reconstructions/llm+dm/domains/logistics/action_model.json @@ -1,29 +1,29 @@ { - "load_truck": { + "Load a package into a truck": { "desc": "This action enables the agent to load a package into a truck. For example, load a package_1 into a truck_1.", "extra_info": [] }, - "unload_truck": { + "Unload a package from a truck": { "desc": "This action enables the agent to unload a package from a truck. For example, unload a package_1 from a truck_1.", "extra_info": [] }, - "load_airplane": { + "Load a package into an airplane": { "desc": "This action enables the agent to load a package into an airplane. For example, load a package_1 into an airplane_1.", "extra_info": [] }, - "unload_airplane": { + "Unload a package from an airplane": { "desc": "This action enables the agent to unload a package from an airplane. For example, unload a package_1 from an airplane_1.", "extra_info": [] }, - "drive_truck": { + "Drive a truck from one location to another in a city": { "desc": "This action enables the agent to drive a truck from one location to another in a city. For example, drive a truck_1 from location_1 to location_2 in city_1.", "extra_info": [] }, - "fly_airplane":{ + "Fly an airplane from one city to another":{ "desc": "This action enables the agent to fly an airplane from one city's airport to another. The airports are locations in the city. For example, fly an airplane_1 from location_0 to location_1.", "extra_info": [] } diff --git a/paper_reconstructions/llm+dm/prompts/domain_desc.txt b/paper_reconstructions/llm+dm/domains/logistics/domain_desc.txt similarity index 100% rename from paper_reconstructions/llm+dm/prompts/domain_desc.txt rename to paper_reconstructions/llm+dm/domains/logistics/domain_desc.txt diff --git a/paper_reconstructions/llm+dm/domains/logistics/hierarchy_requirements.json b/paper_reconstructions/llm+dm/domains/logistics/hierarchy_requirements.json new file mode 100644 index 0000000..5a13d75 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/logistics/hierarchy_requirements.json @@ -0,0 +1,19 @@ +{ + "hierarchy": { + "object": "", + "children": [ + {"truck": "", "children":[]}, + {"plane": "", "children":[]}, + {"package": "", "children":[]}, + {"city": "", "children":[]}, + {"location": "", "children":[]} + ] + }, + "requirements": [ + "typing", + "negative-preconditions", + "disjunctive-preconditions", + "conditional-effects", + "equality" + ] + } \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/prompts/pddl_prompt.txt b/paper_reconstructions/llm+dm/domains/pddl_prompt.txt similarity index 84% rename from paper_reconstructions/llm+dm/prompts/pddl_prompt.txt rename to paper_reconstructions/llm+dm/domains/pddl_prompt.txt index 36e7f24..2f53458 100644 --- a/paper_reconstructions/llm+dm/prompts/pddl_prompt.txt +++ b/paper_reconstructions/llm+dm/domains/pddl_prompt.txt @@ -1,11 +1,11 @@ -You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in an intuitive and readable way. Do not include character '|' into your predicates. You must only use the types listed. +You are defining the preconditions and effects (represented in PDDL format) of an AI agent's actions. Information about the AI agent will be provided in the domain description. Note that individual conditions in preconditions and effects should be listed separately. For example, "object_1 is washed and heated" should be considered as two separate conditions "object_1 is washed" and "object_1 is heated". Also, in PDDL, two predicates cannot have the same name even if they have different parameters. Each predicate in PDDL must have a unique name, and its parameters must be explicitly defined in the predicate definition. It is recommended to define predicate names in an intuitive and readable way. + +End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ``` ``` comment blocks in PDDL. If there are no new predicates needed, leave empty enclosed by ``` ``` comment blocks. Here are two examples from the classical BlocksWorld domain for demonstrating the output format. Domain information: BlocksWorld is a planning domain in artificial intelligence. The AI agent here is a mechanical robot arm that can pick and place the blocks. Only one block may be moved at a time: it may either be placed on the table or placed atop another block. Because of this, any blocks that are, at a given time, under another block cannot be moved. There is only one type of object in this domain, and that is the block. -End your final answers underneath the headers: '### Action Parameters,' '### Action Preconditions,' '### Action Effects,' and '### New Predicates' with ''' ''' comment blocks in PDDL. Follow the exact example syntax as the following: - Example 1 Action: This action enables the robot to put a block onto the table. For example, the robot puts block_1 onto the table. @@ -42,6 +42,7 @@ No predicate has been defined yet - (block-on-table ?x - block): true if the block ?x is placed on the table ``` + Example 2 Action: This action enables the robot to pick up a block on the table. @@ -76,26 +77,14 @@ You can create and define new predicates, but you may also reuse the following p ``` ### New Predicates -No newly defined predicate - -END OF EXAMPLE - -Here is the task. - -## Domain -{domain_desc} +No new predicates were needed, thus we leave empty +``` -## Available types -{types} +``` -## Action name -{action_name} -## Action description -{action_desc} +Here is the task. -## Future actions to be used later -{action_list} +Domain information: {domain_desc} -You can create and define new predicates, but you may also reuse the following predicates: -{predicates} \ No newline at end of file +Action: \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/tyreworld/action_model.json b/paper_reconstructions/llm+dm/domains/tyreworld/action_model.json new file mode 100644 index 0000000..b233b2f --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/tyreworld/action_model.json @@ -0,0 +1,66 @@ +{ + "Open a container": { + "desc": "This action enables the robot to open a container. For example, the robot can open a boot.", + "extra_info": [] + }, + + "Close a container": { + "desc": "This action enables the robot to close a container. For example, the robot can close a boot.", + "extra_info": [] + }, + + "Fetch an object from a container": { + "desc": "This action enables the robot to take an object from a container. For example, the robot can fetch jack from the boot or the robot can fetch wheel_1 from the boot.", + "extra_info": [] + }, + + "Put away an object into a container": { + "desc": "This action enables the robot to put an object into a container. For example, the robot can put away jack into the boot or the robot can put away wheel_1 into the boot.", + "extra_info": [] + }, + + "Loosen a nut in a hub": { + "desc": "This action enables the robot to loosen a nut in a hub. For example, the robot can loosen nut_1 in hub_1. To safely perform this action, the hub needs to be on the ground (i.e., not jacked-up). You may assume the nut remains on the hub after the robot loosens it.", + "extra_info": [] + }, + + "Tighten a nut in a hub": { + "desc": "This action enables the robot to tighten a nut in a hub. For example, the robot can tighten nut_1 in hub_1. To safely perform this action, the hub needs to be on the ground (i.e., not jacked-up).", + "extra_info": [] + }, + + "Jack up a hub": { + "desc": "This action enables the robot to jack up a hub. For example, the robot can jack up hub_1.", + "extra_info": [] + }, + + "Jack down a hub": { + "desc": "This action enables the robot to jack down a hub. For example, the robot can jack down hub_1.", + "extra_info": [] + }, + + "Unfasten a hub": { + "desc": "This action enables the robot to unfasten a hub. To achieve this, the robot needs to first remove the nut on the hub and then unfasten the hub. For example, the robot can unfasten hub_1 that has nut_1. To safely perform this action, the hub needs to be jacked up. At the end of this action, the hub should be unfastened, and nut should be detached from the hub and held by the robot.", + "extra_info": [] + }, + + "Fasten a hub": { + "desc": "This action enables the robot to fasten a hub. To achieve this, the robot needs to first put a nut on the hub and then fasten the hub. For example, the robot can fasten hub_1 that has nut_1. Note that although the robot needs to install a nut into the hub, but the robot is not required to tighten the nut in this action. To safely perform this action, the hub needs to be jacked up.", + "extra_info": [] + }, + + "Remove wheel from hub": { + "desc": "This action enables the robot to remove a wheel from a hub. For example, the robot can remove wheel_1 from hub_1. Note that the hub needs to be unfastened in order to remove the wheel. To safely perform this action, the hub needs to be jacked up.", + "extra_info": [] + }, + + "Put wheel on hub": { + "desc": "This action enables the robot to put a wheel on an unfastened hub. For example, the robot can put wheel_1 on hub_1. Note that the hub needs to be unfastened in order to put on the wheel. To safely perform this action, the hub needs to be jacked up.", + "extra_info": [] + }, + + "Inflate wheel": { + "desc": "This action enables the robot to inflate a wheel. For example, the robot can inflate wheel_1. You also need to make sure the wheel is intact.", + "extra_info": [] + } +} \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/tyreworld/domain_desc.txt b/paper_reconstructions/llm+dm/domains/tyreworld/domain_desc.txt new file mode 100644 index 0000000..15e4fe5 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/tyreworld/domain_desc.txt @@ -0,0 +1 @@ +The AI agent here is a robot that has to replace a flat tyre with a spare one. This involves fetching the tools (wrench, jack, pump) from the boot, undoing the nuts on the flat tyre, jacking up the (appropriate) hub(s), removing the tyre, doing up the spare one, etc. There are three major object types: `small_object`, `container` and `hub`. The object type `small_object` covers tools, wheels and nuts. The `small_object` object type has three subtypes: `tool`, `wheel` and `nut`. The subtype `tool` covers tools like wrenches, jacks, pumps etc. The subtype `wheel` covers various wheels. The subtype `nut` covers various nuts. The object type `container` covers storage spaces like the boot in a car. The object type `hub` covers the hubs in the wheels of the car. Note that there is no restriction on how many objects the AI agent (i.e., the robot) can carry. Also note that each hub has only one nut. \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/domains/tyreworld/hierarchy_requirements.json b/paper_reconstructions/llm+dm/domains/tyreworld/hierarchy_requirements.json new file mode 100644 index 0000000..528a028 --- /dev/null +++ b/paper_reconstructions/llm+dm/domains/tyreworld/hierarchy_requirements.json @@ -0,0 +1,24 @@ +{ + "hierarchy": { + "object": "", + "children": [ + { + "small_object": "", + "children": [ + {"tool": "", "children":[]}, + {"wheel": "", "children":[]}, + {"nut": "", "children":[]} + ] + }, + {"container": "", "children": []}, + {"hub": "", "children": []} + ] + }, + "requirements": [ + "typing", + "negative-preconditions", + "disjunctive-preconditions", + "conditional-effects", + "equality" + ] + } \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/main.py b/paper_reconstructions/llm+dm/main.py index 277ee70..34ea06f 100644 --- a/paper_reconstructions/llm+dm/main.py +++ b/paper_reconstructions/llm+dm/main.py @@ -1,3 +1,5 @@ + + """ Paper: "Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning" Guan et al. (2023) Source code: https://github.com/GuanSuns/LLMs-World-Models-for-Planning @@ -8,203 +10,288 @@ 2. A description of the domain 3. Information of the object types and hierarchy - fixed set of object types specified in prompt -This file contains 2 main module components (Step 1+2 in LLM+DM): - 1. `construct_action_models.py` - 2. `correct_action_models.py` +This paper contains 2 main module components (Step 1+2 in LLM+DM): + 1. `construct_action_models.py` - in this case we are only focusing on this! + 2. `correct_action_models.py` - excluded in this program + +Changes made: + > structure output from LLM to enable L2P type extractions + > using L2P `extract_pddl_action` function in ABA algorithm + > syntax validator + error message changes """ import os from copy import deepcopy from l2p import * +DOMAINS = [ + "household", + "logistics", + "tyreworld", +] + +UNSUPPORTED_KEYWORDS = [ + "forall", + "when", + "exists", + "implies" +] + +def get_action_prompt(prompt_template: str, action_desc: str): + """Creates prompt for specific action.""" + + action_desc_prompt = action_desc['desc'] + for i in action_desc['extra_info']: + action_desc_prompt += ' ' + i + + full_prompt = str(prompt_template) + ' ' + action_desc_prompt + + return full_prompt, action_desc_prompt + + +def get_predicate_prompt(predicates): + """Creates prompt for list of available predicates generated so far.""" + + predicate_prompt = 'You can create and define new predicates, but you may also reuse the following predicates:' + if len(predicates) == 0: + predicate_prompt += '\nNo predicate has been defined yet' + else: + predicate_prompt += "\n".join([f"- {pred['clean']}" for pred in predicates]) + return predicate_prompt -def construct_action_model( - domain_desc, - prompt_template, - action_name, - action_desc, - predicate_list, - max_iterations=3, - syntax_validator=None, -) -> tuple[Action, list[Predicate], str]: - """ - This function constructs an action model for a single action. Specifically, it runs through syntax validator to refine model in a certain - set amount of iterations. +def get_types(hierarchy_requirements): + """Creates proper dictionary types (for L2P) from JSON format.""" + + types = { + name: description + for name, description in hierarchy_requirements["hierarchy"].items() + if name + } + return types + + +def construct_action( + model: LLM, + act_pred_prompt: str, + action_name: str, + predicates: list[Predicate], + types: dict[str,str], + max_iter: int = 8, + syntax_validator: bool = True + ): + """ + This is the inner function of the overall `Action-by-action` algorithm. Specifically, + this function generates a single action from the list of actions and new predicates created. + Process looping until it abides the custom syntax validation check. + + Args: + - model (LLM): the large language model to be inferenced + - act_pred_prompt (str): contains information of action and format creation passed to LLM + - action_name (str): current action to be generated + - predicates (list[Predicate]): current list of predicates generated + - types (dict[str,str]): domain types - used for validation checks + - max_iter (int): max attempts of generating action (defaults at 8) + - syntax_validator (bool): flag if syntax checker is on (defaults to True) + Returns: - - pddl_action (Action): Action model class that contains params, preconditions, effects, and additional info - - predicate_list (list[Predicate]): list of Predicate classes - - llm_response (str): raw output from LLM + - action (Action): action data type containing parameters, preconditions, and effects + - predicates (list[Predicate]): list of updated predicates + - llm_response (str): original LLM output """ + # better format for LLM to interpret + predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) + + # syntax validator check + if syntax_validator: validator = SyntaxValidator() + else: validator = None + no_syntax_error = False i_iter = 0 - - # create action model, check for syntax error - while not no_syntax_error and i_iter < max_iterations: + + # generate single action in loop, loops until no syntax error or max iters reach + while not no_syntax_error and i_iter < max_iter: i_iter += 1 - - # generate action model - pddl_action, new_predicates, llm_response = domain_builder.extract_pddl_action( - model=openai_llm, - domain_desc=domain_desc, - prompt_template=prompt_template, - action_name=action_name, - action_desc=action_desc, - predicates=predicate_list, - types=hierarchy_requirements["hierarchy"], - ) - - # if syntax validator check is set on - if syntax_validator is not None: - - syntax_valid = False - - while not syntax_valid: - # perform syntax check on action model - no_syntax_error, feedback_msg = ( - syntax_validator.validate_usage_predicates( - llm_response, - predicate_list, - hierarchy_requirements["hierarchy"], + print(f'[INFO] generating PDDL of action: `{action_name}`') + try: + # L2P usage for extracting actions and predicates + action, new_predicates, llm_response, validation_info = ( + domain_builder.extract_pddl_action( + model=model, + domain_desc="", + prompt_template=act_pred_prompt, + action_name=action_name, + predicates=predicates, + types=types, + syntax_validator=validator, ) ) - # if there is syntax error, run through feedback mechanism to retrieve new action model - if no_syntax_error is False: - # Update the prompt with the feedback - prompt_template += ( - "\n\nHere is the PDDL action you outputted:\n" - + str(pddl_action) - ) - if len(new_predicates) > 0: - prompt_template += ( - "\n\nHere are the predicates you created from that action:\n" - + format_predicates(new_predicates) - ) - prompt_template += ( - "\n\nHere is the feedback you outputted:\n" + feedback_msg - ) - - # Generate a new PDDL action model based on the feedback - pddl_action, new_predicates, llm_response = ( - domain_builder.extract_pddl_action( - model=openai_llm, - domain_desc=domain_desc, - prompt_template=prompt_template, - action_name=action_name, - action_desc=action_desc, - predicates=predicate_list, - types=hierarchy_requirements["hierarchy"], - ) - ) - else: - syntax_valid = True - - new_predicates = parse_new_predicates(llm_response) - predicate_list.extend(new_predicates) - - return pddl_action, predicate_list, llm_response - - -if __name__ == "__main__": - - # setup prompt templates - action_model = load_file("paper_reconstructions/llm+dm/prompts/action_model.json") - domain_desc = load_file("paper_reconstructions/llm+dm/prompts/domain_desc.txt") - hierarchy_requirements = load_file( - "paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json" - ) - prompt_template = load_file("paper_reconstructions/llm+dm/prompts/pddl_prompt.txt") - - # setup LLM engine - engine = "gpt-4o-mini" - api_key = os.environ.get("OPENAI_API_KEY") - openai_llm = OPENAI(model=engine, api_key=api_key) - - # setup L2P libraries - domain_builder = DomainBuilder() - syntax_validator = SyntaxValidator() + # retrieve validation check and error message + no_error, error_msg = validation_info + + except Exception as e: + no_error = False + error_msg = str(e) + + # if error exists, swap templates and return feedback message + if not no_error: + with open("paper_reconstructions/llm+dm/domains/error_prompt.txt") as f: + error_template = f.read().strip() + error_prompt = error_template.replace("{action_name}", action_name) + error_prompt = error_prompt.replace("{predicates}", predicate_str) + error_prompt = error_prompt.replace("{error_msg}", error_msg) + error_prompt = error_prompt.replace("{llm_response}", llm_response) + + act_pred_prompt = error_prompt + + # break the loop if no syntax error was made + else: + no_syntax_error = True + + # if max attempts reached and there are still errors, print out error on action. + if not no_syntax_error: + print(f'[WARNING] syntax error remaining in the action model: {action_name}') + + predicates.extend(new_predicates) # extend the predicate list + + return action, predicates, llm_response - domain = "logistics" # using logistics domain for this example - max_iterations = 2 - max_feedback = 1 +def run_llm_dm( + model: LLM, + domain: str = "household", + max_iter: int = 2, + max_attempts: int = 8 + ): + """ + This is the main function for `construct_action_models.py` component of LLM+DM paper. Specifically, it generates + actions (params, preconditions, effects) and predicates to create an overall PDDL domain file. + + Args: + - model (LLM): the large language model to be inferenced + - domain (str): choice of domain to task (defaults to `household`) + - max_iter: outer loop iteration; # of overall action list resets (defaults to 2) + - max_attempts: # of attempts to generate a single actions properly (defaults to 8) + """ + + # load in assumptions + prompt_template = load_file("paper_reconstructions/llm+dm/domains/pddl_prompt.txt") + domain_desc_str = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/domain_desc.txt") + + if '{domain_desc}' in prompt_template: + prompt_template = prompt_template.replace('{domain_desc}', domain_desc_str) + + action_model = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/action_model.json") + hierarchy_reqs = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/hierarchy_requirements.json") + + reqs = [":" + r for r in hierarchy_reqs['requirements']] + types = format_types(get_types(hierarchy_reqs)) + actions = list(action_model.keys()) - predicate_list = list() + action_list = list() + predicates = list() + # initialize result folder + result_log_dir = f"paper_reconstructions/llm+dm/results/{domain}" + os.makedirs(result_log_dir, exist_ok=True) + """ Action-by-action algorithm: iteratively generates an action model (parameters, precondition, effects) one at a time. At the same time, it is generating new predicates if needed and is added to a dynamic list. At the end of the iterations, it is ran again once more to create the action models agains, but with using the new predicate list. This algorithm can iterative as many times as needed until no new predicates are added to the list. This is an action model refinement algorithm, that refines itself by a growing predicate list. """ - - # iterate however many times - for i_iter in range(max_iterations): - prev_predicate_list = deepcopy(predicate_list) - + + # outer loop that resets all action creation to be conditioned on updated predicate list + for i_iter in range(max_iter): + readable_results = '' # for logging purposes + prev_predicate_list = deepcopy(predicates) # copy previous predicate list action_list = [] - - # iterate through each action - for i_action, action in enumerate(actions): - - # replace prompt with dynamic predicate list - if len(predicate_list) == 0: - # if no predicates in list - prompt_template = prompt_template.replace( - "{predicates}", "\nNo predicate has been defined yet" - ) - else: - # replace with current predicates - readable_results = "" - for i, p in enumerate(predicate_list): - readable_results += f'\n{i + 1}. {p["raw"]}' - - prompt_template = prompt_template.replace( - "{predicates}", readable_results - ) - - # construct action model - pddl_action, predicate_list, llm_output = construct_action_model( - domain_desc, - prompt_template, - action, - action_model[action]["desc"], - predicate_list, - max_iterations=max_feedback, - syntax_validator=syntax_validator, - ) - action_list.append(pddl_action) - - # at the end of the action-by-action algorithm, clean predicates, types, and build parse PDDL domain - predicate_list = prune_predicates(predicates=predicate_list, actions=action_list) + + # inner loop that generates a single action along with its predicates + for _, action in enumerate(actions): + + # retrieve prompt for specific action + action_prompt, _ = get_action_prompt(prompt_template, action_model[action]) + readable_results += '\n' * 2 + '#' * 20 + '\n' + f'Action: {action}\n' + '#' * 20 + '\n' + + # retrieve prompt for current predicate list + predicate_prompt = get_predicate_prompt(predicates) + readable_results += '-' * 20 + readable_results += f'\n{predicate_prompt}\n' + '-' * 20 + + # assemble template + action_predicate_prompt = f'{action_prompt}\n\n{predicate_prompt}' + action_predicate_prompt += '\n\nParameters:' + + # create single action + corresponding predicates + action, predicates, llm_response = construct_action( + model, action_predicate_prompt, action, predicates, types, max_attempts, True) + + # add action to current list + remove any redundant predicates + action_list.append(action) + predicates = prune_predicates(predicates, action_list) + + readable_results += '\n' + '-' * 10 + '-' * 10 + '\n' + readable_results += llm_response + '\n' + + # record log results into separate file of current iteration + readable_results += '\n' + '-' * 10 + '-' * 10 + '\n' + readable_results += 'Extracted predicates:\n' + for i, p in enumerate(predicates): + readable_results += f'\n{i + 1}. {p["raw"]}' + + with open(os.path.join(result_log_dir, f'{engine}_0_{i_iter}.txt'), 'w') as f: + f.write(readable_results) + + gen_done = False + if len(prev_predicate_list) == len(predicates): + print(f'[INFO] iter {i_iter} | no new predicate has been defined, will terminate the process') + gen_done = True + + if gen_done: + break + + + # format components for PDDL generation predicate_str = "\n".join( - [pred["clean"].replace(":", " ; ") for pred in predicate_list] - ) - - # prune types if not found in action interfaces - types = { + [pred["clean"].replace(":", " ; ") for pred in predicates] + ) + + pruned_types = { name: description - for name, description in hierarchy_requirements["hierarchy"].items() - if name - } - types_str = "\n".join(types) - - # generate domain + for name, description in types.items() + if name not in UNSUPPORTED_KEYWORDS + } # remove unsupported words + types_str = "\n".join(pruned_types) + + # generate PDDL format pddl_domain = domain_builder.generate_domain( - domain=domain, - requirements=hierarchy_requirements["requirements"], - types=types_str, - predicates=predicate_str, - actions=action_list, - ) - - domain_file = "paper_reconstructions/llm+dm/results/domain.pddl" - - # save domain file + domain=domain, + requirements=reqs, + types=types_str, + predicates=predicate_str, + actions=action_list, + ) + + # write in PDDL domain file into results dir + domain_file = f"{result_log_dir}/domain.pddl" with open(domain_file, "w") as f: f.write(pddl_domain) + + + +if __name__ == "__main__": + + engine = "gpt-4o-mini" + api_key = os.environ.get("OPENAI_API_KEY") + gpt_model = OPENAI(model=engine, api_key=api_key) + domain_builder = DomainBuilder() - print(pddl_domain) + # run LLM+DM method on all domains + run_llm_dm(model=gpt_model, domain="logistics") + run_llm_dm(model=gpt_model, domain="household") + run_llm_dm(model=gpt_model, domain="tyreworld") \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json b/paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json deleted file mode 100644 index c8a7f5d..0000000 --- a/paper_reconstructions/llm+dm/prompts/hierarchy_requirements.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "hierarchy": { - "truck": [], - "plane": [], - "package": [], - "city": [], - "location": [] - }, - "requirements": [ - ":strips", - ":typing", - ":equality", - ":negative-preconditions", - ":disjunctive-preconditions", - ":universal-preconditions", - ":conditional-effects" - ] - } \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/domain.pddl b/paper_reconstructions/llm+dm/results/domain.pddl deleted file mode 100644 index 1141dc6..0000000 --- a/paper_reconstructions/llm+dm/results/domain.pddl +++ /dev/null @@ -1,142 +0,0 @@ -(define (domain logistics) - (:requirements - :strips :typing :equality :negative-preconditions :disjunctive-preconditions :universal-preconditions :conditional-effects - ) - (:types - truck - plane - package - city - location - ) - - (:predicates - (package-at ?p - package ?l - location) ; true if the package ?p is located at location ?l - (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l - (truck-has-space ?t - truck) ; true if the truck ?t has space to load more packages - (truck-has-package ?t - truck ?p - package) ; true if the truck ?t is carrying the package ?p - (truck-holding ?t - truck ?p - package) ; true if the truck ?t is currently holding the package ?p - (truck-at-location ?t - truck ?l - location) ; true if the truck ?t is at the location ?l - (package-at-location ?p - package ?l - location) ; true if the package ?p is at the location ?l - (airplane-at-airport ?a - plane) ; true if the airplane ?a is at the designated airport location - (airplane-has-space ?a - plane) ; true if the airplane ?a has space available to load more packages - (airplane-has-package ?a - plane ?p - package) ; true if the airplane ?a is carrying the package ?p - (airplane-holding ?a - plane ?p - package) ; true if the airplane ?a is holding the package ?p - (at-airport ?a - plane ?l - location) ; true if the airplane ?a is at the airport located at ?l - (location-connected ?l1 - location ?l2 - location ?c - city) ; true if location ?l1 is directly connected to location ?l2 in city ?c - (package-on-ground ?p - package) ; true if the package ?p is on the ground and not loaded onto any vehicle - (at-airplane ?a - plane ?l - location) ; true if the airplane ?a is currently at the location ?l - (airplane-in-city ?plane - plane, ?city - city) ; true if the airplane ?plane is currently in the city ?city - ) - -(:action load_truck - :parameters ( -?p - package -?t - truck -?l - location - ) - :precondition -(and - (truck-at ?t ?l) - (package-at ?p ?l) - (truck-has-space ?t) -) - :effect -(and - (not (package-at ?p ?l)) - (truck-has-package ?t ?p) -) -) - -(:action unload_truck - :parameters ( -?p - package -?t - truck -?l - location - ) - :precondition -(and - (truck-holding ?t ?p) - (truck-at-location ?t ?l) -) - :effect -(and - (not (truck-holding ?t ?p)) - (package-at-location ?p ?l) -) -) - -(:action load_airplane - :parameters ( -?p - package -?a - plane - ) - :precondition -(and - (package-on-ground ?p) - (airplane-at-airport ?a) - (airplane-has-space ?a) -) - :effect -(and - (not (package-on-ground ?p)) - (airplane-has-package ?a ?p) -) -) - -(:action unload_airplane - :parameters ( -?p - package -?a - plane -?l - location - ) - :precondition -(and - (airplane-holding ?a ?p) - (at-airplane ?a ?l) -) - :effect -(and - (not (airplane-holding ?a ?p)) - (package-at ?p ?l) -) -) - -(:action drive_truck - :parameters ( -?t - truck -?from - location -?to - location -?c - city - ) - :precondition -(and - (truck-at ?t ?from ?c) - (location-connected ?from ?to ?c) -) - :effect -(and - (not (truck-at ?t ?from ?c)) - (truck-at ?t ?to ?c) -) -) - -(:action fly_airplane - :parameters ( -?plane - plane -?from_city - city -?to_city - city - ) - :precondition -(and - (at-airport ?from_city) - (at-airport ?to_city) - (airplane-in-city ?plane ?from_city) -) - :effect -(and - (not (airplane-in-city ?plane ?from_city)) - (airplane-in-city ?plane ?to_city) -) -) -) \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/household/domain.pddl b/paper_reconstructions/llm+dm/results/household/domain.pddl new file mode 100644 index 0000000..704406f --- /dev/null +++ b/paper_reconstructions/llm+dm/results/household/domain.pddl @@ -0,0 +1,494 @@ +(define (domain household) + (:requirements + :typing :negative-preconditions :disjunctive-preconditions :conditional-effects :equality) + + (:types + object + furnitureAppliance - object + householdObject - object + smallReceptacle - householdObject + ) + + (:predicates + (robot-at ?x - furnitureAppliance) ; true if the robot is currently at the furniture or appliance ?x + (furnitureAppliance-clear ?x - furnitureAppliance) ; true if the furniture or appliance ?x is clear for the robot to navigate to + (object-pickupable ?o - householdObject) ; true if the object ?o can be picked up by the robot + (object-stacked ?o - householdObject) ; true if the object ?o is stacked on top of other household items + (object-in ?o - householdObject ?f - furnitureAppliance) ; true if the object ?o is placed in or on the furniture or appliance ?f + (robot-holding ?o - householdObject) ; true if the robot is currently holding the object ?o + (dirty ?c - smallReceptacle) ; true if the cloth ?c is dirty after cleaning + ) + + (:action Go to a Furniture Piece or an Appliance + :parameters ( + ?from - furnitureAppliance + ?to - furnitureAppliance + ) + :precondition + (and + (robot-at ?from) + (furnitureAppliance-clear ?to) + ) + :effect + (and + (not (robot-at ?from)) + (robot-at ?to) + ) + ) + + (:action Pick up an Object on or in a Furniture Piece or an Appliance + :parameters ( + ?o - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + (not (robot-holding ?x)) + ) + :effect + (and + (not (furnitureAppliance-clear ?f)) + (not (object-pickupable ?o)) + (robot-holding ?o) + ) + ) + + (:action Put an Object on or in a Furniture Piece or an Appliance + :parameters ( + ?o - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + ) + :effect + (and + (not (object-pickupable ?o)) + (not (furnitureAppliance-clear ?f)) + (object-in ?o ?f) + ) + ) + + (:action Stack Objects + :parameters ( + ?o1 - householdObject + ?o2 - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-holding ?o1) + (object-pickupable ?o1) + (object-pickupable ?o2) + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (object-stacked ?o2)) + (object-in ?o2 ?f) + ) + :effect + (and + (not (robot-holding ?o1)) + (not (object-in ?o1 ?f)) + (object-stacked ?o1) + (object-in ?o1 ?f) + ) + ) + + (:action Unstack Objects + :parameters ( + ?o1 - householdObject + ?o2 - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-stacked ?o1) + (object-in ?o1 ?f) + (object-in ?o2 ?f) + (object-pickupable ?o1) + ) + :effect + (and + (not (object-stacked ?o1)) + (not (object-in ?o1 ?f)) + (not (object-in ?o2 ?f)) + (robot-holding ?o1) + (object-in ?o2 ?f) + ) + ) + + (:action Open a Furniture Piece or an Appliance + :parameters ( + ?f - furnitureAppliance + ?o - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (robot-holding ?o)) ; Ensure the robot is not holding any household object + ) + :effect + (and + (not (furnitureAppliance-clear ?f)) ; The furniture or appliance is now open + (object-in ?o ?f) ; The household object may now be accessible inside the furniture or appliance + ) + ) + + (:action Close a Furniture Piece or an Appliance + :parameters ( + ?f - furnitureAppliance + ?o - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?f) + (not (robot-holding ?o)) + ) + :effect + (and + (not (object-in ?o ?f)) + (furnitureAppliance-clear ?f) + ) + ) + + (:action Toggle a Small Appliance On + :parameters ( + ?o - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (robot-holding ?o)) + (object-in ?o ?f) + ) + :effect + (and + (not (object-stacked ?o)) + (robot-holding ?o) + ) + ) + + (:action Toggle a Small Appliance Off + :parameters ( + ?o - householdObject + ?f - furnitureAppliance + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?f) + (not (robot-holding ?o)) + ) + :effect + (and + (not (object-in ?o ?f)) + (object-stacked ?o) + ) + ) + + (:action Slice Objects + :parameters ( + ?o - householdObject + ?k - householdObject + ?c - furnitureAppliance + ?f - furnitureAppliance + ) + :precondition + (and + (robot-holding ?k) + (object-in ?o ?c) + (object-pickupable ?o) + (not (object-stacked ?o)) + (robot-at ?f) + (furnitureAppliance-clear ?f) + ) + :effect + (and + (not (object-in ?o ?c)) + (not (robot-holding ?k)) + (robot-holding ?o) + (object-stacked ?o) + ) + ) + + (:action Heat Food with a Microwave + :parameters ( + ?m - furnitureAppliance + ?r - smallReceptacle + ) + :precondition + (and + (robot-at ?m) + (furnitureAppliance-clear ?m) + (object-in ?r ?m) + (robot-holding ?r) + (not (object-stacked ?r)) + ) + :effect + (and + (not (object-pickupable ?r)) + (not (robot-holding ?r)) + (not (object-in ?r ?m)) + (object-in ?r ?m) ; The food is now considered heated and remains in the microwave + ) + ) + + (:action Heat Food with Pan + :parameters ( + ?f - furnitureAppliance + ?p - furnitureAppliance + ?h - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?p ?f) + (object-in ?h ?p) + (not (robot-holding ?h)) + (object-pickupable ?h) + ) + :effect + (and + (not (object-in ?h ?p)) + (not (object-pickupable ?h)) + (not (object-in ?p ?f)) + (object-in ?h ?f) + (robot-holding ?p) + ) + ) + + (:action Transfer Food from One Small Receptacle to Another + :parameters ( + ?food - householdObject + ?receptacle_1 - smallReceptacle + ?receptacle_2 - smallReceptacle + ?furniture - furnitureAppliance + ) + :precondition + (and + (robot-at ?furniture) + (furnitureAppliance-clear ?furniture) + (object-in ?receptacle_1 ?furniture) + (object-in ?receptacle_2 ?furniture) + (not (object-stacked ?receptacle_1)) + (not (object-stacked ?receptacle_2)) + (object-pickupable ?food) + (robot-holding ?receptacle_1) + ) + :effect + (and + (not (robot-holding ?receptacle_1)) + (not (object-in ?food ?receptacle_1)) + (object-in ?food ?receptacle_2) + (robot-holding ?receptacle_2) + ) + ) + + (:action Puts an Object onto or into a Small Receptacle + :parameters ( + ?o - householdObject + ?r - smallReceptacle + ?f - furnitureAppliance + ) + :precondition + (and + (robot-holding ?o) + (object-pickupable ?o) + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) + ) + :effect + (and + (not (robot-holding ?o)) + (object-in ?o ?r) + (not (object-pickupable ?o)) + (robot-hand-empty) + ) + ) + + (:action Pick up an Object on or in a Small Receptacle + :parameters ( + + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?r) + (object-pickupable ?o) + (not (object-stacked ?o)) + (not (robot-holding ?o)) + ) + :effect + (and + (not (object-in ?o ?r)) + (not (robot-holding ?o)) + (robot-holding ?o) + ) + ) + + (:action Open a Small Receptacle + :parameters ( + ?r - smallReceptacle + ?f - furnitureAppliance + ?o - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) + (object-pickupable ?r) + (not (robot-holding ?o)) ; where ?o is any householdObject + ) + :effect + (and + (not (object-in ?r ?f)) + (robot-holding ?r) + ) + ) + + (:action Close a Small Receptacle + :parameters ( + ?r - smallReceptacle + ?f - furnitureAppliance + ?o - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) + (robot-holding ?o) ; the robot must be holding an object + ) + :effect + (and + (not (object-in ?r ?f)) ; the receptacle is no longer in the open state + (object-in ?r ?f) ; assuming the receptacle is still in the same place after closing + ) + ) + + (:action Mash Food with a Blender + :parameters ( + ?f - furnitureAppliance + ?h - householdObject + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?h) + (not (object-stacked ?h)) + (object-in ?h ?f) + (robot-holding ?h) + ) + :effect + (and + (not (robot-holding ?h)) + (object-in ?h ?f) + (not (object-pickupable ?h)) + ) + ) + + (:action Wash an Object + :parameters ( + ?o - householdObject + ?s - furnitureAppliance + ) + :precondition + (and + (robot-at ?s) + (furnitureAppliance-clear ?s) + (robot-holding ?o) + (object-pickupable ?o) + ) + :effect + (and + (not (robot-holding ?o)) + (object-in ?o ?s) + ) + ) + + (:action Wipe a Surface + :parameters ( + ?f - furnitureAppliance + ?c - smallReceptacle + ) + :precondition + (and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (robot-holding ?c) + (object-pickupable ?c) + ) + :effect + (and + (not (robot-holding ?c)) + (not (object-pickupable ?c)) + (object-in ?c ?f) + (dirty ?c) + ) + ) + + (:action Vacuum a Carpet + :parameters ( + ?v - householdObject + ?c - furnitureAppliance + ) + :precondition + (and + (robot-holding ?v) + (robot-at ?c) + (furnitureAppliance-clear ?c) + (not (dirty ?v)) + ) + :effect + (and + (not (robot-holding ?v)) + (dirty ?v) + ) + ) + + (:action Empty a Vacuum Cleaner + :parameters ( + ?v - householdObject + ?t - smallReceptacle + ?f - furnitureAppliance + ) + :precondition + (and + (robot-holding ?v) + (robot-at ?f) ; The robot is at the furniture appliance + (furnitureAppliance-clear ?f) + (object-in ?v ?f) + ) + :effect + (and + (not (object-in ?v ?f)) + (dirty ?t) ; The trash can is now dirty after emptying the vacuum cleaner + (robot-holding ?v) + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_0.txt b/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_0.txt new file mode 100644 index 0000000..cd415a9 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_0.txt @@ -0,0 +1,1117 @@ + + +#################### +Action: Go to a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates: +No predicate has been defined yet +-------------------- +-------------------- +### Action Parameters +``` +- ?from - furnitureAppliance: the starting piece of furniture or appliance +- ?to - furnitureAppliance: the destination piece of furniture or appliance +``` + +### Action Preconditions +``` +(and + (robot-at ?from) + (furnitureAppliance-clear ?to) +) +``` + +### Action Effects +``` +(and + (not (robot-at ?from)) + (robot-at ?to) +) +``` + +### New Predicates +``` +- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +``` + + +#################### +Action: Pick up an Object on or in a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to pick up +- ?f - furnitureAppliance: the furniture or appliance where the object is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + (not (robot-holding ?o)) + (furnitureAppliance-open ?f) +) +``` + +### Action Effects +``` +(and + (not (furnitureAppliance-clear ?f)) + (not (object-pickupable ?o)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +``` + + +#################### +Action: Put an Object on or in a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to put down +- ?f - furnitureAppliance: the furniture or appliance to put the object on or in +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + (furnitureAppliance-open ?f) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?o)) + (not (furnitureAppliance-clear ?f)) + (not (furnitureAppliance-open ?f)) + (object-stacked ?o) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Stack Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +-------------------- +-------------------- +### Action Parameters +``` +- ?o1 - householdObject: the object to stack (object_1) +- ?o2 - householdObject: the object to stack on (object_2) +- ?f - furnitureAppliance: the furniture or appliance where the stacking occurs +``` + +### Action Preconditions +``` +(and + (robot-holding ?o1) + (object-pickupable ?o1) + (object-pickupable ?o2) + (not (object-stacked ?o2)) + (furnitureAppliance-open ?f) + (robot-at ?f) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o1)) + (not (object-pickupable ?o1)) + (not (object-pickupable ?o2)) + (object-stacked ?o1) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Unstack Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +-------------------- +-------------------- +### Response +The error message indicates that there is an unknown parameter `?f` in the preconditions and the predicate `robot-at`. To resolve this, I will define `?f` as a parameter in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly defined. Here’s the corrected version of the action: + +## Action +Unstack Objects + +### Action Parameters +``` +- ?o1 - householdObject: the object to unstack (on top) +- ?o2 - householdObject: the object below ?o1 +- ?f - furnitureAppliance: the furniture or appliance where the robot is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-stacked ?o1) + (object-pickupable ?o1) + (object-pickupable ?o2) +) +``` + +### Action Effects +``` +(and + (not (object-stacked ?o1)) + (not (object-pickupable ?o1)) + (robot-holding ?o1) +) +``` + +### New Predicates +``` +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +``` + +This revision ensures that all parameters are defined and that the action is correctly structured according to the requirements. + + +#################### +Action: Open a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +-------------------- +-------------------- +### Response +The error message indicates that the parameter `?o` in the preconditions and effects is not defined in the action parameters section. To resolve this, I will define `?o` as a parameter in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly declared. Here’s the corrected version of the action: + +## Action +Open a Furniture Piece or an Appliance + +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to open +- ?o - householdObject: the household object that the robot is holding +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (furnitureAppliance-open ?f)) + (robot-holding ?o) ; where ?o is a householdObject that should not be held while opening +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (furnitureAppliance-open ?f) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and clarifies the action's requirements and effects. + + +#################### +Action: Close a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +-------------------- +-------------------- +### Response +The error message indicates that there is an undefined parameter `?o` in the preconditions and effects of the action. To resolve this, I will define `?o` as a parameter in the action parameters section. This will ensure that all parameters are clearly defined and used consistently throughout the action. + +Here is the corrected version of the action: + +## Action +Close a Furniture Piece or an Appliance + +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to close +- ?o - householdObject: the household object that the robot may be holding +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-open ?f) + (not (robot-holding ?o)) ; Ensure the robot is not holding any object +) +``` + +### Action Effects +``` +(and + (not (furnitureAppliance-open ?f)) + (furnitureAppliance-clear ?f) ; The furniture or appliance is now clear after closing +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and used correctly, addressing the initial error. + + +#################### +Action: Toggle a Small Appliance On +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +-------------------- +-------------------- +### Response +The error message pointed out that the `Parameters` section was missing the required code block formatting. I have corrected this by including the appropriate code block for the parameters section. Below is the revised PDDL model with all sections properly formatted: + +### Action Parameters +``` +- ?o - householdObject: the small appliance to toggle on +- ?f - furnitureAppliance: the furniture or appliance where the robot is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + (furnitureAppliance-open ?f) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-stacked ?o)) + (robot-holding ?o) + (toggle-on ?o) +) +``` + +### New Predicates +``` +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +``` + +This correction ensures that the action is clearly defined with all necessary components properly formatted. + + +#################### +Action: Toggle a Small Appliance Off +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +-------------------- +-------------------- +### Response +The error message indicates that there is an unknown parameter `?f` in the preconditions and the predicate `robot-at`. To resolve this, I will define `?f` as a parameter in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly defined. Here’s the corrected version of the action: + +## Action +Toggle a Small Appliance Off + +### Action Parameters +``` +- ?o - householdObject: the small appliance to toggle off +- ?f - furnitureAppliance: the furniture or appliance where the robot is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (toggle-on ?o) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (toggle-on ?o)) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and that the action is correctly structured according to the requirements. + + +#################### +Action: Slice Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to slice +- ?k - householdObject: the knife used for slicing +- ?c - smallReceptacle: the cutting board where the object is placed +- ?f - furnitureAppliance: the furniture piece with a flat surface +``` + +### Action Preconditions +``` +(and + (robot-holding ?k) + (object-pickupable ?o) + (not (object-stacked ?o)) + (furnitureAppliance-open ?f) + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (robot-holding ?o)) + (object-on ?o ?c) + (object-sliceable ?o) +) +``` + +### Action Effects +``` +(and + (not (object-on ?o ?c)) + (not (robot-holding ?k)) + (robot-holding ?o) + (object-sliced ?o) +) +``` + +### New Predicates +``` +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +``` + + +#################### +Action: Heat Food with a Microwave +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +-------------------- +-------------------- +### Response +The error message indicates that there is a mismatch in the predicate used in the effects section. Specifically, the `toggle-on` predicate is incorrectly applied to a `furnitureAppliance` instead of a `householdObject`. To correct this, I will change the predicate to ensure it aligns with the expected types. + +Here’s the corrected action with the appropriate adjustments: + +### Action Parameters +``` +- ?m - furnitureAppliance: the microwave to use +- ?f - smallReceptacle: the small receptacle containing the food +- ?o - householdObject: the food to heat +``` + +### Action Preconditions +``` +(and + (robot-at ?m) + (furnitureAppliance-clear ?m) + (robot-holding ?f) + (object-on ?o ?f) + (furnitureAppliance-open ?m) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?o)) + (not (object-on ?o ?f)) + (not (furnitureAppliance-open ?m)) + (toggle-on ?f) ; Changed from ?m to ?f to correctly reference the small receptacle +) +``` + +### New Predicates +``` +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +``` + +This correction ensures that the `toggle-on` predicate is applied to the correct type, maintaining the integrity of the action's logic. + + +#################### +Action: Heat Food with Pan +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +-------------------- +-------------------- +### Action Parameters +``` +- ?f - furnitureAppliance: the stove burner where the pan is placed +- ?p - smallReceptacle: the pan used for heating +- ?o - householdObject: the food item to be heated +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (robot-holding ?p) + (object-on ?o ?p) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?o)) + (not (object-on ?o ?p)) + (not (robot-holding ?p)) + (toggle-on ?o) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Transfer Food from One Small Receptacle to Another +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +-------------------- +-------------------- +### Response +The error message indicates a critical issue with the use of predicates in the preconditions, specifically the incorrect reference to a `smallReceptacle` where a `furnitureAppliance` was required. To address this, I will revise the preconditions to ensure that they correctly reference the appropriate predicates and parameters. Here’s the corrected version of the action: + +### Action Parameters +``` +- ?food - householdObject: the food to transfer +- ?receptacle_1 - smallReceptacle: the receptacle to transfer food from +- ?receptacle_2 - smallReceptacle: the receptacle to transfer food to +- ?furniture - furnitureAppliance: the furniture or appliance the robot is currently at +``` + +### Action Preconditions +``` +(and + (robot-at ?furniture) + (furnitureAppliance-clear ?furniture) + (furnitureAppliance-open ?furniture) ; The furniture appliance must be open + (furnitureAppliance-open ?receptacle_1) ; The first receptacle must be open + (furnitureAppliance-open ?receptacle_2) ; The second receptacle must be open + (not (object-stacked ?receptacle_1)) + (not (object-stacked ?receptacle_2)) + (object-pickupable ?food) + (robot-holding ?food) ; The robot must be holding the food, not the receptacle +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?food)) ; The robot is no longer holding the food + (object-on ?food ?receptacle_2) ; The food is now on the second receptacle + (not (object-on ?food ?receptacle_1)) ; The food is no longer on the first receptacle +) +``` + +### New Predicates +``` +``` + +This revision ensures that the preconditions now correctly reference the `furnitureAppliance` predicate, maintaining logical consistency throughout the action. The robot is required to hold the food directly rather than the receptacle, which aligns with the intended action of transferring food between receptacles. + + +#################### +Action: Puts an Object onto or into a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +-------------------- +-------------------- +### Response +The error message indicates that the predicate `furnitureAppliance-open` was incorrectly used without defining the parameter `?f` in the action parameters. To resolve this, I will ensure that all parameters are clearly defined and that the preconditions accurately reflect the action of putting an object into a small receptacle. Additionally, I will introduce a new predicate to check if the small receptacle is clear for the robot to use. + +Here’s the corrected action with the necessary adjustments: + +### Action Parameters +``` +- ?o - householdObject: the household object to put into the receptacle +- ?c - smallReceptacle: the small receptacle to put the object into +- ?f - furnitureAppliance: the furniture or appliance that is relevant to the action +``` + +### Action Preconditions +``` +(and + (robot-holding ?o) + (furnitureAppliance-open ?f) ; Check if the relevant furniture appliance is open + (not (object-stacked ?o)) + (smallReceptacle-clear ?c) ; Check if the small receptacle is clear +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-on ?o ?c) +) +``` + +### New Predicates +``` +(smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +``` + +In this correction, I have defined all necessary parameters, ensuring that the action is logically consistent and that the predicates used in the preconditions are relevant to the action being performed. The predicate `furnitureAppliance-open` is retained to check the state of the furniture appliance, while the new predicate `smallReceptacle-clear` ensures that the receptacle is available for use. + + +#################### +Action: Pick up an Object on or in a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to pick up +- ?c - smallReceptacle: the receptacle containing the object +- ?f - furnitureAppliance: the furniture or appliance where the receptacle is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (furnitureAppliance-open ?f) + (smallReceptacle-clear ?c) + (object-on ?o ?c) + (not (object-stacked ?c)) + (object-pickupable ?o) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-on ?o ?c)) + (not (smallReceptacle-clear ?c)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Open a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +-------------------- +-------------------- +### Action Parameters +``` +- ?c - smallReceptacle: the small receptacle to open +- ?f - furnitureAppliance: the furniture or appliance where the receptacle is placed +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (furnitureAppliance-open ?f) + (smallReceptacle-clear ?c) + (not (object-stacked ?c)) +) +``` + +### Action Effects +``` +(and + (not (smallReceptacle-clear ?c)) + (furnitureAppliance-open ?f) + (robot-holding ?c) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Close a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +-------------------- +-------------------- +### Response +The error message pointed out that the `Parameters` section was missing the required code block formatting. I have corrected this by enclosing the parameters in a code block. Below is the revised action with all sections properly formatted and structured according to the PDDL format. + +### Action Parameters +``` +- ?c - smallReceptacle: the small receptacle to close +- ?f - furnitureAppliance: the furniture or appliance the robot is at +- ?o - householdObject: the object the robot is holding +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (furnitureAppliance-open ?f) + (smallReceptacle-clear ?c) + (not (object-stacked ?c)) + (robot-holding ?o) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (not (smallReceptacle-clear ?c)) + (robot-holding ?c) +) +``` + +### New Predicates +``` +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to close +``` + +This revision ensures that all sections are correctly formatted and that the action is structured appropriately for use in a PDDL model. + + +#################### +Action: Mash Food with a Blender +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +-------------------- +-------------------- +### Action Parameters +``` +- ?f - furnitureAppliance: the blender being used +- ?o - householdObject: the food object being mashed +- ?c - smallReceptacle: the blender as a small receptacle +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (robot-holding ?o) + (object-sliced ?o) + (object-on ?o ?c) + (smallReceptacle-clear ?c) + (not (toggle-on ?c)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (not (smallReceptacle-clear ?c)) + (object-on ?o ?c) + (toggle-on ?c) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Wash an Object +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +-------------------- +-------------------- +### Response +The error message indicates that the parameter `sink` was not defined in the action parameters section. To resolve this, I will define `sink` as a parameter of type `furnitureAppliance`. This will ensure that all parameters used in the preconditions and effects are properly defined. Here’s the corrected version of the action: + +## Action +Wash an Object + +### Action Parameters +``` +- ?o - householdObject: the object to wash +- ?sink - furnitureAppliance: the sink where the washing occurs +``` + +### Action Preconditions +``` +(and + (robot-holding ?o) + (object-pickupable ?o) + (robot-at ?sink) + (furnitureAppliance-clear ?sink) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-washed ?o) + (robot-hand-empty) +) +``` + +### New Predicates +``` +- (object-washed ?o - householdObject): true if the household object ?o has been washed +``` + +This revision ensures that all parameters are defined and that the action is correctly structured according to the PDDL model. + + +#################### +Action: Wipe a Surface +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +- (object-washed ?o - householdObject): true if the household object ?o has been washed +-------------------- +-------------------- +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to be cleaned +- ?c - householdObject: the cloth used for cleaning +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (robot-holding ?c) + (furnitureAppliance-clear ?f) + (not (object-washed ?c)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?c)) + (object-washed ?c) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Vacuum a Carpet +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +- (object-washed ?o - householdObject): true if the household object ?o has been washed +-------------------- +-------------------- +### Action Parameters +``` +- ?v - householdObject: the handheld vacuum cleaner being used +- ?c - furnitureAppliance: the carpet being vacuumed +``` + +### Action Preconditions +``` +(and + (robot-holding ?v) + (robot-at ?c) + (furnitureAppliance-clear ?c) + (not (object-sliced ?c)) + (not (toggle-on ?v)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?v)) + (toggle-on ?v) + (object-sliced ?c) +) +``` + +### New Predicates +``` +- (object-sliced ?c - furnitureAppliance): true if the carpet ?c has been vacuumed +``` + + +#################### +Action: Empty a Vacuum Cleaner +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +- (object-washed ?o - householdObject): true if the household object ?o has been washed +-------------------- +-------------------- +### Action Parameters +``` +- ?v - householdObject: the vacuum cleaner to empty +- ?t - furnitureAppliance: the trash can to dump the dust into +``` + +### Action Preconditions +``` +(and + (robot-holding ?v) + (robot-at ?t) + (furnitureAppliance-open ?t) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?v)) + (not (object-stacked ?v)) + (not (toggle-on ?v)) + (object-sliced ?v) +) +``` + +### New Predicates +``` +- (object-sliced ?v - householdObject): true if the household object ?v (the vacuum cleaner) has been emptied of its dust +``` + +-------------------- +Extracted predicates: + +1. (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +2. (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +3. (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +4. (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +5. (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +6. (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +7. (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +8. (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +9. (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +10. (object-sliced ?o - householdObject): true if the household object ?o has been sliced +11. (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +12. (object-washed ?o - householdObject): true if the household object ?o has been washed \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_1.txt b/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_1.txt new file mode 100644 index 0000000..7b439b9 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/household/gpt-4o-mini_0_1.txt @@ -0,0 +1,1067 @@ + + +#################### +Action: Go to a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household objects +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is open and accessible +- (robot-holding ?o - householdObject): true if the robot is currently holding the household object ?o +- (toggle-on ?o - householdObject): true if the small appliance ?o is switched on +- (object-on ?o - householdObject ?c - smallReceptacle): true if the household object ?o is placed on the small receptacle ?c +- (object-sliceable ?o - householdObject): true if the household object ?o can be sliced +- (object-sliced ?o - householdObject): true if the household object ?o has been sliced +- (smallReceptacle-clear ?c - smallReceptacle): true if the small receptacle ?c is clear for the robot to place an object into +- (object-washed ?o - householdObject): true if the household object ?o has been washed +-------------------- +-------------------- +### Action Parameters +``` +- ?from - furnitureAppliance: the furniture or appliance the robot is navigating from +- ?to - furnitureAppliance: the furniture or appliance the robot is navigating to +``` + +### Action Preconditions +``` +(and + (robot-at ?from) + (furnitureAppliance-clear ?to) +) +``` + +### Action Effects +``` +(and + (not (robot-at ?from)) + (robot-at ?to) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Pick up an Object on or in a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to pick up +- ?f - furnitureAppliance: the furniture or appliance where the object is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) + (not (robot-holding ?x)) +) +``` + +### Action Effects +``` +(and + (not (furnitureAppliance-clear ?f)) + (not (object-pickupable ?o)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +``` + + +#################### +Action: Put an Object on or in a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to put down +- ?f - furnitureAppliance: the furniture or appliance to put the object on or in +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (object-stacked ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?o)) + (not (furnitureAppliance-clear ?f)) + (object-in ?o ?f) +) +``` + +### New Predicates +``` +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +``` + + +#################### +Action: Stack Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +-------------------- +-------------------- +### Action Parameters +``` +- ?o1 - householdObject: the object to stack (object_1) +- ?o2 - householdObject: the object to stack on (object_2) +- ?f - furnitureAppliance: the furniture or appliance where the stacking occurs +``` + +### Action Preconditions +``` +(and + (robot-holding ?o1) + (object-pickupable ?o1) + (object-pickupable ?o2) + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (object-stacked ?o2)) + (object-in ?o2 ?f) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o1)) + (not (object-in ?o1 ?f)) + (object-stacked ?o1) + (object-in ?o1 ?f) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Unstack Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +-------------------- +-------------------- +### Response +The error message highlights that the parameter `?f` was not defined in the action parameters section, leading to confusion in the preconditions and predicates. To resolve this, I will define `?f` as a parameter representing the furniture or appliance where the objects are located. This will ensure that all variables used in the action are properly declared. I will also ensure that the rest of the action remains consistent with the intended functionality. + +### Action Parameters +``` +- ?o1 - householdObject: the object to unstack (the one on top) +- ?o2 - householdObject: the object below (the one being unstacked from) +- ?f - furnitureAppliance: the furniture or appliance where the objects are located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-stacked ?o1) + (object-in ?o1 ?f) + (object-in ?o2 ?f) + (object-pickupable ?o1) +) +``` + +### Action Effects +``` +(and + (not (object-stacked ?o1)) + (not (object-in ?o1 ?f)) + (not (object-in ?o2 ?f)) + (robot-holding ?o1) + (object-in ?o2 ?f) +) +``` + +### New Predicates +``` +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +``` + + +#################### +Action: Open a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there are undefined parameters in the preconditions and effects of the action. Specifically, the parameter `?o` is used without being defined in the action parameters. To resolve this, I will define `?o` as a parameter of type `householdObject` in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly defined. + +Here is the corrected version of the action: + +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to open +- ?o - householdObject: the household object that may be inside the furniture or appliance +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (not (robot-holding ?o)) ; Ensure the robot is not holding any household object +) +``` + +### Action Effects +``` +(and + (not (furnitureAppliance-clear ?f)) ; The furniture or appliance is now open + (object-in ?o ?f) ; The household object may now be accessible inside the furniture or appliance +) +``` + +### New Predicates +``` +- (furnitureAppliance-open ?f - furnitureAppliance): true if the furniture or appliance ?f is currently open +``` + +This revision ensures that all parameters are defined and used correctly throughout the action. + + +#################### +Action: Close a Furniture Piece or an Appliance +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that the `object-in` predicate in the preconditions and effects sections incorrectly specifies the object types instead of just using variables. This needs to be corrected to ensure that the PDDL model adheres to the required format. I will revise the action to fix this issue while keeping the structure intact. + +## Action +Close a Furniture Piece or an Appliance + +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to close +- ?o - householdObject: the object to be affected +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?f) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-in ?o ?f)) + (furnitureAppliance-clear ?f) +) +``` + +### New Predicates +``` +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +``` + +This revision ensures that the `object-in` predicate is used correctly with only the necessary variables in the preconditions and effects. + + +#################### +Action: Toggle a Small Appliance On +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that the parameter `?f` in the preconditions and the predicate `robot-at` is undefined. To resolve this, I will define `?f` as a parameter in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly defined. Here’s the corrected PDDL model: + +### Action Parameters +``` +- ?o - householdObject: the small appliance to toggle on +- ?f - furnitureAppliance: the furniture or appliance where the robot is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?o) + (not (robot-holding ?o)) + (object-in ?o ?f) +) +``` + +### Action Effects +``` +(and + (not (object-stacked ?o)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and the action can be executed without errors related to undefined parameters. + + +#################### +Action: Toggle a Small Appliance Off +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there is an unknown parameter `?f` in the preconditions and the predicate `robot-at`. To resolve this, I will define `?f` as a parameter in the action parameters section. This will ensure that all parameters are clearly defined and that the action can be properly executed. + +Here is the corrected PDDL model: + +### Action Parameters +``` +- ?o - householdObject: the small appliance to toggle off +- ?f - furnitureAppliance: the furniture or appliance where the small appliance is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?f) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-in ?o ?f)) + (object-stacked ?o) +) +``` + +### New Predicates +``` +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +``` + +This revision ensures that all parameters are defined, resolving the issue with the unknown parameter. + + +#################### +Action: Slice Objects +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there is a mismatch in the predicate used in the preconditions. Specifically, the second parameter of the `object-in` predicate should refer to a `furnitureAppliance`, but a `smallReceptacle` was incorrectly used. To correct this, I will replace the `smallReceptacle` with a suitable `furnitureAppliance` that can serve as a cutting board. + +Here’s the corrected action with the appropriate changes: + +### Action Parameters +``` +- ?o - householdObject: the object to slice +- ?k - householdObject: the knife used for slicing +- ?c - furnitureAppliance: the cutting board where the object is placed +- ?f - furnitureAppliance: the furniture piece with a flat surface +``` + +### Action Preconditions +``` +(and + (robot-holding ?k) + (object-in ?o ?c) + (object-pickupable ?o) + (not (object-stacked ?o)) + (robot-at ?f) + (furnitureAppliance-clear ?f) +) +``` + +### Action Effects +``` +(and + (not (object-in ?o ?c)) + (not (robot-holding ?k)) + (robot-holding ?o) + (object-stacked ?o) +) +``` + +### New Predicates +``` +- (object-sliceable ?o - householdObject): true if the object ?o can be sliced +``` + +This correction ensures that the preconditions are logically consistent with the available predicates, allowing the action to be executed correctly. + + +#################### +Action: Heat Food with a Microwave +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?m - furnitureAppliance: the microwave to use +- ?r - smallReceptacle: the small receptacle containing the food to heat +``` + +### Action Preconditions +``` +(and + (robot-at ?m) + (furnitureAppliance-clear ?m) + (object-in ?r ?m) + (robot-holding ?r) + (not (object-stacked ?r)) +) +``` + +### Action Effects +``` +(and + (not (object-pickupable ?r)) + (not (robot-holding ?r)) + (not (object-in ?r ?m)) + (object-in ?r ?m) ; The food is now considered heated and remains in the microwave +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Heat Food with Pan +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there was a mismatch in the parameters used in the preconditions, specifically with the `object-in` predicate. The first parameter should refer to a `householdObject`, but it was incorrectly specified as a `furnitureAppliance`. I will correct this by ensuring that the parameters align correctly with the existing predicates. + +Here’s the corrected action with the appropriate changes: + +### Action Parameters +``` +- ?f - furnitureAppliance: the stove burner where the pan is placed +- ?p - furnitureAppliance: the pan used for heating +- ?h - householdObject: the food item to be heated +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?p ?f) + (object-in ?h ?p) + (not (robot-holding ?h)) + (object-pickupable ?h) +) +``` + +### Action Effects +``` +(and + (not (object-in ?h ?p)) + (not (object-pickupable ?h)) + (not (object-in ?p ?f)) + (object-in ?h ?f) + (robot-holding ?p) +) +``` + +### New Predicates +``` +``` + +This correction ensures that the predicates are consistent with the definitions provided, maintaining the integrity of the action's logic. The parameters now correctly reflect the types required by the predicates, resolving the syntax error. + + +#################### +Action: Transfer Food from One Small Receptacle to Another +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message highlighted a critical issue regarding the use of the `object-in` predicate, where a `smallReceptacle` was incorrectly used instead of a `furnitureAppliance`. To rectify this, I will ensure that the effects of the action correctly represent the relationships between the food item and the appropriate furniture or appliance. Here’s the corrected version of the action: + +### Action Parameters +``` +- ?food - householdObject: the food item to transfer +- ?receptacle_1 - smallReceptacle: the receptacle to transfer food from +- ?receptacle_2 - smallReceptacle: the receptacle to transfer food to +- ?furniture - furnitureAppliance: the furniture or appliance where the receptacles are located +``` + +### Action Preconditions +``` +(and + (robot-at ?furniture) + (furnitureAppliance-clear ?furniture) + (object-in ?receptacle_1 ?furniture) + (object-in ?receptacle_2 ?furniture) + (not (object-stacked ?receptacle_1)) + (not (object-stacked ?receptacle_2)) + (object-pickupable ?food) + (robot-holding ?receptacle_1) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?receptacle_1)) + (not (object-in ?food ?receptacle_1)) + (object-in ?food ?receptacle_2) + (robot-holding ?receptacle_2) +) +``` + +### New Predicates +``` +``` + +This revision ensures that the action is now correctly structured, with the appropriate predicates used for the relationships between the objects involved. The action is ready for use in a PDDL model. + + +#################### +Action: Puts an Object onto or into a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message correctly identifies the need to adjust the predicate used in the preconditions. The second parameter of `object-in` should refer to a `smallReceptacle` instead of a `furnitureAppliance`. I will revise the action to ensure that the preconditions and effects align with the intended action of placing an object into a small receptacle. Here’s the corrected version of the action: + +### Action Parameters +``` +- ?o - householdObject: the object to put into the receptacle +- ?r - smallReceptacle: the receptacle to put the object into +- ?f - furnitureAppliance: the furniture or appliance where the receptacle is located +``` + +### Action Preconditions +``` +(and + (robot-holding ?o) + (object-pickupable ?o) + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-in ?o ?r) + (not (object-pickupable ?o)) + (robot-hand-empty) +) +``` + +### New Predicates +``` +- (object-in ?o - householdObject ?r - smallReceptacle): true if the object ?o is placed in or on the small receptacle ?r +``` + +This correction ensures that the action is logically consistent and adheres to the specified requirements, effectively resolving the initial error. + + +#################### +Action: Pick up an Object on or in a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message pointed out that the `Parameters` section was missing a code block, which is essential for proper formatting. I have corrected this by including the necessary code block in the `Parameters` section while ensuring that all other headers are retained as required. Below is the revised action with the correct formatting. + +### Action Parameters +``` +- ?o - householdObject: the object to pick up +- ?r - smallReceptacle: the receptacle containing the object +- ?f - furnitureAppliance: the furniture or appliance where the robot is located +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?o ?r) + (object-pickupable ?o) + (not (object-stacked ?o)) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (object-in ?o ?r)) + (not (robot-holding ?o)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +``` + +This revision ensures that the `Parameters` section is properly formatted and that all components of the action are clearly defined and consistent. + + +#################### +Action: Open a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there is an undefined parameter `?o` in the preconditions and the predicate `robot-holding`. To resolve this, I will define `?o` in the action parameters section. Additionally, I will ensure that all parameters are clearly defined and that the action is coherent. Here’s the corrected version of the action: + +### Action Parameters +``` +- ?r - smallReceptacle: the small receptacle to open +- ?f - furnitureAppliance: the furniture or appliance on which the receptacle is placed +- ?o - householdObject: the household object that the robot is not currently holding +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) + (object-pickupable ?r) + (not (robot-holding ?o)) ; where ?o is any householdObject +) +``` + +### Action Effects +``` +(and + (not (object-in ?r ?f)) + (robot-holding ?r) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined, and the action is now correctly structured. + + +#################### +Action: Close a Small Receptacle +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that there is an undefined parameter `?o` in the preconditions and the predicate `robot-holding`. To resolve this, I will define `?o` as a parameter in the action parameters section. Additionally, I will ensure that the action's logic is coherent and that all parameters are properly utilized. Here’s the corrected version of the action: + +## Action +Close a Small Receptacle + +### Action Parameters +``` +- ?r - smallReceptacle: the small receptacle to close +- ?f - furnitureAppliance: the furniture or appliance on which the receptacle is placed +- ?o - householdObject: the object that the robot is holding +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-in ?r ?f) + (not (object-stacked ?r)) + (robot-holding ?o) ; the robot must be holding an object +) +``` + +### Action Effects +``` +(and + (not (object-in ?r ?f)) ; the receptacle is no longer in the open state + (object-in ?r ?f) ; assuming the receptacle is still in the same place after closing +) +``` + +### New Predicates +``` +- (object-openable ?r - smallReceptacle): true if the small receptacle ?r can be closed +``` + +This revision ensures that all parameters are defined and used correctly, addressing the initial error while maintaining the intended functionality of the action. + + +#################### +Action: Mash Food with a Blender +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?f - furnitureAppliance: the blender being used +- ?h - householdObject: the food item being mashed +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (object-pickupable ?h) + (not (object-stacked ?h)) + (object-in ?h ?f) + (robot-holding ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?h)) + (object-in ?h ?f) + (not (object-pickupable ?h)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Wash an Object +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?o - householdObject: the object to wash +- ?s - furnitureAppliance: the sink or basin where the washing occurs +``` + +### Action Preconditions +``` +(and + (robot-at ?s) + (furnitureAppliance-clear ?s) + (robot-holding ?o) + (object-pickupable ?o) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-in ?o ?s) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Wipe a Surface +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?f - furnitureAppliance: the furniture or appliance to be cleaned +- ?c - smallReceptacle: the cloth used for cleaning +``` + +### Action Preconditions +``` +(and + (robot-at ?f) + (furnitureAppliance-clear ?f) + (robot-holding ?c) + (object-pickupable ?c) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?c)) + (not (object-pickupable ?c)) + (object-in ?c ?f) + (dirty ?c) +) +``` + +### New Predicates +``` +- (dirty ?c - smallReceptacle): true if the cloth ?c is dirty after cleaning +``` + + +#################### +Action: Vacuum a Carpet +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +- (dirty ?c - smallReceptacle): true if the cloth ?c is dirty after cleaning +-------------------- +-------------------- +### Action Parameters +``` +- ?v - householdObject: the vacuum cleaner being used +- ?c - furnitureAppliance: the carpet being vacuumed +``` + +### Action Preconditions +``` +(and + (robot-holding ?v) + (robot-at ?c) + (furnitureAppliance-clear ?c) + (not (dirty ?v)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?v)) + (dirty ?v) +) +``` + +### New Predicates +``` +- (dirty ?v - householdObject): true if the vacuum cleaner ?v is dirty after vacuuming +``` + + +#################### +Action: Empty a Vacuum Cleaner +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +- (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +- (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +- (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +- (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +- (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +- (dirty ?c - smallReceptacle): true if the cloth ?c is dirty after cleaning +-------------------- +-------------------- +### Response +The error message indicates that there was a mismatch in the parameters used in the preconditions, specifically with the `robot-at` predicate. The first parameter should be a `furnitureAppliance`, but a `smallReceptacle` was incorrectly used. To resolve this, I will ensure that the preconditions correctly reference a `furnitureAppliance` for the robot's location. + +Here is the corrected action with all four parts: + +### Action Parameters +``` +- ?v - householdObject: the vacuum cleaner to empty +- ?t - smallReceptacle: the trash can to dump the dust into +- ?f - furnitureAppliance: the furniture appliance where the vacuum cleaner is located +``` + +### Action Preconditions +``` +(and + (robot-holding ?v) + (robot-at ?f) ; The robot is at the furniture appliance + (furnitureAppliance-clear ?f) + (object-in ?v ?f) +) +``` + +### Action Effects +``` +(and + (not (object-in ?v ?f)) + (dirty ?t) ; The trash can is now dirty after emptying the vacuum cleaner + (robot-holding ?v) +) +``` + +### New Predicates +``` +``` + +This correction ensures that the `robot-at` predicate is applied to a valid `furnitureAppliance`, thus resolving the syntax error and maintaining the integrity of the action. + +-------------------- +Extracted predicates: + +1. (robot-at ?x - furnitureAppliance): true if the robot is currently at the furniture or appliance ?x +2. (furnitureAppliance-clear ?x - furnitureAppliance): true if the furniture or appliance ?x is clear for the robot to navigate to +3. (object-pickupable ?o - householdObject): true if the object ?o can be picked up by the robot +4. (object-stacked ?o - householdObject): true if the object ?o is stacked on top of other household items +5. (object-in ?o - householdObject ?f - furnitureAppliance): true if the object ?o is placed in or on the furniture or appliance ?f +6. (robot-holding ?o - householdObject): true if the robot is currently holding the object ?o +7. (dirty ?c - smallReceptacle): true if the cloth ?c is dirty after cleaning \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/logistics/domain.pddl b/paper_reconstructions/llm+dm/results/logistics/domain.pddl new file mode 100644 index 0000000..4cc4cd4 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/logistics/domain.pddl @@ -0,0 +1,137 @@ +(define (domain logistics) + (:requirements + :typing :negative-preconditions :disjunctive-preconditions :conditional-effects :equality) + + (:types + object + truck - object + plane - object + package - object + city - object + location - object + ) + + (:predicates + (package-at ?p - package ?l - location) ; true if the package ?p is located at location ?l + (truck-at ?t - truck ?l - location) ; true if the truck ?t is located at location ?l + (truck-has-space ?t - truck) ; true if the truck ?t has space to load more packages + (truck-holding ?t - truck ?p - package) ; true if the truck ?t is currently holding package ?p + (airport-location ?l - location) ; true if the location ?l is an airport + (plane-at ?p - plane ?l - location) ; true if the plane ?p is located at location ?l + ) + + (:action Load a package into a truck + :parameters ( + ?p - package + ?t - truck + ?l - location + ) + :precondition + (and + (package-at ?p ?l) + (truck-at ?t ?l) + (truck-has-space ?t) + ) + :effect + (and + (not (package-at ?p ?l)) + (truck-holding ?t ?p) + ) + ) + + (:action Unload a package from a truck + :parameters ( + ?p - package + ?t - truck + ?l - location + ) + :precondition + (and + (truck-at ?t ?l) + (truck-holding ?t ?p) + ) + :effect + (and + (not (truck-holding ?t ?p)) + (package-at ?p ?l) + ) + ) + + (:action Load a package into an airplane + :parameters ( + ?p - package + ?t - truck + ?l - location + ) + :precondition + (and + (package-at ?p ?l) + (truck-at ?t ?l) + (truck-has-space ?t) + ) + :effect + (and + (not (package-at ?p ?l)) + (truck-holding ?t ?p) + ) + ) + + (:action Unload a package from an airplane + :parameters ( + ?p - package + ?a - plane + ?l - location + ?t - truck + ) + :precondition + (and + (truck-at ?t ?l) ; The truck is at the unloading location + (package-at ?p ?a) ; The package is currently at the airplane + (truck-has-space ?t) ; The truck has space to load the package + ) + :effect + (and + (not (package-at ?p ?a)) ; The package is no longer at the airplane + (package-at ?p ?l) ; The package is now at the unloading location + (truck-holding ?t ?p) ; The truck is now holding the package + ) + ) + + (:action Drive a truck from one location to another in a city + :parameters ( + ?t - truck + ?l1 - location + ?l2 - location + ?c - city + ) + :precondition + (and + (truck-at ?t ?l1) + (truck-has-space ?t) + ) + :effect + (and + (not (truck-at ?t ?l1)) + (truck-at ?t ?l2) + ) + ) + + (:action Fly an airplane from one city to another + :parameters ( + ?plane - plane + ?from - location + ?to - location + ) + :precondition + (and + (plane-at ?plane ?from) + (airport-location ?from) + (airport-location ?to) + ) + :effect + (and + (not (plane-at ?plane ?from)) + (plane-at ?plane ?to) + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_0.txt b/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_0.txt new file mode 100644 index 0000000..ef2cc4b --- /dev/null +++ b/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_0.txt @@ -0,0 +1,276 @@ + + +#################### +Action: Load a package into a truck +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates: +No predicate has been defined yet +-------------------- +-------------------- +### Action Parameters +``` +- ?p - package: the package to load +- ?t - truck: the truck to load the package into +- ?l - location: the location where the truck is present +``` + +### Action Preconditions +``` +(and + (package-at ?p ?l) + (truck-at ?t ?l) + (truck-has-space ?t) +) +``` + +### Action Effects +``` +(and + (not (package-at ?p ?l)) + (truck-holding ?t ?p) +) +``` + +### New Predicates +``` +- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +``` + + +#################### +Action: Unload a package from a truck +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Action Parameters +``` +- ?p - package: the package to unload +- ?t - truck: the truck from which to unload the package +- ?l - location: the location where the package will be unloaded +``` + +### Action Preconditions +``` +(and + (truck-at ?t ?l) + (truck-holding ?t ?p) +) +``` + +### Action Effects +``` +(and + (not (truck-holding ?t ?p)) + (package-at ?p ?l) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Load a package into an airplane +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Response +The error message highlights a critical issue with the predicate used in the preconditions. The `truck-has-space` predicate was incorrectly applied to an airplane, which is not valid. To resolve this, I will replace the `truck-has-space` predicate with a new predicate that checks if the airplane has space to load packages. I will create a new predicate called `plane-has-space` for this purpose. + +Here’s the corrected action with the necessary adjustments: + +### Action Parameters +``` +- ?p - package: the package to load into the airplane +- ?a - plane: the airplane to load the package into +- ?l - location: the location where the airplane is located +``` + +### Action Preconditions +``` +(and + (package-at ?p ?l) + (plane-at ?a ?l) + (plane-has-space ?a) +) +``` + +### Action Effects +``` +(and + (not (package-at ?p ?l)) + (plane-holding ?a ?p) +) +``` + +### New Predicates +``` +(plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +(plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +(plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p +``` + +This correction ensures that the preconditions and effects accurately reflect the entities involved in the action of loading a package into an airplane. + + +#################### +Action: Unload a package from an airplane +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +- (plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +- (plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +- (plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p +-------------------- +-------------------- +### Action Parameters +``` +- ?p - package: the package to unload +- ?a - plane: the airplane from which to unload the package +- ?l - location: the location where the package will be unloaded +``` + +### Action Preconditions +``` +(and + (plane-at ?a ?l) + (plane-holding ?a ?p) +) +``` + +### Action Effects +``` +(and + (not (plane-holding ?a ?p)) + (package-at ?p ?l) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Drive a truck from one location to another in a city +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +- (plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +- (plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +- (plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p +-------------------- +-------------------- +### Response +The error message indicates that the predicate `truck-at` was incorrectly provided with three parameters instead of the required two. In PDDL, predicates should only include the variable names without their types in the preconditions. I will correct the preconditions accordingly while keeping the rest of the action intact. + +### Action Parameters +``` +- ?t - truck: the truck to drive +- ?l1 - location: the starting location +- ?l2 - location: the destination location +- ?c - city: the city where the locations are located +``` + +### Action Preconditions +``` +(and + (truck-at ?t ?l1) + (truck-has-space ?t) +) +``` + +### Action Effects +``` +(and + (not (truck-at ?t ?l1)) + (truck-at ?t ?l2) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Fly an airplane from one city to another +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +- (plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +- (plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +- (plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p +-------------------- +-------------------- +### Response +The error message indicates that the parameter `?p` was not defined in the action parameters section, which is necessary for the preconditions and effects to be valid. To resolve this, I will define `?p` as a package parameter in the action parameters list. Additionally, I will ensure that the preconditions and effects are correctly structured to reflect the action of flying an airplane from one city to another. + +Here is the corrected PDDL model: + +### Action Parameters +``` +- ?a - plane: the airplane to fly +- ?from - location: the departure airport location +- ?to - location: the destination airport location +- ?p - package: the package being transported +``` + +### Action Preconditions +``` +(and + (plane-at ?a ?from) + (not (plane-holding ?a ?p)) + (plane-has-space ?a) +) +``` + +### Action Effects +``` +(and + (not (plane-at ?a ?from)) + (plane-at ?a ?to) + (plane-holding ?a ?p) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and that the action's preconditions and effects are logically consistent with the intended operation of flying an airplane. + +-------------------- +Extracted predicates: + +1. (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +2. (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +3. (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +4. (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +5. (plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +6. (plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +7. (plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_1.txt b/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_1.txt new file mode 100644 index 0000000..9c16d25 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/logistics/gpt-4o-mini_0_1.txt @@ -0,0 +1,274 @@ + + +#################### +Action: Load a package into a truck +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +- (plane-at ?a - plane ?l - location): true if the airplane ?a is located at location ?l +- (plane-has-space ?a - plane): true if the airplane ?a has space to load more packages +- (plane-holding ?a - plane ?p - package): true if the airplane ?a is currently holding package ?p +-------------------- +-------------------- +### Action Parameters +``` +- ?p - package: the package to load +- ?t - truck: the truck to load the package into +- ?l - location: the location where the truck is located +``` + +### Action Preconditions +``` +(and + (package-at ?p ?l) + (truck-at ?t ?l) + (truck-has-space ?t) +) +``` + +### Action Effects +``` +(and + (not (package-at ?p ?l)) + (truck-holding ?t ?p) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Unload a package from a truck +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Action Parameters +``` +- ?p - package: the package to unload +- ?t - truck: the truck from which to unload the package +- ?l - location: the location where the package will be unloaded +``` + +### Action Preconditions +``` +(and + (truck-at ?t ?l) + (truck-holding ?t ?p) +) +``` + +### Action Effects +``` +(and + (not (truck-holding ?t ?p)) + (package-at ?p ?l) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Load a package into an airplane +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Response +The error message highlights that the parameter `?t` in the preconditions and the predicate `truck-has-space` was not defined in the action parameters. To resolve this, I will define `?t` as a truck parameter in the action parameters section. Additionally, I will ensure that all other parameters are clearly defined and that the action is coherent with the available predicates. + +Here’s the corrected action with the necessary adjustments: + +### Action Parameters +``` +- ?p - package: the package to load into the truck +- ?t - truck: the truck that will load the package +- ?l - location: the location where the truck is located +``` + +### Action Preconditions +``` +(and + (package-at ?p ?l) + (truck-at ?t ?l) + (truck-has-space ?t) +) +``` + +### Action Effects +``` +(and + (not (package-at ?p ?l)) + (truck-holding ?t ?p) +) +``` + +### New Predicates +``` +(truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +``` + +In this correction, I have defined the truck parameter `?t` in the action parameters section. The preconditions now correctly check that the truck is at the same location as the package and has space to load it. The effects indicate that the package is no longer at its original location and that the truck is now holding the package. The new predicate `truck-holding` is introduced to represent the relationship between the truck and the package being loaded. + + +#################### +Action: Unload a package from an airplane +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Response +The error message indicates that the preconditions incorrectly referenced a plane instead of a location for the `package-at` predicate. To resolve this, I will adjust the preconditions to ensure they accurately reflect the relationships between the package, the truck, and the locations involved. Here’s the corrected action with the necessary modifications. + +### Action Parameters +``` +- ?p - package: the package to unload +- ?a - plane: the airplane from which to unload the package +- ?l - location: the location where the package will be unloaded +- ?t - truck: the truck that will be used for unloading +``` + +### Action Preconditions +``` +(and + (truck-at ?t ?l) ; The truck is at the unloading location + (package-at ?p ?a) ; The package is currently at the airplane + (truck-has-space ?t) ; The truck has space to load the package +) +``` + +### Action Effects +``` +(and + (not (package-at ?p ?a)) ; The package is no longer at the airplane + (package-at ?p ?l) ; The package is now at the unloading location + (truck-holding ?t ?p) ; The truck is now holding the package +) +``` + +### New Predicates +``` +``` + +This revision ensures that the preconditions are correctly defined, allowing for the action to be generated without errors. The relationships between the package, truck, and locations are now accurately represented. + + +#################### +Action: Drive a truck from one location to another in a city +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Response +The error message indicates that the `truck-at` predicate was incorrectly provided with three parameters instead of the required two. The object types should not be included in the preconditions, and only the variable names should be used. I will correct the preconditions accordingly while keeping the rest of the action intact. + +### Action Parameters +``` +- ?t - truck: the truck to drive +- ?l1 - location: the starting location +- ?l2 - location: the destination location +- ?c - city: the city where the locations are located +``` + +### Action Preconditions +``` +(and + (truck-at ?t ?l1) + (truck-has-space ?t) +) +``` + +### Action Effects +``` +(and + (not (truck-at ?t ?l1)) + (truck-at ?t ?l2) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Fly an airplane from one city to another +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +- (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +- (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +- (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +-------------------- +-------------------- +### Response +The error message correctly identifies that the precondition incorrectly uses a `plane` in the `truck-at` predicate, which should reference a `truck`. To resolve this, I will replace the `truck-at` predicate with a new predicate that accurately reflects the airplane's location. I will also ensure that the action parameters and effects are consistent with this change. + +## Action +Fly an airplane from one city to another + +### Action Parameters +``` +- ?plane - plane: the airplane to be flown +- ?from - location: the starting airport location +- ?to - location: the destination airport location +``` + +### Action Preconditions +``` +(and + (plane-at ?plane ?from) + (airport-location ?from) + (airport-location ?to) +) +``` + +### Action Effects +``` +(and + (not (plane-at ?plane ?from)) + (plane-at ?plane ?to) +) +``` + +### New Predicates +``` +- (airport-location ?l - location): true if the location ?l is an airport +- (plane-at ?p - plane ?l - location): true if the plane ?p is located at location ?l +``` + +This correction ensures that the action accurately reflects the use of an airplane and its location, while maintaining the integrity of the existing predicates. + +-------------------- +Extracted predicates: + +1. (package-at ?p - package ?l - location): true if the package ?p is located at location ?l +2. (truck-at ?t - truck ?l - location): true if the truck ?t is located at location ?l +3. (truck-has-space ?t - truck): true if the truck ?t has space to load more packages +4. (truck-holding ?t - truck ?p - package): true if the truck ?t is currently holding package ?p +5. (airport-location ?l - location): true if the location ?l is an airport +6. (plane-at ?p - plane ?l - location): true if the plane ?p is located at location ?l \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/tyreworld/domain.pddl b/paper_reconstructions/llm+dm/results/tyreworld/domain.pddl new file mode 100644 index 0000000..bb73346 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/tyreworld/domain.pddl @@ -0,0 +1,253 @@ +(define (domain tyreworld) + (:requirements + :typing :negative-preconditions :disjunctive-preconditions :conditional-effects :equality) + + (:types + object + small_object - object + tool - small_object + wheel - small_object + nut - small_object + container - object + hub - object + ) + + (:predicates + (container-open ?c - container) ; true if the container ?c is open + (object-in-container ?o - small_object ?c - container) ; true if the object ?o is located in the container ?c + (robot-holding ?o - small_object) ; true if the robot is currently holding the object ?o + (hub-on-ground ?h - hub) ; true if the hub ?h is on the ground and not jacked up + (nut-loosened ?n - nut) ; true if the nut ?n has been loosened + (unfastened ?h - hub) ; true if the hub ?h has been unfastened + (wheel-removed ?w - wheel) ; true if the wheel ?w has been removed from its hub + (wheel-inflated ?w - wheel) ; true if the wheel ?w has been inflated + ) + + (:action Open a container + :parameters ( + ?c - container + ?o - small_object + ) + :precondition + (and + (not (container-open ?c)) + (robot-holding ?o) + (object-in-container ?o ?c) + ) + :effect + (and + (container-open ?c) + (not (robot-holding ?o)) + ) + ) + + (:action Close a container + :parameters ( + ?c - container + ) + :precondition + (and + (container-open ?c) + (not (robot-holding ?o)) + ) + :effect + (and + (not (container-open ?c)) + ) + ) + + (:action Fetch an object from a container + :parameters ( + ?o - small_object + ?c - container + ) + :precondition + (and + (container-open ?c) + (object-in-container ?o ?c) + ) + :effect + (and + (not (object-in-container ?o ?c)) + (robot-holding ?o) + ) + ) + + (:action Put away an object into a container + :parameters ( + ?o - small_object + ?c - container + ) + :precondition + (and + (robot-holding ?o) + (container-open ?c) + ) + :effect + (and + (not (robot-holding ?o)) + (object-in-container ?o ?c) + ) + ) + + (:action Loosen a nut in a hub + :parameters ( + ?n - nut + ?h - hub + ) + :precondition + (and + (robot-holding ?n) + (hub-on-ground ?h) + ) + :effect + (and + (not (robot-holding ?n)) + (nut-loosened ?n) + ) + ) + + (:action Tighten a nut in a hub + :parameters ( + ?n - nut + ?h - hub + ) + :precondition + (and + (robot-holding ?n) + (hub-on-ground ?h) + (not (nut-loosened ?n)) + ) + :effect + (and + (not (robot-holding ?n)) + (nut-loosened ?n) + ) + ) + + (:action Jack up a hub + :parameters ( + ?h - hub + ) + :precondition + (and + (hub-on-ground ?h) + ) + :effect + (and + (not (hub-on-ground ?h)) + ) + ) + + (:action Jack down a hub + :parameters ( + ?h - hub + ?o - small_object + ) + :precondition + (and + (hub-on-ground ?h) + (robot-holding ?o) + ) + :effect + (and + (not (hub-on-ground ?h)) + (not (robot-holding ?o)) + ) + ) + + (:action Unfasten a hub + :parameters ( + ?h - hub + ?n - nut + ) + :precondition + (and + (robot-holding ?n) + (nut-loosened ?n) + (hub-on-ground ?h) + ) + :effect + (and + (not (robot-holding ?n)) + (not (nut-loosened ?n)) + (unfastened ?h) + (robot-holding ?n) + ) + ) + + (:action Fasten a hub + :parameters ( + ?h - hub + ?n - nut + ) + :precondition + (and + (robot-holding ?n) + (unfastened ?h) + (nut-loosened ?n) + (hub-on-ground ?h) + ) + :effect + (and + (not (robot-holding ?n)) + (not (unfastened ?h)) + (hub-on-ground ?h) + ) + ) + + (:action Remove wheel from hub + :parameters ( + ?w - wheel + ?h - hub + ) + :precondition + (and + (robot-holding ?w) + (hub-on-ground ?h) + (unfastened ?h) + ) + :effect + (and + (not (robot-holding ?w)) + (not (unfastened ?h)) + (not (hub-on-ground ?h)) + (wheel-removed ?w) + ) + ) + + (:action Put wheel on hub + :parameters ( + ?w - wheel + ?h - hub + ) + :precondition + (and + (robot-holding ?w) + (unfastened ?h) + (hub-on-ground ?h) + ) + :effect + (and + (not (robot-holding ?w)) + (not (wheel-removed ?w)) + (wheel-removed ?w) + ) + ) + + (:action Inflate wheel + :parameters ( + ?w - wheel + ) + :precondition + (and + (robot-holding ?w) + (not (wheel-removed ?w)) + ) + :effect + (and + (not (robot-holding ?w)) + (wheel-inflated ?w) + ) + ) +) \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_0.txt b/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_0.txt new file mode 100644 index 0000000..a8e03f6 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_0.txt @@ -0,0 +1,522 @@ + + +#################### +Action: Open a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates: +No predicate has been defined yet +-------------------- +-------------------- +### Action Parameters +``` +- ?c - container: the container to open +``` + +### Action Preconditions +``` +(and + (not (container-open ?c)) +) +``` + +### Action Effects +``` +(and + (container-open ?c) +) +``` + +### New Predicates +``` +- (container-open ?c - container): true if the container ?c is open +``` + + +#################### +Action: Close a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +-------------------- +-------------------- +### Action Parameters +``` +- ?c - container: the container to close +``` + +### Action Preconditions +``` +(and + (container-open ?c) +) +``` + +### Action Effects +``` +(and + (not (container-open ?c)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Fetch an object from a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +-------------------- +-------------------- +### Action Parameters +``` +- ?o - small_object: the object to take from the container +- ?c - container: the container from which the object is taken +``` + +### Action Preconditions +``` +(and + (container-open ?c) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (robot-holding ?o) + (not (object-in-container ?o ?c)) +) +``` + +### New Predicates +``` +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +``` + + +#################### +Action: Put away an object into a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?o - small_object: the object to put into the container +- ?c - container: the container to put the object into +``` + +### Action Preconditions +``` +(and + (robot-holding ?o) + (container-open ?c) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-in-container ?o ?c) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Loosen a nut in a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?n - nut: the nut to loosen +- ?h - hub: the hub containing the nut +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (nut-loosened ?n) +) +``` + +### New Predicates +``` +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +``` + + +#################### +Action: Tighten a nut in a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?n - nut: the nut to tighten +- ?h - hub: the hub where the nut is located +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (hub-on-ground ?h) + (not (nut-loosened ?n)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (nut-loosened ?n) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Jack up a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to jack up +``` + +### Action Preconditions +``` +(and + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (hub-on-ground ?h)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Jack down a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Response +The error message indicates that the precondition incorrectly uses the `robot-holding` predicate with a `hub` instead of a `small_object`. To correct this, I will change the action to specify that the robot must be holding a `small_object` instead. Additionally, since the action involves jacking down a hub, I will introduce a new predicate to represent the action of the robot holding a small object while jacking down the hub. + +## Action +Jack down a hub + +### Action Parameters +``` +- ?h - hub: the hub to jack down +- ?o - small_object: the small object the robot is holding +``` + +### Action Preconditions +``` +(and + (hub-on-ground ?h) + (robot-holding ?o) +) +``` + +### Action Effects +``` +(and + (not (hub-on-ground ?h)) + (robot-holding ?o) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Unfasten a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to unfasten +- ?n - nut: the nut on the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (nut-loosened ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (not (nut-loosened ?n)) + (not (hub-on-ground ?h)) + (robot-holding ?n) +) +``` + +### New Predicates +``` +- (hub-unfastened ?h - hub): true if the hub ?h has been unfastened +``` + + +#################### +Action: Fasten a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to fasten +- ?n - nut: the nut to place on the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (hub-on-ground ?h) + (nut-loosened ?n) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (hub-fastened ?h) +) +``` + +### New Predicates +``` +- (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +``` + + +#################### +Action: Remove wheel from hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +-------------------- +-------------------- +### Action Parameters +``` +- ?w - wheel: the wheel to remove +- ?h - hub: the hub from which the wheel is being removed +- ?n - nut: the nut that fastens the wheel to the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (hub-fastened ?h) + (nut-loosened ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?w)) + (not (hub-fastened ?h)) + (not (nut-loosened ?n)) + (not (hub-on-ground ?h)) + (wheel-removed ?w) +) +``` + +### New Predicates +``` +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +``` + + +#################### +Action: Put wheel on hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +-------------------- +-------------------- +### Response +The error message indicates that the parameter `?n` in the preconditions and the predicate `nut-loosened` is undefined. To resolve this, I will define `?n` as a parameter of type `nut` in the action parameters section. This will ensure that all parameters used in the preconditions and effects are properly defined. Here’s the corrected version of the action: + +### Action Parameters +``` +- ?w - wheel: the wheel to put on the hub +- ?h - hub: the hub to put the wheel on +- ?n - nut: the nut that is associated with the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (hub-on-ground ?h) + (not (hub-fastened ?h)) + (nut-loosened ?n) ; Now ?n is defined as a nut + (not (wheel-removed ?w)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?w)) + (not (wheel-removed ?w)) + (hub-fastened ?h) +) +``` + +### New Predicates +``` +``` + +This revision ensures that all parameters are defined and the action can be executed without any errors related to undefined parameters. + + +#################### +Action: Inflate wheel +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +-------------------- +-------------------- +### Action Parameters +``` +- ?w - wheel: the wheel to inflate +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (not (wheel-removed ?w)) +) +``` + +### Action Effects +``` +(and + (not (wheel-removed ?w)) + (wheel-inflated ?w) +) +``` + +### New Predicates +``` +- (wheel-inflated ?w - wheel): true if the wheel ?w has been inflated +``` + +-------------------- +Extracted predicates: + +1. (container-open ?c - container): true if the container ?c is open +2. (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +3. (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +4. (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +5. (nut-loosened ?n - nut): true if the nut ?n has been loosened +6. (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +7. (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +8. (wheel-inflated ?w - wheel): true if the wheel ?w has been inflated \ No newline at end of file diff --git a/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_1.txt b/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_1.txt new file mode 100644 index 0000000..7d98998 --- /dev/null +++ b/paper_reconstructions/llm+dm/results/tyreworld/gpt-4o-mini_0_1.txt @@ -0,0 +1,533 @@ + + +#################### +Action: Open a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (hub-fastened ?h - hub): true if the hub ?h has been fastened with a nut +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +- (wheel-inflated ?w - wheel): true if the wheel ?w has been inflated +-------------------- +-------------------- +### Response +The error message indicates that the precondition for the action incorrectly specifies that the robot is holding a container instead of a small object. To correct this, I will modify the preconditions to ensure that the robot is holding a small object that is located in the container. Here’s the revised action: + +### Action Parameters +``` +- ?c - container: the container to open +- ?o - small_object: the small object that the robot is holding +``` + +### Action Preconditions +``` +(and + (not (container-open ?c)) + (robot-holding ?o) + (object-in-container ?o ?c) +) +``` + +### Action Effects +``` +(and + (container-open ?c) + (not (robot-holding ?o)) +) +``` + +### New Predicates +``` +``` + +This revision ensures that the robot is holding a small object that is inside the specified container, aligning with the available predicates and correcting the initial error. + + +#################### +Action: Close a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Response +The error message indicates that the precondition incorrectly uses the keyword "exists," which is not allowed in this context. To resolve this, we need to rephrase the precondition to avoid using "exists" while ensuring that the robot is not holding any small object before closing the container. I will adjust the preconditions accordingly. + +### Action Parameters +``` +- ?c - container: the container to close +``` + +### Action Preconditions +``` +(and + (container-open ?c) + (not (robot-holding ?o)) +) +``` + +### Action Effects +``` +(and + (not (container-open ?c)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Fetch an object from a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?o - small_object: the object to take +- ?c - container: the container from which to take the object +``` + +### Action Preconditions +``` +(and + (container-open ?c) + (object-in-container ?o ?c) +) +``` + +### Action Effects +``` +(and + (not (object-in-container ?o ?c)) + (robot-holding ?o) +) +``` + +### New Predicates +No new predicates were needed, thus we leave empty +``` +``` + + +#################### +Action: Put away an object into a container +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?o - small_object: the object to put into the container +- ?c - container: the container to put the object into +``` + +### Action Preconditions +``` +(and + (robot-holding ?o) + (container-open ?c) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?o)) + (object-in-container ?o ?c) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Loosen a nut in a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +-------------------- +-------------------- +### Action Parameters +``` +- ?n - nut: the nut to loosen +- ?h - hub: the hub containing the nut +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (nut-loosened ?n) +) +``` + +### New Predicates +``` +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +``` + + +#################### +Action: Tighten a nut in a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?n - nut: the nut to tighten +- ?h - hub: the hub where the nut is located +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (hub-on-ground ?h) + (not (nut-loosened ?n)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (nut-loosened ?n) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Jack up a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to jack up +``` + +### Action Preconditions +``` +(and + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (hub-on-ground ?h)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Jack down a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Response +The error message indicates that the precondition incorrectly specifies the `robot-holding` predicate with a `hub` instead of a `small_object`. To correct this, I will change the action to reflect that the robot must be holding a `small_object` instead. Additionally, I will adjust the effects to ensure that the robot is no longer holding the hub after the action is completed. + +Here is the corrected action: + +### Action Parameters +``` +- ?h - hub: the hub to jack down +- ?o - small_object: the small object the robot is holding +``` + +### Action Preconditions +``` +(and + (hub-on-ground ?h) + (robot-holding ?o) +) +``` + +### Action Effects +``` +(and + (not (hub-on-ground ?h)) + (not (robot-holding ?o)) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Unfasten a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to unfasten +- ?n - nut: the nut on the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (nut-loosened ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (not (nut-loosened ?n)) + (unfastened ?h) + (robot-holding ?n) +) +``` + +### New Predicates +``` +- (unfastened ?h - hub): true if the hub ?h has been unfastened +``` + + +#################### +Action: Fasten a hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (unfastened ?h - hub): true if the hub ?h has been unfastened +-------------------- +-------------------- +### Action Parameters +``` +- ?h - hub: the hub to fasten +- ?n - nut: the nut to put on the hub +``` + +### Action Preconditions +``` +(and + (robot-holding ?n) + (unfastened ?h) + (nut-loosened ?n) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?n)) + (not (unfastened ?h)) + (hub-on-ground ?h) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Remove wheel from hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (unfastened ?h - hub): true if the hub ?h has been unfastened +-------------------- +-------------------- +### Action Parameters +``` +- ?w - wheel: the wheel to remove +- ?h - hub: the hub from which the wheel is being removed +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (hub-on-ground ?h) + (unfastened ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?w)) + (not (unfastened ?h)) + (not (hub-on-ground ?h)) + (wheel-removed ?w) +) +``` + +### New Predicates +``` +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +``` + + +#################### +Action: Put wheel on hub +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (unfastened ?h - hub): true if the hub ?h has been unfastened +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +-------------------- +-------------------- +### Action Parameters +``` +- ?w - wheel: the wheel to put on the hub +- ?h - hub: the hub to put the wheel on +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (unfastened ?h) + (hub-on-ground ?h) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?w)) + (not (wheel-removed ?w)) + (wheel-removed ?w) +) +``` + +### New Predicates +``` +``` + + +#################### +Action: Inflate wheel +#################### +-------------------- +You can create and define new predicates, but you may also reuse the following predicates:- (container-open ?c - container): true if the container ?c is open +- (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +- (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +- (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +- (nut-loosened ?n - nut): true if the nut ?n has been loosened +- (unfastened ?h - hub): true if the hub ?h has been unfastened +- (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +-------------------- +-------------------- +### Action Parameters +``` +- ?w - wheel: the wheel to inflate +``` + +### Action Preconditions +``` +(and + (robot-holding ?w) + (not (wheel-removed ?w)) +) +``` + +### Action Effects +``` +(and + (not (robot-holding ?w)) + (wheel-inflated ?w) +) +``` + +### New Predicates +``` +- (wheel-inflated ?w - wheel): true if the wheel ?w has been inflated +``` + +-------------------- +Extracted predicates: + +1. (container-open ?c - container): true if the container ?c is open +2. (object-in-container ?o - small_object ?c - container): true if the object ?o is located in the container ?c +3. (robot-holding ?o - small_object): true if the robot is currently holding the object ?o +4. (hub-on-ground ?h - hub): true if the hub ?h is on the ground and not jacked up +5. (nut-loosened ?n - nut): true if the nut ?n has been loosened +6. (unfastened ?h - hub): true if the hub ?h has been unfastened +7. (wheel-removed ?w - wheel): true if the wheel ?w has been removed from its hub +8. (wheel-inflated ?w - wheel): true if the wheel ?w has been inflated \ No newline at end of file diff --git a/paper_reconstructions/nl2plan/main.py b/paper_reconstructions/nl2plan/main.py index 106de70..a732d43 100644 --- a/paper_reconstructions/nl2plan/main.py +++ b/paper_reconstructions/nl2plan/main.py @@ -302,5 +302,5 @@ def run_nl2plan(args, domain: str, problem: str): parser.add_argument("--planner", type=str, default="downward/fast-downward.py") args = parser.parse_args() - # run LLM+P method + # run NL2Plan run_nl2plan(args=args, domain="blocksworld", problem="task1") diff --git a/paper_reconstructions/nl2plan/nl2plan/action_construction.py b/paper_reconstructions/nl2plan/nl2plan/action_construction.py index 911ac97..2bdf2b7 100644 --- a/paper_reconstructions/nl2plan/nl2plan/action_construction.py +++ b/paper_reconstructions/nl2plan/nl2plan/action_construction.py @@ -131,7 +131,7 @@ def construct_action( error_template = f.read().strip() error_prompt = error_template.replace("{action_name}", action_name) error_prompt = error_prompt.replace("{action_desc}", action_desc) - error_prompt = error_prompt.replace("{predicate_list}", predicate_str) + error_prompt = error_prompt.replace("{predicates}", predicate_str) error_prompt = error_prompt.replace("{error_msg}", error_msg) error_prompt = error_prompt.replace("{llm_response}", llm_response) diff --git a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt index ec6fc09..f813944 100644 --- a/paper_reconstructions/nl2plan/prompts/action_construction/error.txt +++ b/paper_reconstructions/nl2plan/prompts/action_construction/error.txt @@ -11,7 +11,7 @@ Make sure to reply with all four parts of the action: parameters, preconditions, {action_desc} ### Available Predicates -{predicate_list} +{predicates} ### Original Response {llm_response} \ No newline at end of file From f1a45b2a6a4233aa2278871ad606a42daf28c011 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Fri, 17 Jan 2025 12:19:31 -0500 Subject: [PATCH 13/15] paper reconstructions + updated papers --- README.md | 101 +++++++++++------ docs/paper_recreations.rst | 219 ++++++++++++++++++++++++++----------- 2 files changed, 226 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index df4a951..de2bedc 100644 --- a/README.md +++ b/README.md @@ -163,46 +163,85 @@ For ease of use, our library contains submodule [FastDownward](https://github.co **IMPORTANT** FastDownward is a submodule in L2P. To use the planner, you must clone the GitHub repo of [FastDownward](https://github.com/aibasel/downward/tree/308812cf7315fe896dbcd319493277d82aa36bd2) and run the `planner_path` to that directory. ## Current Works Reconstructed Using L2P -The following are papers that have been reconstructed so far. This list will be updated in the future. - -- [x] `NL2Plan` -- [x] `LLM+DM` -- [x] `LLM+P` -- [x] `PROC2PDDL` +The following are papers that have been reconstructed so far. *Checked* boxes are completed, *unchecked* are papers currently in queue to be reconstructed. This list will be updated in the future. + +- [x] `P+S` [[paper]](https://arxiv.org/abs/2205.05718) +- [x] `LLM+P` [[paper]](https://arxiv.org/abs/2304.11477) +- [x] `PROC2PDDL` [[paper]](https://arxiv.org/abs/2403.00092) +- [x] `LLM+DM` [[paper]](https://arxiv.org/abs/2305.14909) +- [x] `NL2Plan` [[paper]](https://arxiv.org/abs/2405.04215) +- [ ] `LLM+DP` [[paper]](https://arxiv.org/abs/2308.06391) +- [ ] `LLM+EW` [[paper]](https://arxiv.org/abs/2407.12979) +- [ ] `LLM+Consistency` [[paper]](https://arxiv.org/abs/2404.07751) +- [ ] `LaMMa-P`[[paper]](https://arxiv.org/abs/2409.20560) ## Current Model Construction Works -This section provides a taxonomy of research within Model Construction. **More detailed overview coming soon**. +This section presents a taxonomy of research within Model Construction, organized into three broad categories: *Model Generation*, *Model Editing*, and *Model Benchmarks*. Within each category, the most recent contributions are listed last. -**Model Generation** +### Model Generation +This category can be further divided into: *Task Modelling*, ; *Domain Modelling*, *Hybrid Modelling* ***Task Translation Frameworks*** -- **"Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behaviour in out-of-distribution reasoning tasks"** Collins et al. (2022) [paper](https://arxiv.org/abs/2205.05718) [code](https://github.com/collinskatie/structured_flexible_and_robust) -- **"Translating natural language to planning goals with large-language models"** Xie et al. (2023) [paper](https://arxiv.org/abs/2302.05128) [code](https://github.com/clear-nus/gpt-pddl) -- **"Faithful Chain-of-Thought Reasoning"** Lyu et al. (2023) [paper](https://arxiv.org/abs/2301.13379) [code](https://github.com/veronica320/faithful-cot) -- **"LLM+P: Empowering Large Language Models with Optimal Planning Proficiency"** Liu et al. (2023) [paper](https://arxiv.org/abs/2304.11477) [code](https://github.com/Cranial-XIX/llm-pddl) -- **"Dynamic Planning with a LLM"** Dagan et al. (2023) [paper](https://arxiv.org/abs/2308.06391) [code](https://github.com/itl-ed/llm-dp) -- **"TIC: Translate-Infer-Compile for accurate 'text to plan' using LLMs and logical intermediate representations"** Agarwal and Sreepathy (2024) [paper](https://arxiv.org/abs/2402.06608) [code](N/A) -- **"PDDLEGO: Iterative Planning in Textual Environments"** Zhang et al. (2024) [paper](https://arxiv.org/abs/2405.19793) [code](https://github.com/zharry29/nl-to-pddl) +- **"Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behaviour in out-of-distribution reasoning tasks"** Collins et al. (2022) [[paper]](https://arxiv.org/abs/2205.05718) [[code]](https://github.com/collinskatie/structured_flexible_and_robust) +- **"Translating natural language to planning goals with large-language models"** Xie et al. (2023) [[paper]](https://arxiv.org/abs/2302.05128) [[code]](https://github.com/clear-nus/gpt-pddl) +- **"Faithful Chain-of-Thought Reasoning"** Lyu et al. (2023) [[paper]](https://arxiv.org/abs/2301.13379) [[code]](https://github.com/veronica320/faithful-cot) +- **"LLM+P: Empowering Large Language Models with Optimal Planning Proficiency"** Liu et al. (2023) [[paper]](https://arxiv.org/abs/2304.11477) [[code]](https://github.com/Cranial-XIX/llm-pddl) +- **"Dynamic Planning with a LLM"** Dagan et al. (2023) [[paper]](https://arxiv.org/abs/2308.06391) [[code]](https://github.com/itl-ed/llm-dp) +- **"AutoGPT+P: Affordance-based Task Planning with Large Language Models"** Birr et al. (2024) [[paper]](https://arxiv.org/abs/2402.10778) [[code]](https://git.h2t.iar.kit.edu/sw/autogpt-p) +- **"TIC: Translate-Infer-Compile for accurate 'text to plan' using LLMs and logical intermediate representations"** Agarwal and Sreepathy (2024) [[paper]](https://arxiv.org/abs/2402.06608) [[code N/A]]() +- **"PDDLEGO: Iterative Planning in Textual Environments"** Zhang et al. (2024) [[paper]](https://arxiv.org/abs/2405.19793) [[code]](https://github.com/zharry29/nl-to-pddl) +- **"TwoStep: Multi-agent Task Planning using Classical Planners and Large Language Models"** Singh et al. (2024) [[paper]](https://arxiv.org/abs/2403.17246) [[code]](https://glamor-usc.github.io/twostep/) +- **"Towards Human Awareness in Robot Task Planning with Large Language Models"** Liu et al. (2024) [[paper]](https://arxiv.org/abs/2404.11267) [[code N/A]]() +- **"Anticipate & Collab: Data-driven Task Anticipation and Knowledge-driven Planning for Human-robot Collaboration"** Singh et al. (2024) [[paper]](https://arxiv.org/abs/2404.03587) [[code]](https://github.com/dataplan-hrc/DaTAPlan) +- **"PlanCollabNL: Leveraging Large Language Models for Adaptive Plan Generation in Human-Robot Collaboration"** Izquierdo-Badiola et al. (2024) [[paper]](https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=10610055) [[code N/A]]() +- **"TRIP-PAL: Travel Planning with Guarantees by Combining Large Language Models and Automated Planners"** Rosa et al. (2024) [[paper]](https://arxiv.org/abs/2406.10196) [[code N/A]]() +- **"Bootstrapping Object-level Planning with Large Language Models"** Paulius et al. (2024) [[paper]](https://arxiv.org/abs/2409.12262) [[code N/A]]() +- **"LaMMA-P: Generalizable Multi-Agent Long-Horizon Task Allocation and Planning with LM-Driven PDDL Planner"** Zhang et al. (2024) [[paper]](https://arxiv.org/abs/2409.20560) [[code]](https://drive.google.com/drive/folders/1dFfwJve4isw8E92bEQCSxIcQLmax-mqM) ***Domain Translation Frameworks*** -- **"Learning adaptive planning representations with natural language guidance"** Wong et al. (2023) [paper](https://arxiv.org/abs/2312.08566) [code](N/A) -- **"Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning"** Guan et al. (2023) [paper](https://arxiv.org/abs/2305.14909) [code](https://github.com/GuanSuns/LLMs-World-Models-for-Planning) -- **"PROC2PDDL: Open-Domain Planning Representations from Texts"** Zhang et al. (2024) [paper](https://arxiv.org/abs/2403.00092) [code](https://github.com/zharry29/proc2pddl) +- **"Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning"** Guan et al. (2023) [[paper]](https://arxiv.org/abs/2305.14909) [[code]](https://github.com/GuanSuns/LLMs-World-Models-for-Planning) +- **"Learning Compositional Behaviors from Demonstration and Language"** Liu et al. (2024) [[paper]](https://blade-bot.github.io) [[code N/A]]() +- **"Learning adaptive planning representations with natural language guidance"** Wong et al. (2023) [[paper]](https://arxiv.org/abs/2312.08566) [[code N/A]]() +- **"Integrating Action Knowledge and LLMs for Task Planning and Situation Handling in Open Worlds"** Ding et al. (2023) [[paper]](https://arxiv.org/abs/2305.17590) [[code]](https://github.com/yding25/GPT-Planner) +- **"Using Large Language Models to Extract Planning Knowledge from Common Vulnerabilities and Exposures"** Oates et al. (2024) [[paper]](https://icaps24.icaps-conference.org/program/workshops/keps-papers/KEPS-24_paper_12.pdf) [[code]](https://github.com/ronwalf/CLLaMP) +- **"PROC2PDDL: Open-Domain Planning Representations from Texts"** Zhang et al. (2024) [[paper]](https://arxiv.org/abs/2403.00092) [[code]](https://github.com/zharry29/proc2pddl) +- **"Autonomously Learning World-Model Representations For Efficient Robot Planning"** Shah (2024) [[paper]](https://keep.lib.asu.edu/items/193613) [[code N/A]]() +- **"Language-Augmented Symbolic Planner for Open-World Task Planning"** Chen at al. (2024) [[paper]](https://arxiv.org/abs/2407.09792) [[code N/A]]() +- **"Making Large Language Models into World Models with Precondition and Effect Knowledge"** Xie at al. (2024) [[paper]](https://arxiv.org/abs/2409.12278) [[code N/A]]() +- **"Planning in the Dark: LLM-Symbolic Planning Pipeline without Experts"** Huang et al. (2024) [[paper]](https://arxiv.org/abs/2409.15915) [[code]](https://anonymous.4open.science/r/Official-LLM-Symbolic-Planning-without-Experts-7466/README.md) ***Hybrid Translation Frameworks*** -- **"There and Back Again: Extracting Formal Domains for Controllable Neurosymbolic Story Authoring"** Kelly et al. (2023) [paper](https://ojs.aaai.org/index.php/AIIDE/article/view/27502/27275) [code](https://github.com/alex-calderwood/there-and-back) -- **"DELTA: Decomposed Efficient Long-Term Robot Task Planning using Large Language Models"** Liu et al. (2024) [paper](https://arxiv.org/abs/2404.03275) [code](N/A) -- **"ISR-LLM: Iterative Self-Refined Large Language Model for Long-Horizon Sequential Task Planning"** Zhou et al. (2023) [paper](https://arxiv.org/abs/2308.13724) [code](https://github.com/ma-labo/ISR-LLM) -- **"Consolidating Trees of Robotic Plans Generated Using Large Language Models to Improve Reliability"** Sakib and Sun (2024) [paper](https://arxiv.org/abs/2401.07868) [code](N/A) -- **"NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions"** Gestrin et al. (2024) [paper](https://arxiv.org/abs/2405.04215) [code](https://github.com/mrlab-ai/NL2Plan) -- **"Leveraging Environment Interaction for Automated PDDL Generation and Planning with Large Language Models"** Mahdavi et al. (2024) [paper](https://arxiv.org/abs/2407.12979) [code]() -- **"Generating consistent PDDL domains with Large Language Models"** Smirnov et al. (2024) [paper](https://arxiv.org/abs/2404.07751) [code](N/A) - -**Model Editing and Benchmarking** -- **"Exploring the limitations of using large language models to fix planning tasks"** Gragera and Pozanco (2023) [paper](https://icaps23.icaps-conference.org/program/workshops/keps/KEPS-23_paper_3645.pdf) [code](N/A) -- **"Can LLMs Fix Issues with Reasoning Models? Towards More Likely Models for AI Planning"** Caglar et al. (2024) [paper](https://arxiv.org/abs/2311.13720) [code](N/A) -- **"Large Language Models as Planning Domain Generators"** Oswald et al. (2024) [paper](https://arxiv.org/abs/2405.06650) [code](https://github.com/IBM/NL2PDDL) -- **"Planetarium: A Rigorous Benchmark for Translating Text to Structured Planning Languages"** Zuo et al. (2024) [paper](https://arxiv.org/abs/2407.03321) [code](https://github.com/batsresearch/planetarium) +- **"There and Back Again: Extracting Formal Domains for Controllable Neurosymbolic Story Authoring"** Kelly et al. (2023) [[paper]](https://ojs.aaai.org/index.php/AIIDE/article/view/27502/27275) [[code]](https://github.com/alex-calderwood/there-and-back) +- **"The Neuro-Symbolic Inverse Planning Engine (NIPE): Modeling Probabilistic Social Inferences from Linguistic Inputs"** Ying et al. (2023) [[paper]](https://arxiv.org/abs/2306.14325) [[code N/A]]() +- **"MORPHeus: a Multimodal One-armed Robot-assisted Peeling System with Human Users In-the-loop"** Ye et al. (2024) [[paper]](https://emprise.cs.cornell.edu/morpheus/) [[code N/A]]() +- **"InterPreT: Interactive Predicate Learning from Language Feedback for Generalizable Task Planning"** Han et al. (2024) [[paper]](https://interpret-robot.github.io) [[code]](https://github.com/hmz-15/interactive-predicate-learning) +- **"Toward a Method to Generate Capability Ontologies from Natural Language Descriptions"** Silva et al. (2024) [[paper]](https://arxiv.org/abs/2406.07962) [[code N/A]]() +- **"DELTA: Decomposed Efficient Long-Term Robot Task Planning using Large Language Models"** Liu et al. (2024) [[paper]](https://arxiv.org/abs/2404.03275) [[code N/A]]() +- **"ISR-LLM: Iterative Self-Refined Large Language Model for Long-Horizon Sequential Task Planning"** Zhou et al. (2023) [[paper]](https://arxiv.org/abs/2308.13724) [[code]](https://github.com/ma-labo/ISR-LLM) +- **"Consolidating Trees of Robotic Plans Generated Using Large Language Models to Improve Reliability"** Sakib and Sun (2024) [[paper]](https://arxiv.org/abs/2401.07868) [[code N/A]]() +- **"NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions"** Gestrin et al. (2024) [[paper]](https://arxiv.org/abs/2405.04215) [[code]](https://github.com/mrlab-ai/NL2Plan) +- **"Leveraging Environment Interaction for Automated PDDL Generation and Planning with Large Language Models"** Mahdavi et al. (2024) [[paper]](https://arxiv.org/abs/2407.12979) [[code]]() +- **"Generating consistent PDDL domains with Large Language Models"** Smirnov et al. (2024) [[paper]](https://arxiv.org/abs/2404.07751) [[code N/A]]() + + +### Model Editing +- **"Exploring the limitations of using large language models to fix planning tasks"** Gragera and Pozanco (2023) [[paper]](https://icaps23.icaps-conference.org/program/workshops/keps/KEPS-23_paper_3645.pdf) [[code N/A]]() +- **"Can LLMs Fix Issues with Reasoning Models? Towards More Likely Models for AI Planning"** Caglar et al. (2024) [[paper]](https://arxiv.org/abs/2311.13720) [[code N/A]]() +- **"Large Language Models as Planning Domain Generators"** Oswald et al. (2024) [[paper]](https://arxiv.org/abs/2405.06650) [[code]](https://github.com/IBM/NL2PDDL) +- **"Traversing the Linguistic Divide: Aligning Semantically Equivalent Fluents Through Model Refinement"** Sikes et al. (2024) [[paper]](https://drive.google.com/file/d/1gd7DOHY6ztiTO1jllDOmP-V8V-q1N0uG/view) [[code N/A]]() + + +### Model Benchmarks +- **"Planetarium: A Rigorous Benchmark for Translating Text to Structured Planning Languages"** Zuo et al. (2024) [[paper]](https://arxiv.org/abs/2407.03321) [[code]](https://github.com/batsresearch/planetarium) + +As highlighted in our survey paper, there is a notable lack of benchmarking focused on LLMs for extracting PDDL specifications. Below, we present benchmarks evaluating the performance of LLMs directly applied to planning tasks, rather than solely modeling planning specifications: + +- **"ALFWorld: Aligning Text and Embodied Environments for Interactive Learning"** Shridhar et al. (2021) [[paper]](https://arxiv.org/abs/2402.01817) [[code]](https://github.com/alfworld/alfworld) +- **"PlanBench: An Extensible Benchmark for Evaluating Large Language Models on Planning and Reasoning about Change"** Valmeekam et al. (2023) [[paper]](https://proceedings.neurips.cc//paper_files/paper/2023/hash/7a92bcdede88c7afd108072faf5485c8-Abstract-Datasets_and_Benchmarks.html) [[code]](https://github.com/karthikv792/LLMs-Planning) +- **"Automating the Generation of Prompts for LLM-based Action Choice in PDDL Planning"** Stein et al. (2023) [[paper]](https://arxiv.org/abs/2311.09830) [[code]](https://github.com/minecraft-saar/autoplanbench) +- **"NATURAL PLAN: Benchmarking LLMs on Natural Language Planning"** Zheng et al. (2024) [[paper]](https://arxiv.org/abs/2406.04520) [[code]](https://github.com/google-deepmind/natural-plan) +- **"LLMs Can't Plan, But Can Help Planning in LLM-Modulo Frameworks"** Kambhampati et al. (2024) [[paper]](https://arxiv.org/abs/2402.01817) [[code N/A]]() + ## Contact Please contact `20mt1@queensu.ca` for questions, comments, or feedback about the L2P library. diff --git a/docs/paper_recreations.rst b/docs/paper_recreations.rst index 461255e..14fba05 100644 --- a/docs/paper_recreations.rst +++ b/docs/paper_recreations.rst @@ -1,82 +1,175 @@ Paper Recreations ================= -This library is a collection of tools for PDDL model generation extracted from natural language driven by large language models. This library is an expansion from the survey paper **Leveraging Large Language Models for Automated Planning and Model Construction: A Survey**. Papers that have been reconstructed so far and can be found in the GitHub repo. This list will be updated in the future. +This library is a collection of tools for PDDL model generation extracted from natural language driven by large language models. This library is an expansion from the survey paper **Leveraging Large Language Models for Automated Planning and Model Construction: A Survey**. Papers that have been reconstructed so far and can be found in the GitHub repo. + +To see full list of current up-to-date papers, please visit our GitHub page `here `_. This list will be continuously updated. Below is L2P code reconstruction of "action-by-action algorithm" from `"Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning" `_: .. code-block:: python :linenos: - max_iterations = 2 - predicate_list = [] - for i_iter in range(max_iterations): - prev_predicate_list = deepcopy(predicate_list) - - action_list = [] + def construct_action( + model: LLM, + act_pred_prompt: str, + action_name: str, + predicates: list[Predicate], + types: dict[str,str], + max_iter: int = 8, + syntax_validator: bool = True + ): - for i_action, action in enumerate(actions): + # better format for LLM to interpret + predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) + + # syntax validator check + if syntax_validator: validator = SyntaxValidator() + else: validator = None - if len(predicate_list) == 0: - # if no predicates in list - action_prompt = action_prompt.replace('{predicates}', '\nNo predicate has been defined yet') - else: - readable_results = "" - for i, p in enumerate(predicate_list): - readable_results += f'\n{i + 1}. {p["raw"]}' - - action_prompt = action_prompt.replace('{predicates}', readable_results) + no_syntax_error = False + i_iter = 0 + + # generate single action in loop, loops until no syntax error or max iters reach + while not no_syntax_error and i_iter < max_iter: + i_iter += 1 + print(f'[INFO] generating PDDL of action: `{action_name}`') + try: + # L2P usage for extracting actions and predicates + action, new_predicates, llm_response, validation_info = ( + domain_builder.extract_pddl_action( + model=model, + domain_desc="", + prompt_template=act_pred_prompt, + action_name=action_name, + predicates=predicates, + types=types, + syntax_validator=validator, + ) + ) - pddl_action, new_predicates, llm_response = domain_builder.extract_pddl_action( - model=model, - domain_desc=domain_desc, - prompt_template=action_predicate_prompt, - action_name=action, - action_desc=action_model[action]['desc'], - predicates=predicate_list, - types=hierarchy_requirements["hierarchy"] - ) + # retrieve validation check and error message + no_error, error_msg = validation_info - new_predicates = parse_new_predicates(llm_response) - predicate_list.extend(new_predicates) + except Exception as e: + no_error = False + error_msg = str(e) + + # if error exists, swap templates and return feedback message + if not no_error: + with open("paper_reconstructions/llm+dm/domains/error_prompt.txt") as f: + error_template = f.read().strip() + error_prompt = error_template.replace("{action_name}", action_name) + error_prompt = error_prompt.replace("{predicates}", predicate_str) + error_prompt = error_prompt.replace("{error_msg}", error_msg) + error_prompt = error_prompt.replace("{llm_response}", llm_response) + + act_pred_prompt = error_prompt - action_list.append(pddl_action) - predicate_list = prune_predicates(predicate_list, action_list) + # break the loop if no syntax error was made + else: + no_syntax_error = True + + # if max attempts reached and there are still errors, print out error on action. + if not no_syntax_error: + print(f'[WARNING] syntax error remaining in the action model: {action_name}') + + predicates.extend(new_predicates) # extend the predicate list + + return action, predicates, llm_response + - return predicate_list, action_list -Current Model Construction Works --------------------------------- -This section provides a taxonomy of research within Model Construction from the survey paper **Leveraging Large Language Models for Automated Planning and Model Construction: A Survey** (currently under review process). + def run_llm_dm( + model: LLM, + domain: str = "household", + max_iter: int = 2, + max_attempts: int = 8 + ): + """ + This is the main function for `construct_action_models.py` component of LLM+DM paper. Specifically, it generates + actions (params, preconditions, effects) and predicates to create an overall PDDL domain file. + + Args: + - model (LLM): the large language model to be inferenced + - domain (str): choice of domain to task (defaults to `household`) + - max_iter: outer loop iteration; # of overall action list resets (defaults to 2) + - max_attempts: # of attempts to generate a single actions properly (defaults to 8) + """ + + # load in assumptions + prompt_template = load_file("paper_reconstructions/llm+dm/domains/pddl_prompt.txt") + domain_desc_str = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/domain_desc.txt") + + if '{domain_desc}' in prompt_template: + prompt_template = prompt_template.replace('{domain_desc}', domain_desc_str) + + action_model = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/action_model.json") + hierarchy_reqs = load_file(f"paper_reconstructions/llm+dm/domains/{domain}/hierarchy_requirements.json") + + reqs = [":" + r for r in hierarchy_reqs['requirements']] + types = format_types(get_types(hierarchy_reqs)) + + actions = list(action_model.keys()) + action_list = list() + predicates = list() -Task Translation Frameworks -------------------------------- -- "Structured, flexible, and robust: benchmarking and improving large language models towards more human-like behaviour in out-of-distribution reasoning tasks" Collins et al. (2022) `Paper `_ `Code `_ -- "Translating natural language to planning goals with large-language models" Xie et al. (2023) `Paper `_ `Code `_ -- "Faithful Chain-of-Thought Reasoning" Lyu et al. (2023) `Paper `_ `Code `_ -- "LLM+P: Empowering Large Language Models with Optimal Planning Proficiency" Liu et al. (2023) `Paper `_ `Code `_ -- "Dynamic Planning with a LLM" Dagan et al. (2023) `Paper `_ `Code `_ -- "TIC: Translate-Infer-Compile for accurate 'text to plan' using LLMs and logical intermediate representations" Agarwal and Sreepathy (2024) `Paper `_ `Code `_ -- "PDDLEGO: Iterative Planning in Textual Environments" Zhang et al. (2024) `Paper `_ `Code `_ + # initialize result folder + result_log_dir = f"paper_reconstructions/llm+dm/results/{domain}" + os.makedirs(result_log_dir, exist_ok=True) + + """ + Action-by-action algorithm: iteratively generates an action model (parameters, precondition, effects) one at a time. At the same time, + it is generating new predicates if needed and is added to a dynamic list. At the end of the iterations, it is ran again once more to + create the action models agains, but with using the new predicate list. This algorithm can iterative as many times as needed until no + new predicates are added to the list. This is an action model refinement algorithm, that refines itself by a growing predicate list. + """ + + # outer loop that resets all action creation to be conditioned on updated predicate list + for i_iter in range(max_iter): + readable_results = '' # for logging purposes + prev_predicate_list = deepcopy(predicates) # copy previous predicate list + action_list = [] + + # inner loop that generates a single action along with its predicates + for _, action in enumerate(actions): + + # retrieve prompt for specific action + action_prompt, _ = get_action_prompt(prompt_template, action_model[action]) + readable_results += '\n' * 2 + '#' * 20 + '\n' + f'Action: {action}\n' + '#' * 20 + '\n' + + # retrieve prompt for current predicate list + predicate_prompt = get_predicate_prompt(predicates) + readable_results += '-' * 20 + readable_results += f'\n{predicate_prompt}\n' + '-' * 20 -Domain Translation Frameworks ---------------------------------- -- "Learning adaptive planning representations with natural language guidance" Wong et al. (2023) `Paper `_ `Code `_ -- "Leveraging Pre-trained Large Language Models to Construct and Utilize World Models for Model-based Task Planning" Guan et al. (2023) `Paper `_ `Code `_ -- "PROC2PDDL: Open-Domain Planning Representations from Texts" Zhang et al. (2024) `Paper `_ `Code `_ + # assemble template + action_predicate_prompt = f'{action_prompt}\n\n{predicate_prompt}' + action_predicate_prompt += '\n\nParameters:' + + # create single action + corresponding predicates + action, predicates, llm_response = construct_action( + model, action_predicate_prompt, action, predicates, types, max_attempts, True) + + # add action to current list + remove any redundant predicates + action_list.append(action) + predicates = prune_predicates(predicates, action_list) + + readable_results += '\n' + '-' * 10 + '-' * 10 + '\n' + readable_results += llm_response + '\n' -Hybrid Translation Frameworks ---------------------------------- -- "There and Back Again: Extracting Formal Domains for Controllable Neurosymbolic Story Authoring" Kelly et al. (2023) `Paper `_ `Code `_ -- "DELTA: Decomposed Efficient Long-Term Robot Task Planning using Large Language Models" Liu et al. (2024) `Paper `_ `Code `_ -- "ISR-LLM: Iterative Self-Refined Large Language Model for Long-Horizon Sequential Task Planning" Zhou et al. (2023) `Paper `_ `Code `_ -- "Consolidating Trees of Robotic Plans Generated Using Large Language Models to Improve Reliability" Sakib and Sun (2024) `Paper `_ `Code `_ -- "NL2Plan: Robust LLM-Driven Planning from Minimal Text Descriptions" Gestrin et al. (2024) `Paper `_ `Code `_ -- "Leveraging Environment Interaction for Automated PDDL Generation and Planning with Large Language Models" Mahdavi et al. (2024) `Paper `_ `Code `_ -- "Generating consistent PDDL domains with Large Language Models" Smirnov et al. (2024) `Paper `_ `Code `_ + # record log results into separate file of current iteration + readable_results += '\n' + '-' * 10 + '-' * 10 + '\n' + readable_results += 'Extracted predicates:\n' + for i, p in enumerate(predicates): + readable_results += f'\n{i + 1}. {p["raw"]}' + + with open(os.path.join(result_log_dir, f'{engine}_0_{i_iter}.txt'), 'w') as f: + f.write(readable_results) + + gen_done = False + if len(prev_predicate_list) == len(predicates): + print(f'[INFO] iter {i_iter} | no new predicate has been defined, will terminate the process') + gen_done = True -Model Editing and Benchmarking ----------------------------------- -- "Exploring the limitations of using large language models to fix planning tasks" Gragera and Pozanco (2023) `Paper `_ `Code `_ -- "Can LLMs Fix Issues with Reasoning Models? Towards More Likely Models for AI Planning" Caglar et al. (2024) `Paper `_ `Code `_ -- "Large Language Models as Planning Domain Generators" Oswald et al. (2024) `Paper `_ `Code `_ -- "Planetarium: A Rigorous Benchmark for Translating Text to Structured Planning Languages" Zuo et al. (2024) `Paper `_ `Code `_ \ No newline at end of file + if gen_done: + break \ No newline at end of file From 11dacd4a95a05955c1d1c3f3dd320130c98582d6 Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Fri, 17 Jan 2025 12:27:40 -0500 Subject: [PATCH 14/15] fixed doc page --- docs/paper_recreations.rst | 91 +++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/docs/paper_recreations.rst b/docs/paper_recreations.rst index 14fba05..dc6c252 100644 --- a/docs/paper_recreations.rst +++ b/docs/paper_recreations.rst @@ -9,6 +9,19 @@ Below is L2P code reconstruction of "action-by-action algorithm" from `"Leveragi .. code-block:: python :linenos: + DOMAINS = [ + "household", + "logistics", + "tyreworld", + ] + + UNSUPPORTED_KEYWORDS = [ + "forall", + "when", + "exists", + "implies" + ] + def construct_action( model: LLM, act_pred_prompt: str, @@ -18,6 +31,25 @@ Below is L2P code reconstruction of "action-by-action algorithm" from `"Leveragi max_iter: int = 8, syntax_validator: bool = True ): + """ + This is the inner function of the overall `Action-by-action` algorithm. Specifically, + this function generates a single action from the list of actions and new predicates created. + Process looping until it abides the custom syntax validation check. + + Args: + - model (LLM): the large language model to be inferenced + - act_pred_prompt (str): contains information of action and format creation passed to LLM + - action_name (str): current action to be generated + - predicates (list[Predicate]): current list of predicates generated + - types (dict[str,str]): domain types - used for validation checks + - max_iter (int): max attempts of generating action (defaults at 8) + - syntax_validator (bool): flag if syntax checker is on (defaults to True) + + Returns: + - action (Action): action data type containing parameters, preconditions, and effects + - predicates (list[Predicate]): list of updated predicates + - llm_response (str): original LLM output + """ # better format for LLM to interpret predicate_str = "\n".join([f"- {pred['clean']}" for pred in predicates]) @@ -172,4 +204,61 @@ Below is L2P code reconstruction of "action-by-action algorithm" from `"Leveragi gen_done = True if gen_done: - break \ No newline at end of file + break + + + # format components for PDDL generation + predicate_str = "\n".join( + [pred["clean"].replace(":", " ; ") for pred in predicates] + ) + + pruned_types = { + name: description + for name, description in types.items() + if name not in UNSUPPORTED_KEYWORDS + } # remove unsupported words + types_str = "\n".join(pruned_types) + + # generate PDDL format + pddl_domain = domain_builder.generate_domain( + domain=domain, + requirements=reqs, + types=types_str, + predicates=predicate_str, + actions=action_list, + ) + + + # helper functions + def get_action_prompt(prompt_template: str, action_desc: str): + """Creates prompt for specific action.""" + + action_desc_prompt = action_desc['desc'] + for i in action_desc['extra_info']: + action_desc_prompt += ' ' + i + + full_prompt = str(prompt_template) + ' ' + action_desc_prompt + + return full_prompt, action_desc_prompt + + + def get_predicate_prompt(predicates): + """Creates prompt for list of available predicates generated so far.""" + + predicate_prompt = 'You can create and define new predicates, but you may also reuse the following predicates:' + if len(predicates) == 0: + predicate_prompt += '\nNo predicate has been defined yet' + else: + predicate_prompt += "\n".join([f"- {pred['clean']}" for pred in predicates]) + return predicate_prompt + + + def get_types(hierarchy_requirements): + """Creates proper dictionary types (for L2P) from JSON format.""" + + types = { + name: description + for name, description in hierarchy_requirements["hierarchy"].items() + if name + } + return types \ No newline at end of file From 168de4b5cab428d93f64ca73d127064b24057c3f Mon Sep 17 00:00:00 2001 From: Marcus Tantakoun Date: Fri, 17 Jan 2025 12:29:56 -0500 Subject: [PATCH 15/15] commented syntax validator in domain_builder --- l2p/domain_builder.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/l2p/domain_builder.py b/l2p/domain_builder.py index c9b9b6c..3d6d893 100644 --- a/l2p/domain_builder.py +++ b/l2p/domain_builder.py @@ -229,6 +229,7 @@ def extract_pddl_action( action_list (dict[str,str]): dictionary of other actions to be translated predicates (list[Predicate]): list of predicates in current model types (dict[str,str]): current types in model + syntax_validator (SyntaxValidator): custom syntax validator, defaults to None max_retries (int): max # of retries if failure occurs Returns: @@ -270,6 +271,7 @@ def extract_pddl_action( ) new_predicates = parse_new_predicates(llm_response) + # if syntax validator is enabled, run through checks, returns check message validation_info = [True, "All validations passed."] if syntax_validator: for e in syntax_validator.error_types: