Changed effects in normalized PDDL effects according to recent changes.
This commit is contained in:
parent
0beab67bd4
commit
da85683f7c
|
@ -45,6 +45,29 @@ inline void translateEffect(colorlog::ColorStream &outputStream, const ::pddl::n
|
||||||
throw TranslatorException("derived predicates not yet supported by translator");
|
throw TranslatorException("derived predicates not yet supported by translator");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const auto handleAtomicFormula =
|
||||||
|
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
||||||
|
{
|
||||||
|
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto handleNot =
|
||||||
|
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::AtomicFormula> ¬_)
|
||||||
|
{
|
||||||
|
if (!not_->argument.is<::pddl::normalizedAST::PredicatePointer>())
|
||||||
|
throw TranslatorException("only “and” expressions and (negated) predicates supported as action effects currently");
|
||||||
|
|
||||||
|
const auto &predicate = not_->argument.get<::pddl::normalizedAST::PredicatePointer>();
|
||||||
|
|
||||||
|
handlePredicate(predicate, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto handleLiteral =
|
||||||
|
[&](const ::pddl::normalizedAST::Literal &literal)
|
||||||
|
{
|
||||||
|
literal.match(handleAtomicFormula, handleNot);
|
||||||
|
};
|
||||||
|
|
||||||
const auto handleAnd =
|
const auto handleAnd =
|
||||||
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Effect> &and_)
|
[&](const ::pddl::normalizedAST::AndPointer<::pddl::normalizedAST::Effect> &and_)
|
||||||
{
|
{
|
||||||
|
@ -52,36 +75,19 @@ inline void translateEffect(colorlog::ColorStream &outputStream, const ::pddl::n
|
||||||
translateEffect(outputStream, argument, objectType, printObjectName);
|
translateEffect(outputStream, argument, objectType, printObjectName);
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handleAtomicFormula =
|
|
||||||
[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
|
|
||||||
{
|
|
||||||
atomicFormula.match(handlePredicate, handleDerivedPredicate);
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto handleForAll =
|
const auto handleForAll =
|
||||||
[&](const ::pddl::normalizedAST::ForAllPointer<::pddl::normalizedAST::Effect> &)
|
[&](const ::pddl::normalizedAST::ForAllPointer<::pddl::normalizedAST::Effect> &)
|
||||||
{
|
{
|
||||||
throw TranslatorException("“when” expressions not yet supported by translator");
|
throw TranslatorException("“when” expressions not yet supported by translator");
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto handleNot =
|
|
||||||
[&](const ::pddl::normalizedAST::NotPointer<::pddl::normalizedAST::Effect> ¬_)
|
|
||||||
{
|
|
||||||
if (!not_->argument.is<::pddl::normalizedAST::AtomicFormula>() || !not_->argument.get<::pddl::normalizedAST::AtomicFormula>().is<::pddl::normalizedAST::PredicatePointer>())
|
|
||||||
throw TranslatorException("only “and” expressions and (negated) predicates supported as action effects currently");
|
|
||||||
|
|
||||||
const auto &predicate = not_->argument.get<::pddl::normalizedAST::AtomicFormula>().get<::pddl::normalizedAST::PredicatePointer>();
|
|
||||||
|
|
||||||
handlePredicate(predicate, false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto handleWhen =
|
const auto handleWhen =
|
||||||
[&](const ::pddl::normalizedAST::WhenPointer<::pddl::normalizedAST::Precondition, ::pddl::normalizedAST::ConditionalEffect> &)
|
[&](const ::pddl::normalizedAST::WhenPointer<::pddl::normalizedAST::Precondition, ::pddl::normalizedAST::ConditionalEffect> &)
|
||||||
{
|
{
|
||||||
throw TranslatorException("“when” expressions not yet supported by translator");
|
throw TranslatorException("“when” expressions not yet supported by translator");
|
||||||
};
|
};
|
||||||
|
|
||||||
effect.match(handleAtomicFormula, handleAnd, handleForAll, handleNot, handleWhen);
|
effect.match(handleAnd, handleForAll, handleLiteral, handleWhen);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -183,8 +183,7 @@ namespace detail
|
||||||
{
|
{
|
||||||
using ConditionalEffectT = Variant<
|
using ConditionalEffectT = Variant<
|
||||||
Literal,
|
Literal,
|
||||||
AndPointer<Literal>,
|
AndPointer<Literal>>;
|
||||||
NotPointer<ConditionalEffect>>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConditionalEffect : public detail::ConditionalEffectT
|
class ConditionalEffect : public detail::ConditionalEffectT
|
||||||
|
@ -196,16 +195,14 @@ class ConditionalEffect : public detail::ConditionalEffectT
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// TODO: support effects appropriately
|
|
||||||
class Effect;
|
class Effect;
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
using EffectT = Variant<
|
using EffectT = Variant<
|
||||||
AtomicFormula,
|
Literal,
|
||||||
AndPointer<Effect>,
|
AndPointer<Effect>,
|
||||||
ForAllPointer<Effect>,
|
ForAllPointer<Effect>,
|
||||||
NotPointer<Effect>,
|
|
||||||
WhenPointer<Precondition, ConditionalEffect>>;
|
WhenPointer<Precondition, ConditionalEffect>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue