diff --git a/compilers/Dot_Compiler.rb b/compilers/Dot_Compiler.rb index 3132f1a..8115d9e 100644 --- a/compilers/Dot_Compiler.rb +++ b/compilers/Dot_Compiler.rb @@ -15,11 +15,11 @@ def predicates_to_dot(output, group, group_not) #----------------------------------------------- def compile_domain(domain_name, problem_name, operators, methods, predicates, state, tasks, goal_pos, goal_not, all_connections = true) - domain_str = "// Generated by Hype\ndigraph \"#{domain_name}\" {\n nodesep=1\n ranksep=1\n // Operators\n" + domain_str = "// Generated by Hype\ndigraph \"#{domain_name}\" {\n nodesep=1\n ranksep=1\n // Operators\n node [shape=record]\n" # Operators operators.each {|op| # Header - domain_str << " \"#{op[0]}\" [\n shape=record\n label=\"{{#{op[0]}|#{op[1].join(' ')}}|{" + domain_str << " \"#{op[0]}\" [\n label=\"{{#{op[0]}|#{op[1].join(' ')}}|{" # Preconditions predicates_to_dot(domain_str, op[2], op[3]) # Effects @@ -27,14 +27,14 @@ def compile_domain(domain_name, problem_name, operators, methods, predicates, st domain_str << "}}\"\n ]\n" } # Methods - domain_str << " // Methods\n" + domain_str << " // Methods\n node [shape=Mrecord]\n" methods.each {|met| method_str = '' decompositions = [] met.drop(2).each_with_index {|dec,i| decompositions << "#{met[0]}_#{dec[0]}" # Label - method_str << " \"label_#{met[0]}_#{dec[0]}\" [\n shape=Mrecord\n label=\"{{#{met[0]}_#{dec[0]}|#{dec[1].join(' ')}}|" + method_str << " \"label_#{met[0]}_#{dec[0]}\" [\n label=\"{{#{met[0]}_#{dec[0]}|#{dec[1].join(' ')}}|" # Preconditions predicates_to_dot(method_str, dec[2], dec[3]) # Subtasks @@ -46,7 +46,7 @@ def compile_domain(domain_name, problem_name, operators, methods, predicates, st # Connections method_str << "}\"\n ]\n \"#{met[0]}\":n#{i} -> \"label_#{met[0]}_#{dec[0]}\" [style=dotted]\n#{connections}" } - domain_str << " \"#{met[0]}\" [\n shape=Mrecord\n style=bold\n label=\"{{#{met[0]}|#{met[1].join(' ')}}|{#{decompositions.join('|')}}}\"\n ]\n#{method_str}" + domain_str << " \"#{met[0]}\" [\n style=bold\n label=\"{{#{met[0]}|#{met[1].join(' ')}}|{#{decompositions.join('|')}}}\"\n ]\n#{method_str}" } domain_str << '}' end diff --git a/docs/Graph.md b/docs/Graph.md index 1ffbeee..a26f4fa 100644 --- a/docs/Graph.md +++ b/docs/Graph.md @@ -31,29 +31,26 @@ digraph "basic" { nodesep=1 ranksep=1 // Operators + node [shape=record] "pickup" [ - shape=record label="{{pickup|?a}|{not (have ?a)\l|(have ?a)\l}}" ] "drop" [ - shape=record label="{{drop|?a}|{(have ?a)\l|not (have ?a)\l}}" ] // Methods + node [shape=Mrecord] "swap" [ - shape=Mrecord style=bold label="{{swap|?x ?y}|{swap_case_0|swap_case_1}}" ] "label_swap_case_0" [ - shape=Mrecord label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|drop ?x|pickup ?y}" ] "swap":n0 -> "label_swap_case_0" [style=dotted] "label_swap_case_0":n0 -> "drop" "label_swap_case_0":n1 -> "pickup" "label_swap_case_1" [ - shape=Mrecord label="{{swap_case_1|}|(have ?y)\lnot (have ?x)\l|drop ?y|pickup ?x}" ] "swap":n1 -> "label_swap_case_1" [style=dotted] diff --git a/tests/simple.rb b/tests/simple.rb index 9a4bf2b..1410a9f 100644 --- a/tests/simple.rb +++ b/tests/simple.rb @@ -487,29 +487,26 @@ def test_basic_pb1_jshop_parsing_compile_to_dot nodesep=1 ranksep=1 // Operators + node [shape=record] "pickup" [ - shape=record label="{{pickup|?a}|{not (have ?a)\l|(have ?a)\l}}" ] "drop" [ - shape=record label="{{drop|?a}|{(have ?a)\l|not (have ?a)\l}}" ] // Methods + node [shape=Mrecord] "swap" [ - shape=Mrecord style=bold label="{{swap|?x ?y}|{swap_case_0|swap_case_1}}" ] "label_swap_case_0" [ - shape=Mrecord label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|drop ?x|pickup ?y}" ] "swap":n0 -> "label_swap_case_0" [style=dotted] "label_swap_case_0":n0 -> "drop" "label_swap_case_0":n1 -> "pickup" "label_swap_case_1" [ - shape=Mrecord label="{{swap_case_1|}|(have ?y)\lnot (have ?x)\l|drop ?y|pickup ?x}" ] "swap":n1 -> "label_swap_case_1" [style=dotted]