patrick
/
plasp
Archived
1
0
Fork 0

Checking whether variables have types before accessing them in the PDDL translator.

This commit is contained in:
Patrick Lühne 2016-06-13 16:37:35 +02:00
parent 2b55d156ae
commit da85e5dd9b
2 changed files with 24 additions and 2 deletions

View File

@ -40,6 +40,9 @@ void TranslatorASP::checkSupport() const
std::for_each(arguments.cbegin(), arguments.cend(),
[&](const auto &parameter)
{
if (parameter->type() == nullptr)
return;
if (parameter->type()->expressionType() != Expression::Type::PrimitiveType)
throw utils::TranslatorException("Only primitive types supported currently");
});
@ -56,6 +59,9 @@ void TranslatorASP::checkSupport() const
std::for_each(parameters.cbegin(), parameters.cend(),
[&](const auto &parameter)
{
if (parameter->type() == nullptr)
return;
if (parameter->type()->expressionType() != Expression::Type::PrimitiveType)
throw utils::TranslatorException("Only primitive types supported currently");
});
@ -391,9 +397,14 @@ void TranslatorASP::translateVariablesBody(const expressions::Variables &variabl
m_ostream << ", ";
const auto &variable = *dynamic_cast<const expressions::Variable *>(i->get());
const auto &type = *dynamic_cast<const expressions::PrimitiveType *>(variable.type());
m_ostream << "hasType(" << utils::escapeASPVariable(variable.name()) << ", type(" << type.name() << "))";
if (variable.type() != nullptr)
{
const auto &type = *dynamic_cast<const expressions::PrimitiveType *>(variable.type());
m_ostream << "hasType(" << utils::escapeASPVariable(variable.name()) << ", type(" << type.name() << "))";
}
// TODO: handle untyped variables
}
}

View File

@ -0,0 +1,11 @@
(define (domain tsp)
(:requirements :negative-preconditions)
(:predicates
(at ?x)
(visited ?x)
(connected ?x ?y))
(:action move
:parameters (?x ?y)
:precondition (and (at ?x) (not (visited ?y)) (connected ?x ?y))
:effect (and (at ?y) (visited ?y) (not (at ?x)))))