Added functions for checking PDDL requirements.

This commit is contained in:
Patrick Lühne 2016-06-08 12:22:31 +02:00
parent 993d14d409
commit e60af33f75
6 changed files with 30 additions and 6 deletions

View File

@ -33,6 +33,7 @@ class Domain
const Requirements &requirements() const;
bool hasRequirement(Requirement::Type requirementType) const;
void checkRequirement(Requirement::Type requirementType) const;
expressions::PrimitiveTypes &types();
const expressions::PrimitiveTypes &types() const;

View File

@ -32,6 +32,7 @@ class Problem
const Requirements &requirements() const;
bool hasRequirement(Requirement::Type requirementType) const;
void checkRequirement(Requirement::Type requirementType) const;
expressions::Constants &objects();
const expressions::Constants &objects() const;

View File

@ -56,8 +56,8 @@ class Requirement
Type type() const;
void printAsPDDL(std::ostream &ostream) const;
void printAsASP(std::ostream &ostream) const;
std::string toPDDL() const;
std::string toASP() const;
private:
Type m_type;

View File

@ -206,6 +206,16 @@ bool Domain::hasRequirement(Requirement::Type requirementType) const
////////////////////////////////////////////////////////////////////////////////////////////////////
void Domain::checkRequirement(Requirement::Type requirementType) const
{
if (hasRequirement(requirementType))
return;
throw ConsistencyException("Requirement \"" + Requirement(requirementType).toPDDL() + "\" used but never declared");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Domain::computeDerivedRequirements()
{
const auto addRequirementUnique =

View File

@ -190,6 +190,18 @@ bool Problem::hasRequirement(Requirement::Type requirementType) const
////////////////////////////////////////////////////////////////////////////////////////////////////
void Problem::checkRequirement(Requirement::Type requirementType) const
{
m_domain.checkRequirement(requirementType);
if (hasRequirement(requirementType))
return;
throw ConsistencyException("Requirement \"" + Requirement(requirementType).toPDDL() + "\" used but never declared");
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Problem::computeDerivedRequirements()
{
const auto addRequirementUnique =

View File

@ -101,24 +101,24 @@ Requirement::Type Requirement::type() const
////////////////////////////////////////////////////////////////////////////////////////////////////
void Requirement::printAsPDDL(std::ostream &ostream) const
std::string Requirement::toPDDL() const
{
const auto match = requirementTypesToPDDL.left.find(m_type);
BOOST_ASSERT(match != requirementTypesToPDDL.left.end());
ostream << match->second;
return match->second;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void Requirement::printAsASP(std::ostream &ostream) const
std::string Requirement::toASP() const
{
const auto match = requirementTypesToASP.left.find(m_type);
BOOST_ASSERT(match != requirementTypesToASP.left.end());
ostream << match->second;
return match->second;
}
////////////////////////////////////////////////////////////////////////////////////////////////////