Parsing an STN from PDDL plan?

40 views Asked by At

I've been trying to look for more info about PDDL and it's application to STNs but to no avail. So one of my tasks is to "parse an STN" from a plan from PDDL using python.

Just for reference, this is how a PDDL plan is formatted:

0.00000: (make-site r1 w14 b25) [1.00000]
0.00000: (dig r2 w19 black) [100.00000]
0.00000: (move r3 w9 w7) [16.40000]
1.00000: (move r1 w14 w16) [13.20000]
14.20000: (make-site r1 w16 b27) [1.00000]
15.20000: (move r1 w16 w19) [15.40000]
16.40100: (move r3 w7 w5) [14.80000]
30.60100: (move r1 w19 w3) [19.20000]
31.20200: (move r3 w5 w3) [13.40000]
44.60300: (dig r3 r3 r3 w3 orange) [100.00000]
100.00100: (pick-up-black r2 w19 red green orange blue black) [1.00000]
101.00100: (move r2 w19 w16) [15.40000]
116.40100: (deposit r2 w16 b27 black) [1.00000]
117.40100: (move r2 w16 w19) [15.40000]
132.80200: (move r2 w19 w3) [19.20000]
144.60300: (move r3 w3 w1) [14.60000]
144.60400: (pick-up-orange r1 w3 orange black) [1.00000]
145.60400: (move r1 w3 w19) [19.20000]
152.00300: (move r2 w3 w1) [14.60000]
159.20300: (mine-blue r3 w1 blue) [200.00000]
164.80500: (move r1 w19 w16) [15.40000]
166.60400: (move r2 w1 w0) [16.60000]
180.20500: (deposit r1 w16 b27 orange) [1.00000]
181.20500: (move r1 w16 w19) [15.40000]
183.20400: (make-site r2 w0 b26) [1.00000]
183.20400: (mine-green r2 w0 green) [100.00000]
196.60600: (move r1 w19 w3) [19.20000]
215.80600: (dig r1 r1 r1 w3 orange) [100.00000]

I think ultimately the goal is to produce it in a .DOT format through Python so we can visualise the STN using GraphViz. My python is fine but I struggle to find resources for PDDL/DOT... I've been given a sample .DOT file:

digraph plan {
Step3 [label="Step 3: (light_match match1):2[0]"];
Step2 [label="Step 2: (mend_fuse fuse1 match1):2[2]"];
Step1 [label="Step 1: (mend_fuse fuse1 match1):0[2]"];
Step0 [label="Step 0: (light_match match1):0[0]"];
Step0 -> Z  [label="-0.001"];
Step1 -> Z  [label="-4.001"];
Step2 -> Z  [label="-5.001"];
Step3 -> Z  [label="-8.001"];
Step2 -> Step0  [label="-5.0"];
Step0 -> Step3  [label="8.000"];
Step3 -> Step0  [label="-8.000"];
Step1 -> Step2  [label="5.000"];
Step2 -> Step1  [label="-5.000"];
Step3 -> Step2  [label="0"];
Step2 -> Step3  [label="3.0"];
}

I've been reading around for DOT files but usually the examples provided are very simplistic and I am still struggling to apply it to my context. I just have a few questions regarding what some of the values in the .DOT file refer to and I'm hoping someone can help:

  1. I understand the nodes are represented by Step 0-3, and each action has a start and end... but any idea of what those values after the : is referring to? e.g. 2[2] and 0[2]

  2. So the labels e.g. [label="-8.001"]; in this context are the costs right? May be a dumb question but this is calculated by using the time taken for an action right? e.g. in the example i posted: 0.00000: (move r3 w9 w7) [16.40000], the cost is 16.400? or should it be rounded up to 17.000?

  3. So it's a bit confusing why some steps have -ve values e.g. Step2 -> Step1 [label="-5.000"]; but then another has 0 Step3 -> Step2 [label="0"]; Is it safe to assume that 0 means you can't take that step but negative implies you can go back?

  4. Anyone know of any good resources/examples of STN parsing I could refer to? I just need to know where to begin.

Any help is appreciated. Thank you!

0

There are 0 answers