patrick
/
plasp
Archived
1
0
Fork 0

Added action costs support for SAS translator output.

This commit is contained in:
Patrick Lühne 2016-05-23 16:57:12 +02:00
parent c90d5b1d72
commit a5fd698888
2 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,8 @@
#include <incmode>.
% Check feature requirements
:- requiresFeature(actionCosts, true).
#program base.
% Establish initial state

View File

@ -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;