From a5fd6988883cb3222b935a6a07dde2232c4662b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 23 May 2016 16:57:12 +0200 Subject: [PATCH] Added action costs support for SAS translator output. --- encodings/meta-sequential-incremental.lp | 3 +++ src/plasp/sas/TranslatorASP.cpp | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/encodings/meta-sequential-incremental.lp b/encodings/meta-sequential-incremental.lp index be12e91..915af63 100644 --- a/encodings/meta-sequential-incremental.lp +++ b/encodings/meta-sequential-incremental.lp @@ -1,5 +1,8 @@ #include . +% Check feature requirements +:- requiresFeature(actionCosts, true). + #program base. % Establish initial state diff --git a/src/plasp/sas/TranslatorASP.cpp b/src/plasp/sas/TranslatorASP.cpp index 1313ec7..9066ef9 100644 --- a/src/plasp/sas/TranslatorASP.cpp +++ b/src/plasp/sas/TranslatorASP.cpp @@ -23,9 +23,6 @@ TranslatorASP::TranslatorASP(const Description &description) void TranslatorASP::checkSupport() const { - if (m_description.usesActionCosts()) - throw TranslatorException("Action costs are currently unsupported"); - const auto &variables = m_description.variables(); std::for_each(variables.cbegin(), variables.cend(), @@ -48,9 +45,6 @@ void TranslatorASP::checkSupport() const if (!effect.conditions().empty()) throw TranslatorException("Conditional effects are currently unsupported"); }); - - if (operator_.costs() != 1) - throw TranslatorException("Action costs are currently unsupported"); }); if (!m_description.axiomRules().empty()) @@ -63,6 +57,12 @@ void TranslatorASP::translate(std::ostream &ostream) const { checkSupport(); + ostream << "% feature requirements" << std::endl; + + if (m_description.usesActionCosts()) + ostream << "requiresFeature(actionCosts)." << std::endl; + + ostream << std::endl; ostream << "% initial state" << std::endl; const auto &initialStateFacts = m_description.initialState().facts(); @@ -175,6 +175,10 @@ void TranslatorASP::translate(std::ostream &ostream) const effect.postcondition().value().printAsASPPredicate(ostream); ostream << ")." << std::endl; }); + + ostream << "costs("; + operator_.printPredicateAsASP(ostream); + ostream << ", " << operator_.costs() << ")." << std::endl; }); ostream << std::endl;