Compare commits
385 Commits
Author | SHA1 | Date | |
---|---|---|---|
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
|
tests/data/* linguist-documentation
|
||||||
|
instances/* linguist-documentation
|
||||||
|
10
.travis.yml
10
.travis.yml
@@ -11,11 +11,15 @@ matrix:
|
|||||||
- boost-latest
|
- boost-latest
|
||||||
packages:
|
packages:
|
||||||
- g++-5
|
- g++-5
|
||||||
- libboost1.55-all-dev
|
- libboost-program-options1.55-dev
|
||||||
- libgtest-dev
|
- libboost-iostreams1.55-dev
|
||||||
|
- libboost-system1.55-dev
|
||||||
|
- libboost-filesystem1.55-dev
|
||||||
env: COMPILER=g++-5
|
env: COMPILER=g++-5
|
||||||
script:
|
script:
|
||||||
|
- git submodule init
|
||||||
|
- git submodule update
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER
|
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER
|
||||||
- make && make run-tests
|
- make -j3 && make -j3 run-tests
|
||||||
|
46
CHANGELOG.md
Normal file
46
CHANGELOG.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Change Log
|
||||||
|
|
||||||
|
## 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
|
@@ -3,7 +3,7 @@ project(plasp CXX)
|
|||||||
|
|
||||||
find_package(Boost 1.55.0 COMPONENTS program_options iostreams system filesystem REQUIRED)
|
find_package(Boost 1.55.0 COMPONENTS program_options iostreams system filesystem REQUIRED)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "-Wall -Wpedantic")
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
add_definitions(-std=c++14)
|
add_definitions(-std=c++14)
|
||||||
|
|
||||||
|
@@ -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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
68
README.md
68
README.md
@@ -1,50 +1,70 @@
|
|||||||
# plasp—Translate PDDL to ASP
|
# plasp—Translate PDDL to ASP
|
||||||
|
|
||||||
[](https://travis-ci.org/potassco/plasp)
|
[](https://github.com/potassco/plasp/releases)
|
||||||
|
[)](https://travis-ci.org/potassco/plasp?branch=master)
|
||||||
|
[)](https://travis-ci.org/potassco/plasp?branch=develop)
|
||||||
|
|
||||||
`plasp` 3 is in early development and not intended for productive use yet.
|
`plasp` 3 is in early development and not intended for productive use yet.
|
||||||
|
|
||||||
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` translates planning problem instances to ASP facts.
|
||||||
|
`plasp` 3 supports the input languages [PDDL 3.1](https://helios.hud.ac.uk/scommv/IPC-14/software.html) (only basic features currently) 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.
|
Please get in touch with [Patrick Lühne](https://www.luehne.de) if you have any suggestions.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To translate an SAS file into ASP facts, call:
|
### Translating PDDL to ASP Facts
|
||||||
|
|
||||||
|
PDDL instances are translated to ASP facts as follows:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ plasp file.sas
|
$ plasp domain.pddl problem.pddl
|
||||||
```
|
```
|
||||||
|
|
||||||
For instance, a PDDL instance can be solved as follows.
|
Alternatively, PDDL instances may first be translated to SAS, the output format of [Fast Downward](http://www.fast-downward.org/).
|
||||||
First, use [Fast Downward](http://www.fast-downward.org/) to translate the files from PDDL to SAS:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ ./fast-downward.py --translate --build=release64 domain.pddl instance.pddl
|
$ ./fast-downward.py --translate --build=release64 domain.pddl problem.pddl
|
||||||
```
|
```
|
||||||
|
|
||||||
This creates the file `output.sas`.
|
This creates a file called `output.sas`, which may now be translated by `plasp`.
|
||||||
The translated SAS instance can now be solved incrementally with `clingo` and the meta encoding `meta-sequential-incremental.lp`:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ plasp output.sas > instance.lp
|
$ plasp output.sas
|
||||||
$ clingo encodings/meta-sequential-incremental.lp instance.lp
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Solving the Translated Instance
|
||||||
|
|
||||||
|
The translated instance can finally be solved incrementally with `clingo` and a meta encoding, for instance, [`sequential-incremental.lp`](encodings/sequential-incremental.lp):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ plasp domain.pddl problem.pddl > instance.lp
|
||||||
|
$ clingo encodings/sequential-incremental.lp instance.lp
|
||||||
|
```
|
||||||
|
|
||||||
|
## Command-Line Interface
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ plasp [files] [options]
|
||||||
|
```
|
||||||
|
|
||||||
|
`plasp` automatically detects the language of the input program.
|
||||||
|
|
||||||
|
See [command-line interface](doc/command-line-interface.md) for more details.
|
||||||
|
|
||||||
|
## Output Format
|
||||||
|
|
||||||
|
`plasp` 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`’s output, this [simple example encoding](encodings/sequential-incremental.lp) gets you started.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
`plasp` requires a C++14 compiler (preferrably GCC ≥ 6.1), the `boost` libraries (≥ 1.55), and CMake for building.
|
`plasp` requires `boost` and is built via CMake and a C++ compiler.
|
||||||
|
|
||||||
```bash
|
See [building instructions](doc/building-instructions.md) for more details.
|
||||||
$ 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`.
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
@@ -52,5 +72,5 @@ The built `plasp` binary is then located at `plasp/build/release/bin/plasp`.
|
|||||||
|
|
||||||
### Earlier Versions
|
### Earlier Versions
|
||||||
|
|
||||||
* René Knaebel (`plasp` 2)
|
* René Knaebel
|
||||||
* Murat Knecht (`plasp`)
|
* Murat Knecht
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include <plasp/LanguageDetection.h>
|
||||||
|
#include <plasp/pddl/Description.h>
|
||||||
|
#include <plasp/pddl/TranslatorASP.h>
|
||||||
#include <plasp/sas/Description.h>
|
#include <plasp/sas/Description.h>
|
||||||
#include <plasp/sas/TranslatorASP.h>
|
#include <plasp/sas/TranslatorASP.h>
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/TranslatorException.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -13,7 +20,10 @@ int main(int argc, char **argv)
|
|||||||
description.add_options()
|
description.add_options()
|
||||||
("help,h", "Display this help message.")
|
("help,h", "Display this help message.")
|
||||||
("version,v", "Display version information.")
|
("version,v", "Display version information.")
|
||||||
("input,i", po::value<std::string>(), "Specify the SAS input file.");
|
("input,i", po::value<std::vector<std::string>>(), "Specify the PDDL or SAS input file.")
|
||||||
|
("language,l", po::value<std::string>(), "Specify the input language (sas or pddl). Omit for automatic detection.")
|
||||||
|
("warning-level", po::value<std::string>()->default_value("normal"), "Specify whether to output warnings normally (normal), to treat them as critical errors (error), or to ignore them (ignore).")
|
||||||
|
("color", po::value<std::string>()->default_value("auto"), "Specify whether to colorize the output (always, never, or auto).");
|
||||||
|
|
||||||
po::positional_options_description positionalOptionsDescription;
|
po::positional_options_description positionalOptionsDescription;
|
||||||
positionalOptionsDescription.add("input", -1);
|
positionalOptionsDescription.add("input", -1);
|
||||||
@@ -23,12 +33,14 @@ int main(int argc, char **argv)
|
|||||||
const auto printHelp =
|
const auto printHelp =
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
std::cout << "Usage: plasp file [options]" << std::endl;
|
std::cout << "Usage: plasp [files] [options]" << std::endl;
|
||||||
std::cout << "Translate PDDL instances to ASP facts." << std::endl << std::endl;
|
std::cout << "Translate PDDL instances to ASP facts." << std::endl << std::endl;
|
||||||
|
|
||||||
std::cout << description;
|
std::cout << description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
plasp::utils::Logger logger;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
po::store(po::command_line_parser(argc, argv)
|
po::store(po::command_line_parser(argc, argv)
|
||||||
@@ -40,7 +52,8 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
catch (const po::error &e)
|
catch (const po::error &e)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: " << e.what() << std::endl << std::endl;
|
logger.logError(e.what());
|
||||||
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -53,27 +66,108 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (variablesMap.count("version"))
|
if (variablesMap.count("version"))
|
||||||
{
|
{
|
||||||
std::cout << "plasp version 3.0.0" << std::endl;
|
std::cout << "plasp version 3.0.3" << std::endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!variablesMap.count("input"))
|
const auto warningLevel = variablesMap["warning-level"].as<std::string>();
|
||||||
|
|
||||||
|
if (warningLevel == "error")
|
||||||
|
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Error);
|
||||||
|
else if (warningLevel == "ignore")
|
||||||
|
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Ignore);
|
||||||
|
else if (warningLevel == "normal")
|
||||||
|
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Normal);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Error: No input file specified" << std::endl << std::endl;
|
logger.logError("unknown warning level “" + warningLevel + "”");
|
||||||
|
std::cout << std::endl;
|
||||||
|
printHelp();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto colorPolicy = variablesMap["color"].as<std::string>();
|
||||||
|
|
||||||
|
if (colorPolicy == "auto")
|
||||||
|
logger.setColorPolicy(plasp::utils::LogStream::ColorPolicy::Auto);
|
||||||
|
else if (colorPolicy == "never")
|
||||||
|
logger.setColorPolicy(plasp::utils::LogStream::ColorPolicy::Never);
|
||||||
|
else if (colorPolicy == "always")
|
||||||
|
logger.setColorPolicy(plasp::utils::LogStream::ColorPolicy::Always);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.logError("unknown color policy “" + colorPolicy + "”");
|
||||||
|
std::cout << std::endl;
|
||||||
printHelp();
|
printHelp();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sasDescription = plasp::sas::Description::fromFile(variablesMap["input"].as<std::string>());
|
plasp::utils::Parser<plasp::utils::CaseInsensitiveParserPolicy> parser;
|
||||||
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
|
||||||
sasTranslator.translate(std::cout);
|
if (variablesMap.count("input"))
|
||||||
|
{
|
||||||
|
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
||||||
|
|
||||||
|
std::for_each(inputFiles.cbegin(), inputFiles.cend(),
|
||||||
|
[&](const auto &inputFile)
|
||||||
|
{
|
||||||
|
parser.read(inputFile);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
parser.read("std::cin", std::cin);
|
||||||
|
|
||||||
|
const auto detectLanguage =
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
|
if (variablesMap.count("language") == 0)
|
||||||
|
return plasp::detectLanguage(parser);
|
||||||
|
|
||||||
|
const auto languageName = variablesMap["language"].as<std::string>();
|
||||||
|
|
||||||
|
return plasp::Language::fromString(languageName);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto language = detectLanguage();
|
||||||
|
|
||||||
|
if (language == plasp::Language::Type::Unknown)
|
||||||
|
{
|
||||||
|
logger.logError("unknown input language");
|
||||||
|
std::cout << std::endl;
|
||||||
|
printHelp();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (language == plasp::Language::Type::PDDL)
|
||||||
|
{
|
||||||
|
auto pddlLogger = logger;
|
||||||
|
auto context = plasp::pddl::Context(std::move(parser), std::move(pddlLogger));
|
||||||
|
auto description = plasp::pddl::Description::fromContext(std::move(context));
|
||||||
|
const auto translator = plasp::pddl::TranslatorASP(description, description.context().logger.outputStream());
|
||||||
|
translator.translate();
|
||||||
|
}
|
||||||
|
else if (language == plasp::Language::Type::SAS)
|
||||||
|
{
|
||||||
|
const auto description = plasp::sas::Description::fromParser(std::move(parser));
|
||||||
|
const auto translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
||||||
|
translator.translate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const plasp::utils::ParserException &e)
|
||||||
|
{
|
||||||
|
logger.logError(e.coordinate(), e.message());
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
catch (const plasp::utils::TranslatorException &e)
|
||||||
|
{
|
||||||
|
logger.logError(e.what());
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: " << e.what() << std::endl << std::endl;
|
logger.logError(e.what());
|
||||||
printHelp();
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
doc/building-instructions.md
Normal file
44
doc/building-instructions.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Building Instructions
|
||||||
|
|
||||||
|
`plasp` requires a C++14 compiler (preferrably GCC ≥ 6.1 or clang ≥ 3.8), the `boost` libraries (≥ 1.55), and CMake for building.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ 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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ cd plasp
|
||||||
|
$ git pull
|
||||||
|
$ cd build/release
|
||||||
|
$ cmake .
|
||||||
|
$ make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the Tests
|
||||||
|
|
||||||
|
`plasp` provides unit tests written using the [Google Test](https://github.com/google/googletest) framework.
|
||||||
|
Before building and running the tests, make sure you have fetched the Google Test git submodule:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git submodule init
|
||||||
|
$ git submodule update
|
||||||
|
```
|
||||||
|
|
||||||
|
Afterward, enable the flag `BUILD_TESTS` in your CMake configuration.
|
||||||
|
Finally, build and run the tests as follows:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ 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.
|
18
doc/command-line-interface.md
Normal file
18
doc/command-line-interface.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Command-Line Interface
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ plasp [files] [options]
|
||||||
|
```
|
||||||
|
|
||||||
|
`plasp` automatically detects the language of the input files.
|
||||||
|
|
||||||
|
Multiple files may be provided in an arbitrary order.
|
||||||
|
`[files]` may also be omitted, in which case the input is read from `std::cin`.
|
||||||
|
|
||||||
|
`plasp` supports the following options:
|
||||||
|
|
||||||
|
| **option** | **explanation** |
|
||||||
|
|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
| `-l` [ `--language` ] | Specify the input language (`sas` or `pddl`). Omit for automatic detection. |
|
||||||
|
| `--warning-level` arg (=`normal`) | Specify whether to output warnings normally (`normal`), to treat them as critical errors (`error`), or to ignore them (`ignore`). |
|
||||||
|
| `--color` arg (=`auto`) | Specify whether to colorize the output (`always`, `never`, or `auto`). |
|
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).
|
||||||
|
```
|
209
doc/output-format.md
Normal file
209
doc/output-format.md
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
The following illustrates `plasp`’s output format for the problem of turning switches on and off.
|
||||||
|
|
||||||
|
```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)).
|
||||||
|
|
||||||
|
% the variable may be true or false
|
||||||
|
contains(variable(on(X)), value(on(X)), true)) :- has(X, type(switch)).
|
||||||
|
contains(variable(on(X)), value(on(X)), false)) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% declares the action "action(turnOn(X))", which requires switch X to be off and then turns it on
|
||||||
|
action(action(turnOn(X))) :- has(X, type(switch)).
|
||||||
|
precondition(action(turnOn(X)), variable(on(X)), value(on(X), false)) :- has(X, type(switch)).
|
||||||
|
postcondition(action(turnOn(X)), effect(0), variable(on(X)), value(on(X), true)) :- has(X, type(switch)).
|
||||||
|
|
||||||
|
% initially, the switch is off
|
||||||
|
initialState(variable(on(constant(a))), value(on(constant(a)), false)).
|
||||||
|
|
||||||
|
% in the end, the switch should be on
|
||||||
|
goal(variable(on(constant(a))), value(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, [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(<type 1>), type(<type 2>)).
|
||||||
|
|
||||||
|
% specifies <constant> to have type type(<name>)
|
||||||
|
has(<constant>, type(<name>)).
|
||||||
|
```
|
||||||
|
|
||||||
|
[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 predicates, `variable(<PDDL predicate>).`
|
||||||
|
Each variable contains exactly two values (one `true`, one `false`) of the form `value(<PDDL predicate>, <bool>)`.
|
||||||
|
Note that with PDDL, variables and values are named identically.
|
||||||
|
|
||||||
|
### Actions
|
||||||
|
|
||||||
|
```prolog
|
||||||
|
% declares an <action>
|
||||||
|
action(action(<name>)).
|
||||||
|
|
||||||
|
% defines that as a precondition to <action>, <variable> must have value <value>
|
||||||
|
precondition(<action>, <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>).
|
||||||
|
|
||||||
|
% specifies the costs of applying <action>
|
||||||
|
costs(<action>, <number>).
|
||||||
|
```
|
||||||
|
|
||||||
|
Actions may require certain 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.
|
||||||
|
|
||||||
|
### 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> shall obtain <value> in the end
|
||||||
|
goal(<variable>, <value>).
|
||||||
|
```
|
||||||
|
|
||||||
|
The goal specifies all variable assignments that have to be fulfilled after executing the plan.
|
||||||
|
|
||||||
|
### 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.
|
@@ -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.
|
|
28
encodings/pddl-sequential-horizon-boolean.lp
Normal file
28
encodings/pddl-sequential-horizon-boolean.lp
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#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.
|
||||||
|
|
31
encodings/pddl-sequential-incremental-boolean.lp
Normal file
31
encodings/pddl-sequential-incremental-boolean.lp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#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/sequential-incremental.lp
Normal file
40
encodings/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.
|
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 <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Language
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Language
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
PDDL,
|
||||||
|
SAS
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::string toString(Type language);
|
||||||
|
static Language::Type fromString(const std::string &languageName);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Language() = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
49
include/plasp/LanguageDetection.h
Normal file
49
include/plasp/LanguageDetection.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef __PLASP__LANGUAGE_DETECTION_H
|
||||||
|
#define __PLASP__LANGUAGE_DETECTION_H
|
||||||
|
|
||||||
|
#include <plasp/Language.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// LanguageDetection
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
Language::Type detectLanguage(utils::Parser<utils::CaseInsensitiveParserPolicy> &parser)
|
||||||
|
{
|
||||||
|
parser.skipWhiteSpace();
|
||||||
|
|
||||||
|
// SAS begins with "begin_version"
|
||||||
|
if (parser.testAndSkip<std::string>("begin"))
|
||||||
|
{
|
||||||
|
parser.seek(0);
|
||||||
|
return Language::Type::SAS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip potential PDDL comments
|
||||||
|
while (parser.currentCharacter() == ';')
|
||||||
|
{
|
||||||
|
parser.skipLine();
|
||||||
|
parser.skipWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// PDDL contains sections starting with "(define"
|
||||||
|
if (parser.testAndSkip<std::string>("(") && parser.testAndSkip<std::string>("define"))
|
||||||
|
{
|
||||||
|
parser.seek(std::ios::beg);
|
||||||
|
return Language::Type::PDDL;
|
||||||
|
}
|
||||||
|
|
||||||
|
parser.seek(std::ios::beg);
|
||||||
|
return Language::Type::Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
50
include/plasp/pddl/Action.h
Normal file
50
include/plasp/pddl/Action.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef __PLASP__PDDL__ACTION_H
|
||||||
|
#define __PLASP__PDDL__ACTION_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/expressions/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Action
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Action
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void parseDeclaration(Context &context, Domain &domain);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string &name() const;
|
||||||
|
|
||||||
|
const expressions::Variables ¶meters() const;
|
||||||
|
const Expression *precondition() const;
|
||||||
|
const Expression *effect() const;
|
||||||
|
|
||||||
|
void normalizeParameterNames();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Action() = default;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
expressions::Variables m_parameters;
|
||||||
|
std::unique_ptr<Expression> m_precondition;
|
||||||
|
std::unique_ptr<Expression> m_effect;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
57
include/plasp/pddl/ConsistencyException.h
Normal file
57
include/plasp/pddl/ConsistencyException.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#ifndef __PLASP__PDDL__CONSISTENCY_EXCEPTION_H
|
||||||
|
#define __PLASP__PDDL__CONSISTENCY_EXCEPTION_H
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ConsistencyException
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ConsistencyException: public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit ConsistencyException()
|
||||||
|
: ConsistencyException("unspecified consistency error")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit ConsistencyException(const char *message)
|
||||||
|
: ConsistencyException(static_cast<std::string>(message))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit ConsistencyException(const std::string &message)
|
||||||
|
: m_message{message}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~ConsistencyException() throw()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *what() const throw()
|
||||||
|
{
|
||||||
|
if (m_message.empty())
|
||||||
|
return "unspecified consistency error";
|
||||||
|
|
||||||
|
return m_message.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_message;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
70
include/plasp/pddl/Context.h
Normal file
70
include/plasp/pddl/Context.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#ifndef __PLASP__PDDL__CONTEXT_H
|
||||||
|
#define __PLASP__PDDL__CONTEXT_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <plasp/pddl/Parser.h>
|
||||||
|
#include <plasp/utils/Logger.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Context
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Context
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Context() = default;
|
||||||
|
~Context() = default;
|
||||||
|
|
||||||
|
explicit Context(Parser &&otherParser)
|
||||||
|
: parser{std::move(otherParser)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit Context(utils::Logger &&otherLogger)
|
||||||
|
: logger{std::move(otherLogger)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit Context(Parser &&otherParser, utils::Logger &&otherLogger)
|
||||||
|
: parser{std::move(otherParser)},
|
||||||
|
logger{std::move(otherLogger)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Context(const Context &other) = delete;
|
||||||
|
Context &operator=(const Context &other) = delete;
|
||||||
|
|
||||||
|
Context(Context &&other)
|
||||||
|
: parser(std::move(other.parser)),
|
||||||
|
logger(std::move(other.logger))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Context &operator=(Context &&other)
|
||||||
|
{
|
||||||
|
parser = std::move(other.parser);
|
||||||
|
logger = std::move(other.logger);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
Parser parser;
|
||||||
|
utils::Logger logger;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
61
include/plasp/pddl/Description.h
Normal file
61
include/plasp/pddl/Description.h
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#ifndef __PLASP__PDDL__DESCRIPTION_H
|
||||||
|
#define __PLASP__PDDL__DESCRIPTION_H
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
|
#include <plasp/pddl/Domain.h>
|
||||||
|
#include <plasp/pddl/Problem.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Description
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Description
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static Description fromContext(Context &&context);
|
||||||
|
static Description fromStream(std::istream &istream);
|
||||||
|
static Description fromFile(const std::string &path);
|
||||||
|
static Description fromFiles(const std::vector<std::string> &paths);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Context &context();
|
||||||
|
const Context &context() const;
|
||||||
|
|
||||||
|
const Domain &domain() const;
|
||||||
|
|
||||||
|
bool containsProblem() const;
|
||||||
|
const Problem &problem() const;
|
||||||
|
|
||||||
|
void normalizeParameterNames();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Description();
|
||||||
|
|
||||||
|
void parse();
|
||||||
|
void findSections();
|
||||||
|
|
||||||
|
void checkConsistency();
|
||||||
|
|
||||||
|
Context m_context;
|
||||||
|
|
||||||
|
utils::Stream::Position m_domainPosition;
|
||||||
|
std::unique_ptr<Domain> m_domain;
|
||||||
|
utils::Stream::Position m_problemPosition;
|
||||||
|
std::unique_ptr<Problem> m_problem;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
95
include/plasp/pddl/Domain.h
Normal file
95
include/plasp/pddl/Domain.h
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#ifndef __PLASP__PDDL__DOMAIN_H
|
||||||
|
#define __PLASP__PDDL__DOMAIN_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Action.h>
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/Parser.h>
|
||||||
|
#include <plasp/pddl/Requirement.h>
|
||||||
|
#include <plasp/pddl/expressions/Constant.h>
|
||||||
|
#include <plasp/pddl/expressions/PredicateDeclaration.h>
|
||||||
|
#include <plasp/pddl/expressions/PrimitiveType.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Domain
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Domain
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Domain(Context &context);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void findSections();
|
||||||
|
void parse();
|
||||||
|
|
||||||
|
void setName(std::string name);
|
||||||
|
const std::string &name() const;
|
||||||
|
|
||||||
|
const Requirements &requirements() const;
|
||||||
|
bool hasRequirement(Requirement::Type requirementType) const;
|
||||||
|
void checkRequirement(Requirement::Type requirementType);
|
||||||
|
|
||||||
|
expressions::PrimitiveTypes &types();
|
||||||
|
const expressions::PrimitiveTypes &types() const;
|
||||||
|
|
||||||
|
expressions::Constants &constants();
|
||||||
|
const expressions::Constants &constants() const;
|
||||||
|
|
||||||
|
expressions::PredicateDeclarations &predicates();
|
||||||
|
const expressions::PredicateDeclarations &predicates() const;
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<Action>> &actions();
|
||||||
|
const std::vector<std::unique_ptr<Action>> &actions() const;
|
||||||
|
|
||||||
|
void checkConsistency();
|
||||||
|
|
||||||
|
void normalizeParameterNames();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parseSection();
|
||||||
|
|
||||||
|
void parseRequirementSection();
|
||||||
|
void computeDerivedRequirements();
|
||||||
|
|
||||||
|
void parseTypeSection();
|
||||||
|
|
||||||
|
void parseConstantSection();
|
||||||
|
|
||||||
|
void parsePredicateSection();
|
||||||
|
|
||||||
|
void parseActionSection();
|
||||||
|
|
||||||
|
Context &m_context;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
utils::Stream::Position m_requirementsPosition;
|
||||||
|
Requirements m_requirements;
|
||||||
|
|
||||||
|
utils::Stream::Position m_typesPosition;
|
||||||
|
expressions::PrimitiveTypes m_types;
|
||||||
|
|
||||||
|
utils::Stream::Position m_constantsPosition;
|
||||||
|
expressions::Constants m_constants;
|
||||||
|
|
||||||
|
utils::Stream::Position m_predicatesPosition;
|
||||||
|
expressions::PredicateDeclarations m_predicates;
|
||||||
|
|
||||||
|
std::vector<utils::Stream::Position> m_actionPositions;
|
||||||
|
std::vector<std::unique_ptr<Action>> m_actions;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
130
include/plasp/pddl/Expression.h
Normal file
130
include/plasp/pddl/Expression.h
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSION_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSION_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Expression
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Context;
|
||||||
|
class Domain;
|
||||||
|
class ExpressionContext;
|
||||||
|
class ExpressionVisitor;
|
||||||
|
class Problem;
|
||||||
|
|
||||||
|
class Expression;
|
||||||
|
using ExpressionPointer = std::unique_ptr<Expression>;
|
||||||
|
using Expressions = std::vector<ExpressionPointer>;
|
||||||
|
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
class And;
|
||||||
|
using AndPointer = std::unique_ptr<And>;
|
||||||
|
|
||||||
|
class At;
|
||||||
|
using AtPointer = std::unique_ptr<At>;
|
||||||
|
|
||||||
|
class Constant;
|
||||||
|
using ConstantPointer = std::unique_ptr<Constant>;
|
||||||
|
using Constants = std::vector<ConstantPointer>;
|
||||||
|
|
||||||
|
class Either;
|
||||||
|
using EitherPointer = std::unique_ptr<Either>;
|
||||||
|
|
||||||
|
class Imply;
|
||||||
|
using ImplyPointer = std::unique_ptr<Imply>;
|
||||||
|
|
||||||
|
class Not;
|
||||||
|
using NotPointer = std::unique_ptr<Not>;
|
||||||
|
|
||||||
|
class Or;
|
||||||
|
using OrPointer = std::unique_ptr<Or>;
|
||||||
|
|
||||||
|
class Predicate;
|
||||||
|
using PredicatePointer = std::unique_ptr<Predicate>;
|
||||||
|
using Predicates = std::vector<PredicatePointer>;
|
||||||
|
|
||||||
|
class PredicateDeclaration;
|
||||||
|
using PredicateDeclarationPointer = std::unique_ptr<PredicateDeclaration>;
|
||||||
|
using PredicateDeclarations = std::vector<PredicateDeclarationPointer>;
|
||||||
|
|
||||||
|
class PrimitiveType;
|
||||||
|
using PrimitiveTypePointer = std::unique_ptr<PrimitiveType>;
|
||||||
|
using PrimitiveTypes = std::vector<PrimitiveTypePointer>;
|
||||||
|
|
||||||
|
class Unsupported;
|
||||||
|
using UnsupportedPointer = std::unique_ptr<Unsupported>;
|
||||||
|
|
||||||
|
class Variable;
|
||||||
|
using VariablePointer = std::unique_ptr<Variable>;
|
||||||
|
using Variables = std::vector<VariablePointer>;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Expression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
And,
|
||||||
|
At,
|
||||||
|
Binary,
|
||||||
|
Constant,
|
||||||
|
Either,
|
||||||
|
Imply,
|
||||||
|
Not,
|
||||||
|
Or,
|
||||||
|
PredicateDeclaration,
|
||||||
|
Predicate,
|
||||||
|
PrimitiveType,
|
||||||
|
Unsupported,
|
||||||
|
Variable
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~Expression() = default;
|
||||||
|
|
||||||
|
virtual Type expressionType() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
class ExpressionCRTP: public Expression
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Type expressionType() const override final
|
||||||
|
{
|
||||||
|
return Derived::ExpressionType;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ExpressionPointer parseLiteral(Context &context, ExpressionContext &expressionContext);
|
||||||
|
ExpressionPointer parseAtomicFormula(Context &context, ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
ExpressionPointer parsePreconditionExpression(Context &context,
|
||||||
|
ExpressionContext &expressionContext);
|
||||||
|
ExpressionPointer parseExpression(Context &context, ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
ExpressionPointer parseEffectExpression(Context &context,
|
||||||
|
ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
38
include/plasp/pddl/ExpressionContext.h
Normal file
38
include/plasp/pddl/ExpressionContext.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSION_CONTEXT_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSION_CONTEXT_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/Requirement.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ExpressionContext
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class ExpressionContext
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExpressionContext(Domain &domain, expressions::Variables ¶meters);
|
||||||
|
ExpressionContext(Domain &domain, Problem *problem, expressions::Variables ¶meters);
|
||||||
|
|
||||||
|
bool hasRequirement(Requirement::Type requirementType) const;
|
||||||
|
void checkRequirement(Requirement::Type requirementType) const;
|
||||||
|
|
||||||
|
Domain &domain;
|
||||||
|
Problem *problem;
|
||||||
|
|
||||||
|
expressions::Variables ¶meters;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
45
include/plasp/pddl/IO.h
Normal file
45
include/plasp/pddl/IO.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef __PLASP__PDDL__IO_H
|
||||||
|
#define __PLASP__PDDL__IO_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <plasp/pddl/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// IO
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline void skipSection(Parser &parser)
|
||||||
|
{
|
||||||
|
size_t openParentheses = 1;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const auto character = parser.currentCharacter();
|
||||||
|
parser.advance();
|
||||||
|
|
||||||
|
if (character == '(')
|
||||||
|
openParentheses++;
|
||||||
|
else if (character == ')')
|
||||||
|
{
|
||||||
|
openParentheses--;
|
||||||
|
|
||||||
|
if (openParentheses == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
35
include/plasp/pddl/InitialState.h
Normal file
35
include/plasp/pddl/InitialState.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__INITIAL_STATE_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__INITIAL_STATE_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// InitialState
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class InitialState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static std::unique_ptr<InitialState> parseDeclaration(Context &context,
|
||||||
|
ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const Expressions &facts() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Expressions m_facts;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
54
include/plasp/pddl/Parser.h
Normal file
54
include/plasp/pddl/Parser.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#ifndef __PLASP__PDDL__PARSER_H
|
||||||
|
#define __PLASP__PDDL__PARSER_H
|
||||||
|
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Parser
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class PDDLParserPolicy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static char transformCharacter(char c) noexcept
|
||||||
|
{
|
||||||
|
return std::tolower(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isWhiteSpaceCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::iswspace(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isBlankCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::isblank(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isIdentifierCharacter(char c)
|
||||||
|
{
|
||||||
|
return c != '?'
|
||||||
|
&& c != '('
|
||||||
|
&& c != ')'
|
||||||
|
&& c != ';'
|
||||||
|
&& std::isgraph(c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using Parser = utils::Parser<PDDLParserPolicy>;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
85
include/plasp/pddl/Problem.h
Normal file
85
include/plasp/pddl/Problem.h
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#ifndef __PLASP__PDDL__PROBLEM_H
|
||||||
|
#define __PLASP__PDDL__PROBLEM_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/InitialState.h>
|
||||||
|
#include <plasp/pddl/Parser.h>
|
||||||
|
#include <plasp/pddl/Requirement.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Problem
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Problem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Problem(Context &context, Domain &domain);
|
||||||
|
|
||||||
|
void findSections();
|
||||||
|
void parse();
|
||||||
|
|
||||||
|
Domain &domain();
|
||||||
|
const Domain &domain() const;
|
||||||
|
|
||||||
|
const std::string &name() const;
|
||||||
|
|
||||||
|
const Requirements &requirements() const;
|
||||||
|
bool hasRequirement(Requirement::Type requirementType) const;
|
||||||
|
void checkRequirement(Requirement::Type requirementType);
|
||||||
|
|
||||||
|
expressions::Constants &objects();
|
||||||
|
const expressions::Constants &objects() const;
|
||||||
|
|
||||||
|
InitialState &initialState();
|
||||||
|
const InitialState &initialState() const;
|
||||||
|
|
||||||
|
const Expression &goal() const;
|
||||||
|
|
||||||
|
void checkConsistency();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void parseRequirementSection();
|
||||||
|
void computeDerivedRequirements();
|
||||||
|
|
||||||
|
void parseDomainSection();
|
||||||
|
|
||||||
|
void parseObjectSection();
|
||||||
|
|
||||||
|
void parseInitialStateSection();
|
||||||
|
|
||||||
|
void parseGoalSection();
|
||||||
|
|
||||||
|
Context &m_context;
|
||||||
|
Domain &m_domain;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
utils::Stream::Position m_domainPosition;
|
||||||
|
|
||||||
|
utils::Stream::Position m_requirementsPosition;
|
||||||
|
Requirements m_requirements;
|
||||||
|
|
||||||
|
utils::Stream::Position m_objectsPosition;
|
||||||
|
expressions::Constants m_objects;
|
||||||
|
|
||||||
|
utils::Stream::Position m_initialStatePosition;
|
||||||
|
std::unique_ptr<InitialState> m_initialState;
|
||||||
|
|
||||||
|
utils::Stream::Position m_goalPosition;
|
||||||
|
ExpressionPointer m_goal;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
72
include/plasp/pddl/Requirement.h
Normal file
72
include/plasp/pddl/Requirement.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#ifndef __PLASP__PDDL__REQUIREMENT_H
|
||||||
|
#define __PLASP__PDDL__REQUIREMENT_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Requirement
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Requirement;
|
||||||
|
using Requirements = std::vector<Requirement>;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Requirement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
STRIPS,
|
||||||
|
Typing,
|
||||||
|
NegativePreconditions,
|
||||||
|
DisjunctivePreconditions,
|
||||||
|
Equality,
|
||||||
|
ExistentialPreconditions,
|
||||||
|
UniversalPreconditions,
|
||||||
|
QuantifiedPreconditions,
|
||||||
|
ConditionalEffects,
|
||||||
|
Fluents,
|
||||||
|
NumericFluents,
|
||||||
|
ObjectFluents,
|
||||||
|
ADL,
|
||||||
|
DurativeActions,
|
||||||
|
DurationInequalities,
|
||||||
|
ContinuousEffects,
|
||||||
|
DerivedPredicates,
|
||||||
|
TimedInitialLiterals,
|
||||||
|
Preferences,
|
||||||
|
Constraints,
|
||||||
|
ActionCosts,
|
||||||
|
GoalUtilities
|
||||||
|
};
|
||||||
|
|
||||||
|
static Requirement parse(Context &context);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Requirement(Type type);
|
||||||
|
|
||||||
|
Type type() const;
|
||||||
|
|
||||||
|
std::string toPDDL() const;
|
||||||
|
std::string toASP() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
include/plasp/pddl/TranslatorASP.h
Normal file
51
include/plasp/pddl/TranslatorASP.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||||
|
#define __PLASP__PDDL__TRANSLATOR_ASP_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Description.h>
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TranslatorASP
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class TranslatorASP
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TranslatorASP(Description &description, utils::LogStream &outputStream);
|
||||||
|
|
||||||
|
void translate() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void translateDomain() const;
|
||||||
|
void translateTypes() const;
|
||||||
|
void translatePredicates() const;
|
||||||
|
void translateActions() const;
|
||||||
|
|
||||||
|
void translateProblem() const;
|
||||||
|
void translateInitialState() const;
|
||||||
|
void translateGoal() const;
|
||||||
|
|
||||||
|
void translateConstants(const std::string &heading, const expressions::Constants &constants) const;
|
||||||
|
void translateVariablesHead(const expressions::Variables &variables) const;
|
||||||
|
void translateVariablesBody(const expressions::Variables &variables) const;
|
||||||
|
void translateLiteral(const Expression &literal) const;
|
||||||
|
void translatePredicate(const expressions::Predicate &predicate) const;
|
||||||
|
|
||||||
|
Description &m_description;
|
||||||
|
utils::LogStream &m_outputStream;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
33
include/plasp/pddl/expressions/And.h
Normal file
33
include/plasp/pddl/expressions/And.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__AND_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__AND_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/expressions/NAry.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// And
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class And: public NAry<And>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::And;
|
||||||
|
|
||||||
|
static const std::string Identifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
105
include/plasp/pddl/expressions/At.h
Normal file
105
include/plasp/pddl/expressions/At.h
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__AT_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__AT_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// At
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class At: public ExpressionCRTP<At>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::At;
|
||||||
|
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
static AtPointer parse(Context &context, ExpressionContext &expressionContext,
|
||||||
|
ExpressionParser parseExpression);
|
||||||
|
|
||||||
|
static const size_t TimePointStart = std::numeric_limits<size_t>::max();
|
||||||
|
static const size_t TimePointEnd = std::numeric_limits<size_t>::max() - 1;
|
||||||
|
|
||||||
|
public:
|
||||||
|
At();
|
||||||
|
|
||||||
|
size_t timePoint() const;
|
||||||
|
|
||||||
|
const Expression *argument() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setArgument(const Expression *argument);
|
||||||
|
void setArgument(ExpressionPointer &&argument);
|
||||||
|
|
||||||
|
size_t m_timePoint;
|
||||||
|
|
||||||
|
const Expression *m_argument;
|
||||||
|
ExpressionPointer m_argumentStorage;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
AtPointer At::parse(Context &context, ExpressionContext &expressionContext,
|
||||||
|
ExpressionParser parseExpression)
|
||||||
|
{
|
||||||
|
auto &parser = context.parser;
|
||||||
|
|
||||||
|
const auto position = parser.position();
|
||||||
|
|
||||||
|
if (!parser.testAndSkip<std::string>("(")
|
||||||
|
|| !parser.testIdentifierAndSkip("at"))
|
||||||
|
{
|
||||||
|
parser.seek(position);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t timePoint;
|
||||||
|
|
||||||
|
const auto timePointPosition = parser.position();
|
||||||
|
|
||||||
|
if (parser.testIdentifierAndSkip("start"))
|
||||||
|
timePoint = TimePointStart;
|
||||||
|
else if (parser.testIdentifierAndSkip("end"))
|
||||||
|
timePoint = TimePointEnd;
|
||||||
|
else if (parser.probeNumber())
|
||||||
|
{
|
||||||
|
parser.seek(timePointPosition);
|
||||||
|
timePoint = parser.parse<size_t>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parser.seek(position);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto expression = std::make_unique<At>(At());
|
||||||
|
|
||||||
|
expression->m_timePoint = timePoint;
|
||||||
|
|
||||||
|
context.parser.skipWhiteSpace();
|
||||||
|
|
||||||
|
// Parse argument
|
||||||
|
expression->setArgument(parseExpression(context, expressionContext));
|
||||||
|
|
||||||
|
parser.expect<std::string>(")");
|
||||||
|
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
111
include/plasp/pddl/expressions/Binary.h
Normal file
111
include/plasp/pddl/expressions/Binary.h
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__BINARY_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__BINARY_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/ConsistencyException.h>
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/expressions/Variable.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Binary
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
class Binary: public ExpressionCRTP<Derived>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
static std::unique_ptr<Derived> parse(Context &context,
|
||||||
|
ExpressionContext &expressionContext, ExpressionParser parseExpression);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::array<const Expression *, 2> &arguments() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
template<size_t i>
|
||||||
|
void setArgument(const Expression *argument);
|
||||||
|
template<size_t i>
|
||||||
|
void setArgument(ExpressionPointer &&argument);
|
||||||
|
|
||||||
|
std::array<const Expression *, 2> m_arguments;
|
||||||
|
std::array<ExpressionPointer, 2> m_argumentStorage;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
std::unique_ptr<Derived> Binary<Derived>::parse(Context &context,
|
||||||
|
ExpressionContext &expressionContext, ExpressionParser parseExpression)
|
||||||
|
{
|
||||||
|
auto &parser = context.parser;
|
||||||
|
|
||||||
|
const auto position = parser.position();
|
||||||
|
|
||||||
|
if (!parser.testAndSkip<std::string>("(")
|
||||||
|
|| !parser.testIdentifierAndSkip(Derived::Identifier))
|
||||||
|
{
|
||||||
|
parser.seek(position);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto expression = std::make_unique<Derived>();
|
||||||
|
|
||||||
|
// Assume that expression identifier (imply, exists, etc.) is already parsed
|
||||||
|
// Parse arguments of the expression
|
||||||
|
expression->Binary<Derived>::setArgument<0>(parseExpression(context, expressionContext));
|
||||||
|
expression->Binary<Derived>::setArgument<1>(parseExpression(context, expressionContext));
|
||||||
|
|
||||||
|
parser.expect<std::string>(")");
|
||||||
|
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
template<size_t i>
|
||||||
|
void Binary<Derived>::setArgument(const Expression *expression)
|
||||||
|
{
|
||||||
|
static_assert(i <= 2, "Index out of range");
|
||||||
|
|
||||||
|
m_argumentStorage[i] = nullptr;
|
||||||
|
m_arguments[i] = expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
template<size_t i>
|
||||||
|
void Binary<Derived>::setArgument(ExpressionPointer &&expression)
|
||||||
|
{
|
||||||
|
static_assert(i <= 2, "Index out of range");
|
||||||
|
|
||||||
|
m_argumentStorage[i] = std::move(expression);
|
||||||
|
m_arguments[i] = m_argumentStorage[i].get();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
const std::array<const Expression *, 2> &Binary<Derived>::arguments() const
|
||||||
|
{
|
||||||
|
return m_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
64
include/plasp/pddl/expressions/Constant.h
Normal file
64
include/plasp/pddl/expressions/Constant.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__CONSTANT_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__CONSTANT_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
#include <plasp/utils/ParserException.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Constant
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Constant: public ExpressionCRTP<Constant>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Constant;
|
||||||
|
|
||||||
|
static void parseTypedDeclaration(Context &context, Domain &domain);
|
||||||
|
static void parseTypedDeclarations(Context &context, Domain &domain);
|
||||||
|
static void parseTypedDeclaration(Context &context, Problem &problem);
|
||||||
|
static void parseTypedDeclarations(Context &context, Problem &problem);
|
||||||
|
|
||||||
|
static Constant *parseAndFind(Context &context, const Domain &domain);
|
||||||
|
static Constant *parseAndFind(Context &context, const Problem &problem);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string &name() const;
|
||||||
|
const PrimitiveType *type() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static ConstantPointer parseDeclaration(Context &context);
|
||||||
|
static void parseTypedDeclaration(Context &context, Domain &domain, Constants &constants);
|
||||||
|
|
||||||
|
static Constant *parseAndFind(const std::string &constantName, const Constants &constants);
|
||||||
|
|
||||||
|
Constant();
|
||||||
|
|
||||||
|
void setDirty(bool isDirty = true);
|
||||||
|
bool isDirty() const;
|
||||||
|
|
||||||
|
void setType(const PrimitiveType *parentType);
|
||||||
|
|
||||||
|
bool m_isDirty;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
const PrimitiveType *m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
33
include/plasp/pddl/expressions/Either.h
Normal file
33
include/plasp/pddl/expressions/Either.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__EITHER_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__EITHER_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/expressions/NAry.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Either
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Either: public NAry<Either>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Either;
|
||||||
|
|
||||||
|
static const std::string Identifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
33
include/plasp/pddl/expressions/Imply.h
Normal file
33
include/plasp/pddl/expressions/Imply.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__IMPLY_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__IMPLY_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/expressions/Binary.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Imply
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Imply: public Binary<Imply>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Imply;
|
||||||
|
|
||||||
|
static const std::string Identifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
117
include/plasp/pddl/expressions/NAry.h
Normal file
117
include/plasp/pddl/expressions/NAry.h
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__N_ARY_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__N_ARY_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/ConsistencyException.h>
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/pddl/expressions/Variable.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// NAry
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
class NAry: public ExpressionCRTP<Derived>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
static std::unique_ptr<Derived> parse(Context &context,
|
||||||
|
ExpressionContext &expressionContext, ExpressionParser parseExpression);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::vector<const Expression *> &arguments() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void addArgument(const Expression *argument);
|
||||||
|
void addArgument(ExpressionPointer &&argument);
|
||||||
|
|
||||||
|
std::vector<const Expression *> m_arguments;
|
||||||
|
Expressions m_argumentStorage;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
std::unique_ptr<Derived> NAry<Derived>::parse(Context &context,
|
||||||
|
ExpressionContext &expressionContext, ExpressionParser parseExpression)
|
||||||
|
{
|
||||||
|
auto &parser = context.parser;
|
||||||
|
|
||||||
|
const auto position = parser.position();
|
||||||
|
|
||||||
|
if (!parser.testAndSkip<std::string>("(")
|
||||||
|
|| !parser.testIdentifierAndSkip(Derived::Identifier))
|
||||||
|
{
|
||||||
|
parser.seek(position);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto expression = std::make_unique<Derived>();
|
||||||
|
|
||||||
|
parser.skipWhiteSpace();
|
||||||
|
|
||||||
|
// Assume that expression identifier (and, or, etc.) is already parsed
|
||||||
|
// Parse arguments of the expression
|
||||||
|
while (parser.currentCharacter() != ')')
|
||||||
|
{
|
||||||
|
expression->addArgument(parseExpression(context, expressionContext));
|
||||||
|
|
||||||
|
parser.skipWhiteSpace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression->m_arguments.empty())
|
||||||
|
context.logger.logWarning(parser.coordinate(), "“" + Derived::Identifier + "” expressions should not be empty");
|
||||||
|
|
||||||
|
parser.expect<std::string>(")");
|
||||||
|
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
void NAry<Derived>::addArgument(const Expression *argument)
|
||||||
|
{
|
||||||
|
if (!argument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_arguments.emplace_back(argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
void NAry<Derived>::addArgument(ExpressionPointer &&argument)
|
||||||
|
{
|
||||||
|
if (!argument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_argumentStorage.emplace_back(std::move(argument));
|
||||||
|
m_arguments.emplace_back(m_argumentStorage.back().get());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class Derived>
|
||||||
|
const std::vector<const Expression *> &NAry<Derived>::arguments() const
|
||||||
|
{
|
||||||
|
return m_arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
77
include/plasp/pddl/expressions/Not.h
Normal file
77
include/plasp/pddl/expressions/Not.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__NOT_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__NOT_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Not
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Not: public ExpressionCRTP<Not>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Not;
|
||||||
|
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
static NotPointer parse(Context &context, ExpressionContext &expressionContext,
|
||||||
|
ExpressionParser parseExpression);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Not();
|
||||||
|
|
||||||
|
const Expression *argument() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setArgument(const Expression *argument);
|
||||||
|
void setArgument(ExpressionPointer &&argument);
|
||||||
|
|
||||||
|
const Expression *m_argument;
|
||||||
|
ExpressionPointer m_argumentStorage;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<typename ExpressionParser>
|
||||||
|
NotPointer Not::parse(Context &context, ExpressionContext &expressionContext,
|
||||||
|
ExpressionParser parseExpression)
|
||||||
|
{
|
||||||
|
auto &parser = context.parser;
|
||||||
|
|
||||||
|
const auto position = parser.position();
|
||||||
|
|
||||||
|
if (!parser.testAndSkip<std::string>("(")
|
||||||
|
|| !parser.testIdentifierAndSkip("not"))
|
||||||
|
{
|
||||||
|
parser.seek(position);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto expression = std::make_unique<Not>(Not());
|
||||||
|
|
||||||
|
context.parser.skipWhiteSpace();
|
||||||
|
|
||||||
|
// Parse argument
|
||||||
|
expression->setArgument(parseExpression(context, expressionContext));
|
||||||
|
|
||||||
|
parser.expect<std::string>(")");
|
||||||
|
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
33
include/plasp/pddl/expressions/Or.h
Normal file
33
include/plasp/pddl/expressions/Or.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__OR_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__OR_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/expressions/NAry.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Or
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Or: public NAry<Or>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Or;
|
||||||
|
|
||||||
|
static const std::string Identifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
50
include/plasp/pddl/expressions/Predicate.h
Normal file
50
include/plasp/pddl/expressions/Predicate.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__PREDICATE_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__PREDICATE_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Predicate
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Predicate: public ExpressionCRTP<Predicate>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Predicate;
|
||||||
|
|
||||||
|
static PredicatePointer parse(Context &context, ExpressionContext &expressionContext);
|
||||||
|
static PredicatePointer parse(Context &context, const Problem &problem);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string &name() const;
|
||||||
|
const std::vector<const Expression *> &arguments() const;
|
||||||
|
|
||||||
|
bool isDeclared() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Predicate();
|
||||||
|
|
||||||
|
void setDeclared();
|
||||||
|
|
||||||
|
bool m_isDeclared;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
std::vector<const Expression *> m_arguments;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
include/plasp/pddl/expressions/PredicateDeclaration.h
Normal file
51
include/plasp/pddl/expressions/PredicateDeclaration.h
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__PREDICATE_DECLARATION_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__PREDICATE_DECLARATION_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PredicateDeclaration
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class PredicateDeclaration: public ExpressionCRTP<PredicateDeclaration>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::PredicateDeclaration;
|
||||||
|
|
||||||
|
static void parse(Context &context, Domain &domain);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string &name() const;
|
||||||
|
const Variables &arguments() const;
|
||||||
|
|
||||||
|
bool isDeclared() const;
|
||||||
|
|
||||||
|
void normalizeParameterNames();
|
||||||
|
|
||||||
|
private:
|
||||||
|
PredicateDeclaration();
|
||||||
|
|
||||||
|
void setDeclared();
|
||||||
|
|
||||||
|
bool m_isDeclared;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
Variables m_parameters;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
55
include/plasp/pddl/expressions/PrimitiveType.h
Normal file
55
include/plasp/pddl/expressions/PrimitiveType.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__PRIMITIVE_TYPE_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__PRIMITIVE_TYPE_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/ConsistencyException.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
#include <plasp/utils/ParserException.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PrimitiveType
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class PrimitiveType: public ExpressionCRTP<PrimitiveType>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::PrimitiveType;
|
||||||
|
|
||||||
|
static void parseDeclaration(Context &context, Domain &domain);
|
||||||
|
static void parseTypedDeclaration(Context &context, Domain &domain);
|
||||||
|
|
||||||
|
static PrimitiveType *parseAndFind(Context &context, Domain &domain);
|
||||||
|
|
||||||
|
public:
|
||||||
|
PrimitiveType();
|
||||||
|
PrimitiveType(std::string name);
|
||||||
|
|
||||||
|
const std::string &name() const;
|
||||||
|
const std::vector<const PrimitiveType *> &parentTypes() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setDirty(bool isDirty = true);
|
||||||
|
bool isDirty() const;
|
||||||
|
|
||||||
|
bool m_isDirty;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
std::vector<const PrimitiveType *> m_parentTypes;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
28
include/plasp/pddl/expressions/Type.h
Normal file
28
include/plasp/pddl/expressions/Type.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__TYPE_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__TYPE_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Type
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const Expression *parseExistingPrimitiveType(Context &context,
|
||||||
|
ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
40
include/plasp/pddl/expressions/Unsupported.h
Normal file
40
include/plasp/pddl/expressions/Unsupported.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__UNSUPPORTED_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__UNSUPPORTED_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Context.h>
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Unsupported
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Unsupported: public ExpressionCRTP<Unsupported>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Unsupported;
|
||||||
|
|
||||||
|
static UnsupportedPointer parse(Context &context);
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::string &type() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
63
include/plasp/pddl/expressions/Variable.h
Normal file
63
include/plasp/pddl/expressions/Variable.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#ifndef __PLASP__PDDL__EXPRESSIONS__VARIABLE_H
|
||||||
|
#define __PLASP__PDDL__EXPRESSIONS__VARIABLE_H
|
||||||
|
|
||||||
|
#include <plasp/pddl/Expression.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace pddl
|
||||||
|
{
|
||||||
|
namespace expressions
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Variable
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Variable: public ExpressionCRTP<Variable>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const Expression::Type ExpressionType = Expression::Type::Variable;
|
||||||
|
|
||||||
|
static void parseTypedDeclaration(Context &context, ExpressionContext &expressionContext);
|
||||||
|
static void parseTypedDeclarations(Context &context, ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
static const Variable *parseAndFind(Context &context,
|
||||||
|
const ExpressionContext &expressionContext);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void setName(std::string name);
|
||||||
|
const std::string &name() const;
|
||||||
|
|
||||||
|
const Expression *type() const;
|
||||||
|
|
||||||
|
void setDirty(bool isDirty = true);
|
||||||
|
bool isDirty() const;
|
||||||
|
|
||||||
|
void setType(const Expression *type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void parseDeclaration(Context &context, Variables ¶meters);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Variable();
|
||||||
|
|
||||||
|
bool m_isDirty;
|
||||||
|
|
||||||
|
std::string m_name;
|
||||||
|
|
||||||
|
const Expression *m_type;
|
||||||
|
|
||||||
|
// Stores "either" expression if necessary
|
||||||
|
ExpressionPointer m_eitherExpression;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <plasp/sas/Value.h>
|
#include <plasp/sas/Value.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -26,8 +27,8 @@ using AssignedVariables = std::vector<AssignedVariable>;
|
|||||||
class AssignedVariable
|
class AssignedVariable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static AssignedVariable fromSAS(std::istream &istream, const Variables &variables);
|
static AssignedVariable fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
static AssignedVariable fromSAS(std::istream &istream, const Variable &variable);
|
static AssignedVariable fromSAS(utils::Parser<> &parser, const Variable &variable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AssignedVariable(const Variable &variable, const Value &value);
|
explicit AssignedVariable(const Variable &variable, const Value &value);
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -28,7 +29,7 @@ class AxiomRule
|
|||||||
using Condition = AssignedVariable;
|
using Condition = AssignedVariable;
|
||||||
using Conditions = AssignedVariables;
|
using Conditions = AssignedVariables;
|
||||||
|
|
||||||
static AxiomRule fromSAS(std::istream &istream, const Variables &variables);
|
static AxiomRule fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Conditions &conditions() const;
|
const Conditions &conditions() const;
|
||||||
|
@@ -16,7 +16,7 @@ namespace sas
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::ostream &operator >>(std::ostream &ostream, const Description &description);
|
utils::LogStream &operator<<(utils::LogStream &ostream, const Description &description);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include <plasp/sas/MutexGroup.h>
|
#include <plasp/sas/MutexGroup.h>
|
||||||
#include <plasp/sas/Operator.h>
|
#include <plasp/sas/Operator.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,7 @@ namespace sas
|
|||||||
class Description
|
class Description
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static Description fromParser(utils::Parser<> &&parser);
|
||||||
static Description fromStream(std::istream &istream);
|
static Description fromStream(std::istream &istream);
|
||||||
static Description fromFile(const boost::filesystem::path &path);
|
static Description fromFile(const boost::filesystem::path &path);
|
||||||
|
|
||||||
@@ -43,17 +45,21 @@ class Description
|
|||||||
bool usesAxiomRules() const;
|
bool usesAxiomRules() const;
|
||||||
bool usesConditionalEffects() const;
|
bool usesConditionalEffects() const;
|
||||||
|
|
||||||
|
bool hasRequirements() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Description();
|
Description();
|
||||||
|
|
||||||
void parseVersionSection(std::istream &istream) const;
|
void parseContent(utils::Parser<> &parser);
|
||||||
void parseMetricSection(std::istream &istream);
|
|
||||||
void parseVariablesSection(std::istream &istream);
|
void parseVersionSection(utils::Parser<> &parser) const;
|
||||||
void parseMutexSection(std::istream &istream);
|
void parseMetricSection(utils::Parser<> &parser);
|
||||||
void parseInitialStateSection(std::istream &istream);
|
void parseVariablesSection(utils::Parser<> &parser);
|
||||||
void parseGoalSection(std::istream &istream);
|
void parseMutexSection(utils::Parser<> &parser);
|
||||||
void parseOperatorSection(std::istream &istream);
|
void parseInitialStateSection(utils::Parser<> &parser);
|
||||||
void parseAxiomSection(std::istream &istream);
|
void parseGoalSection(utils::Parser<> &parser);
|
||||||
|
void parseOperatorSection(utils::Parser<> &parser);
|
||||||
|
void parseAxiomSection(utils::Parser<> &parser);
|
||||||
|
|
||||||
bool m_usesActionCosts;
|
bool m_usesActionCosts;
|
||||||
|
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -28,7 +29,7 @@ class Effect
|
|||||||
using Condition = AssignedVariable;
|
using Condition = AssignedVariable;
|
||||||
using Conditions = AssignedVariables;
|
using Conditions = AssignedVariables;
|
||||||
|
|
||||||
static Effect fromSAS(std::istream &istream, const Variables &variables, Conditions &preconditions);
|
static Effect fromSAS(utils::Parser<> &parser, const Variables &variables, Conditions &preconditions);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Conditions &conditions() const;
|
const Conditions &conditions() const;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define __PLASP__SAS__GOAL_H
|
#define __PLASP__SAS__GOAL_H
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -20,7 +21,7 @@ class Goal
|
|||||||
using Fact = AssignedVariable;
|
using Fact = AssignedVariable;
|
||||||
using Facts = AssignedVariables;
|
using Facts = AssignedVariables;
|
||||||
|
|
||||||
static Goal fromSAS(std::istream &istream, const Variables &variables);
|
static Goal fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Facts &facts() const;
|
const Facts &facts() const;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define __PLASP__SAS__INITIAL_STATE_H
|
#define __PLASP__SAS__INITIAL_STATE_H
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -20,7 +21,7 @@ class InitialState
|
|||||||
using Fact = AssignedVariable;
|
using Fact = AssignedVariable;
|
||||||
using Facts = AssignedVariables;
|
using Facts = AssignedVariables;
|
||||||
|
|
||||||
static InitialState fromSAS(std::istream &istream, const Variables &variables);
|
static InitialState fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Facts &facts() const;
|
const Facts &facts() const;
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/sas/AssignedVariable.h>
|
#include <plasp/sas/AssignedVariable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -27,7 +28,7 @@ class MutexGroup
|
|||||||
using Fact = AssignedVariable;
|
using Fact = AssignedVariable;
|
||||||
using Facts = AssignedVariables;
|
using Facts = AssignedVariables;
|
||||||
|
|
||||||
static MutexGroup fromSAS(std::istream &istream, const Variables &variables);
|
static MutexGroup fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Facts &facts() const;
|
const Facts &facts() const;
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
#include <plasp/sas/Effect.h>
|
#include <plasp/sas/Effect.h>
|
||||||
#include <plasp/sas/Predicate.h>
|
#include <plasp/sas/Predicate.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -31,10 +33,10 @@ class Operator
|
|||||||
using Condition = AssignedVariable;
|
using Condition = AssignedVariable;
|
||||||
using Conditions = AssignedVariables;
|
using Conditions = AssignedVariables;
|
||||||
|
|
||||||
static Operator fromSAS(std::istream &istream, const Variables &variables);
|
static Operator fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printPredicateAsASP(std::ostream &ostream) const;
|
void printPredicateAsASP(utils::LogStream &ostream) const;
|
||||||
|
|
||||||
const Predicate &predicate() const;
|
const Predicate &predicate() const;
|
||||||
const Conditions &preconditions() const;
|
const Conditions &preconditions() const;
|
||||||
|
@@ -5,6 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
@@ -19,13 +22,13 @@ namespace sas
|
|||||||
class Predicate
|
class Predicate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Predicate fromSAS(std::istream &istream);
|
static Predicate fromSAS(utils::Parser<> &parser);
|
||||||
|
|
||||||
using Arguments = std::vector<std::string>;
|
using Arguments = std::vector<std::string>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printAsSAS(std::ostream &ostream) const;
|
void printAsSAS(utils::LogStream &outputStream) const;
|
||||||
void printAsASP(std::ostream &ostream) const;
|
void printAsASP(utils::LogStream &outputStream) const;
|
||||||
|
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
const Arguments &arguments() const;
|
const Arguments &arguments() const;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define __PLASP__SAS__TRANSLATOR_ASP_H
|
#define __PLASP__SAS__TRANSLATOR_ASP_H
|
||||||
|
|
||||||
#include <plasp/sas/Description.h>
|
#include <plasp/sas/Description.h>
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
|
||||||
@@ -19,12 +20,21 @@ namespace sas
|
|||||||
class TranslatorASP
|
class TranslatorASP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit TranslatorASP(const Description &description);
|
explicit TranslatorASP(const Description &description, utils::LogStream &outputStream);
|
||||||
|
|
||||||
void translate(std::ostream &ostream) const;
|
void translate() const;
|
||||||
|
|
||||||
private:
|
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;
|
const Description &m_description;
|
||||||
|
utils::LogStream &m_outputStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@@ -5,6 +5,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace sas
|
||||||
@@ -36,15 +39,14 @@ struct Value
|
|||||||
static const Value Any;
|
static const Value Any;
|
||||||
static const Value None;
|
static const Value None;
|
||||||
|
|
||||||
static Value fromSAS(std::istream &istream);
|
static Value fromSAS(utils::Parser<> &parser);
|
||||||
static const Value &referenceFromSAS(std::istream &istream, const Variable &variable);
|
static const Value &referenceFromSAS(utils::Parser<> &parser, const Variable &variable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Value negated() const;
|
Value negated() const;
|
||||||
|
|
||||||
void printAsSAS(std::ostream &ostream) const;
|
void printAsSAS(utils::LogStream &outputStream) const;
|
||||||
void printAsASP(std::ostream &ostream) const;
|
void printAsASPPredicate(utils::LogStream &outputStream) const;
|
||||||
void printAsASPPredicate(std::ostream &ostream) const;
|
|
||||||
|
|
||||||
Sign sign() const;
|
Sign sign() const;
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
|
@@ -6,6 +6,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plasp/sas/Value.h>
|
#include <plasp/sas/Value.h>
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -26,11 +28,11 @@ using Variables = std::vector<Variable>;
|
|||||||
class Variable
|
class Variable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Variable fromSAS(std::istream &istream);
|
static Variable fromSAS(utils::Parser<> &parser);
|
||||||
static const Variable &referenceFromSAS(std::istream &istream, const Variables &variables);
|
static const Variable &referenceFromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void printNameAsASPPredicate(std::ostream &ostream) const;
|
void printNameAsASPPredicate(utils::LogStream &outputStream) const;
|
||||||
|
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
int axiomLayer() const;
|
int axiomLayer() const;
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <plasp/sas/Value.h>
|
#include <plasp/sas/Value.h>
|
||||||
#include <plasp/sas/Variable.h>
|
#include <plasp/sas/Variable.h>
|
||||||
|
#include <plasp/utils/Parser.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ using VariableTransitions = std::vector<VariableTransition>;
|
|||||||
class VariableTransition
|
class VariableTransition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static VariableTransition fromSAS(std::istream &istream, const Variables &variables);
|
static VariableTransition fromSAS(utils::Parser<> &parser, const Variables &variables);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Variable &variable() const;
|
const Variable &variable() const;
|
||||||
|
282
include/plasp/utils/Formatting.h
Normal file
282
include/plasp/utils/Formatting.h
Normal file
@@ -0,0 +1,282 @@
|
|||||||
|
#ifndef __PLASP__UTILS__FORMATTING_H
|
||||||
|
#define __PLASP__UTILS__FORMATTING_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Formatting
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum class Color
|
||||||
|
{
|
||||||
|
Black = 0,
|
||||||
|
Red = 1,
|
||||||
|
Green = 2,
|
||||||
|
Yellow = 3,
|
||||||
|
Blue = 4,
|
||||||
|
Magenta = 5,
|
||||||
|
Cyan = 6,
|
||||||
|
White = 7
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum class FontWeight
|
||||||
|
{
|
||||||
|
Normal = 0,
|
||||||
|
Bold = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Format
|
||||||
|
{
|
||||||
|
Format(Color color, FontWeight fontWeight = FontWeight::Normal)
|
||||||
|
: m_color{color},
|
||||||
|
m_fontWeight{fontWeight}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Color m_color;
|
||||||
|
FontWeight m_fontWeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Format &format)
|
||||||
|
{
|
||||||
|
if (!stream.supportsColor())
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
const auto fontWeightCode = static_cast<size_t>(format.m_fontWeight);
|
||||||
|
const auto colorCode = 30 + static_cast<size_t>(format.m_color);
|
||||||
|
|
||||||
|
return (stream << "\033[" << fontWeightCode << ";" << colorCode << "m");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct ResetFormat
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const ResetFormat &)
|
||||||
|
{
|
||||||
|
if (!stream.supportsColor())
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
return (stream << "\033[0m");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Token
|
||||||
|
{
|
||||||
|
Token(const std::string &name)
|
||||||
|
: name(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &name;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct RuleName: public Token
|
||||||
|
{
|
||||||
|
RuleName(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const RuleName &keyword)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::White, utils::FontWeight::Bold)
|
||||||
|
<< keyword.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Keyword: public Token
|
||||||
|
{
|
||||||
|
Keyword(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Keyword &keyword)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Blue, utils::FontWeight::Normal)
|
||||||
|
<< keyword.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Number: public Token
|
||||||
|
{
|
||||||
|
Number(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Number &number)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Yellow, utils::FontWeight::Normal)
|
||||||
|
<< number.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Variable: public Token
|
||||||
|
{
|
||||||
|
Variable(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Variable &variable)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Green, utils::FontWeight::Bold)
|
||||||
|
<< variable.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct String: public Token
|
||||||
|
{
|
||||||
|
String(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const String &string)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Green, utils::FontWeight::Normal)
|
||||||
|
<< "\"" << string.name << "\""
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Boolean: public Token
|
||||||
|
{
|
||||||
|
Boolean(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Boolean &string)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Red, utils::FontWeight::Normal)
|
||||||
|
<< string.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Reserved: public Token
|
||||||
|
{
|
||||||
|
Reserved(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Reserved &string)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::White, utils::FontWeight::Normal)
|
||||||
|
<< string.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Heading1: public Token
|
||||||
|
{
|
||||||
|
Heading1(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Heading1 &heading1)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||||
|
<< "%---------------------------------------" << std::endl
|
||||||
|
<< "% " << heading1.name << std::endl
|
||||||
|
<< "%---------------------------------------"
|
||||||
|
<< utils::ResetFormat()
|
||||||
|
<< std::endl);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct Heading2: public Token
|
||||||
|
{
|
||||||
|
Heading2(const std::string &name)
|
||||||
|
: Token(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const Heading2 &heading2)
|
||||||
|
{
|
||||||
|
return (stream
|
||||||
|
<< utils::Format(utils::Color::Blue, utils::FontWeight::Bold)
|
||||||
|
<< "% " << heading2.name
|
||||||
|
<< utils::ResetFormat());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
335
include/plasp/utils/LogStream.h
Normal file
335
include/plasp/utils/LogStream.h
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
#ifndef __PLASP__UTILS__LOG_STREAM_H
|
||||||
|
#define __PLASP__UTILS__LOG_STREAM_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// LogStream
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
enum class StandardStream
|
||||||
|
{
|
||||||
|
Out,
|
||||||
|
Err
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class LogStream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class ColorPolicy
|
||||||
|
{
|
||||||
|
Never,
|
||||||
|
Auto,
|
||||||
|
Always
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
using CharacterType = std::ostream::char_type;
|
||||||
|
using TraitsType = std::ostream::traits_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LogStream(StandardStream standardStream)
|
||||||
|
: m_standardStream{standardStream},
|
||||||
|
m_colorPolicy{ColorPolicy::Auto}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LogStream(const LogStream &other)
|
||||||
|
: m_standardStream{other.m_standardStream},
|
||||||
|
m_colorPolicy{other.m_colorPolicy}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
LogStream &operator=(const LogStream &other)
|
||||||
|
{
|
||||||
|
m_standardStream = other.m_standardStream;
|
||||||
|
m_colorPolicy = other.m_colorPolicy;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogStream(LogStream &&other)
|
||||||
|
: m_standardStream{other.m_standardStream},
|
||||||
|
m_colorPolicy{other.m_colorPolicy}
|
||||||
|
{
|
||||||
|
other.m_colorPolicy = ColorPolicy::Auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogStream &operator=(LogStream &&other)
|
||||||
|
{
|
||||||
|
m_standardStream = other.m_standardStream;
|
||||||
|
m_colorPolicy = other.m_colorPolicy;
|
||||||
|
|
||||||
|
other.m_colorPolicy = ColorPolicy::Auto;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setColorPolicy(ColorPolicy colorPolicy)
|
||||||
|
{
|
||||||
|
m_colorPolicy = colorPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool supportsColor() const
|
||||||
|
{
|
||||||
|
if (m_colorPolicy == ColorPolicy::Never)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (m_colorPolicy == ColorPolicy::Always)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Autodetect by checking whether output goes to a terminal
|
||||||
|
const auto fileDescriptor =
|
||||||
|
(m_standardStream == utils::StandardStream::Out)
|
||||||
|
? STDOUT_FILENO
|
||||||
|
: STDERR_FILENO;
|
||||||
|
|
||||||
|
return isatty(fileDescriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &ostream()
|
||||||
|
{
|
||||||
|
return (m_standardStream == utils::StandardStream::Out)
|
||||||
|
? std::cout
|
||||||
|
: std::cerr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline LogStream &operator<<(short value);
|
||||||
|
inline LogStream &operator<<(unsigned short value);
|
||||||
|
inline LogStream &operator<<(int value);
|
||||||
|
inline LogStream &operator<<(unsigned int value);
|
||||||
|
inline LogStream &operator<<(long value);
|
||||||
|
inline LogStream &operator<<(unsigned long value);
|
||||||
|
inline LogStream &operator<<(long long value);
|
||||||
|
inline LogStream &operator<<(unsigned long long value);
|
||||||
|
inline LogStream &operator<<(float value);
|
||||||
|
inline LogStream &operator<<(double value);
|
||||||
|
inline LogStream &operator<<(long double value);
|
||||||
|
inline LogStream &operator<<(bool value);
|
||||||
|
inline LogStream &operator<<(const void *value);
|
||||||
|
inline LogStream &operator<<(const char *value);
|
||||||
|
inline LogStream &operator<<(const signed char *value);
|
||||||
|
inline LogStream &operator<<(const unsigned char *value);
|
||||||
|
inline LogStream &operator<<(std::basic_streambuf<CharacterType, TraitsType> *sb);
|
||||||
|
inline LogStream &operator<<(std::ios_base &(*func)(std::ios_base &));
|
||||||
|
inline LogStream &operator<<(std::basic_ios<CharacterType, TraitsType> &(*func)(std::basic_ios<CharacterType, TraitsType> &));
|
||||||
|
inline LogStream &operator<<(std::basic_ostream<CharacterType, TraitsType> &(*func)(std::basic_ostream<CharacterType, TraitsType> &));
|
||||||
|
|
||||||
|
inline LogStream &operator<<(char value);
|
||||||
|
inline LogStream &operator<<(signed char value);
|
||||||
|
inline LogStream &operator<<(unsigned char value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
StandardStream m_standardStream;
|
||||||
|
ColorPolicy m_colorPolicy;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(short value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(unsigned short value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(int value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(unsigned int value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(long value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(unsigned long value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(long long value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(unsigned long long value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(float value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(double value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(long double value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(bool value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(const void *value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(const char *value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(const signed char *value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(const unsigned char *value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(std::basic_streambuf<CharacterType, TraitsType>* sb)
|
||||||
|
{
|
||||||
|
ostream() << sb;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(std::ios_base &(*func)(std::ios_base &))
|
||||||
|
{
|
||||||
|
ostream() << func;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(std::basic_ios<CharacterType, TraitsType> &(*func)(std::basic_ios<CharacterType, TraitsType> &))
|
||||||
|
{
|
||||||
|
ostream() << func;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(std::basic_ostream<CharacterType, TraitsType> &(*func)(std::basic_ostream<CharacterType, TraitsType> &))
|
||||||
|
{
|
||||||
|
ostream() << func;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class CharacterType, class Traits, class Allocator>
|
||||||
|
inline LogStream &operator<<(LogStream &stream, const std::basic_string<CharacterType, Traits, Allocator> &string)
|
||||||
|
{
|
||||||
|
stream.ostream() << string;
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(char value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(signed char value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
LogStream &LogStream::operator<<(unsigned char value)
|
||||||
|
{
|
||||||
|
ostream() << value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
62
include/plasp/utils/Logger.h
Normal file
62
include/plasp/utils/Logger.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
#ifndef __PLASP__UTILS__LOGGER_H
|
||||||
|
#define __PLASP__UTILS__LOGGER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <plasp/utils/LogStream.h>
|
||||||
|
#include <plasp/utils/ParserException.h>
|
||||||
|
#include <plasp/utils/StreamCoordinate.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Logger
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Logger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class WarningLevel
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Error,
|
||||||
|
Ignore
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Logger();
|
||||||
|
|
||||||
|
Logger(const Logger &other);
|
||||||
|
Logger &operator=(const Logger &other);
|
||||||
|
|
||||||
|
Logger(Logger &&other);
|
||||||
|
Logger &operator=(Logger &&other);
|
||||||
|
|
||||||
|
LogStream &outputStream();
|
||||||
|
LogStream &errorStream();
|
||||||
|
|
||||||
|
void setWarningLevel(WarningLevel warningLevel);
|
||||||
|
void setColorPolicy(LogStream::ColorPolicy colorPolicy);
|
||||||
|
|
||||||
|
void logError(const std::string &message);
|
||||||
|
void logError(const StreamCoordinate &coordinate, const std::string &message);
|
||||||
|
void logWarning(const StreamCoordinate &parserCoordinate, const std::string &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
LogStream m_outputStream;
|
||||||
|
LogStream m_errorStream;
|
||||||
|
|
||||||
|
WarningLevel m_warningLevel;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
571
include/plasp/utils/Parser.h
Normal file
571
include/plasp/utils/Parser.h
Normal file
@@ -0,0 +1,571 @@
|
|||||||
|
#ifndef __PLASP__UTILS__PARSER_H
|
||||||
|
#define __PLASP__UTILS__PARSER_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <plasp/utils/ParserException.h>
|
||||||
|
#include <plasp/utils/ParserPolicy.h>
|
||||||
|
#include <plasp/utils/Stream.h>
|
||||||
|
#include <plasp/utils/StreamCoordinate.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
struct Tag
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Parser
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy = CaseSensitiveParserPolicy>
|
||||||
|
class Parser: public Stream, public ParserPolicy
|
||||||
|
{
|
||||||
|
template<class OtherParserPolicy>
|
||||||
|
friend class Parser;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Parser();
|
||||||
|
explicit Parser(std::string streamName, std::istream &istream);
|
||||||
|
|
||||||
|
template<class OtherParser>
|
||||||
|
Parser(OtherParser &&otherParser)
|
||||||
|
{
|
||||||
|
m_stream = std::move(otherParser.m_stream);
|
||||||
|
m_delimiters = std::move(otherParser.m_delimiters);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeComments(const std::string &startSequence, const std::string &endSequence, bool removeEnd);
|
||||||
|
|
||||||
|
char currentCharacter() const;
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
Type parse();
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
bool testAndReturn(const Type &expectedValue);
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
bool testAndSkip(const Type &expectedValue);
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
void expect(const Type &expectedValue);
|
||||||
|
|
||||||
|
std::string parseIdentifier();
|
||||||
|
bool testIdentifierAndReturn(const std::string &identifier);
|
||||||
|
bool testIdentifierAndSkip(const std::string &identifier);
|
||||||
|
|
||||||
|
// TODO: remove
|
||||||
|
bool probeNumber();
|
||||||
|
|
||||||
|
std::string parseLine();
|
||||||
|
|
||||||
|
void skipWhiteSpace();
|
||||||
|
void skipBlankSpace();
|
||||||
|
void skipLine();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string parseImpl(Tag<std::string>);
|
||||||
|
char parseImpl(Tag<char>);
|
||||||
|
uint64_t parseImpl(Tag<uint64_t>);
|
||||||
|
int64_t parseImpl(Tag<int64_t>);
|
||||||
|
uint32_t parseImpl(Tag<uint32_t>);
|
||||||
|
int32_t parseImpl(Tag<int32_t>);
|
||||||
|
bool parseImpl(Tag<bool>);
|
||||||
|
|
||||||
|
bool testImpl(const std::string &expectedValue);
|
||||||
|
bool testImpl(char expectedValue);
|
||||||
|
bool testImpl(uint64_t expectedValue);
|
||||||
|
bool testImpl(int64_t expectedValue);
|
||||||
|
bool testImpl(uint32_t expectedValue);
|
||||||
|
bool testImpl(int32_t expectedValue);
|
||||||
|
bool testImpl(bool expectedValue);
|
||||||
|
|
||||||
|
uint64_t parseIntegerBody();
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
Parser<ParserPolicy>::Parser()
|
||||||
|
: Stream()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
Parser<ParserPolicy>::Parser(std::string streamName, std::istream &istream)
|
||||||
|
: Stream(streamName, istream)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
void Parser<ParserPolicy>::skipWhiteSpace()
|
||||||
|
{
|
||||||
|
check();
|
||||||
|
|
||||||
|
while (!atEnd() && ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
void Parser<ParserPolicy>::skipBlankSpace()
|
||||||
|
{
|
||||||
|
check();
|
||||||
|
|
||||||
|
while (!atEnd() && ParserPolicy::isBlankCharacter(currentCharacter()))
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
void Parser<ParserPolicy>::skipLine()
|
||||||
|
{
|
||||||
|
check();
|
||||||
|
|
||||||
|
while (currentCharacter() != '\n')
|
||||||
|
advance();
|
||||||
|
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
template<typename Type>
|
||||||
|
Type Parser<ParserPolicy>::parse()
|
||||||
|
{
|
||||||
|
return parseImpl(Tag<Type>());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
template<typename Type>
|
||||||
|
bool Parser<ParserPolicy>::testAndReturn(const Type &expectedValue)
|
||||||
|
{
|
||||||
|
const auto previousPosition = position();
|
||||||
|
|
||||||
|
const auto result = testImpl(expectedValue);
|
||||||
|
|
||||||
|
seek(previousPosition);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
template<typename Type>
|
||||||
|
bool Parser<ParserPolicy>::testAndSkip(const Type &expectedValue)
|
||||||
|
{
|
||||||
|
const auto previousPosition = position();
|
||||||
|
|
||||||
|
const auto result = testImpl(expectedValue);
|
||||||
|
|
||||||
|
if (result == false)
|
||||||
|
seek(previousPosition);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
template<typename Type>
|
||||||
|
void Parser<ParserPolicy>::expect(const Type &expectedValue)
|
||||||
|
{
|
||||||
|
if (testAndSkip(expectedValue))
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::stringstream message;
|
||||||
|
message << "unexpected value, expected “" << expectedValue << "”";
|
||||||
|
|
||||||
|
throw ParserException(coordinate(), message.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
std::string Parser<ParserPolicy>::parseIdentifier()
|
||||||
|
{
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
std::string value;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const auto character = currentCharacter();
|
||||||
|
|
||||||
|
if (!ParserPolicy::isIdentifierCharacter(character))
|
||||||
|
return value;
|
||||||
|
|
||||||
|
value.push_back(character);
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testIdentifierAndSkip(const std::string &expectedValue)
|
||||||
|
{
|
||||||
|
return testAndSkip(expectedValue) && !ParserPolicy::isIdentifierCharacter(currentCharacter());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::probeNumber()
|
||||||
|
{
|
||||||
|
const auto previousPosition = position();
|
||||||
|
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
while (!ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
|
||||||
|
if (!std::isdigit(currentCharacter()))
|
||||||
|
{
|
||||||
|
seek(previousPosition);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
std::string Parser<ParserPolicy>::parseLine()
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
const auto character = currentCharacter();
|
||||||
|
advance();
|
||||||
|
|
||||||
|
if (character == '\n')
|
||||||
|
break;
|
||||||
|
else if (character == '\r')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
value.push_back(character);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
void Parser<ParserPolicy>::removeComments(const std::string &startSequence, const std::string &endSequence, bool removeEnd)
|
||||||
|
{
|
||||||
|
const auto inPosition = m_stream.tellg();
|
||||||
|
const auto outPosition = m_stream.tellp();
|
||||||
|
|
||||||
|
m_stream.seekg(0);
|
||||||
|
|
||||||
|
const auto removeRange =
|
||||||
|
[&](const auto &start, const auto &end)
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(start != -1);
|
||||||
|
|
||||||
|
m_stream.clear();
|
||||||
|
m_stream.seekp(start);
|
||||||
|
m_stream.seekg(start);
|
||||||
|
|
||||||
|
auto position = start;
|
||||||
|
|
||||||
|
while (end == -1 || position < end)
|
||||||
|
{
|
||||||
|
m_stream.ignore(1);
|
||||||
|
|
||||||
|
if (atEnd())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_stream.put(' ');
|
||||||
|
position += static_cast<std::streamoff>(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
while (!atEnd())
|
||||||
|
{
|
||||||
|
Position startPosition = m_stream.tellg();
|
||||||
|
|
||||||
|
while (!atEnd())
|
||||||
|
{
|
||||||
|
startPosition = m_stream.tellg();
|
||||||
|
|
||||||
|
if (testAndSkip(startSequence))
|
||||||
|
break;
|
||||||
|
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
Position endPosition = m_stream.tellg();
|
||||||
|
|
||||||
|
while (!atEnd())
|
||||||
|
{
|
||||||
|
endPosition = m_stream.tellg();
|
||||||
|
|
||||||
|
if (testAndSkip(endSequence))
|
||||||
|
break;
|
||||||
|
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removeEnd)
|
||||||
|
endPosition = m_stream.tellg();
|
||||||
|
|
||||||
|
removeRange(startPosition, endPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_stream.clear();
|
||||||
|
|
||||||
|
m_stream.seekg(inPosition);
|
||||||
|
m_stream.seekp(outPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
char Parser<ParserPolicy>::currentCharacter() const
|
||||||
|
{
|
||||||
|
return ParserPolicy::transformCharacter(Stream::currentCharacter());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
std::string Parser<ParserPolicy>::parseImpl(Tag<std::string>)
|
||||||
|
{
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
const auto startPosition = position();
|
||||||
|
|
||||||
|
while (!ParserPolicy::isWhiteSpaceCharacter(currentCharacter()))
|
||||||
|
advance();
|
||||||
|
|
||||||
|
const auto endPosition = position();
|
||||||
|
const auto length = static_cast<size_t>(endPosition - startPosition);
|
||||||
|
|
||||||
|
std::string value;
|
||||||
|
value.reserve(length);
|
||||||
|
|
||||||
|
seek(startPosition);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
value.push_back(currentCharacter());
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
char Parser<ParserPolicy>::parseImpl(Tag<char>)
|
||||||
|
{
|
||||||
|
const auto value = currentCharacter();
|
||||||
|
|
||||||
|
advance();
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
uint64_t Parser<ParserPolicy>::parseIntegerBody()
|
||||||
|
{
|
||||||
|
check();
|
||||||
|
|
||||||
|
if (!std::isdigit(currentCharacter()))
|
||||||
|
throw ParserException(coordinate(), "could not parse integer value");
|
||||||
|
|
||||||
|
uint64_t value = 0;
|
||||||
|
|
||||||
|
while (!atEnd())
|
||||||
|
{
|
||||||
|
const auto character = currentCharacter();
|
||||||
|
|
||||||
|
if (!std::isdigit(character))
|
||||||
|
break;
|
||||||
|
|
||||||
|
value *= 10;
|
||||||
|
value += character - '0';
|
||||||
|
|
||||||
|
advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
int64_t Parser<ParserPolicy>::parseImpl(Tag<int64_t>)
|
||||||
|
{
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
bool positive = testAndSkip<char>('+') || !testAndSkip<char>('-');
|
||||||
|
|
||||||
|
const auto value = parseIntegerBody();
|
||||||
|
|
||||||
|
return (positive ? value : -value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
uint64_t Parser<ParserPolicy>::parseImpl(Tag<uint64_t>)
|
||||||
|
{
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
if (currentCharacter() == '-')
|
||||||
|
throw ParserException(coordinate(), "expected unsigned integer, got signed one");
|
||||||
|
|
||||||
|
return parseIntegerBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
int32_t Parser<ParserPolicy>::parseImpl(Tag<int32_t>)
|
||||||
|
{
|
||||||
|
return static_cast<int32_t>(parseImpl(Tag<int64_t>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
uint32_t Parser<ParserPolicy>::parseImpl(Tag<uint32_t>)
|
||||||
|
{
|
||||||
|
return static_cast<uint32_t>(parseImpl(Tag<uint64_t>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::parseImpl(Tag<bool>)
|
||||||
|
{
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
if (testAndSkip<char>('0'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (testAndSkip<char>('1'))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
throw ParserException(coordinate(), "could not parse Boolean value");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(const std::string &expectedValue)
|
||||||
|
{
|
||||||
|
if (!ParserPolicy::isWhiteSpaceCharacter(expectedValue.front()))
|
||||||
|
skipWhiteSpace();
|
||||||
|
|
||||||
|
const auto match = std::find_if(expectedValue.cbegin(), expectedValue.cend(),
|
||||||
|
[&](const auto &expectedCharacter)
|
||||||
|
{
|
||||||
|
const auto character = static_cast<char>(this->currentCharacter());
|
||||||
|
|
||||||
|
if (character != expectedCharacter)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
this->advance();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (match == expectedValue.cend());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(char expectedValue)
|
||||||
|
{
|
||||||
|
const auto result = (currentCharacter() == expectedValue);
|
||||||
|
|
||||||
|
advance();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(int64_t expectedValue)
|
||||||
|
{
|
||||||
|
const auto value = parseImpl(Tag<int64_t>());
|
||||||
|
|
||||||
|
return (value == expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(uint64_t expectedValue)
|
||||||
|
{
|
||||||
|
const auto value = parseImpl(Tag<uint64_t>());
|
||||||
|
|
||||||
|
return (value == expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(int32_t expectedValue)
|
||||||
|
{
|
||||||
|
return testImpl(static_cast<int64_t>(expectedValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(uint32_t expectedValue)
|
||||||
|
{
|
||||||
|
return testImpl(static_cast<uint64_t>(expectedValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template<class ParserPolicy>
|
||||||
|
bool Parser<ParserPolicy>::testImpl(bool expectedValue)
|
||||||
|
{
|
||||||
|
const auto value = parseImpl(Tag<bool>());
|
||||||
|
|
||||||
|
return (value == expectedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -4,6 +4,8 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <plasp/utils/StreamCoordinate.h>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace utils
|
namespace utils
|
||||||
@@ -18,17 +20,21 @@ namespace utils
|
|||||||
class ParserException: public std::exception
|
class ParserException: public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ParserException()
|
explicit ParserException(const StreamCoordinate &coordinate)
|
||||||
|
: ParserException(coordinate, "unspecified parser error")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit ParserException(const char *message)
|
explicit ParserException(const StreamCoordinate &coordinate, const char *message)
|
||||||
: m_message(message)
|
: ParserException(coordinate, static_cast<std::string>(message))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit ParserException(const std::string &message)
|
explicit ParserException(const StreamCoordinate &coordinate, const std::string &message)
|
||||||
: m_message(message)
|
: m_coordinate{coordinate},
|
||||||
|
m_message{message},
|
||||||
|
m_plainMessage{m_coordinate.sectionName + ":" + std::to_string(m_coordinate.row)
|
||||||
|
+ ":" + std::to_string(m_coordinate.column) + " " + m_message}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,14 +44,23 @@ class ParserException: public std::exception
|
|||||||
|
|
||||||
const char *what() const throw()
|
const char *what() const throw()
|
||||||
{
|
{
|
||||||
if (m_message.empty())
|
return m_plainMessage.c_str();
|
||||||
return "Unspecified error while parsing SAS description file";
|
}
|
||||||
|
|
||||||
return m_message.c_str();
|
const StreamCoordinate &coordinate() const
|
||||||
|
{
|
||||||
|
return m_coordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &message() const
|
||||||
|
{
|
||||||
|
return m_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
StreamCoordinate m_coordinate;
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
|
std::string m_plainMessage;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
72
include/plasp/utils/ParserPolicy.h
Normal file
72
include/plasp/utils/ParserPolicy.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#ifndef __PLASP__UTILS__PARSER_POLICY_H
|
||||||
|
#define __PLASP__UTILS__PARSER_POLICY_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// ParserPolicy
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class CaseSensitiveParserPolicy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr char transformCharacter(char c) noexcept
|
||||||
|
{
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isWhiteSpaceCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::iswspace(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isBlankCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::isblank(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isIdentifierCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::isgraph(c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class CaseInsensitiveParserPolicy
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static char transformCharacter(char c) noexcept
|
||||||
|
{
|
||||||
|
return std::tolower(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isWhiteSpaceCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::iswspace(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isBlankCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::isblank(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isIdentifierCharacter(char c)
|
||||||
|
{
|
||||||
|
return std::isgraph(c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#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
|
|
84
include/plasp/utils/Stream.h
Normal file
84
include/plasp/utils/Stream.h
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
#ifndef __PLASP__UTILS__STREAM_H
|
||||||
|
#define __PLASP__UTILS__STREAM_H
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <plasp/utils/ParserException.h>
|
||||||
|
#include <plasp/utils/StreamCoordinate.h>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Stream
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class Stream
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Position = std::stringstream::pos_type;
|
||||||
|
|
||||||
|
struct Delimiter
|
||||||
|
{
|
||||||
|
Position position;
|
||||||
|
std::string sectionName;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Stream();
|
||||||
|
explicit Stream(std::string streamName, std::istream &istream);
|
||||||
|
|
||||||
|
Stream(const Stream &other) = delete;
|
||||||
|
Stream &operator=(const Stream &other) = delete;
|
||||||
|
|
||||||
|
Stream(Stream &&other)
|
||||||
|
: m_stream{std::move(other.m_stream)},
|
||||||
|
m_delimiters{std::move(other.m_delimiters)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream &operator=(Stream &&other)
|
||||||
|
{
|
||||||
|
m_stream = std::move(other.m_stream);
|
||||||
|
m_delimiters = std::move(other.m_delimiters);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~Stream() = default;
|
||||||
|
|
||||||
|
void read(std::string streamName, std::istream &istream);
|
||||||
|
void read(const boost::filesystem::path &path);
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
void seek(Position position);
|
||||||
|
Position position() const;
|
||||||
|
StreamCoordinate coordinate() const;
|
||||||
|
|
||||||
|
char currentCharacter() const;
|
||||||
|
void advance();
|
||||||
|
bool atEnd() const;
|
||||||
|
|
||||||
|
void check() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
mutable std::stringstream m_stream;
|
||||||
|
|
||||||
|
std::vector<Delimiter> m_delimiters;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
29
include/plasp/utils/StreamCoordinate.h
Normal file
29
include/plasp/utils/StreamCoordinate.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#ifndef __PLASP__UTILS__STREAM_COORDINATE_H
|
||||||
|
#define __PLASP__UTILS__STREAM_COORDINATE_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace plasp
|
||||||
|
{
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// StreamCoordinate
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct StreamCoordinate
|
||||||
|
{
|
||||||
|
std::string sectionName;
|
||||||
|
size_t row;
|
||||||
|
size_t column;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@@ -1,12 +1,12 @@
|
|||||||
#ifndef __PLASP__SAS__TRANSLATOR_EXCEPTION_H
|
#ifndef __PLASP__UTILS__TRANSLATOR_EXCEPTION_H
|
||||||
#define __PLASP__SAS__TRANSLATOR_EXCEPTION_H
|
#define __PLASP__UTILS__TRANSLATOR_EXCEPTION_H
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace plasp
|
namespace plasp
|
||||||
{
|
{
|
||||||
namespace sas
|
namespace utils
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -39,7 +39,7 @@ class TranslatorException: public std::exception
|
|||||||
const char *what() const throw()
|
const char *what() const throw()
|
||||||
{
|
{
|
||||||
if (m_message.empty())
|
if (m_message.empty())
|
||||||
return "Unspecified error while translating SAS description";
|
return "Unspecified error while translating description";
|
||||||
|
|
||||||
return m_message.c_str();
|
return m_message.c_str();
|
||||||
}
|
}
|
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
|
79
instances/PDDL/ipc-2002-driver-log-strips/domain.pddl
Normal file
79
instances/PDDL/ipc-2002-driver-log-strips/domain.pddl
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
(define (domain driverlog)
|
||||||
|
(:requirements :typing)
|
||||||
|
(:types location locatable - object
|
||||||
|
driver truck obj - locatable
|
||||||
|
|
||||||
|
)
|
||||||
|
(:predicates
|
||||||
|
(at ?obj - locatable ?loc - location)
|
||||||
|
(in ?obj1 - obj ?obj - truck)
|
||||||
|
(driving ?d - driver ?v - truck)
|
||||||
|
(link ?x ?y - location) (path ?x ?y - location)
|
||||||
|
(empty ?v - truck)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(:action LOAD-TRUCK
|
||||||
|
:parameters
|
||||||
|
(?obj - obj
|
||||||
|
?truck - truck
|
||||||
|
?loc - location)
|
||||||
|
:precondition
|
||||||
|
(and (at ?truck ?loc) (at ?obj ?loc))
|
||||||
|
:effect
|
||||||
|
(and (not (at ?obj ?loc)) (in ?obj ?truck)))
|
||||||
|
|
||||||
|
(:action UNLOAD-TRUCK
|
||||||
|
:parameters
|
||||||
|
(?obj - obj
|
||||||
|
?truck - truck
|
||||||
|
?loc - location)
|
||||||
|
:precondition
|
||||||
|
(and (at ?truck ?loc) (in ?obj ?truck))
|
||||||
|
:effect
|
||||||
|
(and (not (in ?obj ?truck)) (at ?obj ?loc)))
|
||||||
|
|
||||||
|
(:action BOARD-TRUCK
|
||||||
|
:parameters
|
||||||
|
(?driver - driver
|
||||||
|
?truck - truck
|
||||||
|
?loc - location)
|
||||||
|
:precondition
|
||||||
|
(and (at ?truck ?loc) (at ?driver ?loc) (empty ?truck))
|
||||||
|
:effect
|
||||||
|
(and (not (at ?driver ?loc)) (driving ?driver ?truck) (not (empty ?truck))))
|
||||||
|
|
||||||
|
(:action DISEMBARK-TRUCK
|
||||||
|
:parameters
|
||||||
|
(?driver - driver
|
||||||
|
?truck - truck
|
||||||
|
?loc - location)
|
||||||
|
:precondition
|
||||||
|
(and (at ?truck ?loc) (driving ?driver ?truck))
|
||||||
|
:effect
|
||||||
|
(and (not (driving ?driver ?truck)) (at ?driver ?loc) (empty ?truck)))
|
||||||
|
|
||||||
|
(:action DRIVE-TRUCK
|
||||||
|
:parameters
|
||||||
|
(?truck - truck
|
||||||
|
?loc-from - location
|
||||||
|
?loc-to - location
|
||||||
|
?driver - driver)
|
||||||
|
:precondition
|
||||||
|
(and (at ?truck ?loc-from)
|
||||||
|
(driving ?driver ?truck) (link ?loc-from ?loc-to))
|
||||||
|
:effect
|
||||||
|
(and (not (at ?truck ?loc-from)) (at ?truck ?loc-to)))
|
||||||
|
|
||||||
|
(:action WALK
|
||||||
|
:parameters
|
||||||
|
(?driver - driver
|
||||||
|
?loc-from - location
|
||||||
|
?loc-to - location)
|
||||||
|
:precondition
|
||||||
|
(and (at ?driver ?loc-from) (path ?loc-from ?loc-to))
|
||||||
|
:effect
|
||||||
|
(and (not (at ?driver ?loc-from)) (at ?driver ?loc-to)))
|
||||||
|
|
||||||
|
|
||||||
|
)
|
48
instances/PDDL/ipc-2002-driver-log-strips/problem-01.pddl
Normal file
48
instances/PDDL/ipc-2002-driver-log-strips/problem-01.pddl
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
(define (problem DLOG-2-2-2)
|
||||||
|
(:domain driverlog)
|
||||||
|
(:objects
|
||||||
|
driver1 - driver
|
||||||
|
driver2 - driver
|
||||||
|
truck1 - truck
|
||||||
|
truck2 - truck
|
||||||
|
package1 - obj
|
||||||
|
package2 - obj
|
||||||
|
s0 - location
|
||||||
|
s1 - location
|
||||||
|
s2 - location
|
||||||
|
p1-0 - location
|
||||||
|
p1-2 - location
|
||||||
|
)
|
||||||
|
(:init
|
||||||
|
(at driver1 s2)
|
||||||
|
(at driver2 s2)
|
||||||
|
(at truck1 s0)
|
||||||
|
(empty truck1)
|
||||||
|
(at truck2 s0)
|
||||||
|
(empty truck2)
|
||||||
|
(at package1 s0)
|
||||||
|
(at package2 s0)
|
||||||
|
(path s1 p1-0)
|
||||||
|
(path p1-0 s1)
|
||||||
|
(path s0 p1-0)
|
||||||
|
(path p1-0 s0)
|
||||||
|
(path s1 p1-2)
|
||||||
|
(path p1-2 s1)
|
||||||
|
(path s2 p1-2)
|
||||||
|
(path p1-2 s2)
|
||||||
|
(link s0 s1)
|
||||||
|
(link s1 s0)
|
||||||
|
(link s0 s2)
|
||||||
|
(link s2 s0)
|
||||||
|
(link s2 s1)
|
||||||
|
(link s1 s2)
|
||||||
|
)
|
||||||
|
(:goal (and
|
||||||
|
(at driver1 s1)
|
||||||
|
(at truck1 s1)
|
||||||
|
(at package1 s0)
|
||||||
|
(at package2 s0)
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
)
|
59
instances/PDDL/ipc-2002-driver-log-strips/problem-03.pddl
Normal file
59
instances/PDDL/ipc-2002-driver-log-strips/problem-03.pddl
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
(define (problem DLOG-2-2-4)
|
||||||
|
(:domain driverlog)
|
||||||
|
(:objects
|
||||||
|
driver1 - driver
|
||||||
|
driver2 - driver
|
||||||
|
truck1 - truck
|
||||||
|
truck2 - truck
|
||||||
|
package1 - obj
|
||||||
|
package2 - obj
|
||||||
|
package3 - obj
|
||||||
|
package4 - obj
|
||||||
|
s0 - location
|
||||||
|
s1 - location
|
||||||
|
s2 - location
|
||||||
|
p0-1 - location
|
||||||
|
p2-0 - location
|
||||||
|
p2-1 - location
|
||||||
|
)
|
||||||
|
(:init
|
||||||
|
(at driver1 s1)
|
||||||
|
(at driver2 s0)
|
||||||
|
(at truck1 s1)
|
||||||
|
(empty truck1)
|
||||||
|
(at truck2 s2)
|
||||||
|
(empty truck2)
|
||||||
|
(at package1 s0)
|
||||||
|
(at package2 s0)
|
||||||
|
(at package3 s1)
|
||||||
|
(at package4 s1)
|
||||||
|
(path s0 p0-1)
|
||||||
|
(path p0-1 s0)
|
||||||
|
(path s1 p0-1)
|
||||||
|
(path p0-1 s1)
|
||||||
|
(path s2 p2-0)
|
||||||
|
(path p2-0 s2)
|
||||||
|
(path s0 p2-0)
|
||||||
|
(path p2-0 s0)
|
||||||
|
(path s2 p2-1)
|
||||||
|
(path p2-1 s2)
|
||||||
|
(path s1 p2-1)
|
||||||
|
(path p2-1 s1)
|
||||||
|
(link s1 s0)
|
||||||
|
(link s0 s1)
|
||||||
|
(link s1 s2)
|
||||||
|
(link s2 s1)
|
||||||
|
(link s2 s0)
|
||||||
|
(link s0 s2)
|
||||||
|
)
|
||||||
|
(:goal (and
|
||||||
|
(at driver2 s2)
|
||||||
|
(at truck1 s1)
|
||||||
|
(at truck2 s2)
|
||||||
|
(at package1 s1)
|
||||||
|
(at package2 s1)
|
||||||
|
(at package3 s2)
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
)
|
4
instances/PDDL/ipc-2002-driver-log-strips/solutions
Normal file
4
instances/PDDL/ipc-2002-driver-log-strips/solutions
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
instance | minimal horizon | #solutions with minimal horizon
|
||||||
|
============================================================
|
||||||
|
problem-01.pddl | 7 | 1
|
||||||
|
problem-03.pddl | 12 | 1056
|
75
instances/PDDL/ipc-2004-satellite/domain.pddl
Normal file
75
instances/PDDL/ipc-2004-satellite/domain.pddl
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
|
||||||
|
(define (domain satellite)
|
||||||
|
(:requirements :strips :equality :typing)
|
||||||
|
(:types satellite direction instrument mode)
|
||||||
|
(:predicates
|
||||||
|
(on_board ?i - instrument ?s - satellite)
|
||||||
|
(supports ?i - instrument ?m - mode)
|
||||||
|
(pointing ?s - satellite ?d - direction)
|
||||||
|
(power_avail ?s - satellite)
|
||||||
|
(power_on ?i - instrument)
|
||||||
|
(calibrated ?i - instrument)
|
||||||
|
(have_image ?d - direction ?m - mode)
|
||||||
|
(calibration_target ?i - instrument ?d - direction))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(:action turn_to
|
||||||
|
:parameters (?s - satellite ?d_new - direction ?d_prev - direction)
|
||||||
|
:precondition (and (pointing ?s ?d_prev)
|
||||||
|
)
|
||||||
|
:effect (and (pointing ?s ?d_new)
|
||||||
|
(not (pointing ?s ?d_prev))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(:action switch_on
|
||||||
|
:parameters (?i - instrument ?s - satellite)
|
||||||
|
|
||||||
|
:precondition (and (on_board ?i ?s)
|
||||||
|
(power_avail ?s)
|
||||||
|
)
|
||||||
|
:effect (and (power_on ?i)
|
||||||
|
(not (calibrated ?i))
|
||||||
|
(not (power_avail ?s))
|
||||||
|
)
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(:action switch_off
|
||||||
|
:parameters (?i - instrument ?s - satellite)
|
||||||
|
|
||||||
|
:precondition (and (on_board ?i ?s)
|
||||||
|
(power_on ?i)
|
||||||
|
)
|
||||||
|
:effect (and (not (power_on ?i))
|
||||||
|
(power_avail ?s)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(:action calibrate
|
||||||
|
:parameters (?s - satellite ?i - instrument ?d - direction)
|
||||||
|
:precondition (and (on_board ?i ?s)
|
||||||
|
(calibration_target ?i ?d)
|
||||||
|
(pointing ?s ?d)
|
||||||
|
(power_on ?i)
|
||||||
|
)
|
||||||
|
:effect (calibrated ?i)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
(:action take_image
|
||||||
|
:parameters (?s - satellite ?d - direction ?i - instrument ?m - mode)
|
||||||
|
:precondition (and (calibrated ?i)
|
||||||
|
(on_board ?i ?s)
|
||||||
|
(supports ?i ?m)
|
||||||
|
(power_on ?i)
|
||||||
|
(pointing ?s ?d)
|
||||||
|
(power_on ?i)
|
||||||
|
)
|
||||||
|
:effect (have_image ?d ?m)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
30
instances/PDDL/ipc-2004-satellite/problem-01.pddl
Normal file
30
instances/PDDL/ipc-2004-satellite/problem-01.pddl
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
(define (problem strips-sat-x-1)
|
||||||
|
(:domain satellite)
|
||||||
|
(:objects
|
||||||
|
satellite0 - satellite
|
||||||
|
instrument0 - instrument
|
||||||
|
image1 - mode
|
||||||
|
spectrograph2 - mode
|
||||||
|
thermograph0 - mode
|
||||||
|
Star0 - direction
|
||||||
|
GroundStation1 - direction
|
||||||
|
GroundStation2 - direction
|
||||||
|
Phenomenon3 - direction
|
||||||
|
Phenomenon4 - direction
|
||||||
|
Star5 - direction
|
||||||
|
Phenomenon6 - direction
|
||||||
|
)
|
||||||
|
(:init
|
||||||
|
(supports instrument0 thermograph0)
|
||||||
|
(calibration_target instrument0 GroundStation2)
|
||||||
|
(on_board instrument0 satellite0)
|
||||||
|
(power_avail satellite0)
|
||||||
|
(pointing satellite0 Phenomenon6)
|
||||||
|
)
|
||||||
|
(:goal (and
|
||||||
|
(have_image Phenomenon4 thermograph0)
|
||||||
|
(have_image Star5 thermograph0)
|
||||||
|
(have_image Phenomenon6 thermograph0)
|
||||||
|
))
|
||||||
|
|
||||||
|
)
|
40
instances/PDDL/ipc-2004-satellite/problem-02.pddl
Normal file
40
instances/PDDL/ipc-2004-satellite/problem-02.pddl
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
(define (problem strips-sat-x-1)
|
||||||
|
(:domain satellite)
|
||||||
|
(:objects
|
||||||
|
satellite0 - satellite
|
||||||
|
instrument0 - instrument
|
||||||
|
instrument1 - instrument
|
||||||
|
infrared0 - mode
|
||||||
|
infrared1 - mode
|
||||||
|
image2 - mode
|
||||||
|
GroundStation1 - direction
|
||||||
|
Star0 - direction
|
||||||
|
GroundStation2 - direction
|
||||||
|
Planet3 - direction
|
||||||
|
Planet4 - direction
|
||||||
|
Phenomenon5 - direction
|
||||||
|
Phenomenon6 - direction
|
||||||
|
Star7 - direction
|
||||||
|
)
|
||||||
|
(:init
|
||||||
|
(supports instrument0 infrared1)
|
||||||
|
(supports instrument0 infrared0)
|
||||||
|
(calibration_target instrument0 Star0)
|
||||||
|
(supports instrument1 image2)
|
||||||
|
(supports instrument1 infrared1)
|
||||||
|
(supports instrument1 infrared0)
|
||||||
|
(calibration_target instrument1 GroundStation2)
|
||||||
|
(on_board instrument0 satellite0)
|
||||||
|
(on_board instrument1 satellite0)
|
||||||
|
(power_avail satellite0)
|
||||||
|
(pointing satellite0 Planet4)
|
||||||
|
)
|
||||||
|
(:goal (and
|
||||||
|
(have_image Planet3 infrared0)
|
||||||
|
(have_image Planet4 infrared0)
|
||||||
|
(have_image Phenomenon5 image2)
|
||||||
|
(have_image Phenomenon6 infrared0)
|
||||||
|
(have_image Star7 infrared0)
|
||||||
|
))
|
||||||
|
|
||||||
|
)
|
52
instances/PDDL/ipc-2004-satellite/problem-03.pddl
Normal file
52
instances/PDDL/ipc-2004-satellite/problem-03.pddl
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
(define (problem strips-sat-x-1)
|
||||||
|
(:domain satellite)
|
||||||
|
(:objects
|
||||||
|
satellite0 - satellite
|
||||||
|
instrument0 - instrument
|
||||||
|
instrument1 - instrument
|
||||||
|
instrument2 - instrument
|
||||||
|
satellite1 - satellite
|
||||||
|
instrument3 - instrument
|
||||||
|
image1 - mode
|
||||||
|
infrared0 - mode
|
||||||
|
spectrograph2 - mode
|
||||||
|
Star1 - direction
|
||||||
|
Star2 - direction
|
||||||
|
Star0 - direction
|
||||||
|
Star3 - direction
|
||||||
|
Star4 - direction
|
||||||
|
Phenomenon5 - direction
|
||||||
|
Phenomenon6 - direction
|
||||||
|
Phenomenon7 - direction
|
||||||
|
)
|
||||||
|
(:init
|
||||||
|
(supports instrument0 spectrograph2)
|
||||||
|
(supports instrument0 infrared0)
|
||||||
|
(calibration_target instrument0 Star1)
|
||||||
|
(supports instrument1 image1)
|
||||||
|
(calibration_target instrument1 Star2)
|
||||||
|
(supports instrument2 infrared0)
|
||||||
|
(supports instrument2 image1)
|
||||||
|
(calibration_target instrument2 Star0)
|
||||||
|
(on_board instrument0 satellite0)
|
||||||
|
(on_board instrument1 satellite0)
|
||||||
|
(on_board instrument2 satellite0)
|
||||||
|
(power_avail satellite0)
|
||||||
|
(pointing satellite0 Star4)
|
||||||
|
(supports instrument3 spectrograph2)
|
||||||
|
(supports instrument3 infrared0)
|
||||||
|
(supports instrument3 image1)
|
||||||
|
(calibration_target instrument3 Star0)
|
||||||
|
(on_board instrument3 satellite1)
|
||||||
|
(power_avail satellite1)
|
||||||
|
(pointing satellite1 Star0)
|
||||||
|
)
|
||||||
|
(:goal (and
|
||||||
|
(pointing satellite0 Phenomenon5)
|
||||||
|
(have_image Star3 infrared0)
|
||||||
|
(have_image Star4 spectrograph2)
|
||||||
|
(have_image Phenomenon5 spectrograph2)
|
||||||
|
(have_image Phenomenon7 spectrograph2)
|
||||||
|
))
|
||||||
|
|
||||||
|
)
|
5
instances/PDDL/ipc-2004-satellite/solutions
Normal file
5
instances/PDDL/ipc-2004-satellite/solutions
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
instance | minimal horizon | #solutions with minimal horizon
|
||||||
|
============================================================
|
||||||
|
problem-01.pddl | 9 | 12
|
||||||
|
problem-02.pddl | 13 | 240
|
||||||
|
problem-03.pddl | 11 | 276
|
65
instances/PDDL/ipc-2006-tpp-propositional/domain.pddl
Normal file
65
instances/PDDL/ipc-2006-tpp-propositional/domain.pddl
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
; IPC5 Domain: TPP Propositional
|
||||||
|
; Authors: Alfonso Gerevini and Alessandro Saetti
|
||||||
|
|
||||||
|
(define (domain TPP-Propositional)
|
||||||
|
(:requirements :strips :typing)
|
||||||
|
(:types place locatable level - object
|
||||||
|
depot market - place
|
||||||
|
truck goods - locatable)
|
||||||
|
|
||||||
|
(:predicates (loaded ?g - goods ?t - truck ?l - level)
|
||||||
|
(ready-to-load ?g - goods ?m - market ?l - level)
|
||||||
|
(stored ?g - goods ?l - level)
|
||||||
|
(on-sale ?g - goods ?m - market ?l - level)
|
||||||
|
(next ?l1 ?l2 - level)
|
||||||
|
(at ?t - truck ?p - place)
|
||||||
|
(connected ?p1 ?p2 - place))
|
||||||
|
|
||||||
|
(:action drive
|
||||||
|
:parameters (?t - truck ?from ?to - place)
|
||||||
|
:precondition (and (at ?t ?from) (connected ?from ?to))
|
||||||
|
:effect (and (not (at ?t ?from)) (at ?t ?to)))
|
||||||
|
|
||||||
|
|
||||||
|
; ### LOAD ###
|
||||||
|
; ?l1 is the level of ?g ready to be loaded at ?m before loading
|
||||||
|
; ?l2 is the level of ?g ready to be loaded at ?m after loading
|
||||||
|
; ?l3 is the level of ?g in ?t before loading
|
||||||
|
; ?l4 is the level of ?g in ?t after loading
|
||||||
|
|
||||||
|
(:action load
|
||||||
|
:parameters (?g - goods ?t - truck ?m - market ?l1 ?l2 ?l3 ?l4 - level)
|
||||||
|
:precondition (and (at ?t ?m) (loaded ?g ?t ?l3)
|
||||||
|
(ready-to-load ?g ?m ?l2) (next ?l2 ?l1) (next ?l4 ?l3))
|
||||||
|
:effect (and (loaded ?g ?t ?l4) (not (loaded ?g ?t ?l3))
|
||||||
|
(ready-to-load ?g ?m ?l1) (not (ready-to-load ?g ?m ?l2))))
|
||||||
|
|
||||||
|
|
||||||
|
; ### UNLOAD ###
|
||||||
|
; ?l1 is the level of ?g in ?t before unloading
|
||||||
|
; ?l2 is the level of ?g in ?t after unloading
|
||||||
|
; ?l3 is the level of ?g in ?d before unloading
|
||||||
|
; ?l4 is the level of ?g in ?d after unloading
|
||||||
|
|
||||||
|
(:action unload
|
||||||
|
:parameters (?g - goods ?t - truck ?d - depot ?l1 ?l2 ?l3 ?l4 - level)
|
||||||
|
:precondition (and (at ?t ?d) (loaded ?g ?t ?l2)
|
||||||
|
(stored ?g ?l3) (next ?l2 ?l1) (next ?l4 ?l3))
|
||||||
|
:effect (and (loaded ?g ?t ?l1) (not (loaded ?g ?t ?l2))
|
||||||
|
(stored ?g ?l4) (not (stored ?g ?l3))))
|
||||||
|
|
||||||
|
|
||||||
|
; ### BUY ###
|
||||||
|
; ?l1 is the level of ?g on sale at ?m before buying
|
||||||
|
; ?l2 is the level of ?g on sale at ?m after buying
|
||||||
|
; ?l3 is the level of ?g ready to be loaded at ?m before buying
|
||||||
|
; ?l4 is the level of ?g ready to be loaded at ?m after buying
|
||||||
|
|
||||||
|
(:action buy
|
||||||
|
:parameters (?t - truck ?g - goods ?m - market ?l1 ?l2 ?l3 ?l4 - level)
|
||||||
|
:precondition (and (at ?t ?m) (on-sale ?g ?m ?l2) (ready-to-load ?g ?m ?l3)
|
||||||
|
(next ?l2 ?l1) (next ?l4 ?l3))
|
||||||
|
:effect (and (on-sale ?g ?m ?l1) (not (on-sale ?g ?m ?l2))
|
||||||
|
(ready-to-load ?g ?m ?l4) (not (ready-to-load ?g ?m ?l3))))
|
||||||
|
|
||||||
|
)
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user