diff --git a/compilers/Dot_Compiler.rb b/compilers/Dot_Compiler.rb index 8115d9e..0c84611 100644 --- a/compilers/Dot_Compiler.rb +++ b/compilers/Dot_Compiler.rb @@ -19,7 +19,7 @@ def compile_domain(domain_name, problem_name, operators, methods, predicates, st # Operators operators.each {|op| # Header - domain_str << " \"#{op[0]}\" [\n label=\"{{#{op[0]}|#{op[1].join(' ')}}|{" + domain_str << " \"#{op[0]}\" [\n label=\"{{\\N|#{op[1].join(' ')}}|{" # Preconditions predicates_to_dot(domain_str, op[2], op[3]) # Effects @@ -32,21 +32,21 @@ def compile_domain(domain_name, problem_name, operators, methods, predicates, st method_str = '' decompositions = [] met.drop(2).each_with_index {|dec,i| - decompositions << "#{met[0]}_#{dec[0]}" + decompositions << "<#{i}>#{met[0]}_#{dec[0]}" # Label - method_str << " \"label_#{met[0]}_#{dec[0]}\" [\n label=\"{{#{met[0]}_#{dec[0]}|#{dec[1].join(' ')}}|" + method_str << " \"#{met[0]}_#{dec[0]}\" [\n label=\"{{\\N|#{dec[1].join(' ')}}|" # Preconditions predicates_to_dot(method_str, dec[2], dec[3]) # Subtasks connections = '' dec[4].each_with_index {|subtask,j| - method_str << "|#{subtask.join(' ')}" - connections << " \"label_#{met[0]}_#{dec[0]}\":n#{j} -> \"#{subtask[0]}\"\n" if all_connections or operators.assoc(subtask[0]) + method_str << "|<#{j}>#{subtask.join(' ')}" + connections << " \"#{met[0]}_#{dec[0]}\":#{j} -> \"#{subtask[0]}\"\n" if all_connections or operators.assoc(subtask[0]) } # Connections - method_str << "}\"\n ]\n \"#{met[0]}\":n#{i} -> \"label_#{met[0]}_#{dec[0]}\" [style=dotted]\n#{connections}" + method_str << "}\"\n ]\n \"#{met[0]}\":#{i} -> \"#{met[0]}_#{dec[0]}\" [style=dotted]\n#{connections}" } - domain_str << " \"#{met[0]}\" [\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=\"{{\\N|#{met[1].join(' ')}}|{#{decompositions.join('|')}}}\"\n ]\n#{method_str}" } domain_str << '}' end diff --git a/docs/Graph.md b/docs/Graph.md index a26f4fa..05d9339 100644 --- a/docs/Graph.md +++ b/docs/Graph.md @@ -33,29 +33,29 @@ digraph "basic" { // Operators node [shape=record] "pickup" [ - label="{{pickup|?a}|{not (have ?a)\l|(have ?a)\l}}" + label="{{\N|?a}|{not (have ?a)\l|(have ?a)\l}}" ] "drop" [ - label="{{drop|?a}|{(have ?a)\l|not (have ?a)\l}}" + label="{{\N|?a}|{(have ?a)\l|not (have ?a)\l}}" ] // Methods node [shape=Mrecord] "swap" [ style=bold - label="{{swap|?x ?y}|{swap_case_0|swap_case_1}}" + label="{{\N|?x ?y}|{<0>swap_case_0|<1>swap_case_1}}" ] - "label_swap_case_0" [ - label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|drop ?x|pickup ?y}" + "swap_case_0" [ + label="{{\N|}|(have ?x)\lnot (have ?y)\l|<0>drop ?x|<1>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" [ - label="{{swap_case_1|}|(have ?y)\lnot (have ?x)\l|drop ?y|pickup ?x}" + "swap":0 -> "swap_case_0" [style=dotted] + "swap_case_0":0 -> "drop" + "swap_case_0":1 -> "pickup" + "swap_case_1" [ + label="{{\N|}|(have ?y)\lnot (have ?x)\l|<0>drop ?y|<1>pickup ?x}" ] - "swap":n1 -> "label_swap_case_1" [style=dotted] - "label_swap_case_1":n0 -> "drop" - "label_swap_case_1":n1 -> "pickup" + "swap":1 -> "swap_case_1" [style=dotted] + "swap_case_1":0 -> "drop" + "swap_case_1":1 -> "pickup" } ``` diff --git a/tests/simple.rb b/tests/simple.rb index 1410a9f..c24ee1e 100644 --- a/tests/simple.rb +++ b/tests/simple.rb @@ -489,29 +489,29 @@ def test_basic_pb1_jshop_parsing_compile_to_dot // Operators node [shape=record] "pickup" [ - label="{{pickup|?a}|{not (have ?a)\l|(have ?a)\l}}" + label="{{\N|?a}|{not (have ?a)\l|(have ?a)\l}}" ] "drop" [ - label="{{drop|?a}|{(have ?a)\l|not (have ?a)\l}}" + label="{{\N|?a}|{(have ?a)\l|not (have ?a)\l}}" ] // Methods node [shape=Mrecord] "swap" [ style=bold - label="{{swap|?x ?y}|{swap_case_0|swap_case_1}}" + label="{{\N|?x ?y}|{<0>swap_case_0|<1>swap_case_1}}" ] - "label_swap_case_0" [ - label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|drop ?x|pickup ?y}" + "swap_case_0" [ + label="{{\N|}|(have ?x)\lnot (have ?y)\l|<0>drop ?x|<1>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" [ - label="{{swap_case_1|}|(have ?y)\lnot (have ?x)\l|drop ?y|pickup ?x}" + "swap":0 -> "swap_case_0" [style=dotted] + "swap_case_0":0 -> "drop" + "swap_case_0":1 -> "pickup" + "swap_case_1" [ + label="{{\N|}|(have ?y)\lnot (have ?x)\l|<0>drop ?y|<1>pickup ?x}" ] - "swap":n1 -> "label_swap_case_1" [style=dotted] - "label_swap_case_1":n0 -> "drop" - "label_swap_case_1":n1 -> "pickup" + "swap":1 -> "swap_case_1" [style=dotted] + "swap_case_1":0 -> "drop" + "swap_case_1":1 -> "pickup" }', # Problem nil