From 83bbf9b56be0272174cbe8ee11d5e2027383225d Mon Sep 17 00:00:00 2001 From: Samuel Stante Date: Wed, 2 Oct 2024 15:59:03 +0200 Subject: [PATCH] change non deterministic test domain --- .../domain-missing-requirement.pddl | 86 ++++++++++++++----- data/blocks-non-deterministic/domain.pddl | 86 ++++++++++++++----- data/blocks-non-deterministic/p003-1.pddl | 7 -- data/blocks-non-deterministic/p20.pddl | 6 ++ tests/unit/parser.cpp | 10 +-- 5 files changed, 137 insertions(+), 58 deletions(-) delete mode 100644 data/blocks-non-deterministic/p003-1.pddl create mode 100644 data/blocks-non-deterministic/p20.pddl diff --git a/data/blocks-non-deterministic/domain-missing-requirement.pddl b/data/blocks-non-deterministic/domain-missing-requirement.pddl index 4b58759d..fcdf0e51 100644 --- a/data/blocks-non-deterministic/domain-missing-requirement.pddl +++ b/data/blocks-non-deterministic/domain-missing-requirement.pddl @@ -1,33 +1,73 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; 3 Op-blocks world -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define (domain blocks-domain) -(define (domain blocks3ops) - (:requirements :strips :equality :negative-preconditions) - (:predicates (on ?x ?y) - (ontable ?x) - (clear ?x) + (:requirements :negative-preconditions :equality :typing) + + (:types + block + ) + + (:predicates + (holding-one) + (holding-two) + (holding ?b - block) + (emptyhand) + (on-table ?b - block) + (on ?b1 ?b2 - block) + (clear ?b - block) ) - (:action newtower - :parameters (?x ?y) - :precondition (and (clear ?x) (on ?x ?y)) - :effect (and (ontable ?x) (clear ?y) (not (on ?x ?y))) + (:action pick-up + :parameters (?b1 ?b2 - block) + :precondition (and (not (= ?b1 ?b2)) (emptyhand) (clear ?b1) (on ?b1 ?b2)) + :effect (and (clear ?b2) (not (on ?b1 ?b2)) + (oneof + (and (holding-one) (holding ?b1) (not (emptyhand)) (not (clear ?b1))) + (on-table ?b1))) ) - (:action stack - :parameters (?x ?y) - :precondition (and (not (= ?x ?y)) (clear ?x) (clear ?y) (ontable ?x)) + (:action pick-up-from-table + :parameters (?b - block) + :precondition (and (emptyhand) (clear ?b) (on-table ?b)) :effect (oneof - (and (on ?x ?y) (not (ontable ?x)) (not (clear ?y))) - (and)) + (and) + (and (holding-one) (holding ?b) (not (emptyhand)) (not (on-table ?b)) (not (clear ?b)))) ) - (:action move - :parameters (?x ?y ?z) - :precondition (and (not (= ?x ?z)) (clear ?x) (clear ?z) (on ?x ?y)) + (:action put-on-block + :parameters (?b1 ?b2 - block) + :precondition (and (not (= ?b1 ?b2)) (holding-one) (holding ?b1) (clear ?b2)) + :effect (and (emptyhand) (clear ?b1) (not (holding-one)) (not (holding ?b1)) + (oneof + (and (on ?b1 ?b2) (not (clear ?b2))) + (on-table ?b1))) + ) + + (:action put-down + :parameters (?b - block) + :precondition (and (holding-one) (holding ?b)) + :effect (and (on-table ?b) (emptyhand) (clear ?b) (not (holding-one)) (not (holding ?b))) + ) + + (:action pick-tower + :parameters (?b1 ?b2 ?b3 - block) + :precondition (and (emptyhand) (on ?b1 ?b2) (on ?b2 ?b3) (clear ?b1)) :effect (oneof - (and (on ?x ?z) (not (clear ?z)) (clear ?y) (not (on ?x ?y))) - (and (ontable ?x) (clear ?y) (not (on ?x ?y)))) + (and) + (and (holding-two) (holding ?b2) (clear ?b3) (not (emptyhand)) (not (on ?b2 ?b3)) (not (clear ?b1)))) + ) + + (:action put-tower-on-block + :parameters (?b1 ?b2 ?b3 - block) + :precondition (and (holding-two) (holding ?b2) (on ?b1 ?b2) (clear ?b3)) + :effect (and (emptyhand) (not (holding-two)) (not (holding ?b2)) (clear ?b1) + (oneof + (and (on ?b2 ?b3) (not (clear ?b3))) + (and (on-table ?b1) (on-table ?b2) (clear ?b2) (not (on ?b1 ?b2))))) + ) + + (:action put-tower-down + :parameters (?b1 ?b2 - block) + :precondition (and (holding-two) (holding ?b2) (on ?b1 ?b2)) + :effect (and (on-table ?b2) (emptyhand) (not (holding-two)) (not (holding ?b2)) (clear ?b1)) ) -) +) \ No newline at end of file diff --git a/data/blocks-non-deterministic/domain.pddl b/data/blocks-non-deterministic/domain.pddl index 8f3a7691..80abb69c 100644 --- a/data/blocks-non-deterministic/domain.pddl +++ b/data/blocks-non-deterministic/domain.pddl @@ -1,33 +1,73 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; 3 Op-blocks world -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(define (domain blocks-domain) -(define (domain blocks3ops) - (:requirements :strips :non-deterministic :equality :negative-preconditions) - (:predicates (on ?x ?y) - (ontable ?x) - (clear ?x) + (:requirements :non-deterministic :negative-preconditions :equality :typing) + + (:types + block + ) + + (:predicates + (holding-one) + (holding-two) + (holding ?b - block) + (emptyhand) + (on-table ?b - block) + (on ?b1 ?b2 - block) + (clear ?b - block) ) - (:action newtower - :parameters (?x ?y) - :precondition (and (clear ?x) (on ?x ?y)) - :effect (and (ontable ?x) (clear ?y) (not (on ?x ?y))) + (:action pick-up + :parameters (?b1 ?b2 - block) + :precondition (and (not (= ?b1 ?b2)) (emptyhand) (clear ?b1) (on ?b1 ?b2)) + :effect (and (clear ?b2) (not (on ?b1 ?b2)) + (oneof + (and (holding-one) (holding ?b1) (not (emptyhand)) (not (clear ?b1))) + (on-table ?b1))) ) - (:action stack - :parameters (?x ?y) - :precondition (and (not (= ?x ?y)) (clear ?x) (clear ?y) (ontable ?x)) + (:action pick-up-from-table + :parameters (?b - block) + :precondition (and (emptyhand) (clear ?b) (on-table ?b)) :effect (oneof - (and (on ?x ?y) (not (ontable ?x)) (not (clear ?y))) - (and)) + (and) + (and (holding-one) (holding ?b) (not (emptyhand)) (not (on-table ?b)) (not (clear ?b)))) ) - (:action move - :parameters (?x ?y ?z) - :precondition (and (not (= ?x ?z)) (clear ?x) (clear ?z) (on ?x ?y)) + (:action put-on-block + :parameters (?b1 ?b2 - block) + :precondition (and (not (= ?b1 ?b2)) (holding-one) (holding ?b1) (clear ?b2)) + :effect (and (emptyhand) (clear ?b1) (not (holding-one)) (not (holding ?b1)) + (oneof + (and (on ?b1 ?b2) (not (clear ?b2))) + (on-table ?b1))) + ) + + (:action put-down + :parameters (?b - block) + :precondition (and (holding-one) (holding ?b)) + :effect (and (on-table ?b) (emptyhand) (clear ?b) (not (holding-one)) (not (holding ?b))) + ) + + (:action pick-tower + :parameters (?b1 ?b2 ?b3 - block) + :precondition (and (emptyhand) (on ?b1 ?b2) (on ?b2 ?b3) (clear ?b1)) :effect (oneof - (and (on ?x ?z) (not (clear ?z)) (clear ?y) (not (on ?x ?y))) - (and (ontable ?x) (clear ?y) (not (on ?x ?y)))) + (and) + (and (holding-two) (holding ?b2) (clear ?b3) (not (emptyhand)) (not (on ?b2 ?b3)) (not (clear ?b1)))) + ) + + (:action put-tower-on-block + :parameters (?b1 ?b2 ?b3 - block) + :precondition (and (holding-two) (holding ?b2) (on ?b1 ?b2) (clear ?b3)) + :effect (and (emptyhand) (not (holding-two)) (not (holding ?b2)) (clear ?b1) + (oneof + (and (on ?b2 ?b3) (not (clear ?b3))) + (and (on-table ?b1) (on-table ?b2) (clear ?b2) (not (on ?b1 ?b2))))) + ) + + (:action put-tower-down + :parameters (?b1 ?b2 - block) + :precondition (and (holding-two) (holding ?b2) (on ?b1 ?b2)) + :effect (and (on-table ?b2) (emptyhand) (not (holding-two)) (not (holding ?b2)) (clear ?b1)) ) -) +) \ No newline at end of file diff --git a/data/blocks-non-deterministic/p003-1.pddl b/data/blocks-non-deterministic/p003-1.pddl deleted file mode 100644 index 86e82b04..00000000 --- a/data/blocks-non-deterministic/p003-1.pddl +++ /dev/null @@ -1,7 +0,0 @@ -(define (problem blocks-003-1) - (:domain blocks3ops) - (:requirements :equality :non-deterministic :strips) - (:objects b0 b1 b2) - (:init (clear b1) (on b0 b2) (on b1 b0) (ontable b2)) - (:goal (and (clear b0) (on b0 b1) (on b1 b2) (ontable b2))) -) \ No newline at end of file diff --git a/data/blocks-non-deterministic/p20.pddl b/data/blocks-non-deterministic/p20.pddl new file mode 100644 index 00000000..64254e70 --- /dev/null +++ b/data/blocks-non-deterministic/p20.pddl @@ -0,0 +1,6 @@ +(define (problem bw_10_20) + (:domain blocks-domain) + (:objects b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 - block) + (:init (emptyhand) (on b1 b6) (on b2 b8) (on-table b3) (on b4 b9) (on b5 b3) (on b6 b10) (on b7 b5) (on-table b8) (on b9 b1) (on b10 b2) (clear b4) (clear b7)) + (:goal (and (emptyhand) (on b1 b9) (on b2 b1) (on-table b3) (on-table b4) (on-table b5) (on b6 b7) (on-table b7) (on-table b8) (on b9 b6) (on b10 b3) (clear b2) (clear b4) (clear b5) (clear b8) (clear b10))) +) diff --git a/tests/unit/parser.cpp b/tests/unit/parser.cpp index 9e044b88..9aa3aafc 100644 --- a/tests/unit/parser.cpp +++ b/tests/unit/parser.cpp @@ -43,18 +43,18 @@ TEST(LokiTests, ParserTest) TEST(LokiTests, ParserNonDeterministicTest) { const auto domain_file = fs::path(std::string(DATA_DIR) + "blocks-non-deterministic/domain.pddl"); - const auto problem_file = fs::path(std::string(DATA_DIR) + "blocks-non-deterministic/p003-1.pddl"); + const auto problem_file = fs::path(std::string(DATA_DIR) + "blocks-non-deterministic/p20.pddl"); auto domain_parser = DomainParser(domain_file); auto problem_parser = ProblemParser(problem_file, domain_parser); const auto domain = domain_parser.get_domain(); EXPECT_EQ(domain->get_constants().size(), 0); - EXPECT_EQ(domain->get_predicates().size(), 3); - EXPECT_EQ(domain->get_actions().size(), 3); + EXPECT_EQ(domain->get_predicates().size(), 7); + EXPECT_EQ(domain->get_actions().size(), 7); const auto problem = problem_parser.get_problem(); - EXPECT_EQ(problem->get_objects().size(), 3); - EXPECT_EQ(problem->get_initial_literals().size(), 4); + EXPECT_EQ(problem->get_objects().size(), 10); + EXPECT_EQ(problem->get_initial_literals().size(), 13); } TEST(LokiTests, ParserNonDeterministicMissingRequirementTest)