Changed effects in normalized PDDL effects according to recent changes.
This commit is contained in:
		@@ -45,6 +45,29 @@ inline void translateEffect(colorlog::ColorStream &outputStream, const ::pddl::n
 | 
			
		||||
			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 ::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);
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
	const auto handleAtomicFormula =
 | 
			
		||||
		[&](const ::pddl::normalizedAST::AtomicFormula &atomicFormula)
 | 
			
		||||
		{
 | 
			
		||||
			atomicFormula.match(handlePredicate, handleDerivedPredicate);
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
	const auto handleForAll =
 | 
			
		||||
		[&](const ::pddl::normalizedAST::ForAllPointer<::pddl::normalizedAST::Effect> &)
 | 
			
		||||
		{
 | 
			
		||||
			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 ::pddl::normalizedAST::WhenPointer<::pddl::normalizedAST::Precondition, ::pddl::normalizedAST::ConditionalEffect> &)
 | 
			
		||||
		{
 | 
			
		||||
			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<
 | 
			
		||||
	Literal,
 | 
			
		||||
	AndPointer<Literal>,
 | 
			
		||||
	NotPointer<ConditionalEffect>>;
 | 
			
		||||
	AndPointer<Literal>>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ConditionalEffect : public detail::ConditionalEffectT
 | 
			
		||||
@@ -196,16 +195,14 @@ class ConditionalEffect : public detail::ConditionalEffectT
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
// TODO: support effects appropriately
 | 
			
		||||
class Effect;
 | 
			
		||||
 | 
			
		||||
namespace detail
 | 
			
		||||
{
 | 
			
		||||
using EffectT = Variant<
 | 
			
		||||
	AtomicFormula,
 | 
			
		||||
	Literal,
 | 
			
		||||
	AndPointer<Effect>,
 | 
			
		||||
	ForAllPointer<Effect>,
 | 
			
		||||
	NotPointer<Effect>,
 | 
			
		||||
	WhenPointer<Precondition, ConditionalEffect>>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user