Merge branch 'develop' of github.com:potassco/plasp
This commit is contained in:
commit
8084fe5574
44
README.md
44
README.md
@ -6,36 +6,60 @@
|
||||
|
||||
`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` 3 translates planning problem instances to ASP facts.
|
||||
`plasp` 3 supports the input languages [PDDL](https://helios.hud.ac.uk/scommv/IPC-14/software.html) (only basic features currently) and the [SAS](http://www.fast-downward.org/TranslatorOutputFormat) (full support of the current version 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.
|
||||
|
||||
## 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
|
||||
$ plasp file.sas
|
||||
$ plasp domain.pddl problem.pddl
|
||||
```
|
||||
|
||||
For example, a PDDL instance can be solved as follows.
|
||||
First, use [Fast Downward](http://www.fast-downward.org/) to translate the files from PDDL to SAS:
|
||||
Alternatively, PDDL instances may first be translated to SAS, the output format of [Fast Downward](http://www.fast-downward.org/).
|
||||
|
||||
```bash
|
||||
$ ./fast-downward.py --translate --build=release64 domain.pddl instance.pddl
|
||||
```
|
||||
|
||||
This creates the file `output.sas`.
|
||||
The translated SAS instance can now be solved incrementally with `clingo` and the meta encoding `meta-sequential-incremental.lp`:
|
||||
This creates a file called `output.sas`, which may now be translated by `plasp`.
|
||||
|
||||
```bash
|
||||
$ plasp output.sas > instance.lp
|
||||
$ clingo encodings/meta-sequential-incremental.lp instance.lp
|
||||
$ plasp output.sas
|
||||
```
|
||||
|
||||
### Solving the Translated Instance
|
||||
|
||||
The translated instance can finally be solved incrementally with `clingo` and a meta encoding, for instance, `pddl-meta-sequential-incremental.lp`:
|
||||
|
||||
```bash
|
||||
$ plasp domain.pddl problem.pddl > instance.lp
|
||||
$ clingo encodings/pddl-meta-sequential-incremental.lp instance.lp
|
||||
```
|
||||
|
||||
### Command-Line Interface
|
||||
|
||||
```bash
|
||||
$ plasp [files] [options]
|
||||
```
|
||||
|
||||
`[files]` may be omitted, in which case the input is read from `std::cin`.
|
||||
The `[options]` are listed below:
|
||||
|
||||
| **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`). |
|
||||
|
||||
## Building
|
||||
|
||||
`plasp` requires a C++14 compiler (preferrably GCC ≥ 6.1), the `boost` libraries (≥ 1.55), and CMake for building.
|
||||
`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
|
||||
|
@ -21,7 +21,7 @@ int main(int argc, char **argv)
|
||||
("help,h", "Display this help message.")
|
||||
("version,v", "Display version information.")
|
||||
("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.")
|
||||
("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).");
|
||||
|
||||
@ -33,7 +33,7 @@ int main(int argc, char **argv)
|
||||
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 << description;
|
||||
@ -76,6 +76,15 @@ int main(int argc, char **argv)
|
||||
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
|
||||
{
|
||||
logger.logError("unknown warning level “" + warningLevel + "”");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const auto colorPolicy = variablesMap["color"].as<std::string>();
|
||||
|
||||
@ -85,6 +94,13 @@ int main(int argc, char **argv)
|
||||
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();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -40,13 +40,13 @@ class LogStream
|
||||
public:
|
||||
LogStream(StandardStream standardStream)
|
||||
: m_standardStream{standardStream},
|
||||
m_colorPolicy{ColorPolicy::Never}
|
||||
m_colorPolicy{ColorPolicy::Auto}
|
||||
{
|
||||
}
|
||||
|
||||
LogStream(const LogStream &other)
|
||||
: m_standardStream{other.m_standardStream},
|
||||
m_colorPolicy{ColorPolicy::Never}
|
||||
m_colorPolicy{ColorPolicy::Auto}
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class LogStream
|
||||
: m_standardStream{other.m_standardStream},
|
||||
m_colorPolicy{other.m_colorPolicy}
|
||||
{
|
||||
other.m_colorPolicy = ColorPolicy::Never;
|
||||
other.m_colorPolicy = ColorPolicy::Auto;
|
||||
}
|
||||
|
||||
LogStream &operator=(LogStream &&other)
|
||||
@ -70,7 +70,7 @@ class LogStream
|
||||
m_standardStream = other.m_standardStream;
|
||||
m_colorPolicy = other.m_colorPolicy;
|
||||
|
||||
other.m_colorPolicy = ColorPolicy::Never;
|
||||
other.m_colorPolicy = ColorPolicy::Auto;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ using LanguageNames = boost::bimap<Language::Type, std::string>;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation>
|
||||
(Language::Type::PDDL, "PDDL")
|
||||
(Language::Type::SAS, "SAS")
|
||||
(Language::Type::Unknown, "Unknown");
|
||||
(Language::Type::PDDL, "pddl")
|
||||
(Language::Type::SAS, "sas")
|
||||
(Language::Type::Unknown, "unknown");
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -28,7 +28,7 @@ std::string Language::toString(Language::Type language)
|
||||
const auto match = languageNames.left.find(language);
|
||||
|
||||
if (match == languageNames.left.end())
|
||||
return "Unknown";
|
||||
return "unknown";
|
||||
|
||||
return match->second;
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ void TranslatorASP::translateVariablesBody(const expressions::Variables &variabl
|
||||
|
||||
m_outputStream << utils::Keyword("hasType") << "("
|
||||
<< utils::Variable(utils::escapeASPVariable(variable.name())) << ", "
|
||||
<< utils::Keyword("type") << "(" << type.name() << "))";
|
||||
<< utils::Keyword("type") << "(" << utils::escapeASP(type.name()) << "))";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user