patrick
/
plasp
Archived
1
0
Fork 0

Merge branch 'develop' of github.com:potassco/plasp

This commit is contained in:
Patrick Lühne 2016-06-14 18:54:43 +02:00
commit 8084fe5574
5 changed files with 61 additions and 21 deletions

View File

@ -6,36 +6,60 @@
`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` 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. 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 example, 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 instance.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, `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 ## 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 ```bash
$ git clone https://github.com/potassco/plasp.git $ git clone https://github.com/potassco/plasp.git

View File

@ -21,7 +21,7 @@ int main(int argc, char **argv)
("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::vector<std::string>>(), "Specify the PDDL or 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.") ("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).") ("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)."); ("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 = 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;
@ -76,6 +76,15 @@ int main(int argc, char **argv)
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Error); logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Error);
else if (warningLevel == "ignore") else if (warningLevel == "ignore")
logger.setWarningLevel(plasp::utils::Logger::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>(); 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); logger.setColorPolicy(plasp::utils::LogStream::ColorPolicy::Never);
else if (colorPolicy == "always") else if (colorPolicy == "always")
logger.setColorPolicy(plasp::utils::LogStream::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 try
{ {

View File

@ -40,13 +40,13 @@ class LogStream
public: public:
LogStream(StandardStream standardStream) LogStream(StandardStream standardStream)
: m_standardStream{standardStream}, : m_standardStream{standardStream},
m_colorPolicy{ColorPolicy::Never} m_colorPolicy{ColorPolicy::Auto}
{ {
} }
LogStream(const LogStream &other) LogStream(const LogStream &other)
: m_standardStream{other.m_standardStream}, : 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_standardStream{other.m_standardStream},
m_colorPolicy{other.m_colorPolicy} m_colorPolicy{other.m_colorPolicy}
{ {
other.m_colorPolicy = ColorPolicy::Never; other.m_colorPolicy = ColorPolicy::Auto;
} }
LogStream &operator=(LogStream &&other) LogStream &operator=(LogStream &&other)
@ -70,7 +70,7 @@ class LogStream
m_standardStream = other.m_standardStream; m_standardStream = other.m_standardStream;
m_colorPolicy = other.m_colorPolicy; m_colorPolicy = other.m_colorPolicy;
other.m_colorPolicy = ColorPolicy::Never; other.m_colorPolicy = ColorPolicy::Auto;
return *this; return *this;
} }

View File

@ -17,9 +17,9 @@ using LanguageNames = boost::bimap<Language::Type, std::string>;
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation> const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation>
(Language::Type::PDDL, "PDDL") (Language::Type::PDDL, "pddl")
(Language::Type::SAS, "SAS") (Language::Type::SAS, "sas")
(Language::Type::Unknown, "Unknown"); (Language::Type::Unknown, "unknown");
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
@ -28,7 +28,7 @@ std::string Language::toString(Language::Type language)
const auto match = languageNames.left.find(language); const auto match = languageNames.left.find(language);
if (match == languageNames.left.end()) if (match == languageNames.left.end())
return "Unknown"; return "unknown";
return match->second; return match->second;
} }

View File

@ -325,7 +325,7 @@ void TranslatorASP::translateVariablesBody(const expressions::Variables &variabl
m_outputStream << utils::Keyword("hasType") << "(" m_outputStream << utils::Keyword("hasType") << "("
<< utils::Variable(utils::escapeASPVariable(variable.name())) << ", " << utils::Variable(utils::escapeASPVariable(variable.name())) << ", "
<< utils::Keyword("type") << "(" << type.name() << "))"; << utils::Keyword("type") << "(" << utils::escapeASP(type.name()) << "))";
} }
else else
{ {