diff --git a/CHANGELOG.md b/CHANGELOG.md index 16b7248..ef8fb8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Features: Bug Fixes: * fixes minor formatting issues in SAS translation +* fixes issue with unsupported expression negations ## 3.0.1 (2016-06-14) diff --git a/src/plasp/pddl/TranslatorASP.cpp b/src/plasp/pddl/TranslatorASP.cpp index f84c2ac..aa46027 100644 --- a/src/plasp/pddl/TranslatorASP.cpp +++ b/src/plasp/pddl/TranslatorASP.cpp @@ -412,7 +412,7 @@ void TranslatorASP::translateLiteral(const Expression &literal) const { const auto ¬Expression = dynamic_cast(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"); const auto &predicate = dynamic_cast(*notExpression.argument()); diff --git a/tests/TestPDDLTranslation.cpp b/tests/TestPDDLTranslation.cpp index 71b8adb..f698174 100644 --- a/tests/TestPDDLTranslation.cpp +++ b/tests/TestPDDLTranslation.cpp @@ -15,7 +15,16 @@ boost::iostreams::stream nullStream((boost::iostrea TEST(PDDLTranslationTests, CheckIssues) { // 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()); - ASSERT_NO_THROW(translator.translate()); + { + auto description = Description::fromFile("data/issues/issue-4.pddl"); + 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()); + } } diff --git a/tests/data/issues/issue-5.pddl b/tests/data/issues/issue-5.pddl new file mode 100644 index 0000000..8b51e13 --- /dev/null +++ b/tests/data/issues/issue-5.pddl @@ -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)))))