Skip to content

Commit

Permalink
Add Simple test_basic_pb1_jshop_parsing_compile_to_hddl
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Mar 15, 2024
1 parent 77b3ce5 commit fcd3146
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compilers/HDDL_Compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def compile_domain(domain_name, problem_name, operators, methods, predicates, st
goal_pos.each {|pre| declared[pre[0]] ||= pre}
goal_not.each {|pre| declared[pre[0]] ||= pre}
domain_str = "; Generated by Hype\n(define (domain #{domain_name})
# (:requirements :hierarchy#{' :negative-preconditions' if negative_preconditions}#{' :method-preconditions' if method_preconditions}#{' :equality' if declared.delete('=')})\n\n (:predicates\n"
(:requirements :hierarchy#{' :negative-preconditions' if negative_preconditions}#{' :method-preconditions' if method_preconditions}#{' :equality' if declared.delete('=')})\n\n (:predicates\n"
declared.each_value {|pre|
(pre = pre.join(' ?')).squeeze!('?')
domain_str << " (#{pre})\n"
Expand Down
80 changes: 80 additions & 0 deletions tests/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,86 @@ def test_basic_pb1_pddl_parsing_with_dummy_compile_to_jshop
)
end

def test_basic_pb1_jshop_parsing_compile_to_hddl
compiler_tests(
# Files
'examples/basic/basic.jshop',
'examples/basic/pb1.jshop',
# Extensions and output
[], 'hddl',
# Domain
'; Generated by Hype
(define (domain basic)
(:requirements :hierarchy :negative-preconditions :method-preconditions)
(:predicates
(have ?a)
)
(:action pickup
:parameters (?a)
:precondition (and
(not (have ?a))
)
:effect (and
(have ?a)
)
)
(:action drop
:parameters (?a)
:precondition (and
(have ?a)
)
:effect (and
(not (have ?a))
)
)
(:task swap :parameters (?x ?y))
(:method case_0
:parameters (?x ?y)
:task (swap ?x ?y)
:precondition (and
(have ?x)
(not (have ?y))
)
:ordered-subtasks (and
(drop ?x)
(pickup ?y)
)
)
(:method case_1
:parameters (?x ?y)
:task (swap ?x ?y)
:precondition (and
(have ?y)
(not (have ?x))
)
:ordered-subtasks (and
(drop ?y)
(pickup ?x)
)
)
)',
# Problem
'; Generated by Hype
(define (problem pb1)
(:domain basic)
(:objects
kiwi banjo
)
(:init
(have kiwi)
)
(:htn :ordered-tasks (and
(swap banjo kiwi)
))
)'
)
end

def test_basic_pb1_jshop_parsing_compile_to_markdown
compiler_tests(
# Files
Expand Down

0 comments on commit fcd3146

Please sign in to comment.