From 44a20ca7e3159af728828cd24929ad5293b1aaaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:25:24 +0200 Subject: [PATCH 1/8] Updated usage information in the readme file. --- README.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d17114a..5e6fcef 100644 --- a/README.md +++ b/README.md @@ -6,36 +6,45 @@ `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 now 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 ``` ## 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 From 401cf79cf6a85b2811743ab2fca456f358beb068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:28:45 +0200 Subject: [PATCH 2/8] Fixed incorrect usage information in help message. --- apps/plasp-app/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/plasp-app/main.cpp b/apps/plasp-app/main.cpp index dd43531..384da37 100644 --- a/apps/plasp-app/main.cpp +++ b/apps/plasp-app/main.cpp @@ -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; From b491efa9f454fd350879e27433f9581b39efdda2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:30:06 +0200 Subject: [PATCH 3/8] Minor rephrasing. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5e6fcef..2f3a966 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ $ plasp output.sas ### Solving the Translated Instance -The translated instance can now be solved incrementally with `clingo` and a meta encoding, for instance, `pddl-meta-sequential-incremental.lp`: +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 From fcdd3bba2bcd38b7389378df0b0060b50d2fd808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:40:40 +0200 Subject: [PATCH 4/8] Added command-line options to readme file. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 2f3a966..b139a91 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,21 @@ $ 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 or clang ≥ 3.8), the `boost` libraries (≥ 1.55), and CMake for building. From 52fee6a4c1f5464141abafbba49f759b434fcbfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:42:29 +0200 Subject: [PATCH 5/8] Made the language command-line option lowercase for consistency. --- README.md | 2 +- apps/plasp-app/main.cpp | 2 +- src/plasp/Language.cpp | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b139a91..4a2fe07 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ The `[options]` are listed below: | **option** | **explanation** | |-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------| -| `-l` [ `--language` ] | Specify the input language (`SAS` or `PDDL`). Omit for automatic detection. | +| `-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`). | diff --git a/apps/plasp-app/main.cpp b/apps/plasp-app/main.cpp index 384da37..7bacfae 100644 --- a/apps/plasp-app/main.cpp +++ b/apps/plasp-app/main.cpp @@ -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>(), "Specify the PDDL or SAS input file.") - ("language,l", po::value(), "Specify the input language (SAS or PDDL). Omit for automatic detection.") + ("language,l", po::value(), "Specify the input language (sas or pddl). Omit for automatic detection.") ("warning-level", po::value()->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()->default_value("auto"), "Specify whether to colorize the output (always, never, or auto)."); diff --git a/src/plasp/Language.cpp b/src/plasp/Language.cpp index c23924e..6caaeb0 100644 --- a/src/plasp/Language.cpp +++ b/src/plasp/Language.cpp @@ -17,9 +17,9 @@ using LanguageNames = boost::bimap; //////////////////////////////////////////////////////////////////////////////////////////////////// const LanguageNames languageNames = boost::assign::list_of - (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; } From 0a205680fe84ecb218585fa047588c2c263dc7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:46:47 +0200 Subject: [PATCH 6/8] Made default color policy autodetection again. --- include/plasp/utils/LogStream.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/plasp/utils/LogStream.h b/include/plasp/utils/LogStream.h index e086b6d..87760f3 100644 --- a/include/plasp/utils/LogStream.h +++ b/include/plasp/utils/LogStream.h @@ -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; } From 853d7471c2736a1804f05f193215c43645037b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:47:02 +0200 Subject: [PATCH 7/8] Added error message when using command-line options incorrectly. --- apps/plasp-app/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/apps/plasp-app/main.cpp b/apps/plasp-app/main.cpp index 7bacfae..dc9c2c5 100644 --- a/apps/plasp-app/main.cpp +++ b/apps/plasp-app/main.cpp @@ -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(); @@ -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 { From 3d661cd1f4f863abb0d64729b6216507eb3bb063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 14 Jun 2016 18:53:40 +0200 Subject: [PATCH 8/8] Fixed unescaped ASP identifier. --- src/plasp/pddl/TranslatorASP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plasp/pddl/TranslatorASP.cpp b/src/plasp/pddl/TranslatorASP.cpp index 4ee5c70..ee2eb69 100644 --- a/src/plasp/pddl/TranslatorASP.cpp +++ b/src/plasp/pddl/TranslatorASP.cpp @@ -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 {