diff --git a/include/plasp/pddl/TranslatorASP.h b/include/plasp/pddl/TranslatorASP.h index 534732a..a8b2037 100644 --- a/include/plasp/pddl/TranslatorASP.h +++ b/include/plasp/pddl/TranslatorASP.h @@ -33,6 +33,7 @@ class TranslatorASP void translateActions() const; void translateProblem() const; + void translateObjects() const; void translateVariablesHead(const expressions::Variables &variables) const; void translateVariablesBody(const expressions::Variables &variables) const; diff --git a/src/plasp/pddl/TranslatorASP.cpp b/src/plasp/pddl/TranslatorASP.cpp index 3d609a0..f6cc81d 100644 --- a/src/plasp/pddl/TranslatorASP.cpp +++ b/src/plasp/pddl/TranslatorASP.cpp @@ -1,5 +1,7 @@ #include +#include + #include #include #include @@ -451,6 +453,41 @@ void TranslatorASP::translateProblem() const << "%---------------------------------------" << std::endl << "% problem" << std::endl << "%---------------------------------------" << std::endl; + + BOOST_ASSERT(m_description.containsProblem()); + + const auto &problem = m_description.problem(); + + // Objects + if (!problem.objects().empty()) + { + m_ostream << std::endl; + translateObjects(); + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////// + +void TranslatorASP::translateObjects() const +{ + m_ostream << "% objects"; + + const auto &objects = m_description.problem().objects(); + + std::for_each(objects.cbegin(), objects.cend(), + [&](const auto &object) + { + m_ostream << std::endl; + + m_ostream << "object(" << object->name() << ")." << std::endl; + + const auto *type = object->type(); + + if (type == nullptr) + return; + + m_ostream << "hasType(object(" << object->name() << "), type(" << type->name() << "))." << std::endl; + }); } ////////////////////////////////////////////////////////////////////////////////////////////////////