From ce40e51a9f8ce496242146d583f3a802da3dffd9 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Mon, 7 Nov 2022 09:34:03 +0100 Subject: [PATCH 01/11] fix print type issue --- pddl/core.py | 4 ++-- pddl/helpers/base.py | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pddl/core.py b/pddl/core.py index 7238445..c06eae2 100644 --- a/pddl/core.py +++ b/pddl/core.py @@ -31,7 +31,7 @@ from pddl.custom_types import name as name_type from pddl.custom_types import namelike, to_names -from pddl.helpers.base import assert_, ensure, ensure_sequence, ensure_set +from pddl.helpers.base import assert_, ensure, ensure_sequence, ensure_set, _typed_parameters from pddl.logic.base import FalseFormula, Formula, TrueFormula, is_literal from pddl.logic.predicates import DerivedPredicate, Predicate from pddl.logic.terms import Constant, Variable @@ -280,7 +280,7 @@ def effect(self) -> Optional[Formula]: def __str__(self): """Get the string.""" operator_str = "(:action {0}\n".format(self.name) - operator_str += f" :parameters ({' '.join(map(str, self.parameters))})\n" + operator_str += f" :parameters ({_typed_parameters(self.parameters)})\n" if self.precondition is not None: operator_str += f" :precondition {str(self.precondition)}\n" if self.effect is not None: diff --git a/pddl/helpers/base.py b/pddl/helpers/base.py index 8b20b91..4c678c6 100644 --- a/pddl/helpers/base.py +++ b/pddl/helpers/base.py @@ -55,7 +55,7 @@ def ensure_set(arg: Optional[Collection], immutable: bool = True) -> AbstractSet :return: the same set, or an empty set if the arg was None. """ op = frozenset if immutable else set - return op(arg) if arg is not None and not isinstance(arg, op) else op() + return op(arg) if arg is not None else op() def ensure_sequence(arg: Optional[Sequence], immutable: bool = True) -> Sequence: @@ -67,7 +67,7 @@ def ensure_sequence(arg: Optional[Sequence], immutable: bool = True) -> Sequence :return: the same list, or an empty list if the arg was None. """ op: Type = tuple if immutable else list - return op(arg) if arg is not None and not isinstance(arg, op) else op() + return op(arg) if arg is not None else op() def safe_index(seq: Sequence, *args, **kwargs): @@ -94,6 +94,17 @@ def find(seq: Sequence, condition: Callable[[Any], bool]) -> int: return next((i for i, x in enumerate(seq) if condition(x)), -1) +def _typed_parameters(parameters) -> str: + """Return a list of parameters along with types if available.""" + result = "" + for p in parameters: + if p.type_tags: + result += f"?{p.name} - {' '.join(map(str, p.type_tags))} " + else: + result += str(p) + " " + return result + + class RegexConstrainedString(str): """ A string that is constrained by a regex. From a713b010ca2d351d9bec5f760d97209439958d24 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 11:25:56 +0100 Subject: [PATCH 02/11] fix bug when parsing an And as effect of a When (conditional effect) --- pddl/parser/domain.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pddl/parser/domain.py b/pddl/parser/domain.py index f791687..323c76a 100644 --- a/pddl/parser/domain.py +++ b/pddl/parser/domain.py @@ -207,7 +207,7 @@ def cond_effect(self, args): """Process the 'cond_effect' rule.""" if len(args) >= 3 and args[1] == Symbols.AND.value: p_effects = args[2:-1] - return AndEffect(p_effects) + return And(*p_effects) assert len(args) == 1 return args[0] From 1478e6da03d67f649b644a570918edeab69d8142 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 15:59:03 +0100 Subject: [PATCH 03/11] fix bug on parsing of constants in pddl problems --- pddl/parser/problem.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pddl/parser/problem.py b/pddl/parser/problem.py index 7344415..04fae73 100644 --- a/pddl/parser/problem.py +++ b/pddl/parser/problem.py @@ -125,7 +125,12 @@ def atomic_formula_name(self, args): return EqualTo(obj1, obj2) else: name = args[1] - terms = [self._objects_by_name.get(str(name)) for name in args[2:-1]] + terms = [ + Constant(str(_term_name)) + if self._objects_by_name.get(str(_term_name)) is None + else self._objects_by_name.get(str(_term_name)) + for _term_name in args[2:-1] + ] return Predicate(name, *terms) From d3a500d1b95f824e897ece2f0d2ed926e30880e7 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 15:59:32 +0100 Subject: [PATCH 04/11] apply black formatting --- pddl/core.py | 12 +++++++++--- pddl/formatter.py | 10 ++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pddl/core.py b/pddl/core.py index c06eae2..0374ba1 100644 --- a/pddl/core.py +++ b/pddl/core.py @@ -31,7 +31,13 @@ from pddl.custom_types import name as name_type from pddl.custom_types import namelike, to_names -from pddl.helpers.base import assert_, ensure, ensure_sequence, ensure_set, _typed_parameters +from pddl.helpers.base import ( + assert_, + ensure, + ensure_sequence, + ensure_set, + _typed_parameters, +) from pddl.logic.base import FalseFormula, Formula, TrueFormula, is_literal from pddl.logic.predicates import DerivedPredicate, Predicate from pddl.logic.terms import Constant, Variable @@ -145,9 +151,9 @@ def __init__( :param init: the initial condition. :param goal: the goal condition. """ - self._name: str = name_type(name) + self._name = name_type(name) self._domain: Optional[Domain] = domain - self._domain_name = domain_name + self._domain_name = name_type(domain_name) self._requirements: AbstractSet[Requirements] = ensure_set(requirements) self._objects: AbstractSet[Constant] = ensure_set(objects) self._init: AbstractSet[Formula] = ensure_set(init) diff --git a/pddl/formatter.py b/pddl/formatter.py index afb663e..f5e860a 100644 --- a/pddl/formatter.py +++ b/pddl/formatter.py @@ -52,16 +52,10 @@ def domain_to_string(domain: Domain) -> str: body += _sort_and_print_collection("(:constants ", domain.constants, ")\n") body += _sort_and_print_collection("(:predicates ", domain.predicates, ")\n") body += _sort_and_print_collection( - "", - domain.derived_predicates, - "", - to_string=lambda obj: str(obj) + "\n", + "", domain.derived_predicates, "", to_string=lambda obj: str(obj) + "\n", ) body += _sort_and_print_collection( - "", - domain.actions, - "", - to_string=lambda obj: str(obj) + "\n", + "", domain.actions, "", to_string=lambda obj: str(obj) + "\n", ) result = result + "\n" + indent(body, indentation) + "\n)" result = _remove_empty_lines(result) From 119ee27dbc59b23d95debb23b7d9cc2b42298bc8 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 17:29:23 +0100 Subject: [PATCH 05/11] add and fix tests --- tests/conftest.py | 28 ++-- .../fixtures/code_objects/blocksworld_fond.py | 120 ++++++++++++++++++ .../code_objects/blocksworld_ipc08.py | 21 +-- .../code_objects/triangle_tireworld.py | 9 +- tests/test_docs/base.py | 2 +- tests/test_parser.py | 14 +- 6 files changed, 163 insertions(+), 31 deletions(-) create mode 100644 tests/fixtures/code_objects/blocksworld_fond.py diff --git a/tests/conftest.py b/tests/conftest.py index 705ecd6..46e4edd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,6 +42,7 @@ FIXTURES_PDDL_FILES = FIXTURES_DIR / "pddl_files" BLOCKSWORLD_FILES = FIXTURES_PDDL_FILES / "blocksworld-ipc08" TRIANGLE_FILES = FIXTURES_PDDL_FILES / "triangle-tireworld" +BLOCKSWORLD_FOND_FILES = FIXTURES_PDDL_FILES / "blocksworld_fond" # TODO once missing features are supported, uncomment this # DOMAIN_FILES = [ @@ -49,21 +50,22 @@ # ] DOMAIN_NAMES = [ - "acrobatics", - "beam-walk", - "blocksworld-ipc08", - "doors", + # "acrobatics", + # "beam-walk", + # "blocksworld-ipc08", + # "doors", # "earth_observation", - "elevators", + # "elevators", # "faults-ipc08", # "first-responders-ipc08", - "islands", - "miner", - "spiky-tireworld", - "tireworld", - "tireworld-truck", - "triangle-tireworld", + # "islands", + # "miner", + # "spiky-tireworld", + # "tireworld", + # "tireworld-truck", + # "triangle-tireworld", # "zenotravel", + "blocksworld_fond" ] DOMAIN_FILES = [ @@ -101,5 +103,9 @@ def markdown_parser(): triangle_tireworld_domain, triangle_tireworld_problem_01, ) +from tests.fixtures.code_objects.blocksworld_fond import ( # noqa: E402, F401 + blocksworld_fond_domain, + blocksworld_fond_01, +) ################################################# diff --git a/tests/fixtures/code_objects/blocksworld_fond.py b/tests/fixtures/code_objects/blocksworld_fond.py new file mode 100644 index 0000000..20ef3bb --- /dev/null +++ b/tests/fixtures/code_objects/blocksworld_fond.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2021 WhiteMech +# +# ------------------------------ +# +# This file is part of pddl. +# +# pddl is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# pddl is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with pddl. If not, see . +# + +"""This test module contains the fixtures for 'blocksworld-ipc08' domain and problem.""" +import pytest + +from pddl.core import Action, Domain, Problem, Requirements +from pddl.logic import Constant +from pddl.logic.base import And, OneOf +from pddl.logic.effects import When, AndEffect +from pddl.logic.helpers import constants, variables +from pddl.logic.predicates import EqualTo, Predicate + + +@pytest.fixture(scope="session") +def blocksworld_fond_domain(): + """The 'blocksworld' FOND domain.""" + # terms + x, y, z, b= variables("x y z b") + + # constants: + table = Constant("Table") + + # predicates + on = Predicate("on", x, y) + clear = Predicate("clear", x) + block = Predicate("block", b) + predicates = {on, clear, block} + + # actions + # put-on + put_on_name = "puton" + put_on_parameters = [x, y, z] + put_on_precondition = on(x, z) & clear(x) & clear(y) & ~EqualTo(y, z) & ~EqualTo(x, z) & ~EqualTo(x, y) & ~EqualTo( + x, table) + put_on_effect = OneOf( + AndEffect(on(x, y), ~on(x, z), + When(~EqualTo(z, table), clear(z)), When(~EqualTo(y, table), ~clear(y))), + AndEffect(on(x, table), + When(~EqualTo(z, table), ~on(x, z) & clear(z)), When(~EqualTo(y, table), ~clear(y))), + ) + put_on = Action(put_on_name, put_on_parameters, put_on_precondition, put_on_effect) + + name = "blocks-world-domain" + requirements = { + Requirements.STRIPS, + Requirements.EQUALITY, + Requirements.NON_DETERMINISTIC, + Requirements.CONDITIONAL_EFFECTS + } + actions = { + put_on + } + domain = Domain( + name=name, + requirements=requirements, + constants={table}, + predicates=predicates, + actions=actions, + ) + return domain + + +@pytest.fixture(scope="session") +def blocksworld_fond_01(): + """Blocksworld FOND problem 01.""" + # objects + objects = [A, B, C] = constants("A B C") + + Table = Constant("Table") + + # predicates + block = Predicate("block", A) + on = Predicate("on", C, A) + clear = Predicate("clear", B) + + init = { + block(A), + block(B), + block(C), + block(Table), + on(C, A), + on(A, Table), + on(B, Table), + clear(C), + clear(B), + clear(Table) + } + + goal = (And()) + + problem_name = "sussman-anomaly" + + problem = Problem( + problem_name, + domain_name="blocks-world-domain", + objects=objects, + init=init, + goal=goal, + ) + return problem diff --git a/tests/fixtures/code_objects/blocksworld_ipc08.py b/tests/fixtures/code_objects/blocksworld_ipc08.py index 9ceb769..0745422 100644 --- a/tests/fixtures/code_objects/blocksworld_ipc08.py +++ b/tests/fixtures/code_objects/blocksworld_ipc08.py @@ -25,6 +25,7 @@ from pddl.core import Action, Domain, Problem, Requirements from pddl.logic.base import And, OneOf +from pddl.logic.effects import AndEffect from pddl.logic.helpers import constants, variables from pddl.logic.predicates import EqualTo, Predicate @@ -55,8 +56,8 @@ def blocksworld_domain(): pick_up_parameters = [b1, b2] pick_up_precondition = ~EqualTo(b1, b2) & emptyhand & clear(b1) & on(b1, b2) pick_up_effect = OneOf( - holding(b1) & clear(b2) & ~emptyhand & ~clear(b1) & ~on(b1, b2), - clear(b2) & on_table(b1) & ~on(b1, b2), + AndEffect(holding(b1), clear(b2), ~emptyhand, ~clear(b1), ~on(b1, b2)), + AndEffect(clear(b2), on_table(b1), ~on(b1, b2)), ) pick_up = Action( pick_up_name, pick_up_parameters, pick_up_precondition, pick_up_effect @@ -66,7 +67,7 @@ def blocksworld_domain(): pick_up_from_table_name = "pick-up-from-table" pick_up_from_table_parameters = [b] pick_up_from_table_precondition = emptyhand & clear(b) & on_table(b) - pick_up_from_table_effect = OneOf(And(), holding(b) & ~emptyhand & ~on_table(b)) + pick_up_from_table_effect = OneOf(AndEffect(), AndEffect(holding(b), ~emptyhand, ~on_table(b))) pick_up_from_table = Action( pick_up_from_table_name, pick_up_from_table_parameters, @@ -79,8 +80,8 @@ def blocksworld_domain(): put_on_block_parameters = [b1, b2] put_on_block_precondition = holding(b1) & clear(b2) put_on_block_effect = OneOf( - on(b1, b2) & emptyhand & clear(b1) & ~holding(b1) & ~clear(b2), - on_table(b1) & emptyhand & clear(b1) & ~holding(b1), + AndEffect(on(b1, b2), emptyhand, clear(b1), ~holding(b1), ~clear(b2)), + AndEffect(on_table(b1), emptyhand, clear(b1), ~holding(b1)), ) put_on_block = Action( put_on_block_name, @@ -93,7 +94,7 @@ def blocksworld_domain(): put_down_name = "put-down" put_down_parameters = [b] put_down_precondition = holding(b) - put_down_effect = on_table(b) & emptyhand & clear(b) & ~holding(b) + put_down_effect = AndEffect(on_table(b), emptyhand, clear(b), ~holding(b)) put_down = Action( put_down_name, put_down_parameters, put_down_precondition, put_down_effect ) @@ -101,7 +102,7 @@ def blocksworld_domain(): pick_tower_name = "pick-tower" pick_tower_parameters = [b1, b2, b3] pick_tower_precondition = emptyhand & on(b1, b2) & on(b2, b3) - pick_tower_effect = OneOf(And(), holding(b2) & clear(b3) & ~emptyhand & ~on(b2, b3)) + pick_tower_effect = OneOf(AndEffect(), AndEffect(holding(b2), clear(b3), ~emptyhand, ~on(b2, b3))) pick_tower = Action( pick_tower_name, pick_tower_parameters, @@ -114,8 +115,8 @@ def blocksworld_domain(): put_tower_on_block_parameters = [b1, b2, b3] put_tower_on_block_precondition = holding(b2) & on(b1, b2) & clear(b3) put_tower_on_block_effect = OneOf( - on(b2, b3) & emptyhand & ~holding(b2) & ~clear(b3), - on_table(b2) & emptyhand & ~holding(b2), + AndEffect(on(b2, b3), emptyhand, ~holding(b2), ~clear(b3)), + AndEffect(on_table(b2), emptyhand, ~holding(b2)), ) put_tower_on_block = Action( put_tower_on_block_name, @@ -128,7 +129,7 @@ def blocksworld_domain(): put_tower_down_name = "put-tower-down" put_tower_down_parameters = [b1, b2] put_tower_down_precondition = holding(b2) & on(b1, b2) - put_tower_down_effect = on_table(b2) & emptyhand & ~holding(b2) + put_tower_down_effect = AndEffect(on_table(b2), emptyhand, ~holding(b2)) put_tower_down = Action( put_tower_down_name, put_tower_down_parameters, diff --git a/tests/fixtures/code_objects/triangle_tireworld.py b/tests/fixtures/code_objects/triangle_tireworld.py index 37d1207..8aa554a 100644 --- a/tests/fixtures/code_objects/triangle_tireworld.py +++ b/tests/fixtures/code_objects/triangle_tireworld.py @@ -25,6 +25,7 @@ from pddl.core import Action, Domain, Problem, Requirements from pddl.logic.base import And, OneOf +from pddl.logic.effects import AndEffect from pddl.logic.helpers import constants, variables from pddl.logic.predicates import Predicate @@ -53,10 +54,10 @@ def triangle_tireworld_domain(): move_car_name = "move-car" move_car_parameters = [from_, to] move_car_precondition = vehicleat(from_) & road(from_, to) & not_flattire - move_car_effect = And( + move_car_effect = AndEffect( OneOf( - vehicleat(to) & ~vehicleat(from_), - vehicleat(to) & ~vehicleat(from_) & ~not_flattire, + AndEffect(vehicleat(to), ~vehicleat(from_)), + AndEffect(vehicleat(to), ~vehicleat(from_), ~not_flattire), ) ) move_car = Action( @@ -67,7 +68,7 @@ def triangle_tireworld_domain(): changetire_name = "changetire" changetire_parameters = [loc] changetire_precondition = spare_in(loc) & vehicleat(loc) - changetire_effect = ~spare_in(loc) & not_flattire + changetire_effect = AndEffect(~spare_in(loc), not_flattire) changetire = Action( changetire_name, changetire_parameters, diff --git a/tests/test_docs/base.py b/tests/test_docs/base.py index bb3b04f..20ccacf 100644 --- a/tests/test_docs/base.py +++ b/tests/test_docs/base.py @@ -54,7 +54,7 @@ def compile_and_exec(code: str, locals_dict: Dict = None) -> Dict: class BaseTestMarkdownDocs: - """Base test class for testing Markdown documents.""" + """Base test class for blocksworld_fond Markdown documents.""" MD_FILE: Optional[Path] = None code_blocks: List[Dict] = [] diff --git a/tests/test_parser.py b/tests/test_parser.py index 77fed3e..01cf1c0 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -26,13 +26,13 @@ import pytest from pytest import lazy_fixture # type: ignore # noqa -# from pddl.core import Domain, Problem from pddl.core import Domain, Problem from tests.conftest import ( BLOCKSWORLD_FILES, DOMAIN_FILES, PROBLEM_FILES, TRIANGLE_FILES, + BLOCKSWORLD_FOND_FILES ) @@ -53,6 +53,7 @@ def test_problem_parser(problem_parser, pddl_file: Path): [ (BLOCKSWORLD_FILES / "domain.pddl", lazy_fixture("blocksworld_domain")), (TRIANGLE_FILES / "domain.pddl", lazy_fixture("triangle_tireworld_domain")), + (BLOCKSWORLD_FOND_FILES / "domain.pddl", lazy_fixture("blocksworld_fond_domain")), ], ) def test_check_domain_parser_output(domain_parser, pddl_file: Path, expected_domain): @@ -65,11 +66,14 @@ def test_check_domain_parser_output(domain_parser, pddl_file: Path, expected_dom @pytest.mark.parametrize( "pddl_file,expected_problem", - [(BLOCKSWORLD_FILES / "p01.pddl", lazy_fixture("blocksworld_problem_01"))], + [ + (BLOCKSWORLD_FILES / "p01.pddl", lazy_fixture("blocksworld_problem_01")), + (BLOCKSWORLD_FOND_FILES / "p01.pddl", lazy_fixture("blocksworld_fond_01")) + ] ) def test_check_problem_parser_output(problem_parser, pddl_file: Path, expected_problem): """Test problem parsing.""" - problem = problem_parser(pddl_file.read_text()) + actual_problem = problem_parser(pddl_file.read_text()) - assert isinstance(problem, Problem) - assert problem == expected_problem + assert isinstance(actual_problem, Problem) + assert actual_problem == expected_problem From 6008eb901de3322452c4dac5feb5a49fe618485e Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 17:40:24 +0100 Subject: [PATCH 06/11] add different version of BW nondeterministic --- .../pddl_files/blocksworld_fond/domain.pddl | 29 +++++++++++++++++++ .../pddl_files/blocksworld_fond/p01.pddl | 11 +++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/fixtures/pddl_files/blocksworld_fond/domain.pddl create mode 100644 tests/fixtures/pddl_files/blocksworld_fond/p01.pddl diff --git a/tests/fixtures/pddl_files/blocksworld_fond/domain.pddl b/tests/fixtures/pddl_files/blocksworld_fond/domain.pddl new file mode 100644 index 0000000..98ff5e9 --- /dev/null +++ b/tests/fixtures/pddl_files/blocksworld_fond/domain.pddl @@ -0,0 +1,29 @@ +(define (domain blocks-world-domain) + (:requirements :strips :equality :conditional-effects :non-deterministic) + + (:constants Table) + + (:predicates (on ?x ?y) + (clear ?x) + (block ?b) + ) + + ;; Define step for placing one block on another. + (:action puton + :parameters (?x ?y ?z) + :precondition (and (on ?x ?z) (clear ?x) (clear ?y) + (not (= ?y ?z)) (not (= ?x ?z)) + (not (= ?x ?y)) (not (= ?x Table))) + :effect + (oneof + (and (on ?x ?y) (not (on ?x ?z)) + (when (not (= ?z Table)) (clear ?z)) + (when (not (= ?y Table)) (not (clear ?y))) + ) + (and (on ?x Table) + (when (not (= ?z Table)) (and (not (on ?x ?z)) (clear ?z))) + (when (not (= ?y Table)) (not (clear ?y))) + ) + ) + ) + ) diff --git a/tests/fixtures/pddl_files/blocksworld_fond/p01.pddl b/tests/fixtures/pddl_files/blocksworld_fond/p01.pddl new file mode 100644 index 0000000..38dfc25 --- /dev/null +++ b/tests/fixtures/pddl_files/blocksworld_fond/p01.pddl @@ -0,0 +1,11 @@ +(define (problem sussman-anomaly) ; graphplan 3 steps + (:domain blocks-world-domain) + (:objects A B C) + (:init (block A) (block B) (block C) (block Table) + (on C A) (on A Table) (on B Table) + (clear C) (clear B) (clear Table)) + ;(:goal (eventually (on B A)) + ;) + (:goal (and )) + +) From 5b5a461108ca28d483a54f442a417095e414df5f Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Tue, 8 Nov 2022 18:00:23 +0100 Subject: [PATCH 07/11] fix print type in predicates and objects --- pddl/logic/terms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pddl/logic/terms.py b/pddl/logic/terms.py index 89860c4..7a70d9d 100644 --- a/pddl/logic/terms.py +++ b/pddl/logic/terms.py @@ -86,7 +86,7 @@ def __init__( def __str__(self) -> str: """Get the string representation.""" - return self._name + return f"{self.name} - {' '.join(self.type_tags)}" if self.type_tags else self.name def __repr__(self): """Get a unique representation of the object.""" @@ -117,7 +117,7 @@ def __init__( def __str__(self) -> str: """Get the string representation.""" - return f"?{self._name}" + return f"?{self.name} - {' '.join(self.type_tags)}" if self.type_tags else f"?{self.name}" def __repr__(self): """Get a unique representation of the object.""" From 6c74825bff00d9a70d1fec587323c3a0d0008fbc Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Wed, 9 Nov 2022 09:40:42 +0100 Subject: [PATCH 08/11] fix again print type in predicates and objects --- pddl/formatter.py | 26 ++++++++++++++++++++++++-- pddl/logic/terms.py | 4 ++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pddl/formatter.py b/pddl/formatter.py index f5e860a..967f3bc 100644 --- a/pddl/formatter.py +++ b/pddl/formatter.py @@ -42,6 +42,28 @@ def _sort_and_print_collection( return "" +def _print_predicates_with_types(predicates: Collection): + result = "" + for p in predicates: + if p.arity == 0: + result += f"({p.name})" + else: + result += f"({p.name}" + for t in p.terms: + result += f" ?{t.name} - {' '.join(t.type_tags)}" if t.type_tags else f"?{t.name}" + result += ") " + result += " " + return result.strip() + + +def _print_objects_with_types(objects: Collection): + result = "" + for o in objects: + result += f"{o.name} - {' '.join(o.type_tags)}" if o.type_tags else f"{o.name}" + result += " " + return result.strip() + + def domain_to_string(domain: Domain) -> str: """Print a PDDL domain object.""" result = f"(define (domain {domain.name})" @@ -50,7 +72,7 @@ def domain_to_string(domain: Domain) -> str: body += _sort_and_print_collection("(:requirements ", domain.requirements, ")\n") body += _sort_and_print_collection("(:types ", domain.types, ")\n") body += _sort_and_print_collection("(:constants ", domain.constants, ")\n") - body += _sort_and_print_collection("(:predicates ", domain.predicates, ")\n") + body += f"(:predicates {_print_predicates_with_types(domain.predicates)})\n" body += _sort_and_print_collection( "", domain.derived_predicates, "", to_string=lambda obj: str(obj) + "\n", ) @@ -68,7 +90,7 @@ def problem_to_string(problem: Problem) -> str: body = f"(:domain {problem.domain_name})\n" indentation = " " * 4 body += _sort_and_print_collection("(:requirements ", problem.requirements, ")\n") - body += _sort_and_print_collection("(:objects ", problem.objects, ")\n") + body += f"(:objects {_print_objects_with_types(problem.objects)})\n" body += _sort_and_print_collection("(:init ", problem.init, ")\n") body += f"{'(:goal ' + str(problem.goal) + ')'}\n" if problem.goal != TRUE else "" result = result + "\n" + indent(body, indentation) + "\n)" diff --git a/pddl/logic/terms.py b/pddl/logic/terms.py index 7a70d9d..89860c4 100644 --- a/pddl/logic/terms.py +++ b/pddl/logic/terms.py @@ -86,7 +86,7 @@ def __init__( def __str__(self) -> str: """Get the string representation.""" - return f"{self.name} - {' '.join(self.type_tags)}" if self.type_tags else self.name + return self._name def __repr__(self): """Get a unique representation of the object.""" @@ -117,7 +117,7 @@ def __init__( def __str__(self) -> str: """Get the string representation.""" - return f"?{self.name} - {' '.join(self.type_tags)}" if self.type_tags else f"?{self.name}" + return f"?{self._name}" def __repr__(self): """Get a unique representation of the object.""" From 5fa79e500500e55c23cc638bc24ca4ddd8fdca4e Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Wed, 9 Nov 2022 09:41:32 +0100 Subject: [PATCH 09/11] apply black --- pddl/formatter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pddl/formatter.py b/pddl/formatter.py index 967f3bc..56578f4 100644 --- a/pddl/formatter.py +++ b/pddl/formatter.py @@ -50,7 +50,11 @@ def _print_predicates_with_types(predicates: Collection): else: result += f"({p.name}" for t in p.terms: - result += f" ?{t.name} - {' '.join(t.type_tags)}" if t.type_tags else f"?{t.name}" + result += ( + f" ?{t.name} - {' '.join(t.type_tags)}" + if t.type_tags + else f"?{t.name}" + ) result += ") " result += " " return result.strip() From 0350eef2441ef36da740fe7135c59ae2b200db64 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Wed, 9 Nov 2022 09:46:05 +0100 Subject: [PATCH 10/11] put domains back in tests --- tests/conftest.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 46e4edd..402c8e2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -50,20 +50,20 @@ # ] DOMAIN_NAMES = [ - # "acrobatics", - # "beam-walk", - # "blocksworld-ipc08", - # "doors", + "acrobatics", + "beam-walk", + "blocksworld-ipc08", + "doors", # "earth_observation", - # "elevators", + "elevators", # "faults-ipc08", # "first-responders-ipc08", - # "islands", - # "miner", - # "spiky-tireworld", - # "tireworld", - # "tireworld-truck", - # "triangle-tireworld", + "islands", + "miner", + "spiky-tireworld", + "tireworld", + "tireworld-truck", + "triangle-tireworld", # "zenotravel", "blocksworld_fond" ] From d0d04b2e925539b19521d785c25699db943a80c1 Mon Sep 17 00:00:00 2001 From: Francesco Fuggitti Date: Wed, 9 Nov 2022 10:03:03 +0100 Subject: [PATCH 11/11] add rovers domain --- tests/conftest.py | 3 +- .../pddl_files/rovers_fond/domain.pddl | 220 ++++++++++++++++++ .../fixtures/pddl_files/rovers_fond/p01.pddl | 54 +++++ .../fixtures/pddl_files/rovers_fond/p02.pddl | 55 +++++ .../fixtures/pddl_files/rovers_fond/p03.pddl | 55 +++++ .../fixtures/pddl_files/rovers_fond/p04.pddl | 56 +++++ .../fixtures/pddl_files/rovers_fond/p05.pddl | 57 +++++ .../fixtures/pddl_files/rovers_fond/p06.pddl | 56 +++++ .../fixtures/pddl_files/rovers_fond/p07.pddl | 57 +++++ .../fixtures/pddl_files/rovers_fond/p08.pddl | 57 +++++ .../fixtures/pddl_files/rovers_fond/p09.pddl | 57 +++++ 11 files changed, 726 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/pddl_files/rovers_fond/domain.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p01.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p02.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p03.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p04.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p05.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p06.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p07.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p08.pddl create mode 100644 tests/fixtures/pddl_files/rovers_fond/p09.pddl diff --git a/tests/conftest.py b/tests/conftest.py index 402c8e2..74404a2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -53,6 +53,7 @@ "acrobatics", "beam-walk", "blocksworld-ipc08", + "blocksworld_fond", "doors", # "earth_observation", "elevators", @@ -60,12 +61,12 @@ # "first-responders-ipc08", "islands", "miner", + "rovers_fond", "spiky-tireworld", "tireworld", "tireworld-truck", "triangle-tireworld", # "zenotravel", - "blocksworld_fond" ] DOMAIN_FILES = [ diff --git a/tests/fixtures/pddl_files/rovers_fond/domain.pddl b/tests/fixtures/pddl_files/rovers_fond/domain.pddl new file mode 100644 index 0000000..127637b --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/domain.pddl @@ -0,0 +1,220 @@ +(define (domain dom) + +(:requirements :strips :non-deterministic :typing) + (:types + rover - NO_TYPE + waypoint - NO_TYPE + store - NO_TYPE + camera - NO_TYPE + mode - NO_TYPE + lander - NO_TYPE + objective - NO_TYPE + ) + + (:predicates + (at ?x0 - rover ?x1 - waypoint) + (at_lander ?x0 - lander ?x1 - waypoint) + (can_traverse ?x0 - rover ?x1 - waypoint ?x2 - waypoint) + (equipped_for_soil_analysis ?x0 - rover) + (equipped_for_rock_analysis ?x0 - rover) + (equipped_for_imaging ?x0 - rover) + (empty ?x0 - store) + (have_rock_analysis ?x0 - rover ?x1 - waypoint) + (have_soil_analysis ?x0 - rover ?x1 - waypoint) + (full ?x0 - store) + (calibrated ?x0 - camera ?x1 - rover) + (supports ?x0 - camera ?x1 - mode) + (available ?x0 - rover) + (visible ?x0 - waypoint ?x1 - waypoint) + (have_image ?x0 - rover ?x1 - objective ?x2 - mode) + (communicatedsoildata ?x0 - waypoint) + (communicatedrockdata ?x0 - waypoint) + (communicatedimagedata ?x0 - objective ?x1 - mode) + (at_soil_sample ?x0 - waypoint) + (at_rock_sample ?x0 - waypoint) + (visible_from ?x0 - objective ?x1 - waypoint) + (store_of ?x0 - store ?x1 - rover) + (calibration_target ?x0 - camera ?x1 - objective) + (on_board ?x0 - camera ?x1 - rover) + (channel_free ?x0 - lander) + ) + (:action navigate + :parameters (?x0 - rover ?x1 - waypoint ?x2 - waypoint) + :precondition + (and + (can_traverse ?x0 ?x1 ?x2) + (available ?x0) + (at ?x0 ?x1) + (visible ?x1 ?x2)) + :effect + (and + (at ?x0 ?x2) + (not + (at ?x0 ?x1)) + ) + ) + (:action sample_soil + :parameters (?x0 - rover ?x1 - store ?x2 - waypoint) + :precondition + (and + (at ?x0 ?x2) + (at_soil_sample ?x2) + (equipped_for_soil_analysis ?x0) + (store_of ?x1 ?x0) + (empty ?x1)) + :effect + (and + (oneof + (and + (full ?x1) + (have_soil_analysis ?x0 ?x2) + (not + (empty ?x1)) + ) + (and + (when (at_rock_sample ?x2) + (and + (full ?x1) + (have_rock_analysis ?x0 ?x2) + (not + (empty ?x1)) + ) + ) + ) + ) + ) + ) + (:action sample_rock + :parameters (?x0 - rover ?x1 - store ?x2 - waypoint) + :precondition + (and + (at ?x0 ?x2) + (at_rock_sample ?x2) + (equipped_for_rock_analysis ?x0) + (store_of ?x1 ?x0) + (empty ?x1)) + :effect + (and + (full ?x1) + (have_rock_analysis ?x0 ?x2) + (not + (empty ?x1)) + ) + ) + (:action drop + :parameters (?x0 - rover ?x1 - store) + :precondition + (and + (store_of ?x1 ?x0) + (full ?x1)) + :effect + (and + (empty ?x1) + (not + (full ?x1)) + ) + ) + (:action calibrate + :parameters (?x0 - rover ?x1 - camera ?x2 - objective ?x3 - waypoint) + :precondition + (and + (equipped_for_imaging ?x0) + (calibration_target ?x1 ?x2) + (at ?x0 ?x3) + (visible_from ?x2 ?x3) + (on_board ?x1 ?x0)) + :effect +(calibrated ?x1 ?x0) ) + (:action take_image + :parameters (?x0 - rover ?x1 - waypoint ?x2 - objective ?x3 - camera ?x4 - mode) + :precondition + (and + (calibrated ?x3 ?x0) + (on_board ?x3 ?x0) + (equipped_for_imaging ?x0) + (supports ?x3 ?x4) + (visible_from ?x2 ?x1) + (at ?x0 ?x1)) + :effect + (and + (oneof + (have_image ?x0 ?x2 ?x4) + (and) + ) + (not + (calibrated ?x3 ?x0)) + ) + ) + (:action communicate_soil_data + :parameters (?x0 - rover ?x1 - lander ?x2 - waypoint ?x3 - waypoint ?x4 - waypoint) + :precondition + (and + (at ?x0 ?x3) + (at_lander ?x1 ?x4) + (have_soil_analysis ?x0 ?x2) + (visible ?x3 ?x4) + (available ?x0) + (channel_free ?x1)) + :effect + (and + (channel_free ?x1) + (oneof + (communicatedsoildata ?x2) + (and) + ) + (not + (have_soil_analysis ?x0 ?x2)) + (available ?x0) + (not + (channel_free ?x1)) + ) + ) + (:action communicate_rock_data + :parameters (?x0 - rover ?x1 - lander ?x2 - waypoint ?x3 - waypoint ?x4 - waypoint) + :precondition + (and + (at ?x0 ?x3) + (at_lander ?x1 ?x4) + (have_rock_analysis ?x0 ?x2) + (visible ?x3 ?x4) + (available ?x0) + (channel_free ?x1)) + :effect + (and + (channel_free ?x1) + (oneof + (communicatedrockdata ?x2) + (and) + ) + (not + (have_rock_analysis ?x0 ?x2)) + (available ?x0) + (not + (channel_free ?x1)) + ) + ) + (:action communicate_image_data + :parameters (?x0 - rover ?x1 - lander ?x2 - objective ?x3 - mode ?x4 - waypoint ?x5 - waypoint) + :precondition + (and + (at ?x0 ?x4) + (at_lander ?x1 ?x5) + (have_image ?x0 ?x2 ?x3) + (visible ?x4 ?x5) + (available ?x0) + (channel_free ?x1)) + :effect + (and + (channel_free ?x1) + (oneof + (communicatedimagedata ?x2 ?x3) + (and) + ) + (not + (have_image ?x0 ?x2 ?x3)) + (available ?x0) + (not + (channel_free ?x1)) + ) + ) +) \ No newline at end of file diff --git a/tests/fixtures/pddl_files/rovers_fond/p01.pddl b/tests/fixtures/pddl_files/rovers_fond/p01.pddl new file mode 100644 index 0000000..657a250 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p01.pddl @@ -0,0 +1,54 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint2))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p02.pddl b/tests/fixtures/pddl_files/rovers_fond/p02.pddl new file mode 100644 index 0000000..f0c6663 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p02.pddl @@ -0,0 +1,55 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint2) + (communicatedrockdata waypoint3))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p03.pddl b/tests/fixtures/pddl_files/rovers_fond/p03.pddl new file mode 100644 index 0000000..38b7a75 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p03.pddl @@ -0,0 +1,55 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p04.pddl b/tests/fixtures/pddl_files/rovers_fond/p04.pddl new file mode 100644 index 0000000..3f31d01 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p04.pddl @@ -0,0 +1,56 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p05.pddl b/tests/fixtures/pddl_files/rovers_fond/p05.pddl new file mode 100644 index 0000000..25ee4e3 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p05.pddl @@ -0,0 +1,57 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint0) + (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p06.pddl b/tests/fixtures/pddl_files/rovers_fond/p06.pddl new file mode 100644 index 0000000..e15839e --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p06.pddl @@ -0,0 +1,56 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint0) + (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p07.pddl b/tests/fixtures/pddl_files/rovers_fond/p07.pddl new file mode 100644 index 0000000..25ee4e3 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p07.pddl @@ -0,0 +1,57 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint0) + (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p08.pddl b/tests/fixtures/pddl_files/rovers_fond/p08.pddl new file mode 100644 index 0000000..25ee4e3 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p08.pddl @@ -0,0 +1,57 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint0) + (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) + +) diff --git a/tests/fixtures/pddl_files/rovers_fond/p09.pddl b/tests/fixtures/pddl_files/rovers_fond/p09.pddl new file mode 100644 index 0000000..25ee4e3 --- /dev/null +++ b/tests/fixtures/pddl_files/rovers_fond/p09.pddl @@ -0,0 +1,57 @@ +(define (problem problem5) + + (:domain dom) + (:objects camera0 - camera colour - mode general - lander highres - mode low_res - mode objective0 - objective objective1 - objective rover0 - rover rover0store - store waypoint0 - waypoint waypoint1 - waypoint waypoint2 - waypoint waypoint3 - waypoint) + (:init + (visible waypoint1 waypoint0) + (visible waypoint0 waypoint1) + (visible waypoint2 waypoint0) + (visible waypoint0 waypoint2) + (visible waypoint2 waypoint1) + (visible waypoint1 waypoint2) + (visible waypoint3 waypoint0) + (visible waypoint0 waypoint3) + (visible waypoint3 waypoint1) + (visible waypoint1 waypoint3) + (visible waypoint3 waypoint2) + (visible waypoint2 waypoint3) + (at_soil_sample waypoint0) + (at_rock_sample waypoint1) + (at_soil_sample waypoint2) + (at_rock_sample waypoint2) + (at_soil_sample waypoint3) + (at_rock_sample waypoint3) + (at_lander general waypoint0) + (channel_free general) + (at rover0 waypoint3) + (available rover0) + (store_of rover0store rover0) + (empty rover0store) + (equipped_for_soil_analysis rover0) + (equipped_for_rock_analysis rover0) + (equipped_for_imaging rover0) + (can_traverse rover0 waypoint3 waypoint0) + (can_traverse rover0 waypoint0 waypoint3) + (can_traverse rover0 waypoint3 waypoint1) + (can_traverse rover0 waypoint1 waypoint3) + (can_traverse rover0 waypoint1 waypoint2) + (can_traverse rover0 waypoint2 waypoint1) + (on_board camera0 rover0) + (calibration_target camera0 objective1) + (supports camera0 colour) + (supports camera0 highres) + (visible_from objective0 waypoint0) + (visible_from objective0 waypoint1) + (visible_from objective0 waypoint2) + (visible_from objective0 waypoint3) + (visible_from objective1 waypoint0) + (visible_from objective1 waypoint1) + (visible_from objective1 waypoint2) + (visible_from objective1 waypoint3) + ) + (:goal (and (communicatedsoildata waypoint0) + (communicatedsoildata waypoint2) + (communicatedsoildata waypoint3) + (communicatedimagedata objective1 highres))) + +)