Skip to content

Commit

Permalink
Reuse node name in Dot_Compiler compile_domain
Browse files Browse the repository at this point in the history
Remove label and n prefixes.
  • Loading branch information
Maumagnaguagno committed Mar 20, 2024
1 parent 3f4bc8e commit 48badb0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
14 changes: 7 additions & 7 deletions compilers/Dot_Compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 << "<n#{i}>#{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 << "|<n#{j}>#{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
Expand Down
26 changes: 13 additions & 13 deletions docs/Graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}|{<n0>swap_case_0|<n1>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|<n0>drop ?x|<n1>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|<n0>drop ?y|<n1>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"
}
```

Expand Down
26 changes: 13 additions & 13 deletions tests/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}|{<n0>swap_case_0|<n1>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|<n0>drop ?x|<n1>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|<n0>drop ?y|<n1>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
Expand Down

0 comments on commit 48badb0

Please sign in to comment.