Skip to content

Commit

Permalink
change non deterministic test domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Timisorean committed Oct 2, 2024
1 parent d11c6d0 commit 83bbf9b
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 58 deletions.
86 changes: 63 additions & 23 deletions data/blocks-non-deterministic/domain-missing-requirement.pddl
Original file line number Diff line number Diff line change
@@ -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))
)
)
)
86 changes: 63 additions & 23 deletions data/blocks-non-deterministic/domain.pddl
Original file line number Diff line number Diff line change
@@ -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))
)
)
)
7 changes: 0 additions & 7 deletions data/blocks-non-deterministic/p003-1.pddl

This file was deleted.

6 changes: 6 additions & 0 deletions data/blocks-non-deterministic/p20.pddl
Original file line number Diff line number Diff line change
@@ -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)))
)
10 changes: 5 additions & 5 deletions tests/unit/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 83bbf9b

Please sign in to comment.