Compare commits
759 Commits
Author | SHA1 | Date | |
---|---|---|---|
af325e3991 | |||
31542c6adc | |||
2d0e4b09fa | |||
2288fa891e | |||
7c02b46f7c | |||
1c44dfcda7 | |||
b93e41d5bc | |||
0ff78f43e6 | |||
0f039f0837 | |||
9d04996b0a | |||
b2280c155a | |||
f7e089042d | |||
ce4fe6a113 | |||
3e2adf6db4 | |||
8ff87985f5 | |||
9fde2b8e1b | |||
c283adc42a | |||
9281592c39 | |||
6889e97f47 | |||
23130134bb | |||
5af0c26650 | |||
39410ac98b | |||
5621820fe4 | |||
9e9040cac0 | |||
0cf84dd5ca | |||
b063f5047e | |||
08a2eebe2c | |||
010e7bf41e | |||
|
a1a80332ca | ||
f0e553df23 | |||
0d0a4337a2 | |||
b21b4f47bf | |||
3a7b61de68 | |||
|
efee22a655 | ||
4faa8813e4 | |||
dd1b2f9636 | |||
a31d8638e7 | |||
6af0d4ec7a | |||
021e6c439c | |||
e87f86af95 | |||
ca7ae883ee | |||
72fc7493b2 | |||
1631a70a0b | |||
27f773e091 | |||
6d07fcbd6c | |||
6415f871d7 | |||
feaef5a3fa | |||
624ddc38aa | |||
9803710ff3 | |||
4d8525f52d | |||
d0b7f89925 | |||
032fa14f61 | |||
8b487b0a82 | |||
f6eed53550 | |||
cb61f7cc5e | |||
5ec4dd2aaf | |||
b8bd42d361 | |||
89edafb586 | |||
0d5245b48b | |||
d20b30d34d | |||
b99e7c198a | |||
c3b6d6939f | |||
868c220e42 | |||
cde892c771 | |||
974c94fbb0 | |||
2be3f4256a | |||
5427876e36 | |||
abdc4e31dc | |||
db7ea6f2fe | |||
d8b2aa9720 | |||
63c4da8fad | |||
3fe2886925 | |||
86486207b8 | |||
569b170aba | |||
f6c9e19a60 | |||
6b891fcb8e | |||
|
8b6c4beed8 | ||
|
5e0c8a695c | ||
46cd4de854 | |||
871d3fcdb3 | |||
4ad9355e47 | |||
1dee4655a7 | |||
0a104d222c | |||
80167fd21b | |||
7de9980c10 | |||
89f3eb0306 | |||
716b4801aa | |||
9199b68080 | |||
|
a24ce91acb | ||
|
9ab1ea1c23 | ||
8b232e0155 | |||
aec16f4407 | |||
b2ac47c2d3 | |||
31cf6d287d | |||
b282225363 | |||
95c03396d0 | |||
a5038535f4 | |||
d82ae8544b | |||
0caef2e81c | |||
cb333fd420 | |||
f61cfa532d | |||
39b885c47c | |||
da85683f7c | |||
0beab67bd4 | |||
4622f31fa4 | |||
0eff8e5dcf | |||
1516561a58 | |||
5c93840f85 | |||
ea50cffac9 | |||
8a48a5043a | |||
cc90ef3ec6 | |||
31e5ead21e | |||
d451d2d548 | |||
729ecc9475 | |||
6c9ca0ccb8 | |||
6b1d079f69 | |||
6e858ff52f | |||
ca02b8ce62 | |||
2b0b6570ea | |||
909949ff22 | |||
436933f73f | |||
4d59732263 | |||
12efe41551 | |||
362222c882 | |||
fcb9aa0a76 | |||
d9bae984b2 | |||
994801525a | |||
939c2c735c | |||
287e1041bd | |||
9845c5ae9e | |||
7ae2734e9f | |||
d5dd8e849f | |||
079e2ac539 | |||
aeb8132fc7 | |||
dd51f2b4fd | |||
d7e0beabdf | |||
9d1a8f4c0f | |||
e4f4b5e066 | |||
19f2c2ebf8 | |||
2851f8d286 | |||
9360ad3487 | |||
c0b71290a4 | |||
3d9bf2582f | |||
cbc9c86edd | |||
480da6ff09 | |||
834209d506 | |||
ef606f3d9b | |||
b5131fa00d | |||
768afa9bf5 | |||
59dc239c67 | |||
ec546758a8 | |||
e93085d88a | |||
595891f040 | |||
b7b4d926b4 | |||
12e55da662 | |||
08c55adfbd | |||
ec8007125f | |||
17985e3b5a | |||
002f875c53 | |||
39c0e27cb2 | |||
97c6e58355 | |||
7162fa76f6 | |||
f5a73f09f8 | |||
ee56a105b3 | |||
19f2ad19b0 | |||
178a55d29e | |||
ff782a8642 | |||
e345fd60fd | |||
9c7532bd9d | |||
9d906a195a | |||
2d44ca7955 | |||
799c9ce2fb | |||
c35faab104 | |||
ce812d449b | |||
17b8306394 | |||
df2359712f | |||
de648fbb1d | |||
d0d141ef99 | |||
40b43217fc | |||
c6c36273b5 | |||
586e93190c | |||
9fe489de53 | |||
60d8b9ba77 | |||
1379c24362 | |||
bbf2a7d02d | |||
4c0583c91f | |||
04dffdb09e | |||
dd7fb31309 | |||
268fa84c9e | |||
b9b987490b | |||
230844c3ae | |||
6ce4eecb18 | |||
e364d01cf4 | |||
04ded5e8b8 | |||
83a36003b1 | |||
fc48b8f694 | |||
b0db73ab2f | |||
195cffbf88 | |||
bfb382de52 | |||
101f33df6e | |||
615167e7cd | |||
dde277cc3e | |||
7ead2277e8 | |||
da2a3eefa4 | |||
3877012274 | |||
e0aca18b38 | |||
19c81effbe | |||
f83f9edbef | |||
f90009b6d1 | |||
fbcb790611 | |||
8c98548dbc | |||
20c687a787 | |||
d376c1a993 | |||
10e658a922 | |||
9c30e27875 | |||
14c498c539 | |||
f4c1d65365 | |||
34d9c7a1c2 | |||
0d3cb152f9 | |||
63e15d37e8 | |||
51249fd678 | |||
0de5b9eb56 | |||
8288345bcb | |||
f349b5e351 | |||
de69003105 | |||
c84cafda18 | |||
78b4636028 | |||
9fbe0db567 | |||
1876d1fe0b | |||
30a092b365 | |||
464550cb5b | |||
a6babf3e90 | |||
62b9da844a | |||
fa9fd0935b | |||
1e77a6b043 | |||
216decafc1 | |||
849faad134 | |||
9642bab0c8 | |||
517698475c | |||
0b8da69394 | |||
a7c4fdb242 | |||
06b9632b70 | |||
94dd209e5e | |||
5d65cc3100 | |||
2042d6329d | |||
ff1d582605 | |||
b3fd49ef97 | |||
8a103ea89d | |||
29f8ee0778 | |||
5f240b632a | |||
d711fcd0f1 | |||
e312a91632 | |||
c10187f6ba | |||
d7db0d8ccd | |||
d2f9e55e68 | |||
ebcf263abd | |||
27c6b69874 | |||
386e5356af | |||
88cb8f4516 | |||
9c9995380e | |||
|
ff8dc0e85f | ||
|
1b94053542 | ||
|
d1f1f9230c | ||
|
59e95c7097 | ||
|
18f4a87dd7 | ||
|
664762fdec | ||
|
1458d93408 | ||
33e61beb4f | |||
0b31d8d56c | |||
cb2db2cadf | |||
f1d2c4e532 | |||
a07d105906 | |||
31182b6de9 | |||
586f53a788 | |||
1561aa5eb9 | |||
f4672a5b50 | |||
a5f1ebdc09 | |||
8587aa23c4 | |||
66cb09c8e4 | |||
6355921e59 | |||
4172d320e4 | |||
a8ba375e36 | |||
2334686c59 | |||
ebab65e233 | |||
692d3fe83a | |||
3b110c0b8a | |||
443c126b88 | |||
eb4798df4e | |||
c1340f6297 | |||
9e1cdaaa51 | |||
cfce6b1bbd | |||
c4e19dddae | |||
9b49b8ebe7 | |||
8b069d8149 | |||
f4efb4f3d4 | |||
180cc33ded | |||
431b33a4da | |||
58e784408c | |||
91b2a23c78 | |||
cbbe942dfd | |||
8bab1e19cb | |||
c80688b241 | |||
|
b1e98bd091 | ||
|
367f49253e | ||
|
6f1a64a705 | ||
|
f12ac1c839 | ||
|
03c83702ad | ||
|
e2c38b5459 | ||
|
7f62503237 | ||
e1e9efde25 | |||
fb3f847f6a | |||
|
888f12d88d | ||
|
b8357629a2 | ||
1b56e9ed9b | |||
ba63a9fb05 | |||
2585f726c5 | |||
|
dadb1801aa | ||
37732f35dd | |||
|
2f6255a4e8 | ||
5d8c143e60 | |||
0b94e315b4 | |||
4a422795d9 | |||
1a27a21fa1 | |||
bba069599f | |||
ba751f8c35 | |||
1f7ee57889 | |||
d4faaf428c | |||
a163278fb5 | |||
1e2573d3e7 | |||
5c5f0665e8 | |||
0ca51236bd | |||
a62cc8b3b9 | |||
cc0b9726ed | |||
bec63898af | |||
9cccba42e0 | |||
4fc9b35c13 | |||
34496a7158 | |||
e0ed145716 | |||
2e52357dd2 | |||
104f7165cd | |||
edbc8770e3 | |||
31068bf89c | |||
ad6b3d60eb | |||
bd2ef96216 | |||
faa920e1ad | |||
eb28ed3938 | |||
f4f0e07bc1 | |||
ca6664feb2 | |||
6f3769f364 | |||
0c5936ad38 | |||
263b611a7b | |||
79d449d0df | |||
dd621fcd5c | |||
c2af84a800 | |||
3fa7b93d44 | |||
4d72c20d9b | |||
97ad4268d7 | |||
ed2d64c1c9 | |||
c9ecd0c020 | |||
6aaf7c039d | |||
7aa20a5820 | |||
9afabacde3 | |||
f10f4ac29c | |||
da88a8816c | |||
63de1891af | |||
23e851ccef | |||
5f406e6b18 | |||
9aad139aae | |||
4fb2c331f3 | |||
1a96c3ec72 | |||
b084a1f727 | |||
56ce55677f | |||
c528626fe9 | |||
8361f3767b | |||
b72a17c190 | |||
6842bff04b | |||
6bec233e23 | |||
873ccef4ff | |||
4706d2915f | |||
1d59ad20c1 | |||
b4f7e4f102 | |||
e664fe8470 | |||
28b9d22a4c | |||
be376a9ffb | |||
76f8df13fc | |||
9447912fbf | |||
87717606b2 | |||
|
348bc32cef | ||
|
fcdb0b65c2 | ||
|
0fb79d1268 | ||
|
69757e50ac | ||
06feeab244 | |||
568945c7a8 | |||
dd33e47dd9 | |||
|
7dfe760285 | ||
|
d7b8cec50d | ||
|
92f3018b89 | ||
3806fba9c2 | |||
b44c04d3c0 | |||
220b9959a3 | |||
f8ec341015 | |||
3ceeb3ae40 | |||
56f0091f1e | |||
ec886e345b | |||
786eabb748 | |||
fa18dc7979 | |||
136f9ed00a | |||
e312740629 | |||
31d0a1fb38 | |||
ca30f8a815 | |||
21c337e0fa | |||
8251652445 | |||
5e28dd046b | |||
363070b579 | |||
63ed1299ec | |||
7bd483cd7e | |||
91019f52aa | |||
69a26cb22f | |||
cdb06fa5bf | |||
9c76ce7174 | |||
676dc44619 | |||
b8a3019e5b | |||
e0a15849df | |||
ef57f27c6a | |||
169c5ae8e9 | |||
760143a4a2 | |||
b100bcd446 | |||
04ddbaabae | |||
4a2882711d | |||
08113c961a | |||
e2da46e20a | |||
0cf44da917 | |||
d03638919a | |||
f5d342a442 | |||
06cab2f098 | |||
9d67ae800d | |||
d2a1030320 | |||
5c17d23606 | |||
bc1759aedf | |||
b9aef10db3 | |||
bdb6ac9fba | |||
4d5f935e82 | |||
d604e44dff | |||
2c37da4cb4 | |||
741078c4fd | |||
e101cf2aab | |||
3dfae74468 | |||
2363f42bc9 | |||
491454ca3c | |||
562b2296e5 | |||
3535afb1e1 | |||
7a63e4abb9 | |||
2281cd1cd4 | |||
4037b339e4 | |||
00c3140f3b | |||
0fb282d153 | |||
7a73f99581 | |||
bdd68f04e1 | |||
a5a300b150 | |||
197cec923e | |||
c391a1f566 | |||
1727113a8b | |||
18ac959970 | |||
d00c5bb753 | |||
ffcf07b935 | |||
042531abc3 | |||
4fc7355fba | |||
c12be088c6 | |||
9c3cfe8f7b | |||
d4c168af30 | |||
f2d3aee662 | |||
340db244f6 | |||
8969364f73 | |||
b67168134b | |||
97d33da686 | |||
1f35bda3d2 | |||
6960e8a8c7 | |||
b30cecd297 | |||
99fc6988a3 | |||
cf022f9959 | |||
0a1044743e | |||
94b204615b | |||
230c6dfc15 | |||
8be67e7065 | |||
378b2ae673 | |||
36e517bd80 | |||
569b3d0c97 | |||
daf68d24ab | |||
8a82f52100 | |||
d0864b9efe | |||
18bd606262 | |||
252f50108b | |||
015c34fc2b | |||
d7b47797df | |||
544d4e0635 | |||
73c9d6c1f3 | |||
d9578b6f1c | |||
b5e325cbee | |||
234938349c | |||
9ed7277ec9 | |||
dc87c09442 | |||
00688765fd | |||
3702b72feb | |||
9af383d2f6 | |||
d3039d55e5 | |||
6b5c8df03a | |||
8084fe5574 | |||
3d661cd1f4 | |||
853d7471c2 | |||
0a205680fe | |||
52fee6a4c1 | |||
fcdd3bba2b | |||
b491efa9f4 | |||
401cf79cf6 | |||
44a20ca7e3 | |||
5bda1c2245 | |||
eb3d91f085 | |||
aff396d919 | |||
f7cd24b67a | |||
1e21457efb | |||
583ec78eef | |||
9969281b11 | |||
6fec1cc409 | |||
2984da773d | |||
1b83708a6d | |||
0de2489440 | |||
fd5416c94e | |||
48137ec24d | |||
febef4bed4 | |||
b599670572 | |||
57e9de6b05 | |||
9679706a08 | |||
777c9839a1 | |||
a6c9434590 | |||
fd77b65226 | |||
a23063fd4f | |||
a7cf696357 | |||
94d448d438 | |||
c62f3f88f1 | |||
39a32a6e0a | |||
342a346fce | |||
e0dd9833a3 | |||
591d3fcafd | |||
22f294493e | |||
5d3496fa41 | |||
4b500e4bf6 | |||
da85e5dd9b | |||
2b55d156ae | |||
f24491cd5a | |||
268bee3c5f | |||
5c3ea28e48 | |||
fdbcb261df | |||
2c3481d027 | |||
1c2ad0ceec | |||
7899d3e262 | |||
6b88cb7926 | |||
421125fee6 | |||
8563011939 | |||
e07672ffe6 | |||
23f6f9b26b | |||
e9c464b319 | |||
d3dc9101dd | |||
e018cdbc91 | |||
e2b8fd2880 | |||
680206b40b | |||
1c8af793c2 | |||
46351b2fe7 | |||
30cfa1b45e | |||
0756d63769 | |||
87ca54a253 | |||
9c2f49e4a0 | |||
49002ac52d | |||
b70e62ff3b | |||
046f803538 | |||
639b7646c9 | |||
89bb54a3ec | |||
979d9509c1 | |||
e9d48bcb7d | |||
318bd8297c | |||
0513b3aa0c | |||
458dbd723c | |||
8f0f4bfa65 | |||
da71d4947b | |||
6a83147ac0 | |||
f6cfc55e21 | |||
34a413cf05 | |||
854ade5fa9 | |||
be09230410 | |||
20b40d3e1c | |||
9f0e784a4a | |||
168fcc874e | |||
d446c192cf | |||
eb5a120286 | |||
2e1a011dcf | |||
8ef874eb22 | |||
c6dc84f27f | |||
8bb25e9b90 | |||
c6bdfe3f38 | |||
d1063b345d | |||
dea879199a | |||
9a034cb556 | |||
5cd22d284b | |||
f8fc1865a2 | |||
85444f235b | |||
15061f75a9 | |||
d138e869fc | |||
23170e170a | |||
156dfd88c2 | |||
730a9b7e63 | |||
3041b6a278 | |||
2da5be548a | |||
6f1b38cdb7 | |||
a8e4ef7234 | |||
c7405e054f | |||
9506dcb31e | |||
04aac10f1d | |||
bbb6379907 | |||
26d7e216a6 | |||
d629f50661 | |||
2245422d0f | |||
87889f5efe | |||
fb15a131ac | |||
8428c20bd4 | |||
ff7a6b8c8f | |||
d92a3e9239 | |||
d23ec14e9d | |||
ad23c89266 | |||
1c8958ad9d | |||
c99b7018c6 | |||
f2089f48b8 | |||
75e51c856e | |||
e60af33f75 | |||
993d14d409 | |||
bf0e636d57 | |||
374ac3b07f | |||
183b0c954e | |||
42559fd601 | |||
069ad4ca99 | |||
8db4b5a53e | |||
32883910bb | |||
9b3f78559e | |||
7bd2782fc8 | |||
75fbb5fb48 | |||
af2f9290c6 | |||
31fb8ba79b | |||
ee9626e4d2 | |||
9360f4295a | |||
abfa3b3ca1 | |||
a1b93624d6 | |||
69ff84eecc | |||
78889e18c6 | |||
fa178d5ee1 | |||
eea3272c56 | |||
27e76fc035 | |||
188165bc4d | |||
e6ddad5960 | |||
4228ca01dc | |||
64190ba55a | |||
c489c7fd5a | |||
acc063822e | |||
b612122180 | |||
d5fa00a4a4 | |||
e607ca4e8e | |||
d64c68f754 | |||
e5bf7d754f | |||
0e739755b7 | |||
f8eab1cbb6 | |||
0f2c81f894 | |||
e481732fae | |||
ee597c805e | |||
e561c55f73 | |||
2870bc6434 | |||
7e60631840 | |||
f2a1528ea9 | |||
21af7e9983 | |||
4ae37603f4 | |||
30b4a1f614 | |||
2797b58646 | |||
837612bb8d | |||
813fecbf15 | |||
a776fc9e06 | |||
08eb14e400 | |||
60c072a2b3 | |||
feedb95295 | |||
c93661f44e | |||
daa063c338 | |||
5abf1f8a84 | |||
133aa051eb | |||
d334b4150b | |||
36e28994ee | |||
01908c52f8 | |||
f9463d629a | |||
50315f5fae | |||
8817a3f226 | |||
fcde9c9b6b | |||
fb5a5a71a5 | |||
8134c6af80 | |||
7271a5e52b | |||
7baf15d9f0 | |||
d070b5be9e | |||
63d74e3524 | |||
a07019801c | |||
97ab22461c | |||
138db460a9 | |||
a9c0431ded | |||
7e4a05e1db | |||
0a4541a401 | |||
79773ba634 | |||
b249e1cbf8 | |||
25cf7c8ae8 | |||
3c97ced486 | |||
44482ae438 | |||
f597b3ab80 | |||
b8223b42bd | |||
ced1fd0038 | |||
2654a6ff23 | |||
5f763e90fc | |||
cf1c66a085 | |||
1395b62e60 | |||
85da5024ea | |||
a989f5f86e | |||
1c4c035acc | |||
d26ff2df77 | |||
5c37026ec7 | |||
8aa419b5c2 | |||
c191b418f2 | |||
0eb2714c9e | |||
0b33ac0e7d | |||
f55e366b17 | |||
b89b1708c3 | |||
f9c5a830e1 | |||
348bd98de8 | |||
4d984d32c3 | |||
8d879344f2 | |||
40547691a0 | |||
8f705b0737 | |||
67c9e2148d | |||
42fda5925d | |||
2c564f47d3 | |||
b4bc347006 | |||
f81fd1a1b4 | |||
a1b334a302 | |||
ff420fbe57 | |||
07eb23b312 | |||
6017cfe3d5 | |||
8eb0a4847f | |||
47f269782e | |||
d9a40af3f0 | |||
2281967176 | |||
6b38b55c58 | |||
12ffbb4d80 | |||
045239b620 | |||
dda81e9011 | |||
98a15bbf8e | |||
7a8b562173 | |||
0cbb3453bd | |||
062a04233f | |||
75c841e3c5 | |||
441b8b0154 |
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1 +1,7 @@
|
||||
.gitignore export-ignore
|
||||
.gitattributes export-ignore
|
||||
.gitmodules export-ignore
|
||||
.travis.yml export-ignore
|
||||
|
||||
tests/data/* linguist-documentation
|
||||
instances/* linguist-documentation
|
||||
|
16
.gitmodules
vendored
16
.gitmodules
vendored
@ -1,4 +1,12 @@
|
||||
[submodule "tests/googletest"]
|
||||
path = tests/googletest
|
||||
url = https://github.com/google/googletest.git
|
||||
ignore = dirty
|
||||
[submodule "lib/catch"]
|
||||
path = lib/catch
|
||||
url = https://github.com/catchorg/Catch2
|
||||
[submodule "lib/variant"]
|
||||
path = lib/variant
|
||||
url = https://github.com/mapbox/variant
|
||||
[submodule "tests/data/pddl-instances"]
|
||||
path = tests/data/pddl-instances
|
||||
url = https://github.com/potassco/pddl-instances.git
|
||||
[submodule "lib/cxxopts"]
|
||||
path = lib/cxxopts
|
||||
url = https://github.com/jarro2783/cxxopts
|
||||
|
30
.travis.yml
30
.travis.yml
@ -1,21 +1,29 @@
|
||||
# Use container-based distribution
|
||||
sudo: false
|
||||
language: c++
|
||||
addons:
|
||||
apt:
|
||||
sources: &default_sources
|
||||
- ubuntu-toolchain-r-test
|
||||
matrix:
|
||||
include:
|
||||
- compiler: gcc
|
||||
- env: COMPILER_NAME=g++ _CXX=g++-6
|
||||
os: linux
|
||||
language: cpp
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- boost-latest
|
||||
- *default_sources
|
||||
packages:
|
||||
- g++-5
|
||||
- libboost1.55-all-dev
|
||||
- libgtest-dev
|
||||
env: COMPILER=g++-5
|
||||
- g++-6
|
||||
script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER
|
||||
- make && make run-tests
|
||||
- if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||
CMAKE_URL="http://www.cmake.org/files/v3.9/cmake-3.9.4-Linux-x86_64.tar.gz";
|
||||
mkdir cmake-bin && wget --quiet --no-check-certificate -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake-bin;
|
||||
export PATH=${PWD}/cmake-bin/bin:${PATH};
|
||||
fi
|
||||
- git submodule update --recursive --init
|
||||
- mkdir -p build/debug
|
||||
- cd build/debug
|
||||
- cmake ../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=$_CXX -DTOKENIZE_BUILD_TESTS=ON -DPDDL_BUILD_TESTS=ON -DPLASP_BUILD_TESTS=ON
|
||||
- make -j3 plasp-app && make -j3 run-tokenize-tests && make -j3 run-pddl-tests && make -j3 run-tests
|
||||
|
84
CHANGELOG.md
Normal file
84
CHANGELOG.md
Normal file
@ -0,0 +1,84 @@
|
||||
# Changelog
|
||||
|
||||
## (unreleased)
|
||||
|
||||
## 3.1.1 (2017-11-25)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixes ASP syntax issues caused by hyphens in variable names by replacing all user-defined variables with `X1`, `X2`, etc.
|
||||
|
||||
## 3.1.0 (2017-11-17)
|
||||
|
||||
### Changes
|
||||
|
||||
* new command-line interface based on `plasp` commands:
|
||||
* `plasp translate`: translate PDDL and SAS to ASP facts (replaces former, plain `plasp` calls)
|
||||
* `plasp normalize`: normalize PDDL to plasp’s custom PDDL format
|
||||
* `plasp check-syntax`: check the syntax of PDDL specifications
|
||||
* `plasp beautify`: cleanly format PDDL specifications
|
||||
* new output format to accommodate for new PDDL features
|
||||
|
||||
### Features
|
||||
|
||||
* extended PDDL 3.1 support:
|
||||
* arbitrarily nested expressions in preconditions, effects, and goal description (via derived predicates)
|
||||
* universal and existential quantifiers
|
||||
* disjunctions
|
||||
* conditional effects
|
||||
* implications
|
||||
* equality (parser only)
|
||||
* new output option `--log-level` to control which status messages to show
|
||||
* new basic option `--warnings-as-errors` to abort program execution upon warnings (replaces `--warning-level`)
|
||||
* new compatibility mode for parser to support more legacy domains
|
||||
* new parser option `--parsing-mode` to specify whether to apply strict or compatibility parsing rules
|
||||
|
||||
### Internal
|
||||
|
||||
* PDDL parser reimplemented from scratch in stand-alone `pddl` library
|
||||
* removes dependency to Boost
|
||||
|
||||
## 3.0.3 (2016-09-02)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixes incorrect output format of conditional effects with SAS
|
||||
* fixes parsing issue with unexpected whitespaces in SAS files
|
||||
|
||||
## 3.0.2 (2016-08-18)
|
||||
|
||||
### Features
|
||||
|
||||
* unified translation format for SAS and PDDL files
|
||||
* documentation of `plasp`’s output format
|
||||
* improved output syntax highlighting
|
||||
* uses ASP string literals to avoid escaping PDDL identifiers
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixes minor formatting issues in SAS translation
|
||||
* fixes issue with unsupported expression negations
|
||||
|
||||
## 3.0.1 (2016-06-14)
|
||||
|
||||
### Features
|
||||
|
||||
* basic support for parsing PDDL 3.1 domains and problems
|
||||
* limited support for translating PDDL 3.1 domains and problems to ASP facts
|
||||
* automatic language detection for PDDL and SAS
|
||||
* supports input from `std::cin`
|
||||
* supports colorized output
|
||||
* new command-line option `--language` to explicitly specify input language
|
||||
* new command-line option `--warning-level` to treat warnings as errors or to ignore warnings
|
||||
* new command-line option `--color` to autodetect, enable, or disable color output
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fixes bug in translation of SAS axiom rules
|
||||
|
||||
## 3.0.0 (2016-05-24)
|
||||
|
||||
### Features
|
||||
|
||||
* parses [SAS](http://www.fast-downward.org/TranslatorOutputFormat) files created with [Fast Downward](http://www.fast-downward.org/)
|
||||
* experimental translation from SAS to ASP facts
|
@ -1,20 +1,40 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
project(plasp CXX)
|
||||
|
||||
find_package(Boost 1.55.0 COMPONENTS program_options iostreams system filesystem REQUIRED)
|
||||
option(PLASP_BUILD_TESTS "Build unit tests" OFF)
|
||||
option(PLASP_BUILD_STATIC "Build static binaries" OFF)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wpedantic")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
add_definitions(-std=c++14)
|
||||
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic -Werror ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
|
||||
option(BUILD_TESTS "Build unit tests" OFF)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
if(PLASP_BUILD_STATIC)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
|
||||
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
|
||||
endif()
|
||||
|
||||
if (CMAKE_GENERATOR STREQUAL "Ninja" AND
|
||||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)))
|
||||
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
|
||||
# Rationale in https://github.com/ninja-build/ninja/issues/814
|
||||
set(CMAKE_CXX_FLAGS "-fdiagnostics-color=always ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
add_subdirectory(lib/tokenize)
|
||||
add_subdirectory(lib/colorlog)
|
||||
add_subdirectory(lib/pddl)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(apps)
|
||||
if(BUILD_TESTS)
|
||||
add_subdirectory(app)
|
||||
if(PLASP_BUILD_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif(BUILD_TESTS)
|
||||
endif(PLASP_BUILD_TESTS)
|
||||
|
20
KNOWN-ISSUES.md
Normal file
20
KNOWN-ISSUES.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Known Issues
|
||||
|
||||
## Parser
|
||||
|
||||
- multiple PDDL features are not yet supported (see list of PDDL features supported by `plasp`)
|
||||
- several error messages obtained with syntax errors are misleading
|
||||
|
||||
## Translator
|
||||
|
||||
- in compatibility mode, the outdated `vars` sections within action definitions are handled just like `parameters`, which is semantically incorrect
|
||||
- equality expressions currently partly supported by parser but not the translator
|
||||
|
||||
## ASP Output Format
|
||||
|
||||
- SAS axiom rules and `plasp`’s derived predicates (obtained through normalization) are semantically similar, but differently represented
|
||||
|
||||
## Encodings
|
||||
|
||||
- the [simple example encoding](encodings/sequential-horizon.lp) does not SAS axiom rules
|
||||
- [multiple encodings](encodings/outdated) are outdated and need to be adapted to the output format introduced with `plasp` 3.1.0
|
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Patrick Lühne
|
||||
Copyright © 2016 Patrick Lühne
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
95
README.md
95
README.md
@ -1,56 +1,89 @@
|
||||
# plasp—Translate PDDL to ASP
|
||||
# plasp [![GitHub Release](https://img.shields.io/github/release/potassco/plasp.svg?maxAge=3600)](https://github.com/potassco/plasp/releases) [![Build Status](https://img.shields.io/travis/potassco/plasp/master.svg?maxAge=3600&label=build%20%28master%29)](https://travis-ci.org/potassco/plasp?branch=master) [![Build Status](https://img.shields.io/travis/potassco/plasp/develop.svg?maxAge=3600&label=build%20%28develop%29)](https://travis-ci.org/potassco/plasp?branch=develop)
|
||||
|
||||
[![Build Status](https://travis-ci.org/potassco/plasp.svg?branch=master)](https://travis-ci.org/potassco/plasp)
|
||||
> ASP planning tools for PDDL
|
||||
|
||||
`plasp` 3 is in early development and not intended for productive use yet.
|
||||
## Overview
|
||||
|
||||
As of now, `plasp` 3 experimentally supports the full [SAS Format](http://www.fast-downward.org/TranslatorOutputFormat) (as of version 3) used by [Fast Downward](http://www.fast-downward.org/).
|
||||
`plasp` is a tool collection for planning in [*answer set programming*](https://en.wikipedia.org/wiki/Answer_set_programming).
|
||||
`plasp` 3 supports the input languages [PDDL 3.1](https://helios.hud.ac.uk/scommv/IPC-14/software.html) (except for advanced features such as durative actions, numerical fluents, and preferences) and [SAS](http://www.fast-downward.org/TranslatorOutputFormat) (full support of SAS 3), which is used by [Fast Downward](http://www.fast-downward.org/).
|
||||
|
||||
Please get in touch with [Patrick Lühne](https://www.luehne.de) if you have any suggestions.
|
||||
The most notable tool provided by `plasp` is `plasp translate`, which translates PDDL descriptions to ASP facts.
|
||||
|
||||
## Usage
|
||||
## Translating PDDL to ASP Facts
|
||||
|
||||
To translate an SAS file into ASP facts, call:
|
||||
PDDL instances are translated to ASP facts as follows:
|
||||
|
||||
```bash
|
||||
$ plasp file.sas
|
||||
```sh
|
||||
plasp translate domain.pddl problem.pddl
|
||||
```
|
||||
|
||||
For instance, a PDDL instance can be solved as follows.
|
||||
First, use [Fast Downward](http://www.fast-downward.org/) to translate the files from PDDL to SAS:
|
||||
Alternatively, PDDL instances may first be translated to SAS, the output format of [Fast Downward](http://www.fast-downward.org/).
|
||||
|
||||
```bash
|
||||
$ ./fast-downward.py --translate --build=release64 domain.pddl instance.pddl
|
||||
```sh
|
||||
./fast-downward.py --translate --build=release64 domain.pddl problem.pddl
|
||||
```
|
||||
|
||||
This creates the file `output.sas`.
|
||||
The translated SAS instance can now be solved incrementally with `clingo` and the meta encoding `meta-sequential-incremental.lp`:
|
||||
This creates a file called `output.sas`, which may now be translated by `plasp` as well.
|
||||
|
||||
```bash
|
||||
$ plasp output.sas > instance.lp
|
||||
$ clingo encodings/meta-sequential-incremental.lp instance.lp
|
||||
```sh
|
||||
plasp translate output.sas
|
||||
```
|
||||
|
||||
### Solving the Translated Instance
|
||||
|
||||
The translated instance can finally be solved with `clingo` and a meta encoding, for instance, [`sequential-horizon.lp`](encodings/sequential-horizon.lp):
|
||||
|
||||
```sh
|
||||
plasp translate domain.pddl problem.pddl > instance.lp
|
||||
clingo encodings/sequential-horizon.lp -c horizon=10 instance.lp
|
||||
```
|
||||
|
||||
### Translator Output Format
|
||||
|
||||
`plasp translate` provides a uniform output format for SAS and PDDL input problems.
|
||||
See [output format](doc/output-format.md) for more details.
|
||||
|
||||
If you want to write your own meta encoding for `plasp translate`’s output, this [simple example encoding](encodings/sequential-horizon.lp) gets you started.
|
||||
|
||||
## Provided Tools
|
||||
|
||||
```sh
|
||||
plasp <command> [<option>...] [<input file>...]
|
||||
```
|
||||
|
||||
Aside from translating PDDL to ASP facts, `plasp` provides the following commands:
|
||||
|
||||
| command | description |
|
||||
|---|---|
|
||||
| `translate` | Translate PDDL and SAS to ASP facts |
|
||||
| `normalize` | Normalize PDDL to plasp’s custom PDDL format |
|
||||
| `check-syntax` | Check the syntax of PDDL specifications |
|
||||
| `beautify` | Cleanly format PDDL specifications |
|
||||
| `help` | Display help message |
|
||||
| `version` | Display version information |
|
||||
|
||||
`plasp help` shows a list of all commands provided by `plasp`.
|
||||
To list all available options of a command, call `plasp <command> --help` or `plasp help <command>`.
|
||||
|
||||
`plasp` automatically detects the language (PDDL or SAS) of the input descriptions.
|
||||
|
||||
## Building
|
||||
|
||||
`plasp` requires a C++14 compiler (preferrably GCC ≥ 6.1), the `boost` libraries (≥ 1.55), and CMake for building.
|
||||
`plasp` is built with CMake and a C++ compiler.
|
||||
See [building](doc/building.md) for more details.
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/potassco/plasp.git
|
||||
$ cd plasp
|
||||
$ mkdir -p build/release
|
||||
$ cd build/release
|
||||
$ cmake ../.. -DCMAKE_BUILD_TYPE=Release
|
||||
$ make
|
||||
```
|
||||
## PDDL Feature Support
|
||||
|
||||
The built `plasp` binary is then located at `plasp/build/release/bin/plasp`.
|
||||
`plasp` supports a subset of PDDL 3.1.
|
||||
See [PDDL feature support](doc/pddl-feature-support.md) for a list of supported and unsupported PDDL 3.1 features.
|
||||
|
||||
## Contributors
|
||||
|
||||
* [Patrick Lühne](https://www.luehne.de) (`plasp` 3)
|
||||
* [Patrick Lühne](https://www.luehne.de)
|
||||
* Martin Gebser (encodings)
|
||||
* Torsten Schaub (encodings)
|
||||
|
||||
### Earlier Versions
|
||||
|
||||
* René Knaebel (`plasp` 2)
|
||||
* Murat Knecht (`plasp`)
|
||||
* René Knaebel
|
||||
* Murat Knecht
|
||||
|
1
app/CMakeLists.txt
Normal file
1
app/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(src)
|
71
app/include/plasp-app/Command.h
Normal file
71
app/include/plasp-app/Command.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef __PLASP_APP__COMMAND_H
|
||||
#define __PLASP_APP__COMMAND_H
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <plasp-app/Utils.h>
|
||||
#include <plasp-app/Version.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class Derived, class... OptionGroups>
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
void printHelp()
|
||||
{
|
||||
const auto numberOfOptionGroups = std::tuple_size<std::decay_t<decltype(m_optionGroups)>>();
|
||||
|
||||
std::vector<std::string> optionGroupNames;
|
||||
optionGroupNames.reserve(numberOfOptionGroups + 1);
|
||||
optionGroupNames.emplace_back("");
|
||||
|
||||
forEach(m_optionGroups,
|
||||
[&](auto &optionGroup)
|
||||
{
|
||||
optionGroupNames.emplace_back(optionGroup.Name);
|
||||
});
|
||||
|
||||
std::cout << m_options.help(optionGroupNames) << std::endl;
|
||||
}
|
||||
|
||||
protected:
|
||||
Command()
|
||||
: m_options(std::string("plasp ") + Derived::Name, std::string(Derived::Description) + ".")
|
||||
{
|
||||
forEach(m_optionGroups,
|
||||
[&](auto &optionGroup)
|
||||
{
|
||||
optionGroup.addTo(m_options);
|
||||
});
|
||||
}
|
||||
|
||||
void parseOptions(int argc, char **argv)
|
||||
{
|
||||
const auto parseResult = m_options.parse(argc, argv);
|
||||
|
||||
forEach(m_optionGroups,
|
||||
[&](auto &optionGroup)
|
||||
{
|
||||
optionGroup.read(parseResult);
|
||||
});
|
||||
}
|
||||
|
||||
static void printVersion()
|
||||
{
|
||||
std::cout << Version << std::endl;
|
||||
}
|
||||
|
||||
cxxopts::Options m_options;
|
||||
std::tuple<OptionGroups...> m_optionGroups;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
67
app/include/plasp-app/CommandType.h
Normal file
67
app/include/plasp-app/CommandType.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef __PLASP_APP__COMMAND_TYPE_H
|
||||
#define __PLASP_APP__COMMAND_TYPE_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <plasp-app/commands/CommandBeautify.h>
|
||||
#include <plasp-app/commands/CommandCheckSyntax.h>
|
||||
#include <plasp-app/commands/CommandHelp.h>
|
||||
#include <plasp-app/commands/CommandNormalize.h>
|
||||
#include <plasp-app/commands/CommandTranslate.h>
|
||||
#include <plasp-app/commands/CommandVersion.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Type
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum class CommandType
|
||||
{
|
||||
Help,
|
||||
Version,
|
||||
CheckSyntax,
|
||||
Requirements,
|
||||
Beautify,
|
||||
Normalize,
|
||||
Translate
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const std::map<std::string, CommandType> commandNames =
|
||||
{
|
||||
{"help", CommandType::Help},
|
||||
{"-h", CommandType::Help},
|
||||
{"--help", CommandType::Help},
|
||||
{"version", CommandType::Version},
|
||||
{"-v", CommandType::Version},
|
||||
{"--version", CommandType::Version},
|
||||
{"check-syntax", CommandType::CheckSyntax},
|
||||
{"requirements", CommandType::Requirements},
|
||||
{"beautify", CommandType::Beautify},
|
||||
{"normalize", CommandType::Normalize},
|
||||
{"translate", CommandType::Translate},
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const auto parseCommandType =
|
||||
[](const std::string &commandString)
|
||||
{
|
||||
const auto matchingCommand = commandNames.find(commandString);
|
||||
|
||||
if (matchingCommand == commandNames.cend())
|
||||
throw std::runtime_error(std::string("“") + commandString + "” is not a plasp command");
|
||||
|
||||
return matchingCommand->second;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using AvailableCommands = std::tuple<CommandTranslate, CommandNormalize, CommandCheckSyntax, CommandBeautify, CommandHelp, CommandVersion>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
69
app/include/plasp-app/OptionGroups.h
Normal file
69
app/include/plasp-app/OptionGroups.h
Normal file
@ -0,0 +1,69 @@
|
||||
#ifndef __PLASP_APP__OPTION_GROUPS_H
|
||||
#define __PLASP_APP__OPTION_GROUPS_H
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <pddl/Exception.h>
|
||||
#include <pddl/Mode.h>
|
||||
|
||||
#include <plasp/Language.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Option Groups
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OptionException : public pddl::Exception
|
||||
{
|
||||
public:
|
||||
using Exception::Exception;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct OptionGroupBasic
|
||||
{
|
||||
static constexpr const auto Name = "basic";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void read(const cxxopts::ParseResult &parseResult);
|
||||
|
||||
bool help = false;
|
||||
bool version = false;
|
||||
bool warningsAsErrors = false;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct OptionGroupOutput
|
||||
{
|
||||
static constexpr const auto Name = "output";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void read(const cxxopts::ParseResult &parseResult);
|
||||
|
||||
colorlog::ColorStream::ColorPolicy colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
||||
colorlog::Priority logPriority = colorlog::Priority::Info;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct OptionGroupParser
|
||||
{
|
||||
static constexpr const auto Name = "parser";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void read(const cxxopts::ParseResult &parseResult);
|
||||
|
||||
std::vector<std::string> inputFiles;
|
||||
pddl::Mode parsingMode = pddl::Mode::Strict;
|
||||
plasp::Language::Type language = plasp::Language::Type::Automatic;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
46
app/include/plasp-app/Utils.h
Normal file
46
app/include/plasp-app/Utils.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef __PLASP_APP__UTILS_H
|
||||
#define __PLASP_APP__UTILS_H
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <std::size_t... Index>
|
||||
auto makeIndexDispatcher(std::index_sequence<Index...>)
|
||||
{
|
||||
return
|
||||
[](auto &&f)
|
||||
{
|
||||
(f(std::integral_constant<std::size_t, Index>{}), ...);
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <std::size_t N>
|
||||
auto makeIndexDispatcher()
|
||||
{
|
||||
return makeIndexDispatcher(std::make_index_sequence<N>{});
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename Tuple, typename Functor>
|
||||
void forEach(Tuple &&tuple, Functor &&functor)
|
||||
{
|
||||
constexpr auto n = std::tuple_size<std::decay_t<Tuple>>::value;
|
||||
auto dispatcher = makeIndexDispatcher<n>();
|
||||
dispatcher(
|
||||
[&functor, &tuple](auto index)
|
||||
{
|
||||
functor(std::get<index>(std::forward<Tuple>(tuple)));
|
||||
});
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
14
app/include/plasp-app/Version.h
Normal file
14
app/include/plasp-app/Version.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __PLASP_APP__VERSION_H
|
||||
#define __PLASP_APP__VERSION_H
|
||||
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static constexpr const auto Version = "plasp version 3.1.1-git";
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandBeautify.h
Normal file
25
app/include/plasp-app/commands/CommandBeautify.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_BEAUTIFY_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_BEAUTIFY_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Beautify
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandBeautify : public Command<CommandBeautify, OptionGroupBasic, OptionGroupOutput, OptionGroupParser>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "beautify";
|
||||
static constexpr auto Description = "Cleanly format PDDL specifications";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandCheckSyntax.h
Normal file
25
app/include/plasp-app/commands/CommandCheckSyntax.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_CHECK_SYNTAX_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_CHECK_SYNTAX_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Check Syntax
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandCheckSyntax : public Command<CommandCheckSyntax, OptionGroupBasic, OptionGroupOutput, OptionGroupParser>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "check-syntax";
|
||||
static constexpr auto Description = "Check the syntax of PDDL specifications";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandHelp.h
Normal file
25
app/include/plasp-app/commands/CommandHelp.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_HELP_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_HELP_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Help
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandHelp : public Command<CommandHelp>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "help";
|
||||
static constexpr auto Description = "Display this help message";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandNormalize.h
Normal file
25
app/include/plasp-app/commands/CommandNormalize.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_NORMALIZE_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_NORMALIZE_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Normalize
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandNormalize : public Command<CommandNormalize, OptionGroupBasic, OptionGroupOutput, OptionGroupParser>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "normalize";
|
||||
static constexpr auto Description = "Normalize PDDL to plasp’s custom PDDL format";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandTranslate.h
Normal file
25
app/include/plasp-app/commands/CommandTranslate.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_TRANSLATE_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_TRANSLATE_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Translate
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandTranslate : public Command<CommandTranslate, OptionGroupBasic, OptionGroupOutput, OptionGroupParser>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "translate";
|
||||
static constexpr auto Description = "Translate PDDL and SAS to ASP facts";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
25
app/include/plasp-app/commands/CommandVersion.h
Normal file
25
app/include/plasp-app/commands/CommandVersion.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __PLASP_APP__COMMANDS__COMMAND_VERSION_H
|
||||
#define __PLASP_APP__COMMANDS__COMMAND_VERSION_H
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Version
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CommandVersion : public Command<CommandVersion>
|
||||
{
|
||||
public:
|
||||
static constexpr auto Name = "version";
|
||||
static constexpr auto Description = "Display version information";
|
||||
|
||||
public:
|
||||
int run(int argc, char **argv);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
34
app/src/CMakeLists.txt
Normal file
34
app/src/CMakeLists.txt
Normal file
@ -0,0 +1,34 @@
|
||||
set(target plasp-app)
|
||||
|
||||
file(GLOB core_sources "plasp-app/*.cpp")
|
||||
file(GLOB core_headers "../include/plasp-app/*.h")
|
||||
|
||||
file(GLOB commands_sources "plasp-app/commands/*.cpp")
|
||||
file(GLOB commands_headers "../include/plasp-app/commands/*.h")
|
||||
|
||||
set(includes
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/lib/tokenize/include
|
||||
${PROJECT_SOURCE_DIR}/lib/colorlog/include
|
||||
${PROJECT_SOURCE_DIR}/lib/variant/include
|
||||
${PROJECT_SOURCE_DIR}/lib/pddl/include
|
||||
${PROJECT_SOURCE_DIR}/lib/cxxopts/include
|
||||
${PROJECT_SOURCE_DIR}/app/include
|
||||
)
|
||||
|
||||
set(sources
|
||||
${core_sources}
|
||||
${core_headers}
|
||||
${commands_sources}
|
||||
${commands_headers}
|
||||
)
|
||||
|
||||
set(libraries
|
||||
stdc++fs
|
||||
plasp
|
||||
)
|
||||
|
||||
add_executable(${target} ${sources})
|
||||
target_include_directories(${target} PRIVATE ${includes})
|
||||
target_link_libraries(${target} ${libraries})
|
||||
set_target_properties(${target} PROPERTIES OUTPUT_NAME plasp)
|
108
app/src/plasp-app/OptionGroups.cpp
Normal file
108
app/src/plasp-app/OptionGroups.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
#include <plasp-app/OptionGroups.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Option Groups
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Nasty workaround needed for GCC prior to version 7
|
||||
constexpr decltype(OptionGroupBasic::Name) OptionGroupBasic::Name;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupBasic::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options(Name)
|
||||
("h,help", "Display this help message")
|
||||
("v,version", "Display version information")
|
||||
("warnings-as-errors", "Treat warnings as errors");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupBasic::read(const cxxopts::ParseResult &parseResult)
|
||||
{
|
||||
help = (parseResult.count("help") > 0);
|
||||
version = (parseResult.count("version") > 0);
|
||||
warningsAsErrors = (parseResult.count("warnings-as-errors") > 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Nasty workaround needed for GCC prior to version 7
|
||||
constexpr decltype(OptionGroupOutput::Name) OptionGroupOutput::Name;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupOutput::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options(Name)
|
||||
("color", "Colorize output (always, never, auto)", cxxopts::value<std::string>()->default_value("auto"))
|
||||
("p,log-priority", "Log messages starting from this priority (debug, info, warning, error)", cxxopts::value<std::string>()->default_value("info"));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupOutput::read(const cxxopts::ParseResult &parseResult)
|
||||
{
|
||||
const auto colorPolicyString = parseResult["color"].as<std::string>();
|
||||
|
||||
if (colorPolicyString == "auto")
|
||||
colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
||||
else if (colorPolicyString == "never")
|
||||
colorPolicy = colorlog::ColorStream::ColorPolicy::Never;
|
||||
else if (colorPolicyString == "always")
|
||||
colorPolicy = colorlog::ColorStream::ColorPolicy::Always;
|
||||
else
|
||||
throw OptionException("unknown color policy “" + colorPolicyString + "”");
|
||||
|
||||
const auto logPriorityString = parseResult["log-priority"].as<std::string>();
|
||||
|
||||
try
|
||||
{
|
||||
logPriority = colorlog::priorityFromName(logPriorityString.c_str());
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
throw OptionException(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Nasty workaround needed for GCC prior to version 7
|
||||
constexpr decltype(OptionGroupParser::Name) OptionGroupParser::Name;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupParser::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options(Name)
|
||||
("i,input", "Input files (in PDDL or SAS format)", cxxopts::value<std::vector<std::string>>())
|
||||
("parsing-mode", "Parsing mode (strict, compatibility)", cxxopts::value<std::string>()->default_value("strict"))
|
||||
("l,language", "Input language (pddl, sas, auto)", cxxopts::value<std::string>()->default_value("auto"));
|
||||
options.parse_positional("input");
|
||||
options.positional_help("[<input file...>]");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void OptionGroupParser::read(const cxxopts::ParseResult &parseResult)
|
||||
{
|
||||
const auto parsingModeString = parseResult["parsing-mode"].as<std::string>();
|
||||
|
||||
if (parsingModeString == "compatibility")
|
||||
parsingMode = pddl::Mode::Compatibility;
|
||||
else if (parsingModeString != "strict")
|
||||
throw OptionException("unknown parsing mode “" + parsingModeString + "”");
|
||||
|
||||
if (parseResult.count("input"))
|
||||
inputFiles = parseResult["input"].as<std::vector<std::string>>();
|
||||
|
||||
const auto languageName = parseResult["language"].as<std::string>();
|
||||
language = plasp::Language::fromString(languageName);
|
||||
|
||||
if (language == plasp::Language::Type::Unknown)
|
||||
throw OptionException("unknown input language “" + languageName + "”");
|
||||
}
|
145
app/src/plasp-app/commands/CommandBeautify.cpp
Normal file
145
app/src/plasp-app/commands/CommandBeautify.cpp
Normal file
@ -0,0 +1,145 @@
|
||||
#include <plasp-app/commands/CommandBeautify.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
#include <colorlog/Logger.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <pddl/AST.h>
|
||||
#include <pddl/ASTOutput.h>
|
||||
#include <pddl/Exception.h>
|
||||
#include <pddl/Mode.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
#include <plasp/LanguageDetection.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Beautify
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandBeautify::run(int argc, char **argv)
|
||||
{
|
||||
parseOptions(argc, argv);
|
||||
|
||||
const auto &basicOptions = std::get<OptionGroupBasic>(m_optionGroups);
|
||||
const auto &outputOptions = std::get<OptionGroupOutput>(m_optionGroups);
|
||||
const auto &parserOptions = std::get<OptionGroupParser>(m_optionGroups);
|
||||
|
||||
if (basicOptions.help)
|
||||
{
|
||||
printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (basicOptions.version)
|
||||
{
|
||||
printVersion();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
colorlog::Logger logger;
|
||||
logger.setColorPolicy(outputOptions.colorPolicy);
|
||||
logger.setLogPriority(outputOptions.logPriority);
|
||||
|
||||
if (basicOptions.warningsAsErrors)
|
||||
logger.setAbortPriority(colorlog::Priority::Warning);
|
||||
|
||||
const auto printCompatibilityInfo =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.parsingMode != pddl::Mode::Compatibility)
|
||||
logger.log(colorlog::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
tokenize::Tokenizer<tokenize::CaseInsensitiveTokenizerPolicy> tokenizer;
|
||||
|
||||
if (!parserOptions.inputFiles.empty())
|
||||
std::for_each(parserOptions.inputFiles.cbegin(), parserOptions.inputFiles.cend(),
|
||||
[&](const auto &inputFile)
|
||||
{
|
||||
tokenizer.read(inputFile);
|
||||
});
|
||||
else
|
||||
{
|
||||
logger.log(colorlog::Priority::Info, "reading from stdin");
|
||||
tokenizer.read("std::cin", std::cin);
|
||||
}
|
||||
|
||||
const auto detectLanguage =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.language == plasp::Language::Type::Automatic)
|
||||
return plasp::detectLanguage(tokenizer);
|
||||
|
||||
return parserOptions.language;
|
||||
};
|
||||
|
||||
switch (detectLanguage())
|
||||
{
|
||||
case plasp::Language::Type::Automatic:
|
||||
case plasp::Language::Type::Unknown:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO: get rid of unknown language type, use exception instead
|
||||
case plasp::Language::Type::PDDL:
|
||||
{
|
||||
const auto logWarning =
|
||||
[&](const auto &location, const auto &warning)
|
||||
{
|
||||
logger.log(colorlog::Priority::Warning, location, warning);
|
||||
};
|
||||
|
||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||
context.mode = parserOptions.parsingMode;
|
||||
auto description = pddl::parseDescription(context);
|
||||
logger.outputStream() << description;
|
||||
break;
|
||||
}
|
||||
|
||||
case plasp::Language::Type::SAS:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "Beautification is only supported for PDDL specifications");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const tokenize::TokenizerException &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.location(), e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const pddl::ParserException &e)
|
||||
{
|
||||
if (e.location())
|
||||
logger.log(colorlog::Priority::Error, e.location().value(), e.message().c_str());
|
||||
else
|
||||
logger.log(colorlog::Priority::Error, e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
145
app/src/plasp-app/commands/CommandCheckSyntax.cpp
Normal file
145
app/src/plasp-app/commands/CommandCheckSyntax.cpp
Normal file
@ -0,0 +1,145 @@
|
||||
#include <plasp-app/commands/CommandCheckSyntax.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
#include <colorlog/Logger.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <pddl/AST.h>
|
||||
#include <pddl/ASTOutput.h>
|
||||
#include <pddl/Exception.h>
|
||||
#include <pddl/Mode.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
#include <plasp/LanguageDetection.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Check Syntax
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandCheckSyntax::run(int argc, char **argv)
|
||||
{
|
||||
parseOptions(argc, argv);
|
||||
|
||||
const auto &basicOptions = std::get<OptionGroupBasic>(m_optionGroups);
|
||||
const auto &outputOptions = std::get<OptionGroupOutput>(m_optionGroups);
|
||||
const auto &parserOptions = std::get<OptionGroupParser>(m_optionGroups);
|
||||
|
||||
if (basicOptions.help)
|
||||
{
|
||||
printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (basicOptions.version)
|
||||
{
|
||||
printVersion();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
colorlog::Logger logger;
|
||||
logger.setColorPolicy(outputOptions.colorPolicy);
|
||||
logger.setLogPriority(outputOptions.logPriority);
|
||||
|
||||
if (basicOptions.warningsAsErrors)
|
||||
logger.setAbortPriority(colorlog::Priority::Warning);
|
||||
|
||||
const auto printCompatibilityInfo =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.parsingMode != pddl::Mode::Compatibility)
|
||||
logger.log(colorlog::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
tokenize::Tokenizer<tokenize::CaseInsensitiveTokenizerPolicy> tokenizer;
|
||||
|
||||
if (!parserOptions.inputFiles.empty())
|
||||
std::for_each(parserOptions.inputFiles.cbegin(), parserOptions.inputFiles.cend(),
|
||||
[&](const auto &inputFile)
|
||||
{
|
||||
tokenizer.read(inputFile);
|
||||
});
|
||||
else
|
||||
{
|
||||
logger.log(colorlog::Priority::Info, "reading from stdin");
|
||||
tokenizer.read("std::cin", std::cin);
|
||||
}
|
||||
|
||||
const auto detectLanguage =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.language == plasp::Language::Type::Automatic)
|
||||
return plasp::detectLanguage(tokenizer);
|
||||
|
||||
return parserOptions.language;
|
||||
};
|
||||
|
||||
switch (detectLanguage())
|
||||
{
|
||||
case plasp::Language::Type::Automatic:
|
||||
case plasp::Language::Type::Unknown:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO: get rid of unknown language type, use exception instead
|
||||
case plasp::Language::Type::PDDL:
|
||||
{
|
||||
const auto logWarning =
|
||||
[&](const auto &location, const auto &warning)
|
||||
{
|
||||
logger.log(colorlog::Priority::Warning, location, warning);
|
||||
};
|
||||
|
||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||
context.mode = parserOptions.parsingMode;
|
||||
auto description = pddl::parseDescription(context);
|
||||
logger.log(colorlog::Priority::Info, "no syntax errors found");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
case plasp::Language::Type::SAS:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "Syntax checking is only supported for PDDL specifications");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const tokenize::TokenizerException &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.location(), e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const pddl::ParserException &e)
|
||||
{
|
||||
if (e.location())
|
||||
logger.log(colorlog::Priority::Error, e.location().value(), e.message().c_str());
|
||||
else
|
||||
logger.log(colorlog::Priority::Error, e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
87
app/src/plasp-app/commands/CommandHelp.cpp
Normal file
87
app/src/plasp-app/commands/CommandHelp.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
#include <plasp-app/commands/CommandHelp.h>
|
||||
|
||||
#include <colorlog/Logger.h>
|
||||
|
||||
#include <plasp-app/CommandType.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Help
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandHelp::run(int argc, char **argv)
|
||||
{
|
||||
colorlog::Logger logger;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (parseCommandType(argv[1]))
|
||||
{
|
||||
case CommandType::Help:
|
||||
case CommandType::Version:
|
||||
break;
|
||||
|
||||
case CommandType::Translate:
|
||||
CommandTranslate().printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
case CommandType::Normalize:
|
||||
CommandNormalize().printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
case CommandType::Beautify:
|
||||
CommandBeautify().printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
case CommandType::CheckSyntax:
|
||||
CommandCheckSyntax().printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
default:
|
||||
logger.log(colorlog::Priority::Error, std::string("command “") + argv[1] + "” not yet implemented");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
catch (std::exception &exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
std::cout
|
||||
<< "ASP planning tools for PDDL." << std::endl
|
||||
<< "Usage:" << std::endl
|
||||
<< " plasp <command> [<arguments>]" << std::endl << std::endl
|
||||
<< " available commands:" << std::endl;
|
||||
|
||||
AvailableCommands availableCommands;
|
||||
|
||||
size_t lengthOfLongestCommandName = 0;
|
||||
|
||||
forEach(availableCommands,
|
||||
[&](const auto &command)
|
||||
{
|
||||
lengthOfLongestCommandName = std::max(lengthOfLongestCommandName, std::strlen(command.Name));
|
||||
});
|
||||
|
||||
const auto printSpaces =
|
||||
[](const auto numberOfSpaces)
|
||||
{
|
||||
for (auto i = static_cast<decltype(numberOfSpaces)>(0); i < numberOfSpaces; i++)
|
||||
std::cout << " ";
|
||||
};
|
||||
|
||||
forEach(availableCommands,
|
||||
[&](const auto &command)
|
||||
{
|
||||
const auto lengthOfCommandName = std::strlen(command.Name);
|
||||
|
||||
std::cout << " " << command.Name;
|
||||
printSpaces(lengthOfLongestCommandName - lengthOfCommandName + 2);
|
||||
std::cout << command.Description << std::endl;
|
||||
});
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
148
app/src/plasp-app/commands/CommandNormalize.cpp
Normal file
148
app/src/plasp-app/commands/CommandNormalize.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
#include <plasp-app/commands/CommandNormalize.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
#include <colorlog/Logger.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <pddl/AST.h>
|
||||
#include <pddl/Exception.h>
|
||||
#include <pddl/Mode.h>
|
||||
#include <pddl/Normalize.h>
|
||||
#include <pddl/NormalizedASTOutput.h>
|
||||
#include <pddl/Parse.h>
|
||||
#include <pddl/detail/normalization/Reduction.h>
|
||||
|
||||
#include <plasp/LanguageDetection.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Normalize
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandNormalize::run(int argc, char **argv)
|
||||
{
|
||||
parseOptions(argc, argv);
|
||||
|
||||
const auto &basicOptions = std::get<OptionGroupBasic>(m_optionGroups);
|
||||
const auto &outputOptions = std::get<OptionGroupOutput>(m_optionGroups);
|
||||
const auto &parserOptions = std::get<OptionGroupParser>(m_optionGroups);
|
||||
|
||||
if (basicOptions.help)
|
||||
{
|
||||
printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (basicOptions.version)
|
||||
{
|
||||
printVersion();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
colorlog::Logger logger;
|
||||
logger.setColorPolicy(outputOptions.colorPolicy);
|
||||
logger.setLogPriority(outputOptions.logPriority);
|
||||
|
||||
if (basicOptions.warningsAsErrors)
|
||||
logger.setAbortPriority(colorlog::Priority::Warning);
|
||||
|
||||
const auto printCompatibilityInfo =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.parsingMode != pddl::Mode::Compatibility)
|
||||
logger.log(colorlog::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
tokenize::Tokenizer<tokenize::CaseInsensitiveTokenizerPolicy> tokenizer;
|
||||
|
||||
if (!parserOptions.inputFiles.empty())
|
||||
std::for_each(parserOptions.inputFiles.cbegin(), parserOptions.inputFiles.cend(),
|
||||
[&](const auto &inputFile)
|
||||
{
|
||||
tokenizer.read(inputFile);
|
||||
});
|
||||
else
|
||||
{
|
||||
logger.log(colorlog::Priority::Info, "reading from stdin");
|
||||
tokenizer.read("std::cin", std::cin);
|
||||
}
|
||||
|
||||
const auto detectLanguage =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.language == plasp::Language::Type::Automatic)
|
||||
return plasp::detectLanguage(tokenizer);
|
||||
|
||||
return parserOptions.language;
|
||||
};
|
||||
|
||||
switch (detectLanguage())
|
||||
{
|
||||
case plasp::Language::Type::Automatic:
|
||||
case plasp::Language::Type::Unknown:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO: get rid of unknown language type, use exception instead
|
||||
case plasp::Language::Type::PDDL:
|
||||
{
|
||||
const auto logWarning =
|
||||
[&](const auto &location, const auto &warning)
|
||||
{
|
||||
logger.log(colorlog::Priority::Warning, location, warning);
|
||||
};
|
||||
|
||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||
context.mode = parserOptions.parsingMode;
|
||||
auto description = pddl::parseDescription(context);
|
||||
auto normalizedDescription = pddl::normalize(std::move(description));
|
||||
logger.outputStream() << normalizedDescription;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
case plasp::Language::Type::SAS:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "Normalization is only supported for PDDL specifications");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const tokenize::TokenizerException &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.location(), e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const pddl::ParserException &e)
|
||||
{
|
||||
if (e.location())
|
||||
logger.log(colorlog::Priority::Error, e.location().value(), e.message().c_str());
|
||||
else
|
||||
logger.log(colorlog::Priority::Error, e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
161
app/src/plasp-app/commands/CommandTranslate.cpp
Normal file
161
app/src/plasp-app/commands/CommandTranslate.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
#include <plasp-app/commands/CommandTranslate.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
#include <colorlog/Logger.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <pddl/AST.h>
|
||||
#include <pddl/Exception.h>
|
||||
#include <pddl/Mode.h>
|
||||
#include <pddl/Normalize.h>
|
||||
#include <pddl/NormalizedASTOutput.h>
|
||||
#include <pddl/Parse.h>
|
||||
#include <pddl/detail/normalization/Reduction.h>
|
||||
|
||||
#include <plasp/LanguageDetection.h>
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/TranslatorASP.h>
|
||||
#include <plasp/sas/Description.h>
|
||||
#include <plasp/sas/TranslatorASP.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Translate
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandTranslate::run(int argc, char **argv)
|
||||
{
|
||||
parseOptions(argc, argv);
|
||||
|
||||
const auto &basicOptions = std::get<OptionGroupBasic>(m_optionGroups);
|
||||
const auto &outputOptions = std::get<OptionGroupOutput>(m_optionGroups);
|
||||
const auto &parserOptions = std::get<OptionGroupParser>(m_optionGroups);
|
||||
|
||||
if (basicOptions.help)
|
||||
{
|
||||
printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (basicOptions.version)
|
||||
{
|
||||
printVersion();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
colorlog::Logger logger;
|
||||
logger.setColorPolicy(outputOptions.colorPolicy);
|
||||
logger.setLogPriority(outputOptions.logPriority);
|
||||
|
||||
if (basicOptions.warningsAsErrors)
|
||||
logger.setAbortPriority(colorlog::Priority::Warning);
|
||||
|
||||
const auto printCompatibilityInfo =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.parsingMode != pddl::Mode::Compatibility)
|
||||
logger.log(colorlog::Priority::Info, "try using --parsing-mode=compatibility for extended legacy feature support");
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
tokenize::Tokenizer<tokenize::CaseInsensitiveTokenizerPolicy> tokenizer;
|
||||
|
||||
if (!parserOptions.inputFiles.empty())
|
||||
std::for_each(parserOptions.inputFiles.cbegin(), parserOptions.inputFiles.cend(),
|
||||
[&](const auto &inputFile)
|
||||
{
|
||||
tokenizer.read(inputFile);
|
||||
});
|
||||
else
|
||||
{
|
||||
logger.log(colorlog::Priority::Info, "reading from stdin");
|
||||
tokenizer.read("std::cin", std::cin);
|
||||
}
|
||||
|
||||
const auto detectLanguage =
|
||||
[&]()
|
||||
{
|
||||
if (parserOptions.language == plasp::Language::Type::Automatic)
|
||||
return plasp::detectLanguage(tokenizer);
|
||||
|
||||
return parserOptions.language;
|
||||
};
|
||||
|
||||
switch (detectLanguage())
|
||||
{
|
||||
case plasp::Language::Type::Automatic:
|
||||
case plasp::Language::Type::Unknown:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// TODO: get rid of unknown language type, use exception instead
|
||||
case plasp::Language::Type::PDDL:
|
||||
{
|
||||
const auto logWarning =
|
||||
[&](const auto &location, const auto &warning)
|
||||
{
|
||||
logger.log(colorlog::Priority::Warning, location, warning);
|
||||
};
|
||||
|
||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||
context.mode = parserOptions.parsingMode;
|
||||
auto description = pddl::parseDescription(context);
|
||||
auto normalizedDescription = pddl::normalize(std::move(description));
|
||||
const auto translator = plasp::pddl::TranslatorASP(std::move(normalizedDescription), logger.outputStream());
|
||||
translator.translate();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
case plasp::Language::Type::SAS:
|
||||
{
|
||||
const auto description = plasp::sas::Description::fromTokenizer(std::move(tokenizer));
|
||||
const auto translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
||||
translator.translate();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const tokenize::TokenizerException &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.location(), e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const pddl::ParserException &e)
|
||||
{
|
||||
if (e.location())
|
||||
logger.log(colorlog::Priority::Error, e.location().value(), e.message().c_str());
|
||||
else
|
||||
logger.log(colorlog::Priority::Error, e.message().c_str());
|
||||
|
||||
printCompatibilityInfo();
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const plasp::TranslatorException &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
14
app/src/plasp-app/commands/CommandVersion.cpp
Normal file
14
app/src/plasp-app/commands/CommandVersion.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include <plasp-app/commands/CommandVersion.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Command Version
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int CommandVersion::run(int, char **)
|
||||
{
|
||||
printVersion();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
69
app/src/plasp-app/main.cpp
Normal file
69
app/src/plasp-app/main.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cxxopts.hpp>
|
||||
|
||||
#include <colorlog/Logger.h>
|
||||
#include <colorlog/Priority.h>
|
||||
|
||||
#include <plasp-app/Command.h>
|
||||
#include <plasp-app/CommandType.h>
|
||||
#include <plasp-app/Version.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Main
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
colorlog::Logger logger;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
CommandHelp().run(argc - 1, &argv[1]);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (parseCommandType(argv[1]))
|
||||
{
|
||||
case CommandType::Help:
|
||||
return CommandHelp().run(argc - 1, &argv[1]);
|
||||
|
||||
case CommandType::Version:
|
||||
return CommandVersion().run(argc - 1, &argv[1]);
|
||||
|
||||
case CommandType::Translate:
|
||||
return CommandTranslate().run(argc - 1, &argv[1]);
|
||||
|
||||
case CommandType::Normalize:
|
||||
return CommandNormalize().run(argc - 1, &argv[1]);
|
||||
|
||||
case CommandType::Beautify:
|
||||
return CommandBeautify().run(argc - 1, &argv[1]);
|
||||
|
||||
case CommandType::CheckSyntax:
|
||||
return CommandCheckSyntax().run(argc - 1, &argv[1]);
|
||||
|
||||
default:
|
||||
logger.log(colorlog::Priority::Error, std::string("command “") + argv[1] + "” not yet implemented");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
catch (std::exception &exception)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, exception.what());
|
||||
std::cout << std::endl;
|
||||
|
||||
CommandHelp().run(argc - 1, &argv[1]);
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_FAILURE;
|
||||
}
|
@ -1 +0,0 @@
|
||||
add_subdirectory(plasp-app)
|
@ -1,23 +0,0 @@
|
||||
set(target plasp_app)
|
||||
|
||||
file(GLOB core_sources "*.cpp")
|
||||
file(GLOB core_headers "*.h")
|
||||
|
||||
include_directories(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
set(sources
|
||||
${core_sources}
|
||||
${core_headers}
|
||||
)
|
||||
|
||||
set(libraries
|
||||
${Boost_LIBRARIES}
|
||||
plasp
|
||||
)
|
||||
|
||||
add_executable(${target} ${sources})
|
||||
target_link_libraries(${target} ${libraries})
|
||||
set_target_properties(plasp_app PROPERTIES OUTPUT_NAME plasp)
|
@ -1,81 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <plasp/sas/Description.h>
|
||||
#include <plasp/sas/TranslatorASP.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
namespace po = boost::program_options;
|
||||
|
||||
po::options_description description("Allowed options");
|
||||
description.add_options()
|
||||
("help,h", "Display this help message.")
|
||||
("version,v", "Display version information.")
|
||||
("input,i", po::value<std::string>(), "Specify the SAS input file.");
|
||||
|
||||
po::positional_options_description positionalOptionsDescription;
|
||||
positionalOptionsDescription.add("input", -1);
|
||||
|
||||
po::variables_map variablesMap;
|
||||
|
||||
const auto printHelp =
|
||||
[&]()
|
||||
{
|
||||
std::cout << "Usage: plasp file [options]" << std::endl;
|
||||
std::cout << "Translate PDDL instances to ASP facts." << std::endl << std::endl;
|
||||
|
||||
std::cout << description;
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
po::store(po::command_line_parser(argc, argv)
|
||||
.options(description)
|
||||
.positional(positionalOptionsDescription)
|
||||
.run(),
|
||||
variablesMap);
|
||||
po::notify(variablesMap);
|
||||
}
|
||||
catch (const po::error &e)
|
||||
{
|
||||
std::cerr << "Error: " << e.what() << std::endl << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (variablesMap.count("help"))
|
||||
{
|
||||
printHelp();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (variablesMap.count("version"))
|
||||
{
|
||||
std::cout << "plasp version 3.0.0" << std::endl;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
if (!variablesMap.count("input"))
|
||||
{
|
||||
std::cerr << "Error: No input file specified" << std::endl << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const auto sasDescription = plasp::sas::Description::fromFile(variablesMap["input"].as<std::string>());
|
||||
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
||||
sasTranslator.translate(std::cout);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
std::cerr << "Error: " << e.what() << std::endl << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
47
doc/building.md
Normal file
47
doc/building.md
Normal file
@ -0,0 +1,47 @@
|
||||
# Building
|
||||
|
||||
`plasp` requires a C++17 compiler (preferably GCC ≥ 6.1 or clang ≥ 3.8) and CMake for building.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/potassco/plasp.git
|
||||
cd plasp
|
||||
mkdir -p build/release
|
||||
cd build/release
|
||||
cmake ../.. -DCMAKE_BUILD_TYPE=Release
|
||||
make
|
||||
```
|
||||
|
||||
The built `plasp` binary is then located at `plasp/build/release/bin/plasp`.
|
||||
|
||||
To update `plasp` to the most recent version, perform the following steps:
|
||||
|
||||
```sh
|
||||
cd plasp
|
||||
git checkout master
|
||||
git pull
|
||||
cd build/release
|
||||
cmake .
|
||||
make
|
||||
```
|
||||
|
||||
## Running the Tests
|
||||
|
||||
`plasp` provides unit tests written with [Catch2](https://github.com/catchorg/Catch2).
|
||||
Before building and running the tests, make sure you have fetched the Catch submodule:
|
||||
|
||||
```sh
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
Afterward, enable the flag `BUILD_TESTS` in your CMake configuration.
|
||||
Finally, build and run the tests as follows:
|
||||
|
||||
```sh
|
||||
make run-tokenize-tests
|
||||
make run-pddl-tests
|
||||
make run-tests
|
||||
```
|
||||
|
||||
After updating `plasp`, make sure to execute CMake again in order for the tests to run correctly.
|
||||
Else, external files required by the test suite may be reported missing.
|
22
doc/feature-requirements.md
Normal file
22
doc/feature-requirements.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Feature Requirements
|
||||
|
||||
Feature requirements are part of `plasp`’s [output format](output-format.md).
|
||||
Currently, `plasp` detects feature requirements only for SAS problems.
|
||||
|
||||
`plasp` supports the following feature requirements:
|
||||
|
||||
SAS feature | description
|
||||
------------|------------
|
||||
`actionCosts` | actions have associated costs (see [action costs](output-format.md#action-costs))
|
||||
`axiomRules` | immediate actions are used, which are executed as soon as the preconditions are satisfied (see [axiom rules](output-format.md#axiom-rules))
|
||||
`conditionalEffects` | some effects of an action may have additional conditions (see [actions](output-format.md#actions))
|
||||
|
||||
## Example
|
||||
|
||||
The following specifies that the input problem has the two requirements `actionCosts` and `conditionalEffects`.
|
||||
|
||||
```prolog
|
||||
% requirements
|
||||
requiresFeature(actionCosts).
|
||||
requiresFeature(conditionalEffects).
|
||||
```
|
290
doc/output-format.md
Normal file
290
doc/output-format.md
Normal file
@ -0,0 +1,290 @@
|
||||
# Output Format
|
||||
|
||||
`plasp` 3 translates SAS and PDDL files into a uniform ASP fact format.
|
||||
|
||||
## Overview
|
||||
|
||||
Essentially, `plasp`’s output format consists of [state variables](#variables) that are modified by [actions](#actions) if their preconditions are fulfilled.
|
||||
Variables reference [entities](#constants-objects) that are affected by the actions.
|
||||
As with PDDL, the objective is to achieve a specific [goal](#goal) starting from an [initial state](#initial-state) by executing a sequence of actions.
|
||||
|
||||
`plasp`’s variables correspond to the multivalued variables in SAS.
|
||||
PDDL predicates are turned into Boolean variables to make the output format consistent.
|
||||
|
||||
Actions are modeled exactly as PDDL actions and SAS operators.
|
||||
|
||||
## In a Nutshell
|
||||
|
||||
Consider the following, simplistic PDDL problem of turning a switch on:
|
||||
|
||||
```lisp
|
||||
; simplistic example of turning a switch on
|
||||
(define (domain switch)
|
||||
(:requirements :typing)
|
||||
(:types switch)
|
||||
(:predicates
|
||||
(on ?x - switch))
|
||||
(:action turn-on
|
||||
:parameters
|
||||
(?x - switch)
|
||||
:precondition
|
||||
(not (on ?x))
|
||||
:effect
|
||||
(on ?x)))
|
||||
|
||||
; example problem with one switch
|
||||
(define (problem switch-problem)
|
||||
(:domain switch)
|
||||
(:objects a - switch)
|
||||
(:init
|
||||
(not (on a)))
|
||||
(:goal
|
||||
(on a)))
|
||||
```
|
||||
|
||||
This is translated by `plasp translate` into the following output format (slightly restructured for clarity):
|
||||
|
||||
```prolog
|
||||
% declares the type “type("switch")”
|
||||
type(type("switch")).
|
||||
|
||||
% introduces a switch “constant("a")”
|
||||
constant(constant("a")).
|
||||
has(constant("a"), type("switch")).
|
||||
|
||||
% declares a variable “variable(on(X))” for switches X
|
||||
variable(variable(("on", X))) :- has(X, type("switch")).
|
||||
|
||||
% variables may have the values true and false
|
||||
boolean(true).
|
||||
boolean(false).
|
||||
contains(X, value(X, B)) :- variable(X), boolean(B).
|
||||
|
||||
% declares the action “action(turnOn(X))”, which requires switch X to be off and then turns it on
|
||||
action(action(("turn-on", X))) :- has(X, type("switch")).
|
||||
precondition(action(("turn-on", X)), variable(("on", X)), value(variable(("on", X)), false))
|
||||
:- action(action(("turn-on", X))).
|
||||
postcondition(action(("turn-on", X)), effect(unconditional), variable(("on", X)), value(variable(("on", X)), true))
|
||||
:- action(action(("turn-on", X))).
|
||||
|
||||
% initially, the switch is off
|
||||
initialState(variable(("on", constant("a"))), value(variable(("on", constant("a"))), false)).
|
||||
|
||||
% in the end, the switch should be on
|
||||
goal(variable(("on", constant("a"))), value(variable(("on", constant("a"))), true)).
|
||||
```
|
||||
|
||||
## Syntax and Semantics
|
||||
|
||||
`plasp` structures the translated ASP facts into multiple sections, which are explained in the following.
|
||||
|
||||
### Feature Requirements
|
||||
|
||||
```prolog
|
||||
% declares a required feature
|
||||
requires(feature(<name>)).
|
||||
```
|
||||
|
||||
`plasp` recognizes and declares advanced features used by the input problem, such as [conditional effects](#actions), [mutex groups](#mutex-groups) and [axiom rules](#axiom-rules) (currently only SAS).
|
||||
See the [full list of supported features](feature-requirements.md) for more information.
|
||||
|
||||
The feature requirement predicates may be used in meta encodings to warn about unsupported features.
|
||||
|
||||
### Types
|
||||
|
||||
```prolog
|
||||
% declares a <type>
|
||||
type(type(<name>)).
|
||||
|
||||
% specifies that <type 1> inherits <type 2>
|
||||
inherits(<type 1>, <type 2>).
|
||||
|
||||
% specifies <constant> to have type <type>
|
||||
has(<constant>, <type>).
|
||||
```
|
||||
|
||||
[Variables](#variables), [constants](#constants-objects), and [objects](#constants-objects) may be typed. Types are only available with PDDL and if typing is enabled.
|
||||
|
||||
`plasp` automatically generates all matching `has` predicates for objects with types that inherit other types.
|
||||
|
||||
### Variables
|
||||
|
||||
```prolog
|
||||
% declares a <variable>
|
||||
variable(variable(<name>)).
|
||||
|
||||
% adds a <value> to the domain of a <variable>
|
||||
contains(<variable>, <value>).
|
||||
```
|
||||
|
||||
`plasp`’s variables represent the current state of the planning problem.
|
||||
Variables are linked to the problem's [objects](#constants-objects) and [constants](#constants-objects).
|
||||
|
||||
`plasp`’s variables are multivalued, and each variable has exactly one value at each point in time.
|
||||
|
||||
With SAS, variable names are numbers starting at 0, `variable(<number>)`.
|
||||
SAS variables are inherently multivalued, which results in two or more values of the form `value(<SAS predicate>, <SAS value>)` for each variable.
|
||||
|
||||
With PDDL, Boolean variables are created from the PDDL predicates.
|
||||
Variables are named after the PDDL predicate signatures, `variable(<PDDL predicate>).`
|
||||
Each variable contains exactly two values (one `true`, one `false`) of the form `value(<variable>, <bool>)`.
|
||||
Note that with PDDL, values contain the corresponding variables as the first argument to make the format consistent with the multi-valued variables obtained with SAS input.
|
||||
|
||||
### Derived Variables
|
||||
|
||||
```prolog
|
||||
% declares a <derived variable>
|
||||
derivedVariable(derivedVariable(<name>)).
|
||||
|
||||
% adds a <value> to the domain of a <derived variable>
|
||||
contains(<derived variable>, <value>).
|
||||
```
|
||||
|
||||
Derived variables are introduced whenever the translator needs to use [derived predicates](#derived-predicates).
|
||||
When the preconditions of a [derived predicate](#derived-predicates) are met, the corresponding derived variable (named after the derived predicate) is set as an effect.
|
||||
|
||||
Derived variables are analogously defined to common variables and may also be referenced in preconditions, conditions of conditional effects, and goal descriptions, just as variables.
|
||||
|
||||
In contrast to common variables, derived variables *are not subject to inertia rules.*
|
||||
In other words, derived variables are computed for each time step separately, and reset when going to the next time step (their values don’t automatically carry over to the next time step).
|
||||
|
||||
### Actions
|
||||
|
||||
```prolog
|
||||
% declares an <action>
|
||||
action(action(<name>)).
|
||||
|
||||
% defines that as a precondition to <action>, <variable> and <derived variable> must have value <value>
|
||||
precondition(<action>, <variable>, <value>).
|
||||
precondition(<action>, <derived variable>, <value>).
|
||||
|
||||
% defines that after applying <action>, <variable> is assigned <value>
|
||||
postcondition(<action>, effect(<number>), <variable>, <value>).
|
||||
|
||||
% defines the condition of a conditional effect
|
||||
precondition(effect(<number>), <variable>, <value>).
|
||||
precondition(effect(<number>), <derived variable>, <value>).
|
||||
|
||||
% specifies the costs of applying <action>
|
||||
costs(<action>, <number>).
|
||||
```
|
||||
|
||||
Actions may require certain [variables](#variables) (or [derived variables](#derived-variables)) to have specific values in order to be executed.
|
||||
After applying an action, variables get new values according to the action's postconditions.
|
||||
|
||||
Actions may have *conditional effects*, that is, certain postconditions are only applied if additional conditions are satisfied.
|
||||
For this reason, each conditional effect is uniquely identified with a predicate `effect(<number>)` as the second argument of the `postcondition` facts.
|
||||
The conditions of conditional effects are given by additional `precondition` facts that take the respective `effect(<number>)` predicates as the first argument.
|
||||
|
||||
Unconditional effects are identified with `effect(unconditional)`.
|
||||
|
||||
Conditional effects are currently only supported with SAS input problems.
|
||||
|
||||
Actions may also have *action costs* required to apply them. Action costs are currently supported for SAS only.
|
||||
|
||||
### Derived Predicates
|
||||
|
||||
```prolog
|
||||
% declares a <derived predicate> of with conjunctive (type(and)) or disjunctive (type(or)) preconditions
|
||||
derivedPredicate(derivedPredicate(<name>), type(<and/or>)).
|
||||
|
||||
% defines that as a precondition to <derived predicate>, <variable> and <derived variable> must have value <value>
|
||||
precondition(<derived predicate>, type(<and/or>), <variable>, <value>).
|
||||
precondition(<derived predicate>, type(<and/or>), <derived variable>, <value>).
|
||||
|
||||
% defines that after applying <action>, <derived variable> is assigned <value>
|
||||
postcondition(<derived predicate>, type(<and/or>), effect(<number>), <derived variable>, <value>).
|
||||
|
||||
% defines the condition of a conditional effect
|
||||
precondition(effect(<number>), <variable>, <value>).
|
||||
precondition(effect(<number>), <derived variable>, <value>).
|
||||
|
||||
% specifies the costs of applying <action>
|
||||
costs(<action>, <number>).
|
||||
```
|
||||
|
||||
Derived predicates are introduced by the translator when there are nested expressions or disjunctions in action preconditions, conditions of conditional effects, or goal descriptions.
|
||||
Derived predicates operate on [derived variables](#derived-variables) of the same name.
|
||||
|
||||
Like actions, derived predicates must satisfy preconditions in order for their effect to be applicable.
|
||||
The effect of all derived predicates is to set the corresponding [derived variables](#derived-variables) to `true` or `false`.
|
||||
|
||||
In contrast to actions, however, derived predicates specify whether their preconditions are to be interpreted as a *conjunction* (`type(and)`) or as a *disjunction* (`type(or)`).
|
||||
Encoding authors need to ensure that derived predicate preconditions are interpreted in the correct way.
|
||||
|
||||
### Constants/Objects
|
||||
|
||||
```prolog
|
||||
% declares a <constant> or object
|
||||
constant(constant(<name>)).
|
||||
|
||||
% specifies <constant> to have type type(<name>)
|
||||
has(<constant>, <type>).
|
||||
```
|
||||
|
||||
Constants and objects are the entities that are affected by [actions](#actions), for instance, the blocks in a Blocks World problem.
|
||||
Constants are global for a domain, while objects are problem-specific.
|
||||
|
||||
`plasp` does not distinguish between the two (modeling both as constants), as both are identically used static identifiers.
|
||||
|
||||
### Initial State
|
||||
|
||||
```prolog
|
||||
% initializes <variable> with a specific <value>
|
||||
initialState(<variable>, <value>).
|
||||
```
|
||||
|
||||
The initial state contains all [variable](#variables) assignments that hold before executing any [actions](#actions).
|
||||
|
||||
Note that with PDDL, `plasp` sets all unspecified initial state variables to `false` in order to make the initial state total.
|
||||
|
||||
### Goal
|
||||
|
||||
```prolog
|
||||
% specifies that <variable> and <derived variable> shall obtain a respective <value> in the end
|
||||
goal(<variable>, <value>).
|
||||
goal(<derived variable>, <value>).
|
||||
```
|
||||
|
||||
The goal specifies all assignments of [variables](#variables) and [derived variables](#derived-variables) that have to be fulfilled after executing the action sequence.
|
||||
|
||||
### Mutex Groups
|
||||
|
||||
```prolog
|
||||
% declares a <mutex group>
|
||||
mutexGroup(mutexGroup(<number>)).
|
||||
|
||||
% adds the assignment of <variable> to <value> to a <mutex group>
|
||||
contains(<mutex group>, <variable>, <value>).
|
||||
```
|
||||
|
||||
SAS contains information about mutually exclusive [variable](#variables) assignments.
|
||||
That is, *at most one* variable assignment of each mutex group must be satisfied at all times.
|
||||
|
||||
Mutex group facts are only present with SAS input programs and not PDDL.
|
||||
|
||||
Mutex groups contain essential information in order to find plans correctly.
|
||||
That is, if mutex groups are present in `plasp`’s output, they have to be accounted for appropriately.
|
||||
|
||||
### Axiom Rules
|
||||
|
||||
```prolog
|
||||
% declares an <axiom rule>
|
||||
axiomRule(axiomRule(<number>)).
|
||||
|
||||
% defines that as a precondition to <axiom rule>, <variable> must have value <value>
|
||||
precondition(<axiom rule>, <variable>, <value>).
|
||||
|
||||
% defines that after applying <axiom rule>, <variable> is assigned <value>
|
||||
postcondition(<axiom rule>, effect(unconditional), <variable>, <value>).
|
||||
```
|
||||
|
||||
Axiom rules are similar to [actions](#actions) in that they modify [variables](#variables) if certain preconditions are satisfied.
|
||||
However, axiom rules must be applied *immediately* as soon as their preconditions are satisfied.
|
||||
|
||||
The second argument of `postcondition`, `effect(unconditional)`, is not used and exists only for consistency with [actions](#actions).
|
||||
|
||||
Axiom rule facts are only present with SAS input programs and not PDDL.
|
||||
|
||||
Axiom rules contain essential information in order to find plans correctly.
|
||||
That is, if axiom rules are present in `plasp`’s output, they have to be accounted for appropriately.
|
27
doc/pddl-feature-support.md
Normal file
27
doc/pddl-feature-support.md
Normal file
@ -0,0 +1,27 @@
|
||||
# PDDL Feature Support
|
||||
|
||||
This document describes the PDDL features are currently supported by `plasp`’s very own translator.
|
||||
|
||||
This doesn’t cover PDDL feature support through SAS conversion with [Fast Downward](http://www.fast-downward.org/) (please refer to [Fast Downward’s homepage](http://www.fast-downward.org/) for more information).
|
||||
|
||||
The table below lists the features of PDDL 3.1 and whether or not they are supported by `plasp`.
|
||||
Unless otherwise noted, this refers to `plasp`’s parser, normalizer, translator, and ASP output format.
|
||||
|
||||
| PDDL feature | description | supported by `plasp` |
|
||||
|---|---|---|
|
||||
| STRIPS | basic STRIPS functionality, the general PDDL sections (`:domain`, `:problem`, `:predicates`, `:action`) | yes |
|
||||
| typing | typed variables and constants, type inheritance | yes (except for `either` type directives) |
|
||||
| negative preconditions | typed variables and constants, type inheritance | yes |
|
||||
| disjunctive preconditions | `or` expressions in preconditions | yes |
|
||||
| existential preconditions | `exists` expressions in preconditions | yes |
|
||||
| universal preconditions | `forall` expressions in preconditions | yes |
|
||||
| conditional effects | `when` expressions in action effects | yes |
|
||||
| universal effects | `forall` expressions in effects | yes |
|
||||
| equality | `=` expressions for atomic formulas | no (parser support only) |
|
||||
| numeric fluents | numeric function definitions in `:functions` section, assignment operators, arithmetic preconditions | no |
|
||||
| action costs | actions are assigned costs through numeric fluents | no |
|
||||
| durative actions | temporal planning with action durations | no |
|
||||
| derived predicates | predicates whose truth value is defined by a formula | no (`plasp` introduces *custom* derived predicates to support nested expressions, but derived predicates specified in the PDDL input are currently not supported) |
|
||||
| timed initial literals | initial state may specify literals that become true at a specified time point | no |
|
||||
| preferences | preferences in action preconditions and goals | no |
|
||||
| constraints | additional constraints for domain and problem | no |
|
@ -1,40 +0,0 @@
|
||||
#include <incmode>.
|
||||
|
||||
% Check feature requirements
|
||||
:- requiresFeature(actionCosts).
|
||||
:- requiresFeature(axiomRules).
|
||||
:- requiresFeature(conditionalEffects).
|
||||
|
||||
#program base.
|
||||
|
||||
% Establish initial state
|
||||
holds(Var, Val, 0) :- initialState(Var, Val).
|
||||
|
||||
#program step(t).
|
||||
|
||||
% Perform actions
|
||||
1 {occurs(action(A), t) : action(A)} 1.
|
||||
|
||||
% Check preconditions
|
||||
:- occurs(A, t), precondition(A, Var, Val), not holds(Var, Val, t - 1).
|
||||
|
||||
% Apply effects
|
||||
caused(Var, Val, t) :- occurs(A, t), postcondition(A, _, Var, Val).
|
||||
modified(Var, t) :- caused(Var, Val, t).
|
||||
|
||||
holds(Var, Val, t) :- caused(Var, Val, t).
|
||||
holds(Var, Val, t) :- holds(Var, Val, t - 1), not modified(Var, t).
|
||||
|
||||
% Check that variables have unique values
|
||||
:- variable(X), Var = variable(X), not 1 {holds(Var, Val, t) : contains(Var, Val)} 1.
|
||||
|
||||
% Check mutexes
|
||||
:- mutexGroup(X), M = mutexGroup(X), not {holds(Var, Val, t) : contains(M, Var, Val)} 1.
|
||||
|
||||
#program check(t).
|
||||
|
||||
% Verify that goal is met
|
||||
:- query(t), goal(Var, Val), not holds(Var, Val, t).
|
||||
|
||||
#show query/1.
|
||||
#show occurs/2.
|
27
encodings/outdated/pddl-sequential-horizon-boolean.lp
Normal file
27
encodings/outdated/pddl-sequential-horizon-boolean.lp
Normal file
@ -0,0 +1,27 @@
|
||||
#const horizon=1.
|
||||
|
||||
step(0..horizon).
|
||||
|
||||
precondition(Action,variable(Fluent),Value) :- precondition(Action, variable(Fluent),value(Fluent,Value)).
|
||||
postcondition(Action,variable(Fluent),Value) :- postcondition(Action,effect(unconditional),variable(Fluent),value(Fluent,Value)).
|
||||
|
||||
holds(variable(Fluent),0) :- initialState(variable(Fluent),value(Fluent,true)).
|
||||
|
||||
{ occurs(Action,T) : action(Action) } = 1 :- step(T), T>0.
|
||||
|
||||
:- occurs(Action,T), precondition(Action,Fluent,true), not holds(Fluent,T-1).
|
||||
:- occurs(Action,T), precondition(Action,Fluent,false), holds(Fluent,T-1).
|
||||
|
||||
caused(Fluent,T) :- occurs(Action,T), postcondition(Action,Fluent,true).
|
||||
|
||||
holds(Fluent,T) :- caused(Fluent,T).
|
||||
holds(Fluent,T) :- holds(Fluent,T-1), not occurs(Action,T) : postcondition(Action,Fluent,false); T<=horizon.
|
||||
|
||||
goalAt(T) :- holds(variable(Variable),T) : goal(variable(Variable), value(Variable,true));
|
||||
not holds(variable(Variable),T) : goal(variable(Variable), value(Variable,false));
|
||||
T=horizon.
|
||||
|
||||
:- not goalAt(horizon).
|
||||
|
||||
#show occurs/2.
|
||||
% #show holds/2.
|
30
encodings/outdated/pddl-sequential-incremental-boolean.lp
Normal file
30
encodings/outdated/pddl-sequential-incremental-boolean.lp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <incmode>.
|
||||
|
||||
#program base.
|
||||
|
||||
precondition(Action,variable(Fluent),Value) :- precondition(Action, variable(Fluent),value(Fluent,Value)).
|
||||
postcondition(Action,variable(Fluent),Value) :- postcondition(Action,effect(unconditional),variable(Fluent),value(Fluent,Value)).
|
||||
|
||||
holds(variable(Fluent),0) :- initialState(variable(Fluent),value(Fluent,true)).
|
||||
|
||||
#program step(t).
|
||||
|
||||
{ occurs(Action,t) : action(Action) } = 1.
|
||||
|
||||
:- occurs(Action,t), precondition(Action,Fluent,true), not holds(Fluent,t-1).
|
||||
:- occurs(Action,t), precondition(Action,Fluent,false), holds(Fluent,t-1).
|
||||
|
||||
caused(Fluent,t) :- occurs(Action,t), postcondition(Action,Fluent,true).
|
||||
|
||||
holds(Fluent,t) :- caused(Fluent,t).
|
||||
holds(Fluent,t) :- holds(Fluent,t-1), not occurs(Action,t) : postcondition(Action,Fluent,false).
|
||||
|
||||
#program check(t).
|
||||
|
||||
goalAt(t) :- holds(variable(Variable),t) : goal(variable(Variable), value(Variable,true));
|
||||
not holds(variable(Variable),t) : goal(variable(Variable), value(Variable,false)).
|
||||
|
||||
:- not goalAt(t), query(t).
|
||||
|
||||
#show occurs/2.
|
||||
% #show holds/2.
|
@ -0,0 +1,52 @@
|
||||
#include <incmode>.
|
||||
|
||||
% Check feature requirements
|
||||
% :- requires(feature(actionCosts)).
|
||||
|
||||
#program base.
|
||||
|
||||
% Establish initial state
|
||||
holds(Variable, Value, 0) :- initialState(Variable, Value), not stateVariable(Variable).
|
||||
|
||||
% Identify (head and) state variables
|
||||
headVariable(Rule,Variable) :- variable(Variable), axiomRule(Rule), postcondition(Rule,_,Variable,_).
|
||||
stateVariable(Variable) :- headVariable(_,Variable).
|
||||
|
||||
#program step(t). % t=1,2,...
|
||||
|
||||
% Perform actions
|
||||
1 {occurs(Action, t) : action(Action)} 1.
|
||||
|
||||
% Check preconditions
|
||||
:- occurs(Action, t), precondition(Action, Variable, Value), not holds(Variable, Value, t - 1).
|
||||
|
||||
% Apply effects
|
||||
caused(Variable, Value, t) :- occurs(Action, t), postcondition(Action, Effect, Variable, Value),
|
||||
holds(Variable', Value', t - 1) : precondition(Effect, Variable', Value').
|
||||
changed(Variable, t) :- caused(Variable, Value, t).
|
||||
|
||||
holds(Variable, Value, t) :- caused(Variable, Value, t).
|
||||
holds(Variable, Value, t) :- holds(Variable, Value, t - 1), not changed(Variable, t), not stateVariable(Variable).
|
||||
|
||||
#program check(t). % t=0,1,...
|
||||
|
||||
% Check that variables have unique values
|
||||
:- variable(Variable), {holds(Variable, Value, t) : contains(Variable, Value)} != 1.
|
||||
|
||||
% Check mutexes
|
||||
:- mutexGroup(MutexGroup), {holds(Variable, Value, t) : contains(MutexGroup, Variable, Value)} > 1.
|
||||
|
||||
% Apply axioms
|
||||
derived(Variable, Value, t) :- axiomRule(Rule), postcondition(Rule,_,Variable,Value),
|
||||
holds(Variable', Value', t) : precondition(Rule, Variable', Value'), not headVariable(Rule,Variable').
|
||||
|
||||
modified(Variable, t) :- derived(Variable, Value, t).
|
||||
|
||||
holds(Variable, Value, t) :- derived(Variable, Value, t), stateVariable(Variable).
|
||||
holds(Variable, Value, t) :- not modified(Variable, t), stateVariable(Variable), initialState(Variable, Value).
|
||||
|
||||
% Verify that goal is met
|
||||
:- query(t), goal(Variable, Value), not holds(Variable, Value, t).
|
||||
|
||||
#show occurs/2.
|
||||
% #show holds/3.
|
40
encodings/outdated/sequential-incremental.lp
Normal file
40
encodings/outdated/sequential-incremental.lp
Normal file
@ -0,0 +1,40 @@
|
||||
#include <incmode>.
|
||||
|
||||
% Check feature requirements
|
||||
:- requires(feature(actionCosts)).
|
||||
:- requires(feature(axiomRules)).
|
||||
:- requires(feature(conditionalEffects)).
|
||||
|
||||
#program base.
|
||||
|
||||
% Establish initial state
|
||||
holds(Variable, Value, 0) :- initialState(Variable, Value).
|
||||
|
||||
#program step(t).
|
||||
|
||||
% Perform actions
|
||||
1 {occurs(Action, t) : action(Action)} 1.
|
||||
|
||||
% Check preconditions
|
||||
:- occurs(Action, t), precondition(Action, Variable, Value), not holds(Variable, Value, t - 1).
|
||||
|
||||
% Apply effects
|
||||
caused(Variable, Value, t) :- occurs(Action, t), postcondition(Action, _, Variable, Value).
|
||||
modified(Variable, t) :- caused(Variable, Value, t).
|
||||
|
||||
holds(Variable, Value, t) :- caused(Variable, Value, t).
|
||||
holds(Variable, Value, t) :- holds(Variable, Value, t - 1), not modified(Variable, t).
|
||||
|
||||
% Check that variables have unique values
|
||||
:- variable(Variable), not 1 {holds(Variable, Value, t) : contains(Variable, Value)} 1.
|
||||
|
||||
% Check mutexes
|
||||
:- mutexGroup(MutexGroup), not {holds(Variable, Value, t) : contains(MutexGroup, Variable, Value)} 1.
|
||||
|
||||
#program check(t).
|
||||
|
||||
% Verify that goal is met
|
||||
:- query(t), goal(Variable, Value), not holds(Variable, Value, t).
|
||||
|
||||
#show query/1.
|
||||
#show occurs/2.
|
71
encodings/sequential-horizon.lp
Normal file
71
encodings/sequential-horizon.lp
Normal file
@ -0,0 +1,71 @@
|
||||
#const horizon=1.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Horizon, must be defined externally
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
time(0..horizon).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Establish initial state
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
holds(Variable, Value, 0) :- initialState(Variable, Value).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Compute derived predicates
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% conjunctive preconditions
|
||||
satisfied(DerivedPredicate, type(and), T) :- derivedPredicate(DerivedPredicate, type(and)), holds(Variable, Value, T) : precondition(DerivedPredicate, type(and), Variable, Value); time(T).
|
||||
|
||||
% disjunctive preconditions
|
||||
satisfied(DerivedPredicate, type(or), T) :- precondition(DerivedPredicate, type(or), Variable, Value), holds(Variable, Value, T), time(T).
|
||||
|
||||
holds(DerivedVariable, Value, T) :- satisfied(DerivedPredicate, Type, T), postcondition(DerivedPredicate, Type, effect(unconditional), DerivedVariable, Value).
|
||||
|
||||
holds(derivedVariable(DerivedVariable), value(DerivedVariable, false), T) :- derivedVariable(DerivedVariable), not holds(derivedVariable(DerivedVariable), value(DerivedVariable, true), T), time(T).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Perform actions
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
1 {occurs(Action, T) : action(Action)} 1 :- time(T), T > 0.
|
||||
|
||||
% Check preconditions
|
||||
:- occurs(Action, T), precondition(Action, Variable, Value), not holds(Variable, Value, T - 1).
|
||||
|
||||
% Apply effects
|
||||
caused(Variable, Value, T) :-
|
||||
occurs(Action, T),
|
||||
postcondition(Action, Effect, Variable, Value),
|
||||
holds(VariablePre, ValuePre, T - 1) : precondition(Effect, VariablePre, ValuePre).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Inertia rules
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
modified(Variable, T) :- caused(Variable, Value, T).
|
||||
|
||||
holds(Variable, Value, T) :- caused(Variable, Value, T).
|
||||
holds(variable(V), Value, T) :- holds(variable(V), Value, T - 1), not modified(variable(V), T), time(T).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Variables and mutex groups
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% Check that variables have unique values
|
||||
:- variable(Variable), not 1 {holds(Variable, Value, T) : contains(Variable, Value)} 1, time(T).
|
||||
|
||||
% Check mutexes
|
||||
:- mutexGroup(MutexGroup), not {holds(Variable, Value, T) : contains(MutexGroup, Variable, Value)} 1, time(T).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Verify that goal is met
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
:- goal(Variable, Value), not holds(Variable, Value, horizon).
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
#show occurs/2.
|
73
encodings/strips/README.md
Normal file
73
encodings/strips/README.md
Normal file
@ -0,0 +1,73 @@
|
||||
# Incremental STRIPS Planning Encodings
|
||||
|
||||
This suite of incremental STRIPS planning encodings implements diverse methods.
|
||||
The included encoding files provide the following functionalities:
|
||||
|
||||
## Encodings
|
||||
|
||||
### [incmode.lp](incmode.lp): include built-in “iclingo“ script for incremental grounding and solving
|
||||
|
||||
### [preprocess.lp](preprocess.lp): static analysis of potentially relevant actions
|
||||
|
||||
* Parameter: `_closure` (default value: `3`)
|
||||
* Value `1`: forward chaining of effects w.r.t. initial variable values
|
||||
* Value `2`: backward regression of effects w.r.t. goal variable values
|
||||
* Value `3`: both forward chaining and backward regression of effects
|
||||
* Otherwise: off (simply take all actions as given)
|
||||
|
||||
### [strips-incremental.lp](strips-incremental.lp): sequential and parallel planning encoding variants
|
||||
* Parameter: `_parallel` (default value: `0`)
|
||||
* Value `1`: “forall” parallel actions that can be arranged in any sequence
|
||||
* Value `2`: “exists” parallel actions that can be arranged in some sequence
|
||||
* Value `3`: “exists“ parallel actions omitting achievement of preconditions
|
||||
* Value `4`: “exists“ parallel actions like `3` implemented by acyclicity
|
||||
* Otherwise: sequential actions
|
||||
* Parameter: `planner_on` (default value: `0`)
|
||||
* Value `0`: no compatibility to ASP-based planner (no idle steps permitted)
|
||||
* Otherwise: compatibility to ASP-based planner (idle steps permitted)
|
||||
|
||||
### [redundancy.lp](redundancy.lp): enforcement of ‘redundant’ actions to constrain parallel plans
|
||||
* Remarks:
|
||||
* Only relevant together with parallel actions not implemented by acyclicity
|
||||
* Encoded constraints seem rather ineffective though
|
||||
* Heavy space overhead in combination with “exists” parallel actions
|
||||
|
||||
### [postprocess.lp](postprocess.lp): plan feasibility checking and conversion to sequential plan
|
||||
|
||||
## Usage Examples
|
||||
|
||||
Some example invocations (using `clingo` 5.1.0) are as follows:
|
||||
|
||||
```bash
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=0
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=1
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _closure=2
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=1
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=2
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=3
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=4
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=1 redundancy.lp
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=2 redundancy.lp
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp -c _parallel=3 redundancy.lp
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl)
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=1 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl)
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=2 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl)
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=3 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl)
|
||||
|
||||
plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl | clingo - incmode.lp preprocess.lp strips-incremental.lp --outf=1 -c _parallel=4 | grep -A1 -e "ANSWER" | tail -n1 | clingo - postprocess.lp <(plasp ../../instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl ../../instances/PDDL/ipc-2000-elevator-m10-strips/problem-04-00.pddl)
|
||||
```
|
3
encodings/strips/incmode.lp
Normal file
3
encodings/strips/incmode.lp
Normal file
@ -0,0 +1,3 @@
|
||||
% Include built-in "iclingo" script for incremental grounding and solving
|
||||
|
||||
#include <incmode>.
|
58
encodings/strips/postprocess.lp
Normal file
58
encodings/strips/postprocess.lp
Normal file
@ -0,0 +1,58 @@
|
||||
% Convert a plan (possibly with parallel actions), given by atoms over occurs/2,
|
||||
% to a sequential plan, expressed by atoms over sequence/2
|
||||
|
||||
time(T) :- occurs(A,T).
|
||||
time :- time(T).
|
||||
|
||||
:- goal(X,V), not initialState(X,V), not time.
|
||||
|
||||
last(T2) :- time, T2 = #max{T1 : time(T1)}.
|
||||
|
||||
offset(T2,M) :- time(T2), M = #count{A,T1 : occurs(A,T1), T1 < T2}.
|
||||
finish(T,M+N) :- offset(T,M), N = #count{A : occurs(A,T)}.
|
||||
index(T,M+1..N) :- offset(T,M), finish(T,N).
|
||||
|
||||
postcondition(A,X,V) :- postcondition(A,E,X,V), occurs(A,T).
|
||||
postcondition(A,X) :- postcondition(A,X,V).
|
||||
|
||||
before(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 != A2,
|
||||
precondition(A1,X,V), postcondition(A2,X), not postcondition(A2,X,V).
|
||||
|
||||
order(A1,A2,T) :- occurs(A1,T), occurs(A2,T), A1 < A2, A <= A1 : occurs(A,T), A < A2.
|
||||
first(A2,T) :- occurs(A2,T), #false : order(A1,A2,T).
|
||||
|
||||
undone(A,T,M) :- occurs(A,T), offset(T,M).
|
||||
undone(A,T,N) :- undone(A,T,N-1), select(A1,T,N), A != A1, index(T,N+1).
|
||||
|
||||
done(A,T,N) :- select(A,T,N).
|
||||
done(A,T,N) :- done(A,T,N-1), index(T,N).
|
||||
|
||||
:- finish(T,N), occurs(A,T), not done(A,T,N).
|
||||
|
||||
hold(X,V,0) :- initialState(X,V).
|
||||
hold(X,V,N) :- select(A,T,N), postcondition(A,X,V).
|
||||
hold(X,V,N) :- select(A,T,N), hold(X,V,N-1), not postcondition(A,X).
|
||||
|
||||
:- last(T), finish(T,N), goal(X,V), not hold(X,V,N).
|
||||
|
||||
hold(X,N) :- hold(X,V,N).
|
||||
|
||||
:- hold(X,N), #count{V : hold(X,V,N)} > 1.
|
||||
|
||||
preconditions(A,T,N) :- undone(A,T,N), hold(X,V,N) : precondition(A,X,V).
|
||||
applicable(A,T,N) :- preconditions(A,T,N), done(A1,T,N) : before(A1,A,T).
|
||||
|
||||
inapplicable(A,T,N) :- done(A,T,N), index(T,N+1).
|
||||
inapplicable(A,T,N) :- undone(A,T,N), precondition(A,X,V1), hold(X,V2,N), V1 != V2.
|
||||
inapplicable(A,T,N) :- undone(A1,T,N), before(A1,A,T).
|
||||
|
||||
continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), first(A1,T).
|
||||
continue(A2,T,N) :- order(A1,A2,T), inapplicable(A1,T,N), continue(A1,T,N).
|
||||
|
||||
select(A,T,N+1) :- applicable(A,T,N), first(A,T).
|
||||
select(A,T,N+1) :- applicable(A,T,N), continue(A,T,N).
|
||||
|
||||
% DISPLAY PART
|
||||
|
||||
#show.
|
||||
#show sequence(A,N) : select(A,T,N).
|
50
encodings/strips/preprocess.lp
Normal file
50
encodings/strips/preprocess.lp
Normal file
@ -0,0 +1,50 @@
|
||||
% Constant '_closure' to (de)activate analysis of potentially relevant actions
|
||||
% - value '1': forward chaining of effects w.r.t. initial variable values
|
||||
% - value '2': backward regression of effects w.r.t. goal variable values
|
||||
% - value '3': both forward chaining and backward regression of effects
|
||||
% - otherwise: off
|
||||
|
||||
#const _closure = 3.
|
||||
|
||||
% BASE PROGRAM
|
||||
|
||||
% Check feature requirements
|
||||
|
||||
:- requires(feature(actionCosts)).
|
||||
:- requires(feature(axiomRules)).
|
||||
:- requires(feature(conditionalEffects)).
|
||||
|
||||
% Basic redundancy check for actions
|
||||
|
||||
postcondition(A,X,V) :- postcondition(A,E,X,V).
|
||||
|
||||
has_condition(A,X,0) :- action(A), precondition(A,X,V).
|
||||
has_condition(A,X,1) :- action(A), postcondition(A,X,V).
|
||||
|
||||
inconsistent(A) :- has_condition(A,X,P),
|
||||
#count{V : precondition(A,X,V), P = 0;
|
||||
V : postcondition(A,X,V), P = 1} > 1.
|
||||
consistent(A) :- action(A), not inconsistent(A).
|
||||
irredundant(A) :- consistent(A), postcondition(A,X,V), not precondition(A,X,V).
|
||||
|
||||
% Forward chaining of effects w.r.t. initial variable values
|
||||
|
||||
feasible(X,V) :- initialState(X,V).
|
||||
feasible(X,V) :- possible(A), postcondition(A,X,V).
|
||||
|
||||
possible(A) :- irredundant(A), feasible(X,V) : precondition(A,X,V).
|
||||
possible(A) :- irredundant(A), _closure != 1, _closure != 3.
|
||||
|
||||
:- goal(X,V), not feasible(X,V).
|
||||
|
||||
% Backward regression of effects w.r.t. goal variable values
|
||||
|
||||
produce(X,V) :- goal(X,V), not initialState(X,V).
|
||||
produce(X,V) :- active(A), precondition(A,X,V), not initialState(X,V).
|
||||
produce(X,V) :- persist(X,V), active(A), has_condition(A,X,1), not postcondition(A,X,V).
|
||||
|
||||
persist(X,V) :- goal(X,V), initialState(X,V).
|
||||
persist(X,V) :- active(A), precondition(A,X,V), initialState(X,V).
|
||||
|
||||
active(A) :- possible(A), postcondition(A,X,V), produce(X,V).
|
||||
active(A) :- possible(A), _closure != 2, _closure != 3.
|
50
encodings/strips/redundancy.lp
Normal file
50
encodings/strips/redundancy.lp
Normal file
@ -0,0 +1,50 @@
|
||||
% Additional rules for enforcing the inclusion of parallel actions in plans,
|
||||
% whenever such 'redundant' actions are compatible with states and other actions
|
||||
|
||||
% BASE PROGRAM
|
||||
|
||||
selfdefeat(A) :- selfdefeat(A,X).
|
||||
disjoin(A,A1) :- active(A), has_condition(A,X,P), selfdefeat(A1,X), not selfdefeat(A).
|
||||
|
||||
compatible(A,A1) :- active(A), active(A1), A != A1, 1 < _parallel, _parallel < 4,
|
||||
not diverge(A,A1), not exclude(A,A1), not disable(A,A1) : disable(A1,A).
|
||||
compatible(A) :- compatible(A,A1).
|
||||
compatible(A) :- active(A), active(A1), A != A1, _parallel = 1, not selfdefeat(A),
|
||||
not diverge(A,A1), not exclude(A,A1), not disjoin(A,A1).
|
||||
|
||||
disable(A,A1,A2) :- compatible(A,A1), compatible(A,A2), compatible(A1,A2),
|
||||
disable(A1,A2), not disable(A1,A).
|
||||
|
||||
disabled(A,A1) :- compatible(A), disable(A,A1).
|
||||
disabled(A,A2) :- simulate(A,A1), disable(A,A1,A2).
|
||||
|
||||
simulate(A,A1) :- compatible(A,A1), not disable(A1,A), disabled(A,A1).
|
||||
simulate(A,A1) :- compatible(A,A1), not disable(A1,A), scope(X,V),
|
||||
postcondition(A1,X,V), not precondition(A1,X,V).
|
||||
|
||||
% STEP PROGRAM
|
||||
|
||||
#program step(t).
|
||||
|
||||
defeated(A,t) :- compatible(A), postcondition(A,X,V), fluent(X), not holds(X,V,t).
|
||||
|
||||
defeated(A,t) :- compatible(A), precondition(A,X,V), not holds(X,V,t-1), _parallel != 2.
|
||||
defeated(A,t) :- compatible(A), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t),
|
||||
_parallel = 1.
|
||||
defeated(A,t) :- compatible(A), has_condition(A,X,1), not has_condition(A,X,0), single(X,t).
|
||||
|
||||
proceed(A,X,V,t) :- compatible(A), holds(X,V,t-1), scope(X,V).
|
||||
proceed(A,X,V,t) :- simulate(A,A1), perform(A,A1,t), occurs(A1,t), scope(X,V),
|
||||
postcondition(A1,X,V), not precondition(A1,X,V).
|
||||
|
||||
perform(A,A1,t) :- simulate(A,A1),
|
||||
proceed(A,X,V,t) : precondition(A1,X,V), _parallel = 2;
|
||||
alright(A,A2,t) : disable(A,A1,A2).
|
||||
|
||||
alright(A,A1,t) :- disabled(A,A1), not occurs(A1,t).
|
||||
alright(A,A1,t) :- disabled(A,A1), perform(A,A1,t).
|
||||
|
||||
defeated(A,t) :- compatible(A), precondition(A,X,V), not proceed(A,X,V,t), _parallel = 2.
|
||||
defeated(A,t) :- compatible(A), disable(A,A1), not alright(A,A1,t).
|
||||
|
||||
:- compatible(A), not occurs(A,t), not defeated(A,t), 0 < _parallel, _parallel < 4.
|
143
encodings/strips/strips-incremental.lp
Normal file
143
encodings/strips/strips-incremental.lp
Normal file
@ -0,0 +1,143 @@
|
||||
% Constant '_parallel' to enable parallel actions
|
||||
% - value '0': parallel actions *without* checking for mutual disablement
|
||||
% - value '1': "forall" parallel actions that can be arranged in any sequence
|
||||
% - value '2': "exists" parallel actions that can be arranged in some sequence
|
||||
% - value '3': "exists" parallel actions omitting achievement of preconditions
|
||||
% - value '4': "exists" parallel actions like '3' implemented by acyclicity
|
||||
% - otherwise: sequential actions
|
||||
|
||||
#const _parallel = 5.
|
||||
|
||||
% Constant '_shallow' to cheaply approximate mutually disabling parallel actions
|
||||
% - value '0': detect incompatible pre/postconditions to reduce parallel actions
|
||||
% - otherwise: over-approximate parallel actions (in testing mutual disablement)
|
||||
|
||||
#const _shallow = 0.
|
||||
|
||||
% Constant '_inertia' to choose flat or tiered format for transition constraints
|
||||
% - value '0': use flat rules (integrity constraints) for transition constraints
|
||||
% - otherwise: use rules that provide auxiliary atoms for transition constraints
|
||||
|
||||
#const _inertia = 0.
|
||||
|
||||
% Constant 'planner_on' to enable encoding support for ASP-based planner
|
||||
% - value '0': no compatibility to ASP-based planner (no idle steps permitted)
|
||||
% - otherwise: compatibility to ASP-based planner (idle steps permitted)
|
||||
|
||||
#const planner_on = 0.
|
||||
|
||||
% BASE PROGRAM
|
||||
|
||||
% Define auxiliary predicates for actions w.r.t. parallel mode
|
||||
|
||||
selfdefeat(A,X) :- active(A), precondition(A,X,V), _parallel = 1,
|
||||
has_condition(A,X,1), not postcondition(A,X,V).
|
||||
|
||||
diverge(A1,A2,X) :- active(A1), active(A2), postcondition(A1,X,V),
|
||||
has_condition(A2,X,1), not postcondition(A2,X,V),
|
||||
0 <= _parallel, _parallel < 5, _shallow = 0.
|
||||
diverge(A1,A2) :- diverge(A1,A2,X).
|
||||
|
||||
exclude(A1,A2) :- active(A1), active(A2), precondition(A1,X,V),
|
||||
has_condition(A2,X,0), not precondition(A2,X,V),
|
||||
0 <= _parallel, _parallel < 5, _parallel != 2, _shallow = 0.
|
||||
|
||||
disable(A1,A2) :- active(A1), active(A2), A1 != A2, postcondition(A1,X,V),
|
||||
has_condition(A2,X,0), not precondition(A2,X,V),
|
||||
not diverge(A1,A2), not exclude(A1,A2),
|
||||
1 < _parallel, _parallel < 5.
|
||||
|
||||
disable :- _parallel = 4, #sum{1,A1 : disable(A1,A2); -1,A2 : disable(A1,A2)} > 0.
|
||||
|
||||
scope(X,V) :- active(A), precondition(A,X,V), _parallel = 2.
|
||||
|
||||
% Define relevant fluents w.r.t. parallel mode
|
||||
|
||||
fluent(X,V) :- produce(X,V).
|
||||
fluent(X,V) :- persist(X,V).
|
||||
fluent(X,V) :- initialState(X,V), fluent(X).
|
||||
fluent(X,V) :- active(A), postcondition(A,X,V), fluent(X).
|
||||
fluent(X) :- fluent(X,V).
|
||||
fluent(X) :- diverge(A1,A2,X), not exclude(A1,A2).
|
||||
fluent(X) :- active(A), has_condition(A,X,1), 0 <= _parallel, _parallel < 5, _shallow != 0.
|
||||
|
||||
% Define unsubsumed mutexes
|
||||
|
||||
mutex(G,X) :- mutexGroup(G), contains(G,X,V), fluent(X,V).
|
||||
mutex(G) :- mutexGroup(G), #count{X : mutex(G,X)} > 1.
|
||||
|
||||
% Define initial state
|
||||
|
||||
holds(X,V,0) :- initialState(X,V), fluent(X).
|
||||
|
||||
:- fluent(X), #count{V : holds(X,V,0)} > 1.
|
||||
:- mutex(G), #count{X,V : holds(X,V,0), contains(G,X,V)} > 1.
|
||||
|
||||
% STEP PROGRAM
|
||||
|
||||
#program step(t).
|
||||
|
||||
% Generate successor state
|
||||
|
||||
1 {holds(X,V,t) : fluent(X,V)} 1 :- fluent(X).
|
||||
|
||||
:- mutex(G), #count{X,V : holds(X,V,t), contains(G,X,V)} > 1.
|
||||
|
||||
change(X,t) :- holds(X,V,t-1), not holds(X,V,t), _inertia != 0.
|
||||
|
||||
% Generate actions
|
||||
|
||||
{occurs(A,t)} :- active(A).
|
||||
|
||||
:- planner_on = 0, not occurs(A,t) : active(A).
|
||||
|
||||
:- occurs(A,t), postcondition(A,X,V), fluent(X), not holds(X,V,t).
|
||||
|
||||
effect(X,t) :- occurs(A,t), postcondition(A,X,V), fluent(X), not precondition(A,X,V),
|
||||
_inertia != 0.
|
||||
|
||||
:- change(X,t), not effect(X,t).
|
||||
|
||||
:- _inertia = 0, holds(X,V,t), not holds(X,V,t-1),
|
||||
not occurs(A,t) : active(A), postcondition(A,X,V), not precondition(A,X,V).
|
||||
|
||||
% Checks w.r.t. parallel mode
|
||||
|
||||
:- _parallel != 0, _parallel != 1, _parallel != 2, _parallel != 3, _parallel != 4,
|
||||
#count{A : occurs(A,t)} > 1.
|
||||
|
||||
:- _parallel != 2, occurs(A,t), precondition(A,X,V), not holds(X,V,t-1).
|
||||
|
||||
:- _parallel = 1, occurs(A,t), precondition(A,X,V), not has_condition(A,X,1), not holds(X,V,t).
|
||||
|
||||
single(X,t) :- occurs(A,t), selfdefeat(A,X).
|
||||
|
||||
:- single(X,t), #count{A : occurs(A,t), postcondition(A,X,V), not precondition(A,X,V)} > 1.
|
||||
|
||||
proceed(X,V,t) :- holds(X,V,t-1), scope(X,V).
|
||||
proceed(X,V,t) :- perform(A,t), scope(X,V), postcondition(A,X,V), not precondition(A,X,V),
|
||||
occurs(A,t).
|
||||
|
||||
perform(A,t) :- active(A), 1 < _parallel, _parallel < 4,
|
||||
proceed(X,V,t) : precondition(A,X,V), _parallel = 2;
|
||||
alright(A1,t) : disable(A,A1).
|
||||
|
||||
alright(A,t) :- active(A), 1 < _parallel, _parallel < 4, not occurs(A,t).
|
||||
alright(A,t) :- perform(A,t).
|
||||
|
||||
:- 1 < _parallel, _parallel < 4, active(A), not alright(A,t).
|
||||
|
||||
#edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A1,t), _parallel = 4, not disable.
|
||||
#edge((A1,t),(A2,t)) : disable(A1,A2), occurs(A2,t), disable.
|
||||
|
||||
% CHECK PROGRAM
|
||||
|
||||
#program check(t).
|
||||
|
||||
% Check goal conditions
|
||||
|
||||
:- query(t), goal(X,V), not holds(X,V,t).
|
||||
|
||||
% DISPLAY PART
|
||||
|
||||
#show occurs/2.
|
36
include/plasp/Language.h
Normal file
36
include/plasp/Language.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef __PLASP__LANGUAGE_H
|
||||
#define __PLASP__LANGUAGE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Language
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Language
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
Unknown,
|
||||
Automatic,
|
||||
PDDL,
|
||||
SAS
|
||||
};
|
||||
|
||||
static Language::Type fromString(const std::string &languageName);
|
||||
|
||||
public:
|
||||
Language() = delete;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
|
||||
#endif
|
52
include/plasp/LanguageDetection.h
Normal file
52
include/plasp/LanguageDetection.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef __PLASP__LANGUAGE_DETECTION_H
|
||||
#define __PLASP__LANGUAGE_DETECTION_H
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/Language.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// LanguageDetection
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline Language::Type detectLanguage(tokenize::Tokenizer<tokenize::CaseInsensitiveTokenizerPolicy> &tokenizer)
|
||||
{
|
||||
tokenizer.skipWhiteSpace();
|
||||
|
||||
// SAS begins with "begin_version"
|
||||
if (tokenizer.testAndSkip<std::string>("begin"))
|
||||
{
|
||||
tokenizer.seek(0);
|
||||
return Language::Type::SAS;
|
||||
}
|
||||
|
||||
// Skip potential PDDL comments
|
||||
while (tokenizer.currentCharacter() == ';')
|
||||
{
|
||||
tokenizer.skipLine();
|
||||
tokenizer.skipWhiteSpace();
|
||||
}
|
||||
|
||||
// PDDL contains sections starting with “(define”
|
||||
// Some legacy domains contain “in-package” sections, however
|
||||
if (tokenizer.testAndSkip<std::string>("(")
|
||||
&& (tokenizer.testAndSkip<std::string>("define") || tokenizer.testAndSkip<std::string>("in-package")))
|
||||
{
|
||||
tokenizer.seek(std::ios::beg);
|
||||
return Language::Type::PDDL;
|
||||
}
|
||||
|
||||
tokenizer.seek(std::ios::beg);
|
||||
return Language::Type::Unknown;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,13 +1,11 @@
|
||||
#ifndef __PLASP__SAS__TRANSLATOR_EXCEPTION_H
|
||||
#define __PLASP__SAS__TRANSLATOR_EXCEPTION_H
|
||||
#ifndef __PLASP__TRANSLATOR_EXCEPTION_H
|
||||
#define __PLASP__TRANSLATOR_EXCEPTION_H
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -39,7 +37,7 @@ class TranslatorException: public std::exception
|
||||
const char *what() const throw()
|
||||
{
|
||||
if (m_message.empty())
|
||||
return "Unspecified error while translating SAS description";
|
||||
return "Unspecified error while translating description";
|
||||
|
||||
return m_message.c_str();
|
||||
}
|
||||
@ -50,7 +48,6 @@ class TranslatorException: public std::exception
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
49
include/plasp/pddl/TranslatorASP.h
Normal file
49
include/plasp/pddl/TranslatorASP.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||
#define __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
#include <pddl/NormalizedASTForward.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TranslatorASP
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TranslatorASP
|
||||
{
|
||||
public:
|
||||
explicit TranslatorASP(const ::pddl::normalizedAST::Description &description, colorlog::ColorStream &outputStream);
|
||||
|
||||
void translate() const;
|
||||
|
||||
private:
|
||||
void translateDomain() const;
|
||||
void translateUtils() const;
|
||||
void translateTypes() const;
|
||||
void translatePredicates() const;
|
||||
void translateDerivedPredicates(const ::pddl::normalizedAST::DerivedPredicateDeclarations &derivedPredicates) const;
|
||||
void translateActions() const;
|
||||
|
||||
void translateProblem() const;
|
||||
void translateInitialState() const;
|
||||
void translateGoal() const;
|
||||
void translateConstants(const std::string &heading, const ::pddl::ast::ConstantDeclarations &constants) const;
|
||||
|
||||
const ::pddl::normalizedAST::Description &m_description;
|
||||
colorlog::ColorStream &m_outputStream;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
110
include/plasp/pddl/translation/ConditionalEffect.h
Normal file
110
include/plasp/pddl/translation/ConditionalEffect.h
Normal file
@ -0,0 +1,110 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__CONDITIONAL_EFFECT_H
|
||||
#define __PLASP__PDDL__TRANSLATION__CONDITIONAL_EFFECT_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
#include <plasp/pddl/translation/Variables.h>
|
||||
#include <plasp/pddl/translation/VariableStack.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ConditionalEffect
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename PrintObjectName>
|
||||
inline void translateConditionalEffect(colorlog::ColorStream &outputStream,
|
||||
const ::pddl::normalizedAST::ConditionalEffect &conditionalEffect,
|
||||
PrintObjectName printObjectName, VariableStack &variableStack,
|
||||
size_t &numberOfConditionalEffects, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("postcondition") << "(";
|
||||
printObjectName();
|
||||
outputStream
|
||||
<< ", " << colorlog::Keyword("effect") << "("
|
||||
<< colorlog::Number<size_t>(numberOfConditionalEffects) << ")"
|
||||
<< ", ";
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
outputStream << ") :- " << colorlog::Function("action") << "(";
|
||||
printObjectName();
|
||||
outputStream << ")";
|
||||
|
||||
if (!variableStack.layers.empty())
|
||||
for (const auto &layer : variableStack.layers)
|
||||
{
|
||||
if (!layer->empty())
|
||||
outputStream << ", ";
|
||||
|
||||
translateVariablesForRuleBody(outputStream, *layer, variableIDs);
|
||||
}
|
||||
|
||||
outputStream << ".";
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &, bool = true)
|
||||
{
|
||||
// TODO: refactor as to exclude derived predicates from the Effect variant
|
||||
throw TranslatorException("derived predicates should not appear in effects, please report to the bug tracker");
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleLiteral =
|
||||
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||
{
|
||||
literal.match(handleAtomicFormula, handleNot);
|
||||
};
|
||||
|
||||
const auto handleAnd =
|
||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Literal> &and_)
|
||||
{
|
||||
for (const auto &argument : and_->arguments)
|
||||
handleLiteral(argument);
|
||||
};
|
||||
|
||||
conditionalEffect.match(handleAnd, handleLiteral);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
127
include/plasp/pddl/translation/DerivedPredicate.h
Normal file
127
include/plasp/pddl/translation/DerivedPredicate.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__DERIVED_PREDICATE_H
|
||||
#define __PLASP__PDDL__TRANSLATION__DERIVED_PREDICATE_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
#include <plasp/pddl/translation/Variables.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DerivedPredicate
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void translateDerivedPredicate(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate, VariableIDMap &variableIDs);
|
||||
void translateDerivedPredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicateDeclaration &derivedPredicateDeclaration, VariableIDMap &variableIDs);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: avoid code duplication with translatePredicate
|
||||
inline void translateDerivedPredicate(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto &arguments = derivedPredicate.arguments;
|
||||
|
||||
if (arguments.empty())
|
||||
{
|
||||
outputStream << *derivedPredicate.declaration;
|
||||
return;
|
||||
}
|
||||
|
||||
outputStream << "(" << *derivedPredicate.declaration;
|
||||
|
||||
for (const auto &argument : arguments)
|
||||
{
|
||||
outputStream << ", ";
|
||||
|
||||
const auto handleConstant =
|
||||
[&](const ::pddl::normalizedAST::ConstantPointer &constant)
|
||||
{
|
||||
outputStream << colorlog::Keyword("constant") << "(" << *constant << ")";
|
||||
};
|
||||
|
||||
const auto handleVariable =
|
||||
[&](const ::pddl::normalizedAST::VariablePointer &variable)
|
||||
{
|
||||
translateVariable(outputStream, *variable, variableIDs);
|
||||
};
|
||||
|
||||
argument.match(handleConstant, handleVariable);
|
||||
}
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateDerivedPredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicateDeclaration &derivedPredicateDeclaration, VariableIDMap &variableIDs)
|
||||
{
|
||||
outputStream << colorlog::Keyword("derivedVariable") << "(";
|
||||
|
||||
if (derivedPredicateDeclaration.parameters.empty())
|
||||
{
|
||||
outputStream << derivedPredicateDeclaration << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
outputStream << "(" << derivedPredicateDeclaration;
|
||||
translateVariablesForRuleHead(outputStream, derivedPredicateDeclaration.parameters, variableIDs);
|
||||
outputStream << "))";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateDerivedPredicateToVariable(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate, VariableIDMap &variableIDs, bool isPositive = true)
|
||||
{
|
||||
outputStream << colorlog::Keyword("derivedVariable") << "(";
|
||||
|
||||
translateDerivedPredicate(outputStream, derivedPredicate, variableIDs);
|
||||
|
||||
outputStream
|
||||
<< "), "
|
||||
<< colorlog::Keyword("value") << "("
|
||||
<< colorlog::Keyword("derivedVariable") << "(";
|
||||
|
||||
translateDerivedPredicate(outputStream, derivedPredicate, variableIDs);
|
||||
|
||||
outputStream << "), ";
|
||||
|
||||
if (isPositive)
|
||||
outputStream << colorlog::Boolean("true");
|
||||
else
|
||||
outputStream << colorlog::Boolean("false");
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateDerivedPredicateDeclarationToVariable(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicateDeclaration &derivedPredicateDeclaration, VariableIDMap &variableIDs, bool isPositive = true)
|
||||
{
|
||||
translateDerivedPredicateDeclaration(outputStream, derivedPredicateDeclaration, variableIDs);
|
||||
outputStream << ", " << colorlog::Keyword("value") << "(";
|
||||
translateDerivedPredicateDeclaration(outputStream, derivedPredicateDeclaration, variableIDs);
|
||||
outputStream << ", ";
|
||||
|
||||
if (isPositive)
|
||||
outputStream << colorlog::Boolean("true");
|
||||
else
|
||||
outputStream << colorlog::Boolean("false");
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
106
include/plasp/pddl/translation/DerivedPredicatePrecondition.h
Normal file
106
include/plasp/pddl/translation/DerivedPredicatePrecondition.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__DERIVED_PREDICATE_PRECONDITION_H
|
||||
#define __PLASP__PDDL__TRANSLATION__DERIVED_PREDICATE_PRECONDITION_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/DerivedPredicate.h>
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DerivedPredicatePrecondition
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename PrintObjectName>
|
||||
inline void translateDerivedPredicatePrecondition(colorlog::ColorStream &outputStream,
|
||||
const ::pddl::normalizedAST::DerivedPredicatePrecondition &derivedPredicatePrecondition,
|
||||
const std::string &objectType, PrintObjectName printObjectName, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("precondition") << "(";
|
||||
printObjectName();
|
||||
outputStream << ", ";
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
outputStream << ") :- " << colorlog::Function(objectType.c_str()) << "(";
|
||||
printObjectName();
|
||||
outputStream << ").";
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("precondition") << "(";
|
||||
printObjectName();
|
||||
outputStream << ", ";
|
||||
translateDerivedPredicateToVariable(outputStream, *derivedPredicate, variableIDs, isPositive);
|
||||
outputStream << ") :- " << colorlog::Function(objectType.c_str()) << "(";
|
||||
printObjectName();
|
||||
outputStream << ").";
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleLiteral =
|
||||
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||
{
|
||||
literal.match(handleAtomicFormula, handleNot);
|
||||
};
|
||||
|
||||
const auto handleAnd =
|
||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Literal> &and_)
|
||||
{
|
||||
for (const auto &argument : and_->arguments)
|
||||
handleLiteral(argument);
|
||||
};
|
||||
|
||||
const auto handleOr =
|
||||
[&](const ::pddl::normalizedAST::OrPointer<::pddl::normalizedAST::Literal> &or_)
|
||||
{
|
||||
for (const auto &argument : or_->arguments)
|
||||
handleLiteral(argument);
|
||||
};
|
||||
|
||||
derivedPredicatePrecondition.match(handleLiteral, handleAnd, handleOr);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
172
include/plasp/pddl/translation/Effect.h
Normal file
172
include/plasp/pddl/translation/Effect.h
Normal file
@ -0,0 +1,172 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__EFFECT_H
|
||||
#define __PLASP__PDDL__TRANSLATION__EFFECT_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/ConditionalEffect.h>
|
||||
#include <plasp/pddl/translation/Precondition.h>
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
#include <plasp/pddl/translation/Variables.h>
|
||||
#include <plasp/pddl/translation/VariableStack.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Effect
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename PrintObjectName>
|
||||
inline void translateEffect(colorlog::ColorStream &outputStream,
|
||||
const ::pddl::normalizedAST::Effect &effect, PrintObjectName printObjectName,
|
||||
VariableStack &variableStack, size_t &numberOfConditionalEffects, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("postcondition") << "(";
|
||||
printObjectName();
|
||||
outputStream
|
||||
<< ", " << colorlog::Keyword("effect") << "("
|
||||
<< colorlog::Reserved("unconditional") << ")"
|
||||
<< ", ";
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
outputStream << ") :- " << colorlog::Function("action") << "(";
|
||||
printObjectName();
|
||||
outputStream << ")";
|
||||
|
||||
if (!variableStack.layers.empty())
|
||||
for (const auto &layer : variableStack.layers)
|
||||
{
|
||||
if (!layer->empty())
|
||||
outputStream << ", ";
|
||||
|
||||
translateVariablesForRuleBody(outputStream, *layer, variableIDs);
|
||||
}
|
||||
|
||||
outputStream << ".";
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &, bool = true)
|
||||
{
|
||||
// TODO: refactor as to exclude derived predicates from the Effect variant
|
||||
throw TranslatorException("derived predicates should not appear in effects, please report to the bug tracker");
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleLiteral =
|
||||
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||
{
|
||||
literal.match(handleAtomicFormula, handleNot);
|
||||
};
|
||||
|
||||
const auto handleAnd =
|
||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Effect> &and_)
|
||||
{
|
||||
for (const auto &argument : and_->arguments)
|
||||
translateEffect(outputStream, argument, printObjectName, variableStack,
|
||||
numberOfConditionalEffects, variableIDs);
|
||||
};
|
||||
|
||||
const auto handleForAll =
|
||||
[&](const ::pddl::normalizedAST::ForAllPointer<::pddl::normalizedAST::Effect> &forAll)
|
||||
{
|
||||
variableStack.push(&forAll->parameters);
|
||||
|
||||
translateEffect(outputStream, forAll->argument, printObjectName,
|
||||
variableStack, numberOfConditionalEffects, variableIDs);
|
||||
|
||||
variableStack.pop();
|
||||
};
|
||||
|
||||
const auto handleWhen =
|
||||
[&](const ::pddl::normalizedAST::WhenPointer<::pddl::normalizedAST::Precondition,
|
||||
::pddl::normalizedAST::ConditionalEffect> &when)
|
||||
{
|
||||
numberOfConditionalEffects++;
|
||||
|
||||
const auto printConditionalEffectIdentifier =
|
||||
[&]()
|
||||
{
|
||||
outputStream << colorlog::Keyword("effect") << "("
|
||||
<< colorlog::Number<size_t>(numberOfConditionalEffects) << ")";
|
||||
};
|
||||
|
||||
const auto printPreconditionRuleBody =
|
||||
[&]()
|
||||
{
|
||||
outputStream << " :- " << colorlog::Function("action") << "(";
|
||||
printObjectName();
|
||||
outputStream << ")";
|
||||
|
||||
for (const auto &layer : variableStack.layers)
|
||||
{
|
||||
if (!layer->empty())
|
||||
outputStream << ", ";
|
||||
|
||||
translateVariablesForRuleBody(outputStream, *layer, variableIDs);
|
||||
}
|
||||
};
|
||||
|
||||
translatePrecondition(outputStream, when->argumentLeft,
|
||||
printConditionalEffectIdentifier, printPreconditionRuleBody, variableIDs);
|
||||
|
||||
translateConditionalEffect(outputStream, when->argumentRight, printObjectName,
|
||||
variableStack, numberOfConditionalEffects, variableIDs);
|
||||
};
|
||||
|
||||
effect.match(handleAnd, handleForAll, handleLiteral, handleWhen);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename PrintObjectName>
|
||||
inline void translateEffect(colorlog::ColorStream &outputStream,
|
||||
const ::pddl::normalizedAST::Effect &effect, PrintObjectName printObjectName,
|
||||
size_t &numberOfConditionalEffects, VariableIDMap &variableIDs)
|
||||
{
|
||||
VariableStack variableStack;
|
||||
|
||||
translateEffect(outputStream, effect, printObjectName, variableStack,
|
||||
numberOfConditionalEffects, variableIDs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
73
include/plasp/pddl/translation/Fact.h
Normal file
73
include/plasp/pddl/translation/Fact.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__FACT_H
|
||||
#define __PLASP__PDDL__TRANSLATION__FACT_H
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Fact
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateFact(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Fact &fact)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("initialState") << "(";
|
||||
|
||||
VariableIDMap variableIDs;
|
||||
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
return handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &, bool = true)
|
||||
{
|
||||
throw TranslatorException("derived predicates should not occur in initial state");
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
return handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
fact.match(handleAtomicFormula, handleNot);
|
||||
|
||||
outputStream << ").";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
102
include/plasp/pddl/translation/Goal.h
Normal file
102
include/plasp/pddl/translation/Goal.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__GOAL_H
|
||||
#define __PLASP__PDDL__TRANSLATION__GOAL_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/DerivedPredicate.h>
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Goal
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateGoal(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Goal &goal)
|
||||
{
|
||||
VariableIDMap variableIDs;
|
||||
|
||||
const auto ensureNoVariables =
|
||||
[](const auto &predicate)
|
||||
{
|
||||
for (const auto &argument : predicate->arguments)
|
||||
if (argument.template is<::pddl::normalizedAST::VariablePointer>())
|
||||
throw TranslatorException("goal descriptions must be variable-free");
|
||||
};
|
||||
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
ensureNoVariables(predicate);
|
||||
|
||||
outputStream << std::endl << colorlog::Function("goal") << "(";
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
outputStream << ").";
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate, bool isPositive = true)
|
||||
{
|
||||
ensureNoVariables(derivedPredicate);
|
||||
|
||||
outputStream << std::endl << colorlog::Function("goal") << "(";
|
||||
translateDerivedPredicateToVariable(outputStream, *derivedPredicate, variableIDs, isPositive);
|
||||
outputStream << ").";
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleLiteral =
|
||||
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||
{
|
||||
literal.match(handleAtomicFormula, handleNot);
|
||||
};
|
||||
|
||||
const auto handleAnd =
|
||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Literal> &and_)
|
||||
{
|
||||
for (const auto &argument : and_->arguments)
|
||||
handleLiteral(argument);
|
||||
};
|
||||
|
||||
goal.match(handleLiteral, handleAnd);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
99
include/plasp/pddl/translation/Precondition.h
Normal file
99
include/plasp/pddl/translation/Precondition.h
Normal file
@ -0,0 +1,99 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
||||
#define __PLASP__PDDL__TRANSLATION__PRECONDITION_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
#include <plasp/pddl/translation/DerivedPredicate.h>
|
||||
#include <plasp/pddl/translation/Predicate.h>
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Precondition
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename PrintObjectName, typename PrintRuleBody>
|
||||
inline void translatePrecondition(colorlog::ColorStream &outputStream,
|
||||
const ::pddl::normalizedAST::Precondition &precondition, PrintObjectName printObjectName,
|
||||
PrintRuleBody printRuleBody, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto handlePredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("precondition") << "(";
|
||||
printObjectName();
|
||||
outputStream << ", ";
|
||||
translatePredicateToVariable(outputStream, *predicate, variableIDs, isPositive);
|
||||
outputStream << ")";
|
||||
printRuleBody();
|
||||
outputStream << ".";
|
||||
};
|
||||
|
||||
const auto handleNegatedPredicate =
|
||||
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
||||
{
|
||||
handlePredicate(predicate, false);
|
||||
};
|
||||
|
||||
const auto handleDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate, bool isPositive = true)
|
||||
{
|
||||
outputStream << std::endl << colorlog::Function("precondition") << "(";
|
||||
printObjectName();
|
||||
outputStream << ", ";
|
||||
translateDerivedPredicateToVariable(outputStream, *derivedPredicate, variableIDs, isPositive);
|
||||
outputStream << ")";
|
||||
printRuleBody();
|
||||
outputStream << ".";
|
||||
};
|
||||
|
||||
const auto handleNegatedDerivedPredicate =
|
||||
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
||||
{
|
||||
handleDerivedPredicate(derivedPredicate, false);
|
||||
};
|
||||
|
||||
const auto handleAtomicFormula =
|
||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||
{
|
||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleNot =
|
||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||
{
|
||||
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
||||
};
|
||||
|
||||
const auto handleLiteral =
|
||||
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||
{
|
||||
literal.match(handleAtomicFormula, handleNot);
|
||||
};
|
||||
|
||||
const auto handleAnd =
|
||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Literal> &and_)
|
||||
{
|
||||
for (const auto &argument : and_->arguments)
|
||||
handleLiteral(argument);
|
||||
};
|
||||
|
||||
precondition.match(handleLiteral, handleAnd);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
109
include/plasp/pddl/translation/Predicate.h
Normal file
109
include/plasp/pddl/translation/Predicate.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
||||
#define __PLASP__PDDL__TRANSLATION__PREDICATE_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
#include <plasp/pddl/translation/Primitives.h>
|
||||
#include <plasp/pddl/translation/Variables.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Predicate
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void translatePredicate(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Predicate &predicate, VariableIDMap &variableIDs);
|
||||
void translatePredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::PredicateDeclaration &predicateDeclaration, VariableIDMap &variableIDs);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translatePredicate(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Predicate &predicate, VariableIDMap &variableIDs)
|
||||
{
|
||||
const auto &arguments = predicate.arguments;
|
||||
|
||||
if (arguments.empty())
|
||||
{
|
||||
outputStream << *predicate.declaration;
|
||||
return;
|
||||
}
|
||||
|
||||
outputStream << "(" << *predicate.declaration;
|
||||
|
||||
for (const auto &argument : arguments)
|
||||
{
|
||||
outputStream << ", ";
|
||||
|
||||
const auto handleConstant =
|
||||
[&](const ::pddl::normalizedAST::ConstantPointer &constant)
|
||||
{
|
||||
outputStream << colorlog::Keyword("constant") << "(" << *constant << ")";
|
||||
};
|
||||
|
||||
const auto handleVariable =
|
||||
[&](const ::pddl::normalizedAST::VariablePointer &variable)
|
||||
{
|
||||
translateVariable(outputStream, *variable, variableIDs);
|
||||
};
|
||||
|
||||
argument.match(handleConstant, handleVariable);
|
||||
}
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translatePredicateDeclaration(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::PredicateDeclaration &predicateDeclaration, VariableIDMap &variableIDs)
|
||||
{
|
||||
outputStream << colorlog::Keyword("variable") << "(";
|
||||
|
||||
if (predicateDeclaration.parameters.empty())
|
||||
{
|
||||
outputStream << predicateDeclaration << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
outputStream << "(" << predicateDeclaration;
|
||||
translateVariablesForRuleHead(outputStream, predicateDeclaration.parameters, variableIDs);
|
||||
outputStream << "))";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void translatePredicateToVariable(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Predicate &predicate, VariableIDMap &variableIDs, bool isPositive = true)
|
||||
{
|
||||
outputStream << colorlog::Keyword("variable") << "(";
|
||||
|
||||
translatePredicate(outputStream, predicate, variableIDs);
|
||||
|
||||
outputStream
|
||||
<< "), "
|
||||
<< colorlog::Keyword("value") << "("
|
||||
<< colorlog::Keyword("variable") << "(";
|
||||
|
||||
translatePredicate(outputStream, predicate, variableIDs);
|
||||
|
||||
outputStream << "), ";
|
||||
|
||||
if (isPositive)
|
||||
outputStream << colorlog::Boolean("true");
|
||||
else
|
||||
outputStream << colorlog::Boolean("false");
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
100
include/plasp/pddl/translation/Primitives.h
Normal file
100
include/plasp/pddl/translation/Primitives.h
Normal file
@ -0,0 +1,100 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
||||
#define __PLASP__PDDL__TRANSLATION__PRIMITIVES_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Primitives
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::ConstantDeclaration &constantDeclaration)
|
||||
{
|
||||
assert(!constantDeclaration.name.empty());
|
||||
|
||||
return (stream << colorlog::String(constantDeclaration.name.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::Constant &constant)
|
||||
{
|
||||
assert(constant.declaration != nullptr);
|
||||
|
||||
return (stream << *constant.declaration);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::PrimitiveTypeDeclaration &primitiveTypeDeclaration)
|
||||
{
|
||||
assert(!primitiveTypeDeclaration.name.empty());
|
||||
|
||||
return (stream << colorlog::String(primitiveTypeDeclaration.name.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::PrimitiveType &primitiveType)
|
||||
{
|
||||
assert(primitiveType.declaration != nullptr);
|
||||
|
||||
return (stream << *primitiveType.declaration);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: move to appropriate header
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::Action &action)
|
||||
{
|
||||
return (stream << colorlog::String(action.name.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: move to appropriate header
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::PredicateDeclaration &predicateDeclaration)
|
||||
{
|
||||
return (stream << colorlog::String(predicateDeclaration.name.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: move to appropriate header
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::Predicate &predicate)
|
||||
{
|
||||
return (stream << *predicate.declaration);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: move to appropriate header
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::DerivedPredicateDeclaration &derivedPredicateDeclaration)
|
||||
{
|
||||
return (stream << colorlog::String(derivedPredicateDeclaration.name.c_str()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// TODO: move to appropriate header
|
||||
inline colorlog::ColorStream &operator<<(colorlog::ColorStream &stream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate)
|
||||
{
|
||||
return (stream << *derivedPredicate.declaration);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
64
include/plasp/pddl/translation/Variable.h
Normal file
64
include/plasp/pddl/translation/Variable.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__VARIABLE_H
|
||||
#define __PLASP__PDDL__TRANSLATION__VARIABLE_H
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Variable
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using VariableIDMap = std::map<const ::pddl::normalizedAST::VariableDeclaration *, size_t>;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateVariableDeclaration(colorlog::ColorStream &stream, ::pddl::normalizedAST::VariableDeclaration &variableDeclaration, VariableIDMap &variableIDs)
|
||||
{
|
||||
assert(!variableDeclaration.name.empty());
|
||||
|
||||
const auto variableID =
|
||||
[&]()
|
||||
{
|
||||
const auto matchingVariableID = variableIDs.find(&variableDeclaration);
|
||||
|
||||
if (matchingVariableID != variableIDs.cend())
|
||||
return matchingVariableID->second;
|
||||
|
||||
const auto variableID = variableIDs.size() + 1;
|
||||
|
||||
variableIDs.insert({&variableDeclaration, variableID});
|
||||
|
||||
return variableID;
|
||||
};
|
||||
|
||||
stream
|
||||
<< colorlog::Format({colorlog::Color::Green, colorlog::FontWeight::Bold})
|
||||
<< "X" << variableID()
|
||||
<< colorlog::ResetFormat();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void translateVariable(colorlog::ColorStream &stream, ::pddl::normalizedAST::Variable &variable, VariableIDMap &variableIDs)
|
||||
{
|
||||
assert(variable.declaration != nullptr);
|
||||
|
||||
translateVariableDeclaration(stream, *variable.declaration, variableIDs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
39
include/plasp/pddl/translation/VariableStack.h
Normal file
39
include/plasp/pddl/translation/VariableStack.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__VARIABLE_STACK_H
|
||||
#define __PLASP__PDDL__TRANSLATION__VARIABLE_STACK_H
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// VariableStack
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct VariableStack
|
||||
{
|
||||
using Layer = ::pddl::normalizedAST::VariableDeclarations *;
|
||||
|
||||
void push(Layer layer)
|
||||
{
|
||||
layers.push_back(layer);
|
||||
}
|
||||
|
||||
void pop()
|
||||
{
|
||||
layers.pop_back();
|
||||
}
|
||||
|
||||
std::vector<Layer> layers;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
75
include/plasp/pddl/translation/Variables.h
Normal file
75
include/plasp/pddl/translation/Variables.h
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
||||
#define __PLASP__PDDL__TRANSLATION__VARIABLES_H
|
||||
|
||||
#include <colorlog/Formatting.h>
|
||||
|
||||
#include <pddl/NormalizedAST.h>
|
||||
#include <pddl/Parse.h>
|
||||
|
||||
#include <plasp/TranslatorException.h>
|
||||
#include <plasp/pddl/translation/Variable.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace pddl
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Variables
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
void translateVariablesForRuleHead(colorlog::ColorStream &outputStream, const T &variables, VariableIDMap &variableIDs);
|
||||
template<class T>
|
||||
void translateVariablesForRuleBody(colorlog::ColorStream &outputStream, const T &variables, VariableIDMap &variableIDs);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
inline void translateVariablesForRuleHead(colorlog::ColorStream &outputStream, const T &variables, VariableIDMap &variableIDs)
|
||||
{
|
||||
for (const auto &variable : variables)
|
||||
{
|
||||
outputStream << ", ";
|
||||
translateVariableDeclaration(outputStream, *variable, variableIDs);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
void translateVariablesForRuleBody(colorlog::ColorStream &outputStream, const T &variables, VariableIDMap &variableIDs)
|
||||
{
|
||||
for (const auto &variable : variables)
|
||||
{
|
||||
if (&variable != &*variables.begin())
|
||||
outputStream << ", ";
|
||||
|
||||
if (variable->type)
|
||||
{
|
||||
if (!variable->type.value().template is<::pddl::normalizedAST::PrimitiveTypePointer>())
|
||||
throw TranslatorException("only primitive types supported currently");
|
||||
|
||||
const auto &type = variable->type.value().template get<::pddl::normalizedAST::PrimitiveTypePointer>();
|
||||
|
||||
outputStream << colorlog::Function("has") << "(";
|
||||
translateVariableDeclaration(outputStream, *variable, variableIDs);
|
||||
outputStream << ", " << colorlog::Keyword("type") << "(" << *type << "))";
|
||||
}
|
||||
else
|
||||
{
|
||||
outputStream << colorlog::Function("has") << "(";
|
||||
translateVariableDeclaration(outputStream, *variable, variableIDs);
|
||||
outputStream << ", " << colorlog::Keyword("type") << "(" << colorlog::String("object") << "))";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -4,6 +4,8 @@
|
||||
#include <iosfwd>
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/Value.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
@ -26,8 +28,8 @@ using AssignedVariables = std::vector<AssignedVariable>;
|
||||
class AssignedVariable
|
||||
{
|
||||
public:
|
||||
static AssignedVariable fromSAS(std::istream &istream, const Variables &variables);
|
||||
static AssignedVariable fromSAS(std::istream &istream, const Variable &variable);
|
||||
static AssignedVariable fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
static AssignedVariable fromSAS(tokenize::Tokenizer<> &tokenizer, const Variable &variable);
|
||||
|
||||
public:
|
||||
explicit AssignedVariable(const Variable &variable, const Value &value);
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
@ -28,7 +30,7 @@ class AxiomRule
|
||||
using Condition = AssignedVariable;
|
||||
using Conditions = AssignedVariables;
|
||||
|
||||
static AxiomRule fromSAS(std::istream &istream, const Variables &variables);
|
||||
static AxiomRule fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
const Conditions &conditions() const;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
#include <plasp/sas/Description.h>
|
||||
|
||||
namespace plasp
|
||||
@ -16,7 +18,7 @@ namespace sas
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::ostream &operator >>(std::ostream &ostream, const Description &description);
|
||||
colorlog::ColorStream &operator<<(colorlog::ColorStream &ostream, const Description &description);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef __PLASP__SAS__DESCRIPTION_H
|
||||
#define __PLASP__SAS__DESCRIPTION_H
|
||||
|
||||
#include <experimental/filesystem>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AxiomRule.h>
|
||||
#include <plasp/sas/Goal.h>
|
||||
@ -28,8 +29,9 @@ namespace sas
|
||||
class Description
|
||||
{
|
||||
public:
|
||||
static Description fromTokenizer(tokenize::Tokenizer<> &&tokenizer);
|
||||
static Description fromStream(std::istream &istream);
|
||||
static Description fromFile(const boost::filesystem::path &path);
|
||||
static Description fromFile(const std::experimental::filesystem::path &path);
|
||||
|
||||
public:
|
||||
bool usesActionCosts() const;
|
||||
@ -43,17 +45,21 @@ class Description
|
||||
bool usesAxiomRules() const;
|
||||
bool usesConditionalEffects() const;
|
||||
|
||||
bool hasRequirements() const;
|
||||
|
||||
private:
|
||||
Description();
|
||||
|
||||
void parseVersionSection(std::istream &istream) const;
|
||||
void parseMetricSection(std::istream &istream);
|
||||
void parseVariablesSection(std::istream &istream);
|
||||
void parseMutexSection(std::istream &istream);
|
||||
void parseInitialStateSection(std::istream &istream);
|
||||
void parseGoalSection(std::istream &istream);
|
||||
void parseOperatorSection(std::istream &istream);
|
||||
void parseAxiomSection(std::istream &istream);
|
||||
void parseContent(tokenize::Tokenizer<> &tokenizer);
|
||||
|
||||
void parseVersionSection(tokenize::Tokenizer<> &tokenizer) const;
|
||||
void parseMetricSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseVariablesSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseMutexSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseInitialStateSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseGoalSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseOperatorSection(tokenize::Tokenizer<> &tokenizer);
|
||||
void parseAxiomSection(tokenize::Tokenizer<> &tokenizer);
|
||||
|
||||
bool m_usesActionCosts;
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
@ -28,7 +30,7 @@ class Effect
|
||||
using Condition = AssignedVariable;
|
||||
using Conditions = AssignedVariables;
|
||||
|
||||
static Effect fromSAS(std::istream &istream, const Variables &variables, Conditions &preconditions);
|
||||
static Effect fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables, Conditions &preconditions);
|
||||
|
||||
public:
|
||||
const Conditions &conditions() const;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __PLASP__SAS__GOAL_H
|
||||
#define __PLASP__SAS__GOAL_H
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
|
||||
namespace plasp
|
||||
@ -20,7 +22,7 @@ class Goal
|
||||
using Fact = AssignedVariable;
|
||||
using Facts = AssignedVariables;
|
||||
|
||||
static Goal fromSAS(std::istream &istream, const Variables &variables);
|
||||
static Goal fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
const Facts &facts() const;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __PLASP__SAS__INITIAL_STATE_H
|
||||
#define __PLASP__SAS__INITIAL_STATE_H
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
|
||||
namespace plasp
|
||||
@ -20,7 +22,7 @@ class InitialState
|
||||
using Fact = AssignedVariable;
|
||||
using Facts = AssignedVariables;
|
||||
|
||||
static InitialState fromSAS(std::istream &istream, const Variables &variables);
|
||||
static InitialState fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
const Facts &facts() const;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
|
||||
namespace plasp
|
||||
@ -27,7 +29,7 @@ class MutexGroup
|
||||
using Fact = AssignedVariable;
|
||||
using Facts = AssignedVariables;
|
||||
|
||||
static MutexGroup fromSAS(std::istream &istream, const Variables &variables);
|
||||
static MutexGroup fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
const Facts &facts() const;
|
||||
|
@ -4,11 +4,16 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
#include <plasp/sas/AssignedVariable.h>
|
||||
#include <plasp/sas/Effect.h>
|
||||
#include <plasp/sas/Predicate.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
@ -31,10 +36,10 @@ class Operator
|
||||
using Condition = AssignedVariable;
|
||||
using Conditions = AssignedVariables;
|
||||
|
||||
static Operator fromSAS(std::istream &istream, const Variables &variables);
|
||||
static Operator fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
void printPredicateAsASP(std::ostream &ostream) const;
|
||||
void printPredicateAsASP(colorlog::ColorStream &stream) const;
|
||||
|
||||
const Predicate &predicate() const;
|
||||
const Conditions &preconditions() const;
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
@ -19,13 +23,13 @@ namespace sas
|
||||
class Predicate
|
||||
{
|
||||
public:
|
||||
static Predicate fromSAS(std::istream &istream);
|
||||
static Predicate fromSAS(tokenize::Tokenizer<> &tokenizer);
|
||||
|
||||
using Arguments = std::vector<std::string>;
|
||||
|
||||
public:
|
||||
void printAsSAS(std::ostream &ostream) const;
|
||||
void printAsASP(std::ostream &ostream) const;
|
||||
void printAsSAS(colorlog::ColorStream &stream) const;
|
||||
void printAsASP(colorlog::ColorStream &stream) const;
|
||||
|
||||
const std::string &name() const;
|
||||
const Arguments &arguments() const;
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef __PLASP__SAS__TRANSLATOR_ASP_H
|
||||
#define __PLASP__SAS__TRANSLATOR_ASP_H
|
||||
|
||||
#include <plasp/sas/Description.h>
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
#include <plasp/sas/Description.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
@ -19,12 +21,21 @@ namespace sas
|
||||
class TranslatorASP
|
||||
{
|
||||
public:
|
||||
explicit TranslatorASP(const Description &description);
|
||||
explicit TranslatorASP(const Description &description, colorlog::ColorStream &outputStream);
|
||||
|
||||
void translate(std::ostream &ostream) const;
|
||||
void translate() const;
|
||||
|
||||
private:
|
||||
void translateRequirements() const;
|
||||
void translateInitialState() const;
|
||||
void translateGoal() const;
|
||||
void translateVariables() const;
|
||||
void translateActions() const;
|
||||
void translateMutexes() const;
|
||||
void translateAxiomRules() const;
|
||||
|
||||
const Description &m_description;
|
||||
colorlog::ColorStream &m_outputStream;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace sas
|
||||
@ -36,15 +40,14 @@ struct Value
|
||||
static const Value Any;
|
||||
static const Value None;
|
||||
|
||||
static Value fromSAS(std::istream &istream);
|
||||
static const Value &referenceFromSAS(std::istream &istream, const Variable &variable);
|
||||
static Value fromSAS(tokenize::Tokenizer<> &tokenizer);
|
||||
static const Value &referenceFromSAS(tokenize::Tokenizer<> &tokenizer, const Variable &variable);
|
||||
|
||||
public:
|
||||
Value negated() const;
|
||||
|
||||
void printAsSAS(std::ostream &ostream) const;
|
||||
void printAsASP(std::ostream &ostream) const;
|
||||
void printAsASPPredicate(std::ostream &ostream) const;
|
||||
void printAsSAS(colorlog::ColorStream &stream) const;
|
||||
void printAsASPPredicate(colorlog::ColorStream &stream) const;
|
||||
|
||||
Sign sign() const;
|
||||
const std::string &name() const;
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <colorlog/ColorStream.h>
|
||||
|
||||
#include <plasp/sas/Value.h>
|
||||
|
||||
namespace plasp
|
||||
@ -26,11 +30,11 @@ using Variables = std::vector<Variable>;
|
||||
class Variable
|
||||
{
|
||||
public:
|
||||
static Variable fromSAS(std::istream &istream);
|
||||
static const Variable &referenceFromSAS(std::istream &istream, const Variables &variables);
|
||||
static Variable fromSAS(tokenize::Tokenizer<> &tokenizer);
|
||||
static const Variable &referenceFromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
void printNameAsASPPredicate(std::ostream &ostream) const;
|
||||
void printNameAsASPPredicate(colorlog::ColorStream &outputStream) const;
|
||||
|
||||
const std::string &name() const;
|
||||
int axiomLayer() const;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
#include <tokenize/Tokenizer.h>
|
||||
|
||||
#include <plasp/sas/Value.h>
|
||||
#include <plasp/sas/Variable.h>
|
||||
|
||||
@ -25,7 +27,7 @@ using VariableTransitions = std::vector<VariableTransition>;
|
||||
class VariableTransition
|
||||
{
|
||||
public:
|
||||
static VariableTransition fromSAS(std::istream &istream, const Variables &variables);
|
||||
static VariableTransition fromSAS(tokenize::Tokenizer<> &tokenizer, const Variables &variables);
|
||||
|
||||
public:
|
||||
const Variable &variable() const;
|
||||
|
@ -1,56 +0,0 @@
|
||||
#ifndef __PLASP__UTILS__PARSER_EXCEPTION_H
|
||||
#define __PLASP__UTILS__PARSER_EXCEPTION_H
|
||||
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace utils
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// ParserException
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ParserException: public std::exception
|
||||
{
|
||||
public:
|
||||
explicit ParserException()
|
||||
{
|
||||
}
|
||||
|
||||
explicit ParserException(const char *message)
|
||||
: m_message(message)
|
||||
{
|
||||
}
|
||||
|
||||
explicit ParserException(const std::string &message)
|
||||
: m_message(message)
|
||||
{
|
||||
}
|
||||
|
||||
~ParserException() throw()
|
||||
{
|
||||
}
|
||||
|
||||
const char *what() const throw()
|
||||
{
|
||||
if (m_message.empty())
|
||||
return "Unspecified error while parsing SAS description file";
|
||||
|
||||
return m_message.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_message;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -1,91 +0,0 @@
|
||||
#ifndef __PLASP__UTILS__PARSING_H
|
||||
#define __PLASP__UTILS__PARSING_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
namespace utils
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Parsing
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
T parse(std::istream &istream)
|
||||
{
|
||||
T value;
|
||||
|
||||
try
|
||||
{
|
||||
istream >> value;
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
throw ParserException(std::string("Could not parse value of type ") + typeid(T).name() + " (" + e.what() + ")");
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T>
|
||||
void parseExpected(std::istream &istream, const T &expectedValue)
|
||||
{
|
||||
const auto value = parse<T>(istream);
|
||||
|
||||
if (value == expectedValue)
|
||||
return;
|
||||
|
||||
std::stringstream errorStream;
|
||||
|
||||
errorStream << "Invalid format, expected " << expectedValue << ", got " + value;
|
||||
|
||||
throw utils::ParserException(errorStream.str());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::string escapeASP(const std::string &string)
|
||||
{
|
||||
auto escaped = string;
|
||||
|
||||
boost::replace_all(escaped, "_", "__");
|
||||
boost::replace_all(escaped, "-", "_h");
|
||||
boost::replace_all(escaped, "@", "_a");
|
||||
|
||||
return escaped;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::string unescapeASP(const std::string &string)
|
||||
{
|
||||
auto unescaped = string;
|
||||
|
||||
boost::replace_all(unescaped, "_a", "@");
|
||||
boost::replace_all(unescaped, "_h", "-");
|
||||
boost::replace_all(unescaped, "__", "_");
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
34
instances/PDDL/ipc-1998-gripper/domain.pddl
Normal file
34
instances/PDDL/ipc-1998-gripper/domain.pddl
Normal file
@ -0,0 +1,34 @@
|
||||
(define (domain gripper-strips)
|
||||
(:predicates (room ?r)
|
||||
(ball ?b)
|
||||
(gripper ?g)
|
||||
(at-robby ?r)
|
||||
(at ?b ?r)
|
||||
(free ?g)
|
||||
(carry ?o ?g))
|
||||
|
||||
(:action move
|
||||
:parameters (?from ?to)
|
||||
:precondition (and (room ?from) (room ?to) (at-robby ?from))
|
||||
:effect (and (at-robby ?to)
|
||||
(not (at-robby ?from))))
|
||||
|
||||
|
||||
|
||||
(:action pick
|
||||
:parameters (?obj ?room ?gripper)
|
||||
:precondition (and (ball ?obj) (room ?room) (gripper ?gripper)
|
||||
(at ?obj ?room) (at-robby ?room) (free ?gripper))
|
||||
:effect (and (carry ?obj ?gripper)
|
||||
(not (at ?obj ?room))
|
||||
(not (free ?gripper))))
|
||||
|
||||
|
||||
(:action drop
|
||||
:parameters (?obj ?room ?gripper)
|
||||
:precondition (and (ball ?obj) (room ?room) (gripper ?gripper)
|
||||
(carry ?obj ?gripper) (at-robby ?room))
|
||||
:effect (and (at ?obj ?room)
|
||||
(free ?gripper)
|
||||
(not (carry ?obj ?gripper)))))
|
||||
|
22
instances/PDDL/ipc-1998-gripper/problem-01.pddl
Normal file
22
instances/PDDL/ipc-1998-gripper/problem-01.pddl
Normal file
@ -0,0 +1,22 @@
|
||||
(define (problem strips-gripper-x-1)
|
||||
(:domain gripper-strips)
|
||||
(:objects rooma roomb ball4 ball3 ball2 ball1 left right)
|
||||
(:init (room rooma)
|
||||
(room roomb)
|
||||
(ball ball4)
|
||||
(ball ball3)
|
||||
(ball ball2)
|
||||
(ball ball1)
|
||||
(at-robby rooma)
|
||||
(free left)
|
||||
(free right)
|
||||
(at ball4 rooma)
|
||||
(at ball3 rooma)
|
||||
(at ball2 rooma)
|
||||
(at ball1 rooma)
|
||||
(gripper left)
|
||||
(gripper right))
|
||||
(:goal (and (at ball4 roomb)
|
||||
(at ball3 roomb)
|
||||
(at ball2 roomb)
|
||||
(at ball1 roomb))))
|
28
instances/PDDL/ipc-1998-gripper/problem-02.pddl
Normal file
28
instances/PDDL/ipc-1998-gripper/problem-02.pddl
Normal file
@ -0,0 +1,28 @@
|
||||
(define (problem strips-gripper-x-2)
|
||||
(:domain gripper-strips)
|
||||
(:objects rooma roomb ball6 ball5 ball4 ball3 ball2 ball1 left right)
|
||||
(:init (room rooma)
|
||||
(room roomb)
|
||||
(ball ball6)
|
||||
(ball ball5)
|
||||
(ball ball4)
|
||||
(ball ball3)
|
||||
(ball ball2)
|
||||
(ball ball1)
|
||||
(at-robby rooma)
|
||||
(free left)
|
||||
(free right)
|
||||
(at ball6 rooma)
|
||||
(at ball5 rooma)
|
||||
(at ball4 rooma)
|
||||
(at ball3 rooma)
|
||||
(at ball2 rooma)
|
||||
(at ball1 rooma)
|
||||
(gripper left)
|
||||
(gripper right))
|
||||
(:goal (and (at ball6 roomb)
|
||||
(at ball5 roomb)
|
||||
(at ball4 roomb)
|
||||
(at ball3 roomb)
|
||||
(at ball2 roomb)
|
||||
(at ball1 roomb))))
|
4
instances/PDDL/ipc-1998-gripper/solutions
Normal file
4
instances/PDDL/ipc-1998-gripper/solutions
Normal file
@ -0,0 +1,4 @@
|
||||
instance | minimal horizon | #solutions with minimal horizon
|
||||
============================================================
|
||||
problem-01.pddl | 11 | 384
|
||||
problem-02.pddl | 17 | 46080
|
49
instances/PDDL/ipc-2000-blocks-track-1-typed/domain.pddl
Normal file
49
instances/PDDL/ipc-2000-blocks-track-1-typed/domain.pddl
Normal file
@ -0,0 +1,49 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; 4 Op-blocks world
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define (domain BLOCKS)
|
||||
(:requirements :strips :typing)
|
||||
(:types block)
|
||||
(:predicates (on ?x - block ?y - block)
|
||||
(ontable ?x - block)
|
||||
(clear ?x - block)
|
||||
(handempty)
|
||||
(holding ?x - block)
|
||||
)
|
||||
|
||||
(:action pick-up
|
||||
:parameters (?x - block)
|
||||
:precondition (and (clear ?x) (ontable ?x) (handempty))
|
||||
:effect
|
||||
(and (not (ontable ?x))
|
||||
(not (clear ?x))
|
||||
(not (handempty))
|
||||
(holding ?x)))
|
||||
|
||||
(:action put-down
|
||||
:parameters (?x - block)
|
||||
:precondition (holding ?x)
|
||||
:effect
|
||||
(and (not (holding ?x))
|
||||
(clear ?x)
|
||||
(handempty)
|
||||
(ontable ?x)))
|
||||
(:action stack
|
||||
:parameters (?x - block ?y - block)
|
||||
:precondition (and (holding ?x) (clear ?y))
|
||||
:effect
|
||||
(and (not (holding ?x))
|
||||
(not (clear ?y))
|
||||
(clear ?x)
|
||||
(handempty)
|
||||
(on ?x ?y)))
|
||||
(:action unstack
|
||||
:parameters (?x - block ?y - block)
|
||||
:precondition (and (on ?x ?y) (clear ?x) (handempty))
|
||||
:effect
|
||||
(and (holding ?x)
|
||||
(clear ?y)
|
||||
(not (clear ?x))
|
||||
(not (handempty))
|
||||
(not (on ?x ?y)))))
|
@ -0,0 +1,7 @@
|
||||
(define (problem BLOCKS-4-0)
|
||||
(:domain BLOCKS)
|
||||
(:objects D B A C - block)
|
||||
(:INIT (CLEAR C) (CLEAR A) (CLEAR B) (CLEAR D) (ONTABLE C) (ONTABLE A)
|
||||
(ONTABLE B) (ONTABLE D) (HANDEMPTY))
|
||||
(:goal (AND (ON D C) (ON C B) (ON B A)))
|
||||
)
|
@ -0,0 +1,7 @@
|
||||
(define (problem BLOCKS-5-1)
|
||||
(:domain BLOCKS)
|
||||
(:objects A D C E B - block)
|
||||
(:INIT (CLEAR B) (CLEAR E) (CLEAR C) (ONTABLE D) (ONTABLE E) (ONTABLE C)
|
||||
(ON B A) (ON A D) (HANDEMPTY))
|
||||
(:goal (AND (ON D C) (ON C B) (ON B A) (ON A E)))
|
||||
)
|
@ -0,0 +1,7 @@
|
||||
(define (problem BLOCKS-8-1)
|
||||
(:domain BLOCKS)
|
||||
(:objects B A G C F D H E - block)
|
||||
(:INIT (CLEAR E) (CLEAR H) (CLEAR D) (CLEAR F) (ONTABLE C) (ONTABLE G)
|
||||
(ONTABLE D) (ONTABLE F) (ON E C) (ON H A) (ON A B) (ON B G) (HANDEMPTY))
|
||||
(:goal (AND (ON C D) (ON D B) (ON B G) (ON G F) (ON F H) (ON H A) (ON A E)))
|
||||
)
|
@ -0,0 +1,8 @@
|
||||
(define (problem BLOCKS-9-2)
|
||||
(:domain BLOCKS)
|
||||
(:objects B I C E D A G F H - block)
|
||||
(:INIT (CLEAR H) (CLEAR F) (ONTABLE G) (ONTABLE F) (ON H A) (ON A D) (ON D E)
|
||||
(ON E C) (ON C I) (ON I B) (ON B G) (HANDEMPTY))
|
||||
(:goal (AND (ON F G) (ON G H) (ON H D) (ON D I) (ON I E) (ON E B) (ON B C)
|
||||
(ON C A)))
|
||||
)
|
6
instances/PDDL/ipc-2000-blocks-track-1-typed/solutions
Normal file
6
instances/PDDL/ipc-2000-blocks-track-1-typed/solutions
Normal file
@ -0,0 +1,6 @@
|
||||
instance | minimal horizon | #solutions with minimal horizon
|
||||
============================================================
|
||||
problem-04-00.pddl | 6 | 1
|
||||
problem-05-01.pddl | 10 | 2
|
||||
problem-08-01.pddl | 20 | 60
|
||||
problem-09-02.pddl | 20 | 37
|
66
instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl
Normal file
66
instances/PDDL/ipc-2000-elevator-m10-strips/domain.pddl
Normal file
@ -0,0 +1,66 @@
|
||||
(define (domain miconic)
|
||||
(:requirements :strips)
|
||||
(:types passenger - object
|
||||
floor - object
|
||||
)
|
||||
|
||||
(:predicates
|
||||
(origin ?person - passenger ?floor - floor)
|
||||
;; entry of ?person is ?floor
|
||||
;; inertia
|
||||
|
||||
(destin ?person - passenger ?floor - floor)
|
||||
;; exit of ?person is ?floor
|
||||
;; inertia
|
||||
|
||||
(above ?floor1 - floor ?floor2 - floor)
|
||||
;; ?floor2 is located above of ?floor1
|
||||
|
||||
(boarded ?person - passenger)
|
||||
;; true if ?person has boarded the lift
|
||||
|
||||
(not-boarded ?person - passenger)
|
||||
;; true if ?person has not boarded the lift
|
||||
|
||||
(served ?person - passenger)
|
||||
;; true if ?person has alighted as her destination
|
||||
|
||||
(not-served ?person - passenger)
|
||||
;; true if ?person is not at their destination
|
||||
|
||||
(lift-at ?floor - floor)
|
||||
;; current position of the lift is at ?floor
|
||||
)
|
||||
|
||||
|
||||
;;stop and allow boarding
|
||||
|
||||
(:action board
|
||||
:parameters (?f - floor ?p - passenger)
|
||||
:precondition (and (lift-at ?f) (origin ?p ?f))
|
||||
:effect (boarded ?p))
|
||||
|
||||
(:action depart
|
||||
:parameters (?f - floor ?p - passenger)
|
||||
:precondition (and (lift-at ?f) (destin ?p ?f)
|
||||
(boarded ?p))
|
||||
:effect (and (not (boarded ?p))
|
||||
(served ?p)))
|
||||
;;drive up
|
||||
|
||||
(:action up
|
||||
:parameters (?f1 - floor ?f2 - floor)
|
||||
:precondition (and (lift-at ?f1) (above ?f1 ?f2))
|
||||
:effect (and (lift-at ?f2) (not (lift-at ?f1))))
|
||||
|
||||
|
||||
;;drive down
|
||||
|
||||
(:action down
|
||||
:parameters (?f1 - floor ?f2 - floor)
|
||||
:precondition (and (lift-at ?f1) (above ?f2 ?f1))
|
||||
:effect (and (lift-at ?f2) (not (lift-at ?f1))))
|
||||
)
|
||||
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
|
||||
(define (problem mixed-f6-p3-u0-v0-g0-a0-n0-A0-B0-N0-F0-r0)
|
||||
(:domain miconic)
|
||||
(:objects p0 p1 p2 - passenger
|
||||
f0 f1 f2 f3 f4 f5 - floor)
|
||||
|
||||
|
||||
(:init
|
||||
(above f0 f1)
|
||||
(above f0 f2)
|
||||
(above f0 f3)
|
||||
(above f0 f4)
|
||||
(above f0 f5)
|
||||
|
||||
(above f1 f2)
|
||||
(above f1 f3)
|
||||
(above f1 f4)
|
||||
(above f1 f5)
|
||||
|
||||
(above f2 f3)
|
||||
(above f2 f4)
|
||||
(above f2 f5)
|
||||
|
||||
(above f3 f4)
|
||||
(above f3 f5)
|
||||
|
||||
(above f4 f5)
|
||||
|
||||
|
||||
|
||||
(origin p0 f1)
|
||||
(destin p0 f4)
|
||||
|
||||
(origin p1 f3)
|
||||
(destin p1 f1)
|
||||
|
||||
(origin p2 f5)
|
||||
(destin p2 f1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(lift-at f0)
|
||||
)
|
||||
|
||||
|
||||
(:goal (and
|
||||
(served p0)
|
||||
(served p1)
|
||||
(served p2)
|
||||
))
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,58 @@
|
||||
|
||||
|
||||
|
||||
(define (problem mixed-f6-p3-u0-v0-g0-a0-n0-A0-B0-N0-F0-r1)
|
||||
(:domain miconic)
|
||||
(:objects p0 p1 p2 - passenger
|
||||
f0 f1 f2 f3 f4 f5 - floor)
|
||||
|
||||
|
||||
(:init
|
||||
(above f0 f1)
|
||||
(above f0 f2)
|
||||
(above f0 f3)
|
||||
(above f0 f4)
|
||||
(above f0 f5)
|
||||
|
||||
(above f1 f2)
|
||||
(above f1 f3)
|
||||
(above f1 f4)
|
||||
(above f1 f5)
|
||||
|
||||
(above f2 f3)
|
||||
(above f2 f4)
|
||||
(above f2 f5)
|
||||
|
||||
(above f3 f4)
|
||||
(above f3 f5)
|
||||
|
||||
(above f4 f5)
|
||||
|
||||
|
||||
|
||||
(origin p0 f2)
|
||||
(destin p0 f5)
|
||||
|
||||
(origin p1 f5)
|
||||
(destin p1 f2)
|
||||
|
||||
(origin p2 f4)
|
||||
(destin p2 f1)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(lift-at f0)
|
||||
)
|
||||
|
||||
|
||||
(:goal (and
|
||||
(served p0)
|
||||
(served p1)
|
||||
(served p2)
|
||||
))
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
|
||||
|
||||
|
||||
(define (problem mixed-f8-p4-u0-v0-g0-a0-n0-A0-B0-N0-F0-r0)
|
||||
(:domain miconic)
|
||||
(:objects p0 p1 p2 p3 - passenger
|
||||
f0 f1 f2 f3 f4 f5 f6 f7 - floor)
|
||||
|
||||
|
||||
(:init
|
||||
(above f0 f1)
|
||||
(above f0 f2)
|
||||
(above f0 f3)
|
||||
(above f0 f4)
|
||||
(above f0 f5)
|
||||
(above f0 f6)
|
||||
(above f0 f7)
|
||||
|
||||
(above f1 f2)
|
||||
(above f1 f3)
|
||||
(above f1 f4)
|
||||
(above f1 f5)
|
||||
(above f1 f6)
|
||||
(above f1 f7)
|
||||
|
||||
(above f2 f3)
|
||||
(above f2 f4)
|
||||
(above f2 f5)
|
||||
(above f2 f6)
|
||||
(above f2 f7)
|
||||
|
||||
(above f3 f4)
|
||||
(above f3 f5)
|
||||
(above f3 f6)
|
||||
(above f3 f7)
|
||||
|
||||
(above f4 f5)
|
||||
(above f4 f6)
|
||||
(above f4 f7)
|
||||
|
||||
(above f5 f6)
|
||||
(above f5 f7)
|
||||
|
||||
(above f6 f7)
|
||||
|
||||
|
||||
|
||||
(origin p0 f7)
|
||||
(destin p0 f6)
|
||||
|
||||
(origin p1 f1)
|
||||
(destin p1 f3)
|
||||
|
||||
(origin p2 f1)
|
||||
(destin p2 f7)
|
||||
|
||||
(origin p3 f2)
|
||||
(destin p3 f4)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(lift-at f0)
|
||||
)
|
||||
|
||||
|
||||
(:goal (and
|
||||
(served p0)
|
||||
(served p1)
|
||||
(served p2)
|
||||
(served p3)
|
||||
))
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
|
||||
|
||||
|
||||
(define (problem mixed-f8-p4-u0-v0-g0-a0-n0-A0-B0-N0-F0-r1)
|
||||
(:domain miconic)
|
||||
(:objects p0 p1 p2 p3 - passenger
|
||||
f0 f1 f2 f3 f4 f5 f6 f7 - floor)
|
||||
|
||||
|
||||
(:init
|
||||
(above f0 f1)
|
||||
(above f0 f2)
|
||||
(above f0 f3)
|
||||
(above f0 f4)
|
||||
(above f0 f5)
|
||||
(above f0 f6)
|
||||
(above f0 f7)
|
||||
|
||||
(above f1 f2)
|
||||
(above f1 f3)
|
||||
(above f1 f4)
|
||||
(above f1 f5)
|
||||
(above f1 f6)
|
||||
(above f1 f7)
|
||||
|
||||
(above f2 f3)
|
||||
(above f2 f4)
|
||||
(above f2 f5)
|
||||
(above f2 f6)
|
||||
(above f2 f7)
|
||||
|
||||
(above f3 f4)
|
||||
(above f3 f5)
|
||||
(above f3 f6)
|
||||
(above f3 f7)
|
||||
|
||||
(above f4 f5)
|
||||
(above f4 f6)
|
||||
(above f4 f7)
|
||||
|
||||
(above f5 f6)
|
||||
(above f5 f7)
|
||||
|
||||
(above f6 f7)
|
||||
|
||||
|
||||
|
||||
(origin p0 f0)
|
||||
(destin p0 f5)
|
||||
|
||||
(origin p1 f7)
|
||||
(destin p1 f4)
|
||||
|
||||
(origin p2 f0)
|
||||
(destin p2 f7)
|
||||
|
||||
(origin p3 f1)
|
||||
(destin p3 f6)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(lift-at f0)
|
||||
)
|
||||
|
||||
|
||||
(:goal (and
|
||||
(served p0)
|
||||
(served p1)
|
||||
(served p2)
|
||||
(served p3)
|
||||
))
|
||||
)
|
||||
|
||||
|
6
instances/PDDL/ipc-2000-elevator-m10-strips/solutions
Normal file
6
instances/PDDL/ipc-2000-elevator-m10-strips/solutions
Normal file
@ -0,0 +1,6 @@
|
||||
instance | minimal horizon | #solutions with minimal horizon
|
||||
============================================================
|
||||
problem-03-00.pddl | 10 | 12
|
||||
problem-03-01.pddl | 11 | 40
|
||||
problem-04-00.pddl | 14 | 180
|
||||
problem-04-01.pddl | 13 | 120
|
42
instances/PDDL/ipc-2002-depots-strips/domain.pddl
Normal file
42
instances/PDDL/ipc-2002-depots-strips/domain.pddl
Normal file
@ -0,0 +1,42 @@
|
||||
(define (domain Depot)
|
||||
(:requirements :typing)
|
||||
(:types place locatable - object
|
||||
depot distributor - place
|
||||
truck hoist surface - locatable
|
||||
pallet crate - surface)
|
||||
|
||||
(:predicates (at ?x - locatable ?y - place)
|
||||
(on ?x - crate ?y - surface)
|
||||
(in ?x - crate ?y - truck)
|
||||
(lifting ?x - hoist ?y - crate)
|
||||
(available ?x - hoist)
|
||||
(clear ?x - surface))
|
||||
|
||||
(:action Drive
|
||||
:parameters (?x - truck ?y - place ?z - place)
|
||||
:precondition (and (at ?x ?y))
|
||||
:effect (and (not (at ?x ?y)) (at ?x ?z)))
|
||||
|
||||
(:action Lift
|
||||
:parameters (?x - hoist ?y - crate ?z - surface ?p - place)
|
||||
:precondition (and (at ?x ?p) (available ?x) (at ?y ?p) (on ?y ?z) (clear ?y))
|
||||
:effect (and (not (at ?y ?p)) (lifting ?x ?y) (not (clear ?y)) (not (available ?x))
|
||||
(clear ?z) (not (on ?y ?z))))
|
||||
|
||||
(:action Drop
|
||||
:parameters (?x - hoist ?y - crate ?z - surface ?p - place)
|
||||
:precondition (and (at ?x ?p) (at ?z ?p) (clear ?z) (lifting ?x ?y))
|
||||
:effect (and (available ?x) (not (lifting ?x ?y)) (at ?y ?p) (not (clear ?z)) (clear ?y)
|
||||
(on ?y ?z)))
|
||||
|
||||
(:action Load
|
||||
:parameters (?x - hoist ?y - crate ?z - truck ?p - place)
|
||||
:precondition (and (at ?x ?p) (at ?z ?p) (lifting ?x ?y))
|
||||
:effect (and (not (lifting ?x ?y)) (in ?y ?z) (available ?x)))
|
||||
|
||||
(:action Unload
|
||||
:parameters (?x - hoist ?y - crate ?z - truck ?p - place)
|
||||
:precondition (and (at ?x ?p) (at ?z ?p) (available ?x) (in ?y ?z))
|
||||
:effect (and (not (in ?y ?z)) (not (available ?x)) (lifting ?x ?y)))
|
||||
|
||||
)
|
34
instances/PDDL/ipc-2002-depots-strips/problem-01.pddl
Normal file
34
instances/PDDL/ipc-2002-depots-strips/problem-01.pddl
Normal file
@ -0,0 +1,34 @@
|
||||
(define (problem depotprob1818) (:domain Depot)
|
||||
(:objects
|
||||
depot0 - Depot
|
||||
distributor0 distributor1 - Distributor
|
||||
truck0 truck1 - Truck
|
||||
pallet0 pallet1 pallet2 - Pallet
|
||||
crate0 crate1 - Crate
|
||||
hoist0 hoist1 hoist2 - Hoist)
|
||||
(:init
|
||||
(at pallet0 depot0)
|
||||
(clear crate1)
|
||||
(at pallet1 distributor0)
|
||||
(clear crate0)
|
||||
(at pallet2 distributor1)
|
||||
(clear pallet2)
|
||||
(at truck0 distributor1)
|
||||
(at truck1 depot0)
|
||||
(at hoist0 depot0)
|
||||
(available hoist0)
|
||||
(at hoist1 distributor0)
|
||||
(available hoist1)
|
||||
(at hoist2 distributor1)
|
||||
(available hoist2)
|
||||
(at crate0 distributor0)
|
||||
(on crate0 pallet1)
|
||||
(at crate1 depot0)
|
||||
(on crate1 pallet0)
|
||||
)
|
||||
|
||||
(:goal (and
|
||||
(on crate0 pallet2)
|
||||
(on crate1 pallet1)
|
||||
)
|
||||
))
|
40
instances/PDDL/ipc-2002-depots-strips/problem-02.pddl
Normal file
40
instances/PDDL/ipc-2002-depots-strips/problem-02.pddl
Normal file
@ -0,0 +1,40 @@
|
||||
(define (problem depotprob7512) (:domain Depot)
|
||||
(:objects
|
||||
depot0 - Depot
|
||||
distributor0 distributor1 - Distributor
|
||||
truck0 truck1 - Truck
|
||||
pallet0 pallet1 pallet2 - Pallet
|
||||
crate0 crate1 crate2 crate3 - Crate
|
||||
hoist0 hoist1 hoist2 - Hoist)
|
||||
(:init
|
||||
(at pallet0 depot0)
|
||||
(clear crate0)
|
||||
(at pallet1 distributor0)
|
||||
(clear crate3)
|
||||
(at pallet2 distributor1)
|
||||
(clear crate2)
|
||||
(at truck0 depot0)
|
||||
(at truck1 depot0)
|
||||
(at hoist0 depot0)
|
||||
(available hoist0)
|
||||
(at hoist1 distributor0)
|
||||
(available hoist1)
|
||||
(at hoist2 distributor1)
|
||||
(available hoist2)
|
||||
(at crate0 depot0)
|
||||
(on crate0 pallet0)
|
||||
(at crate1 distributor1)
|
||||
(on crate1 pallet2)
|
||||
(at crate2 distributor1)
|
||||
(on crate2 crate1)
|
||||
(at crate3 distributor0)
|
||||
(on crate3 pallet1)
|
||||
)
|
||||
|
||||
(:goal (and
|
||||
(on crate0 pallet2)
|
||||
(on crate1 crate3)
|
||||
(on crate2 pallet0)
|
||||
(on crate3 pallet1)
|
||||
)
|
||||
))
|
4
instances/PDDL/ipc-2002-depots-strips/solutions
Normal file
4
instances/PDDL/ipc-2002-depots-strips/solutions
Normal file
@ -0,0 +1,4 @@
|
||||
instance | minimal horizon | #solutions with minimal horizon
|
||||
============================================================
|
||||
problem-01.pddl | 10 | 16
|
||||
problem-02.pddl | 15 | 448
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user