Started testing PDDL problem parsing for a Blocks World problem.
This commit is contained in:
parent
ad23c89266
commit
d23ec14e9d
@ -27,6 +27,7 @@ class Description
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const Domain &domain() const;
|
const Domain &domain() const;
|
||||||
|
const Problem &problem() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Description();
|
Description();
|
||||||
|
@ -88,6 +88,15 @@ const Domain &Description::domain() const
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
const Problem &Description::problem() const
|
||||||
|
{
|
||||||
|
BOOST_ASSERT(m_problem);
|
||||||
|
|
||||||
|
return *m_problem;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Description::parseContent()
|
void Description::parseContent()
|
||||||
{
|
{
|
||||||
// First, determine the locations of domain and problem
|
// First, determine the locations of domain and problem
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
#include <plasp/pddl/expressions/PrimitiveType.h>
|
#include <plasp/pddl/expressions/PrimitiveType.h>
|
||||||
#include <plasp/pddl/expressions/Reference.h>
|
#include <plasp/pddl/expressions/Reference.h>
|
||||||
|
|
||||||
|
using namespace plasp::pddl;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TEST(PDDLParserTests, ParseBlocksWorldDomain)
|
TEST(PDDLParserTests, ParseBlocksWorldDomain)
|
||||||
{
|
{
|
||||||
using namespace plasp::pddl;
|
|
||||||
|
|
||||||
const auto description = Description::fromFile("data/blocksworld-domain.pddl");
|
const auto description = Description::fromFile("data/blocksworld-domain.pddl");
|
||||||
|
|
||||||
ASSERT_NO_THROW(description.domain());
|
ASSERT_NO_THROW(description.domain());
|
||||||
@ -96,10 +96,38 @@ TEST(PDDLParserTests, ParseBlocksWorldDomain)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TEST(PDDLParserTests, ParseBlocksWorldProblem)
|
||||||
|
{
|
||||||
|
const auto description = Description::fromFiles({"data/blocksworld-domain.pddl", "data/blocksworld-problem.pddl"});
|
||||||
|
|
||||||
|
ASSERT_NO_THROW(description.problem());
|
||||||
|
|
||||||
|
const auto &problem = description.problem();
|
||||||
|
|
||||||
|
// Name
|
||||||
|
ASSERT_EQ(problem.name(), "blocks-4-0");
|
||||||
|
ASSERT_EQ(problem.domain().name(), "blocks");
|
||||||
|
|
||||||
|
// Requirements
|
||||||
|
// TODO: compute domain vs. problem requirements correctly and check them
|
||||||
|
|
||||||
|
// Objects
|
||||||
|
ASSERT_EQ(problem.objects().size(), 4u);
|
||||||
|
|
||||||
|
ASSERT_EQ(problem.objects()[0]->name(), "d");
|
||||||
|
ASSERT_NE(problem.objects()[0]->type(), nullptr);
|
||||||
|
ASSERT_EQ(problem.objects()[0]->type()->name(), "block");
|
||||||
|
ASSERT_EQ(problem.objects()[3]->name(), "c");
|
||||||
|
ASSERT_NE(problem.objects()[3]->type(), nullptr);
|
||||||
|
ASSERT_EQ(problem.objects()[3]->type()->name(), "block");
|
||||||
|
|
||||||
|
// TODO: check initial state and goal
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TEST(PDDLParserTests, ParseStorageDomain)
|
TEST(PDDLParserTests, ParseStorageDomain)
|
||||||
{
|
{
|
||||||
using namespace plasp::pddl;
|
|
||||||
|
|
||||||
const auto description = plasp::pddl::Description::fromFile("data/storage-domain.pddl");
|
const auto description = plasp::pddl::Description::fromFile("data/storage-domain.pddl");
|
||||||
|
|
||||||
ASSERT_NO_THROW(description.domain());
|
ASSERT_NO_THROW(description.domain());
|
||||||
@ -191,8 +219,6 @@ TEST(PDDLParserTests, ParseStorageDomain)
|
|||||||
|
|
||||||
TEST(PDDLParserTests, ParseConstants)
|
TEST(PDDLParserTests, ParseConstants)
|
||||||
{
|
{
|
||||||
using namespace plasp::pddl;
|
|
||||||
|
|
||||||
const auto description = Description::fromFile("data/woodworking-domain.pddl");
|
const auto description = Description::fromFile("data/woodworking-domain.pddl");
|
||||||
|
|
||||||
ASSERT_NO_THROW(description.domain());
|
ASSERT_NO_THROW(description.domain());
|
||||||
@ -222,7 +248,12 @@ TEST(PDDLParserTests, ParseConstants)
|
|||||||
|
|
||||||
TEST(PDDLParserTests, ParseWithWhiteSpace)
|
TEST(PDDLParserTests, ParseWithWhiteSpace)
|
||||||
{
|
{
|
||||||
using namespace plasp::pddl;
|
|
||||||
|
|
||||||
ASSERT_NO_THROW(Description::fromFile("data/white-space-test.pddl"));
|
ASSERT_NO_THROW(Description::fromFile("data/white-space-test.pddl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TEST(PDDLParserTests, ParseWithoutDomain)
|
||||||
|
{
|
||||||
|
ASSERT_THROW(Description::fromFile("data/blocksworld-problem.pddl"), plasp::pddl::ConsistencyException);
|
||||||
|
}
|
||||||
|
7
tests/data/blocksworld-problem.pddl
Normal file
7
tests/data/blocksworld-problem.pddl
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
(define (problem BLOCKS-4-0)
|
||||||
|
(:domain BLOCKS)
|
||||||
|
(:objects D B A C - block)
|
||||||
|
(:INIT (CLEAR C) (CLEAR A) (CLEAR B) (CLEAR D) (ONTABLE C) (ONTABLE A)
|
||||||
|
(ONTABLE B) (ONTABLE D) (HANDEMPTY))
|
||||||
|
(:goal (AND (ON D C) (ON C B) (ON B A)))
|
||||||
|
)
|
Reference in New Issue
Block a user