Fixed issue with unsupported expression negations.

This commit is contained in:
Patrick Lühne 2016-08-16 18:58:30 +02:00
parent 69a26cb22f
commit 91019f52aa
4 changed files with 59 additions and 4 deletions

View File

@ -12,6 +12,7 @@ Features:
Bug Fixes: Bug Fixes:
* fixes minor formatting issues in SAS translation * fixes minor formatting issues in SAS translation
* fixes issue with unsupported expression negations
## 3.0.1 (2016-06-14) ## 3.0.1 (2016-06-14)

View File

@ -412,7 +412,7 @@ void TranslatorASP::translateLiteral(const Expression &literal) const
{ {
const auto &notExpression = dynamic_cast<const expressions::Not &>(literal); const auto &notExpression = dynamic_cast<const expressions::Not &>(literal);
if (notExpression.expressionType() != Expression::Type::Predicate) if (notExpression.argument()->expressionType() != Expression::Type::Predicate)
throw utils::TranslatorException("only negations of primitive predicates supported as literals currently"); throw utils::TranslatorException("only negations of primitive predicates supported as literals currently");
const auto &predicate = dynamic_cast<const expressions::Predicate &>(*notExpression.argument()); const auto &predicate = dynamic_cast<const expressions::Predicate &>(*notExpression.argument());

View File

@ -15,7 +15,16 @@ boost::iostreams::stream<boost::iostreams::null_sink> nullStream((boost::iostrea
TEST(PDDLTranslationTests, CheckIssues) TEST(PDDLTranslationTests, CheckIssues)
{ {
// Check that translating domains without typing information works // Check that translating domains without typing information works
auto description = Description::fromFile("data/issues/issue-4.pddl"); {
const auto translator = TranslatorASP(description, description.context().logger.outputStream()); auto description = Description::fromFile("data/issues/issue-4.pddl");
ASSERT_NO_THROW(translator.translate()); const auto translator = TranslatorASP(description, description.context().logger.outputStream());
ASSERT_NO_THROW(translator.translate());
}
// Check that translating the simple blocks world domain works
{
auto description = Description::fromFile("data/issues/issue-5.pddl");
const auto translator = TranslatorASP(description, description.context().logger.outputStream());
ASSERT_NO_THROW(translator.translate());
}
} }

View File

@ -0,0 +1,45 @@
(define (domain BLOCKS)
(:requirements :strips :typing)
(:types block)
(:predicates (on ?x - block ?y - block)
(ontable ?x - block)
(clear ?x - block)
(handempty)
(holding ?x - block)
)
(:action pick-up
:parameters (?x - block)
:precondition (and (clear ?x) (ontable ?x) (handempty))
:effect
(and (not (ontable ?x))
(not (clear ?x))
(not (handempty))
(holding ?x)))
(:action put-down
:parameters (?x - block)
:precondition (holding ?x)
:effect
(and (not (holding ?x))
(clear ?x)
(handempty)
(ontable ?x)))
(:action stack
:parameters (?x - block ?y - block)
:precondition (and (holding ?x) (clear ?y))
:effect
(and (not (holding ?x))
(not (clear ?y))
(clear ?x)
(handempty)
(on ?x ?y)))
(:action unstack
:parameters (?x - block ?y - block)
:precondition (and (on ?x ?y) (clear ?x) (handempty))
:effect
(and (holding ?x)
(clear ?y)
(not (clear ?x))
(not (handempty))
(not (on ?x ?y)))))