Added functions for checking PDDL requirements.
This commit is contained in:
parent
993d14d409
commit
e60af33f75
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 =
|
||||
|
@ -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 =
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user