2016-06-10 17:40:32 +02:00
|
|
|
#include <plasp/pddl/TranslatorASP.h>
|
|
|
|
|
2016-06-13 02:48:16 +02:00
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
#include <colorlog/Formatting.h>
|
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
#include <pddlparse/NormalizedAST.h>
|
2017-06-20 01:53:55 +02:00
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
#include <plasp/TranslatorException.h>
|
2017-06-20 01:53:55 +02:00
|
|
|
|
|
|
|
#include <plasp/pddl/translation/Effect.h>
|
|
|
|
#include <plasp/pddl/translation/Goal.h>
|
2016-12-08 00:52:09 +01:00
|
|
|
#include <plasp/pddl/translation/Precondition.h>
|
2016-12-08 01:27:38 +01:00
|
|
|
#include <plasp/pddl/translation/Predicate.h>
|
2016-12-08 00:52:09 +01:00
|
|
|
#include <plasp/pddl/translation/Primitives.h>
|
2016-12-08 01:05:39 +01:00
|
|
|
#include <plasp/pddl/translation/Variables.h>
|
2016-06-10 17:40:32 +02:00
|
|
|
|
|
|
|
namespace plasp
|
|
|
|
{
|
|
|
|
namespace pddl
|
|
|
|
{
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// TranslatorASP
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
TranslatorASP::TranslatorASP(const ::pddl::normalizedAST::Description &description, colorlog::ColorStream &outputStream)
|
2017-06-20 01:53:55 +02:00
|
|
|
: m_description{description},
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream(outputStream)
|
2016-06-10 17:40:32 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-12 22:31:18 +02:00
|
|
|
void TranslatorASP::translate() const
|
2016-06-10 17:40:32 +02:00
|
|
|
{
|
2016-06-12 22:31:18 +02:00
|
|
|
translateDomain();
|
2016-06-10 17:40:32 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
if (m_description.problem)
|
2016-06-12 22:25:12 +02:00
|
|
|
{
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-12 22:31:18 +02:00
|
|
|
translateProblem();
|
2016-06-12 22:25:12 +02:00
|
|
|
}
|
2016-06-10 17:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-12 22:31:18 +02:00
|
|
|
void TranslatorASP::translateDomain() const
|
2016-06-10 17:40:32 +02:00
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading1("domain");
|
2016-06-10 17:40:32 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &domain = m_description.domain;
|
2016-06-10 17:40:32 +02:00
|
|
|
|
|
|
|
// Types
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-14 13:53:09 +02:00
|
|
|
translateTypes();
|
2016-06-10 17:52:19 +02:00
|
|
|
|
|
|
|
// Constants
|
2017-06-20 01:53:55 +02:00
|
|
|
if (!domain->constants.empty())
|
2016-06-12 22:19:24 +02:00
|
|
|
{
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2017-06-20 01:53:55 +02:00
|
|
|
translateConstants("constants", domain->constants);
|
2016-06-12 22:19:24 +02:00
|
|
|
}
|
2016-06-12 22:25:12 +02:00
|
|
|
|
|
|
|
// Predicates
|
2017-06-20 01:53:55 +02:00
|
|
|
if (!domain->predicates.empty())
|
2016-06-12 22:25:12 +02:00
|
|
|
{
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-12 22:39:04 +02:00
|
|
|
translatePredicates();
|
|
|
|
}
|
2016-06-12 22:47:39 +02:00
|
|
|
|
|
|
|
// Actions
|
2017-06-20 01:53:55 +02:00
|
|
|
if (!domain->actions.empty())
|
2016-06-12 22:47:39 +02:00
|
|
|
{
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-12 22:47:39 +02:00
|
|
|
translateActions();
|
|
|
|
}
|
2016-06-12 22:39:04 +02:00
|
|
|
}
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-06-12 22:39:04 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-06-12 22:39:04 +02:00
|
|
|
void TranslatorASP::translateTypes() const
|
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2("types");
|
2016-06-14 16:38:41 +02:00
|
|
|
|
|
|
|
m_outputStream << std::endl;
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &types = m_description.domain->types;
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-06-14 13:53:09 +02:00
|
|
|
if (types.empty())
|
|
|
|
{
|
2016-08-13 02:32:27 +02:00
|
|
|
m_outputStream
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("type") << "("
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::String("object") << "))." << std::endl;
|
2016-08-13 02:32:27 +02:00
|
|
|
|
2016-06-14 13:53:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-08 01:05:39 +01:00
|
|
|
for (const auto &type : types)
|
|
|
|
{
|
|
|
|
m_outputStream
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("type") << "("
|
|
|
|
<< colorlog::Keyword("type") << "("
|
2017-06-20 01:53:55 +02:00
|
|
|
<< *type
|
2016-12-08 01:05:39 +01:00
|
|
|
<< "))." << std::endl;
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &parentTypes = type->parentTypes;
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-12-08 01:05:39 +01:00
|
|
|
std::for_each(parentTypes.cbegin(), parentTypes.cend(),
|
|
|
|
[&](const auto &parentType)
|
|
|
|
{
|
|
|
|
m_outputStream
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("inherits") << "(" << colorlog::Keyword("type")
|
|
|
|
<< "(" << *type << "), " << colorlog::Keyword("type")
|
2017-06-20 01:53:55 +02:00
|
|
|
<< "(" << *parentType << "))." << std::endl;
|
2016-12-08 01:05:39 +01:00
|
|
|
});
|
|
|
|
}
|
2016-08-16 18:35:55 +02:00
|
|
|
|
|
|
|
m_outputStream
|
|
|
|
<< std::endl
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("has") << "("
|
|
|
|
<< colorlog::Variable("X") << ", "
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T2") << ")) :- "
|
|
|
|
<< colorlog::Function("has") << "("
|
|
|
|
<< colorlog::Variable("X") << ", "
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T1") << ")), "
|
|
|
|
<< colorlog::Function("inherits") << "("
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T1") << "), "
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::Variable("T2") << "))."
|
2016-08-16 18:35:55 +02:00
|
|
|
<< std::endl;
|
2016-06-12 22:39:04 +02:00
|
|
|
}
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-06-12 22:39:04 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-06-12 22:25:12 +02:00
|
|
|
|
2016-06-12 22:39:04 +02:00
|
|
|
void TranslatorASP::translatePredicates() const
|
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2("variables");
|
2016-06-12 22:39:04 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &predicates = m_description.domain->predicates;
|
2016-06-12 22:39:04 +02:00
|
|
|
|
2016-12-08 01:05:39 +01:00
|
|
|
for (const auto &predicate : predicates)
|
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << std::endl << colorlog::Function("variable") << "(";
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
translatePredicateDeclaration(m_outputStream, *predicate);
|
2016-08-13 02:48:30 +02:00
|
|
|
|
2016-12-08 01:27:38 +01:00
|
|
|
m_outputStream << ")";
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
translateVariablesForRuleBody(m_outputStream, predicate->parameters);
|
2016-12-07 01:56:06 +01:00
|
|
|
|
2016-12-08 01:05:39 +01:00
|
|
|
m_outputStream << ".";
|
|
|
|
}
|
2016-12-07 01:56:06 +01:00
|
|
|
|
|
|
|
m_outputStream
|
|
|
|
<< std::endl << std::endl
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("boolean") << "(" << colorlog::Boolean("true") << ")." << std::endl
|
|
|
|
<< colorlog::Function("boolean") << "(" << colorlog::Boolean("false") << ")." << std::endl
|
2016-12-07 01:56:06 +01:00
|
|
|
<< std::endl
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("contains") << "("
|
|
|
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
|
|
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Variable("B") << ")) :- "
|
|
|
|
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
|
|
|
|
<< colorlog::Function("boolean") << "(" << colorlog::Variable("B") << ")."
|
2016-12-07 01:56:06 +01:00
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-12 22:47:39 +02:00
|
|
|
void TranslatorASP::translateActions() const
|
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2("actions");
|
2016-06-12 22:47:39 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &actions = m_description.domain->actions;
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
for (const auto &action : actions)
|
|
|
|
{
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto printActionName =
|
|
|
|
[&]()
|
2016-12-07 02:11:54 +01:00
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Keyword("action") << "(";
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
if (action->parameters.empty())
|
|
|
|
{
|
|
|
|
m_outputStream << *action << ")";
|
|
|
|
return;
|
|
|
|
}
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
m_outputStream << "(" << *action;
|
|
|
|
translateVariablesForRuleHead(m_outputStream, action->parameters);
|
|
|
|
m_outputStream << "))";
|
2016-12-07 02:11:54 +01:00
|
|
|
};
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
m_outputStream << std::endl;
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
// Name
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Function("action") << "(";
|
2017-06-20 01:53:55 +02:00
|
|
|
printActionName();
|
2016-12-07 02:11:54 +01:00
|
|
|
m_outputStream << ")";
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
translateVariablesForRuleBody(m_outputStream, action->parameters);
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
m_outputStream << ".";
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
// Precondition
|
2017-06-20 01:53:55 +02:00
|
|
|
if (action->precondition)
|
|
|
|
translatePrecondition(m_outputStream, action->precondition.value(), "action", printActionName);
|
2016-06-13 02:38:56 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
if (action->effect)
|
|
|
|
translateEffect(m_outputStream, action->effect.value(), "action", printActionName);
|
2016-12-07 02:11:54 +01:00
|
|
|
|
|
|
|
m_outputStream << std::endl;
|
|
|
|
}
|
2016-06-12 22:55:35 +02:00
|
|
|
}
|
2016-06-12 22:47:39 +02:00
|
|
|
|
2016-06-12 22:55:35 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-06-12 22:47:39 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
void TranslatorASP::translateConstants(const std::string &heading, const ::pddl::normalizedAST::ConstantDeclarations &constants) const
|
2016-06-14 13:21:41 +02:00
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2(heading.c_str());
|
2016-06-14 13:21:41 +02:00
|
|
|
|
2016-12-08 01:05:39 +01:00
|
|
|
for (const auto &constant : constants)
|
2016-06-12 22:55:35 +02:00
|
|
|
{
|
2016-12-08 01:05:39 +01:00
|
|
|
m_outputStream << std::endl
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("constant") << "("
|
|
|
|
<< colorlog::Keyword("constant") << "("
|
2017-06-20 01:53:55 +02:00
|
|
|
<< *constant
|
2016-12-08 01:05:39 +01:00
|
|
|
<< "))." << std::endl;
|
2016-06-14 13:21:41 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &type = constant->type;
|
2016-06-12 22:55:35 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
if (type)
|
2016-06-13 16:37:35 +02:00
|
|
|
{
|
2017-06-23 04:18:07 +02:00
|
|
|
if (!type.value().is<::pddl::normalizedAST::PrimitiveTypePointer>())
|
2017-06-22 20:58:31 +02:00
|
|
|
throw TranslatorException("only primitive types supported currently");
|
2017-06-20 01:53:55 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto &primitveType = type.value().get<::pddl::normalizedAST::PrimitiveTypePointer>();
|
2017-06-20 01:53:55 +02:00
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Function("has") << "("
|
|
|
|
<< colorlog::Keyword("constant") << "(" << *constant << "), "
|
|
|
|
<< colorlog::Keyword("type") << "(" << *primitveType << "))." << std::endl;
|
2016-06-13 16:37:35 +02:00
|
|
|
}
|
2016-06-14 13:21:41 +02:00
|
|
|
else
|
2016-06-14 16:38:41 +02:00
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Function("has") << "("
|
|
|
|
<< colorlog::Keyword("constant") << "(" << *constant << "), "
|
|
|
|
<< colorlog::Keyword("type") << "(" << colorlog::String("object") << "))." << std::endl;
|
2016-06-14 16:38:41 +02:00
|
|
|
}
|
2016-06-12 22:55:35 +02:00
|
|
|
}
|
2016-06-10 17:40:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-12 22:31:18 +02:00
|
|
|
void TranslatorASP::translateProblem() const
|
2016-06-10 17:40:32 +02:00
|
|
|
{
|
2017-06-20 01:53:55 +02:00
|
|
|
assert(m_description.problem);
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading1("problem");
|
2016-06-13 02:48:16 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &problem = m_description.problem.value();
|
2016-06-13 02:48:16 +02:00
|
|
|
|
|
|
|
// Objects
|
2017-06-20 01:53:55 +02:00
|
|
|
if (!problem->objects.empty())
|
2016-06-13 02:48:16 +02:00
|
|
|
{
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2017-06-20 01:53:55 +02:00
|
|
|
translateConstants("objects", problem->objects);
|
2016-06-13 02:48:16 +02:00
|
|
|
}
|
2016-06-13 02:59:43 +02:00
|
|
|
|
|
|
|
// Initial State
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-13 02:59:43 +02:00
|
|
|
translateInitialState();
|
2016-06-13 03:19:24 +02:00
|
|
|
|
|
|
|
// Goal
|
2017-06-20 01:53:55 +02:00
|
|
|
if (problem->goal)
|
|
|
|
{
|
|
|
|
m_outputStream << std::endl;
|
|
|
|
translateGoal();
|
|
|
|
}
|
2016-06-13 02:48:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-13 02:59:43 +02:00
|
|
|
void TranslatorASP::translateInitialState() const
|
|
|
|
{
|
2017-06-20 01:53:55 +02:00
|
|
|
assert(m_description.problem);
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2("initial state");
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &facts = m_description.problem.value()->initialState.facts;
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2017-06-23 03:30:27 +02:00
|
|
|
// TODO: move to separate header
|
2017-06-20 01:53:55 +02:00
|
|
|
for (const auto &fact : facts)
|
2016-12-07 02:11:54 +01:00
|
|
|
{
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << std::endl << colorlog::Function("initialState") << "(";
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handlePredicate =
|
|
|
|
[&](const ::pddl::normalizedAST::PredicatePointer &predicate, bool isPositive = true)
|
2017-06-23 03:30:27 +02:00
|
|
|
{
|
2017-06-23 04:18:07 +02:00
|
|
|
translatePredicateToVariable(m_outputStream, *predicate, isPositive);
|
2017-06-23 03:30:27 +02:00
|
|
|
};
|
2016-08-13 03:22:25 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handleNegatedPredicate =
|
|
|
|
[&](const ::pddl::normalizedAST::PredicatePointer &predicate)
|
2017-06-23 03:30:27 +02:00
|
|
|
{
|
2017-06-23 04:18:07 +02:00
|
|
|
return handlePredicate(predicate, false);
|
|
|
|
};
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handleDerivedPredicate =
|
|
|
|
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &, bool = true)
|
|
|
|
{
|
|
|
|
// TODO: implement
|
|
|
|
//translatePredicateToVariable(m_outputStream, *predicate, true);
|
|
|
|
};
|
2017-06-20 01:53:55 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handleNegatedDerivedPredicate =
|
|
|
|
[&](const ::pddl::normalizedAST::DerivedPredicatePointer &derivedPredicate)
|
|
|
|
{
|
|
|
|
return handleDerivedPredicate(derivedPredicate, false);
|
2017-06-23 03:30:27 +02:00
|
|
|
};
|
2017-06-20 01:53:55 +02:00
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handleAtomicFormula =
|
|
|
|
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
2017-06-23 03:30:27 +02:00
|
|
|
{
|
2017-06-23 04:18:07 +02:00
|
|
|
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
2017-06-23 03:30:27 +02:00
|
|
|
};
|
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
const auto handleNot =
|
|
|
|
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
2017-06-23 03:30:27 +02:00
|
|
|
{
|
2017-06-23 04:18:07 +02:00
|
|
|
not_->argument.match(handleNegatedPredicate, handleNegatedDerivedPredicate);
|
2017-06-23 03:30:27 +02:00
|
|
|
};
|
|
|
|
|
2017-06-23 04:18:07 +02:00
|
|
|
fact.match(handleAtomicFormula, handleNot);
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2016-12-07 02:11:54 +01:00
|
|
|
m_outputStream << ").";
|
|
|
|
}
|
2016-06-13 02:59:43 +02:00
|
|
|
|
2016-08-17 19:02:51 +02:00
|
|
|
m_outputStream
|
|
|
|
<< std::endl << std::endl
|
2017-06-22 20:58:31 +02:00
|
|
|
<< colorlog::Function("initialState") << "("
|
|
|
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
|
|
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("false") << ")) :- "
|
|
|
|
<< colorlog::Function("variable") << "(" << colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << ")), "
|
|
|
|
<< colorlog::Keyword("not") << " "
|
|
|
|
<< colorlog::Function("initialState") << "("
|
|
|
|
<< colorlog::Keyword("variable") << "(" << colorlog::Variable("X") << "), "
|
|
|
|
<< colorlog::Keyword("value") << "(" << colorlog::Variable("X") << ", " << colorlog::Boolean("true") << "))."
|
2016-08-17 19:02:51 +02:00
|
|
|
<< std::endl;
|
2016-06-13 02:59:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-13 03:19:24 +02:00
|
|
|
void TranslatorASP::translateGoal() const
|
|
|
|
{
|
2017-06-20 01:53:55 +02:00
|
|
|
assert(m_description.problem);
|
|
|
|
assert(m_description.problem.value()->goal);
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2017-06-22 20:58:31 +02:00
|
|
|
m_outputStream << colorlog::Heading2("goal");
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2017-06-20 01:53:55 +02:00
|
|
|
const auto &goal = m_description.problem.value()->goal.value();
|
|
|
|
// TODO: refactor
|
|
|
|
::plasp::pddl::translateGoal(m_outputStream, goal);
|
2016-06-13 03:19:24 +02:00
|
|
|
|
2016-06-14 16:14:39 +02:00
|
|
|
m_outputStream << std::endl;
|
2016-06-13 03:19:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-10 17:40:32 +02:00
|
|
|
}
|
|
|
|
}
|