Started implementing PDDL normalization.

This commit is contained in:
2017-06-23 04:18:07 +02:00
parent e4f4b5e066
commit 9d1a8f4c0f
35 changed files with 1028 additions and 117 deletions

View File

@@ -82,6 +82,14 @@ class ParserException : public Exception
////////////////////////////////////////////////////////////////////////////////////////////////////
class NormalizationException : public Exception
{
public:
using Exception::Exception;
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
#endif

View File

@@ -0,0 +1,24 @@
#ifndef __PDDL_PARSE__NORMALIZE_H
#define __PDDL_PARSE__NORMALIZE_H
#include <pddlparse/AST.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedAST.h>
#include <pddlparse/detail/normalization/Description.h>
namespace pddl
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Normalize
//
////////////////////////////////////////////////////////////////////////////////////////////////////
using detail::normalize;
////////////////////////////////////////////////////////////////////////////////////////////////////
}
#endif

View File

@@ -133,6 +133,7 @@ struct Problem
Domain *domain;
std::string name;
DerivedPredicateDeclarations derivedPredicates;
ConstantDeclarations objects;
InitialState initialState;
std::experimental::optional<Goal> goal;

View File

@@ -66,6 +66,9 @@ using ast::AtPointer;
using ast::Either;
using ast::EitherPointer;
using ast::Exists;
using ast::ExistsPointer;
using ast::ForAll;
using ast::ForAllPointer;
using ast::Not;
using ast::NotPointer;
using ast::When;
@@ -170,7 +173,7 @@ namespace detail
using EffectT = Variant<
AtomicFormula,
AndPointer<Effect>,
ast::ForAllPointer<Effect>,
ForAllPointer<Effect>,
NotPointer<Effect>,
WhenPointer<Precondition, ConditionalEffect>>;
}

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__ACTION_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__ACTION_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Action
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::ActionPointer normalize(ast::ActionPointer &&domain, normalizedAST::DerivedPredicateDeclarations &derivedPredicates);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__ATOMIC_FORMULA_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__ATOMIC_FORMULA_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// AtomicFormula
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::AtomicFormula normalize(ast::AtomicFormula &&atomicFormula);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__DESCRIPTION_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__DESCRIPTION_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Description
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::Description normalize(ast::Description &&description);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__DOMAIN_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__DOMAIN_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Domain
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::DomainPointer normalize(ast::DomainPointer &&domain);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__EFFECT_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__EFFECT_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Effect
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::Effect normalize(ast::Effect &&effect);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__FACT_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__FACT_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Fact
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::Fact normalize(ast::Fact &&fact);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__INITIAL_STATE_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__INITIAL_STATE_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// InitialState
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::InitialState normalize(ast::InitialState &&initialState);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__LITERAL_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__LITERAL_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Literal
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::Literal normalize(ast::Literal &&literal);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__PRECONDITION_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__PRECONDITION_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Precondition
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::Precondition normalize(ast::Precondition &&precondition, normalizedAST::DerivedPredicateDeclarations &derivedPredicates);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif

View File

@@ -0,0 +1,26 @@
#ifndef __PDDL_PARSE__DETAIL__NORMALIZATION__PROBLEM_H
#define __PDDL_PARSE__DETAIL__NORMALIZATION__PROBLEM_H
#include <pddlparse/ASTForward.h>
#include <pddlparse/Context.h>
#include <pddlparse/NormalizedASTForward.h>
namespace pddl
{
namespace detail
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Problem
//
////////////////////////////////////////////////////////////////////////////////////////////////////
normalizedAST::ProblemPointer normalize(ast::ProblemPointer &&problem, normalizedAST::Domain *domain);
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif