Added translation of objects in PDDL problems.
This commit is contained in:
parent
e018cdbc91
commit
d3dc9101dd
@ -33,6 +33,7 @@ class TranslatorASP
|
|||||||
void translateActions() const;
|
void translateActions() const;
|
||||||
|
|
||||||
void translateProblem() const;
|
void translateProblem() const;
|
||||||
|
void translateObjects() const;
|
||||||
|
|
||||||
void translateVariablesHead(const expressions::Variables &variables) const;
|
void translateVariablesHead(const expressions::Variables &variables) const;
|
||||||
void translateVariablesBody(const expressions::Variables &variables) const;
|
void translateVariablesBody(const expressions::Variables &variables) const;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <plasp/pddl/TranslatorASP.h>
|
#include <plasp/pddl/TranslatorASP.h>
|
||||||
|
|
||||||
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
#include <plasp/pddl/expressions/And.h>
|
#include <plasp/pddl/expressions/And.h>
|
||||||
#include <plasp/pddl/expressions/Not.h>
|
#include <plasp/pddl/expressions/Not.h>
|
||||||
#include <plasp/pddl/expressions/Predicate.h>
|
#include <plasp/pddl/expressions/Predicate.h>
|
||||||
@ -451,6 +453,41 @@ void TranslatorASP::translateProblem() const
|
|||||||
<< "%---------------------------------------" << std::endl
|
<< "%---------------------------------------" << std::endl
|
||||||
<< "% problem" << std::endl
|
<< "% problem" << std::endl
|
||||||
<< "%---------------------------------------" << 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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Reference in New Issue
Block a user