Skip to content

Commit

Permalink
Set default node shape in Dot_Compiler compile_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
Maumagnaguagno committed Mar 19, 2024
1 parent 89c0015 commit 3f4bc8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
10 changes: 5 additions & 5 deletions compilers/Dot_Compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ 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
predicates_to_dot(domain_str << '|', op[4], op[5])
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 << "<n#{i}>#{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
Expand All @@ -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
Expand Down
7 changes: 2 additions & 5 deletions docs/Graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}|{<n0>swap_case_0|<n1>swap_case_1}}"
]
"label_swap_case_0" [
shape=Mrecord
label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|<n0>drop ?x|<n1>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|<n0>drop ?y|<n1>pickup ?x}"
]
"swap":n1 -> "label_swap_case_1" [style=dotted]
Expand Down
7 changes: 2 additions & 5 deletions tests/simple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}|{<n0>swap_case_0|<n1>swap_case_1}}"
]
"label_swap_case_0" [
shape=Mrecord
label="{{swap_case_0|}|(have ?x)\lnot (have ?y)\l|<n0>drop ?x|<n1>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|<n0>drop ?y|<n1>pickup ?x}"
]
"swap":n1 -> "label_swap_case_1" [style=dotted]
Expand Down

0 comments on commit 3f4bc8e

Please sign in to comment.