Made form of variables within values consistent.

Previously, variables referenced within values were unpacked within
values. This was inconsistent, because all predicates are usually used
in their unpacked form in the rest of the output format. This commit
makes this consistent by using variables in their packed form within
values, making it more compact to handle them.
This commit is contained in:
Patrick Lühne 2017-11-03 01:49:24 +01:00
parent 3a7b61de68
commit b21b4f47bf
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
3 changed files with 26 additions and 11 deletions

View File

@ -25,6 +25,7 @@ void translateDerivedPredicateDeclaration(colorlog::ColorStream &outputStream, c
////////////////////////////////////////////////////////////////////////////////////////////////////
// TODO: avoid code duplication with translatePredicate
inline void translateDerivedPredicate(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate)
{
const auto &arguments = derivedPredicate.arguments;
@ -81,10 +82,17 @@ inline void translateDerivedPredicateDeclaration(colorlog::ColorStream &outputSt
inline void translateDerivedPredicateToVariable(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::DerivedPredicate &derivedPredicate, bool isPositive = true)
{
outputStream << colorlog::Keyword("derivedVariable") << "(";
translateDerivedPredicate(outputStream, derivedPredicate);
outputStream << "), " << colorlog::Keyword("value") << "(";
outputStream
<< "), "
<< colorlog::Keyword("value") << "("
<< colorlog::Keyword("derivedVariable") << "(";
translateDerivedPredicate(outputStream, derivedPredicate);
outputStream << ", ";
outputStream << "), ";
if (isPositive)
outputStream << colorlog::Boolean("true");

View File

@ -81,10 +81,17 @@ inline void translatePredicateDeclaration(colorlog::ColorStream &outputStream, c
void translatePredicateToVariable(colorlog::ColorStream &outputStream, const ::pddl::normalizedAST::Predicate &predicate, bool isPositive = true)
{
outputStream << colorlog::Keyword("variable") << "(";
translatePredicate(outputStream, predicate);
outputStream << "), " << colorlog::Keyword("value") << "(";
outputStream
<< "), "
<< colorlog::Keyword("value") << "("
<< colorlog::Keyword("variable") << "(";
translatePredicate(outputStream, predicate);
outputStream << ", ";
outputStream << "), ";
if (isPositive)
outputStream << colorlog::Boolean("true");

View File

@ -186,9 +186,9 @@ void TranslatorASP::translatePredicates() const
m_outputStream
<< std::endl << std::endl
<< colorlog::Function("contains") << "("
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Variable("X") << ", "
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Variable("B") << ")) :- "
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
<< colorlog::Function("variable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Function("boolean") << "(" << colorlog::Variable("B") << ")."
<< std::endl;
}
@ -218,9 +218,9 @@ void TranslatorASP::translateDerivedPredicates(const ::pddl::normalizedAST::Deri
m_outputStream
<< std::endl << std::endl
<< colorlog::Function("contains") << "("
<< colorlog::Keyword("derivedVariable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Variable("X") << ", "
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Variable("B") << ")) :- "
<< colorlog::Function("derivedVariable") << "(" << colorlog::Keyword("derivedVariable") << "(" << colorlog::Variable("X") << ")), "
<< colorlog::Function("derivedVariable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Function("boolean") << "(" << colorlog::Variable("B") << ")."
<< std::endl;
@ -443,12 +443,12 @@ void TranslatorASP::translateInitialState() const
m_outputStream
<< std::endl << std::endl
<< colorlog::Function("initialState") << "("
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Variable("X") << ", "
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("false") << ")) :- "
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
<< colorlog::Function("variable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Keyword("not") << " "
<< colorlog::Function("initialState") << "("
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
<< colorlog::Variable("X") << ", "
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("true") << "))."
<< std::endl;
}