From 5db8af9ffc2b4ae80ce91851fc29581069b5e3ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 23 May 2016 00:24:48 +0200 Subject: [PATCH] Fixed meta encoding for sequential, incremental planning. --- encodings/meta-sequential-incremental.lp | 7 ++++++- include/plasp/sas/Value.h | 1 - src/plasp/sas/TranslatorASP.cpp | 16 ++++++++-------- src/plasp/sas/Value.cpp | 10 ---------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/encodings/meta-sequential-incremental.lp b/encodings/meta-sequential-incremental.lp index 7c11f13..be1adb4 100644 --- a/encodings/meta-sequential-incremental.lp +++ b/encodings/meta-sequential-incremental.lp @@ -19,6 +19,12 @@ holds(F, t) :- occurs(A, t), postcondition(A, F, true), action(A). deleted(F, t) :- occurs(A, t), postcondition(A, F, false), action(A). holds(F, t) :- holds(F, t - 1), not deleted(F, t). +% Enforce mutexes +deleted(F2, t) :- mutex(F1, true, F2, true), holds(F1, t). +holds(F2, t) :- mutex(F1, true, F2, false), holds(F1, t). +deleted(F2, t) :- mutex(F1, false, F2, true), not holds(F1, t). +holds(F2, t) :- mutex(F1, false, F2, false), not holds(F1, t). + #program check(t). % Verify that goal is met @@ -26,5 +32,4 @@ holds(F, t) :- holds(F, t - 1), not deleted(F, t). :- query(t), goal(F, false), holds(F, t). #show query/1. -#show holds/2. #show occurs/2. diff --git a/include/plasp/sas/Value.h b/include/plasp/sas/Value.h index fdf2d3c..eb9321c 100644 --- a/include/plasp/sas/Value.h +++ b/include/plasp/sas/Value.h @@ -42,7 +42,6 @@ struct Value void printAsSAS(std::ostream &ostream) const; void printAsASP(std::ostream &ostream) const; void printAsASPPredicateBody(std::ostream &ostream) const; - void printAsASPHoldsPredicate(std::ostream &ostream) const; Sign sign() const; const std::string &name() const; diff --git a/src/plasp/sas/TranslatorASP.cpp b/src/plasp/sas/TranslatorASP.cpp index 715283d..884ab8b 100644 --- a/src/plasp/sas/TranslatorASP.cpp +++ b/src/plasp/sas/TranslatorASP.cpp @@ -181,11 +181,11 @@ void TranslatorASP::translate(std::ostream &ostream) const const auto &value1 = *i; const auto &value2 = *j; - ostream << ":- "; - value1.printAsASPHoldsPredicate(ostream); + ostream << "mutex("; + value1.printAsASPPredicateBody(ostream); ostream << ", "; - value2.printAsASPHoldsPredicate(ostream); - ostream << "." << std::endl; + value2.printAsASPPredicateBody(ostream); + ostream << ")." << std::endl; } }); @@ -205,11 +205,11 @@ void TranslatorASP::translate(std::ostream &ostream) const const auto &value1 = i->value(); const auto &value2 = j->value(); - ostream << ":- "; - value1.printAsASPHoldsPredicate(ostream); + ostream << "mutex("; + value1.printAsASPPredicateBody(ostream); ostream << ", "; - value2.printAsASPHoldsPredicate(ostream); - ostream << "." << std::endl; + value2.printAsASPPredicateBody(ostream); + ostream << ")." << std::endl; } }); } diff --git a/src/plasp/sas/Value.cpp b/src/plasp/sas/Value.cpp index b87f8eb..bd008a0 100644 --- a/src/plasp/sas/Value.cpp +++ b/src/plasp/sas/Value.cpp @@ -120,16 +120,6 @@ void Value::printAsASPPredicateBody(std::ostream &ostream) const //////////////////////////////////////////////////////////////////////////////////////////////////// -void Value::printAsASPHoldsPredicate(std::ostream &ostream) const -{ - if (m_sign == Value::Sign::Negative) - ostream << "not "; - - ostream << "holds(" << utils::escapeASP(m_name) << ", t)"; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// - void Value::printAsSAS(std::ostream &ostream) const { if (m_sign == Value::Sign::Positive)