Fixed meta encoding for sequential, incremental planning.
This commit is contained in:
parent
5b42b09e5d
commit
5db8af9ffc
@ -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).
|
deleted(F, t) :- occurs(A, t), postcondition(A, F, false), action(A).
|
||||||
holds(F, t) :- holds(F, t - 1), not deleted(F, t).
|
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).
|
#program check(t).
|
||||||
|
|
||||||
% Verify that goal is met
|
% 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).
|
:- query(t), goal(F, false), holds(F, t).
|
||||||
|
|
||||||
#show query/1.
|
#show query/1.
|
||||||
#show holds/2.
|
|
||||||
#show occurs/2.
|
#show occurs/2.
|
||||||
|
@ -42,7 +42,6 @@ struct Value
|
|||||||
void printAsSAS(std::ostream &ostream) const;
|
void printAsSAS(std::ostream &ostream) const;
|
||||||
void printAsASP(std::ostream &ostream) const;
|
void printAsASP(std::ostream &ostream) const;
|
||||||
void printAsASPPredicateBody(std::ostream &ostream) const;
|
void printAsASPPredicateBody(std::ostream &ostream) const;
|
||||||
void printAsASPHoldsPredicate(std::ostream &ostream) const;
|
|
||||||
|
|
||||||
Sign sign() const;
|
Sign sign() const;
|
||||||
const std::string &name() const;
|
const std::string &name() const;
|
||||||
|
@ -181,11 +181,11 @@ void TranslatorASP::translate(std::ostream &ostream) const
|
|||||||
const auto &value1 = *i;
|
const auto &value1 = *i;
|
||||||
const auto &value2 = *j;
|
const auto &value2 = *j;
|
||||||
|
|
||||||
ostream << ":- ";
|
ostream << "mutex(";
|
||||||
value1.printAsASPHoldsPredicate(ostream);
|
value1.printAsASPPredicateBody(ostream);
|
||||||
ostream << ", ";
|
ostream << ", ";
|
||||||
value2.printAsASPHoldsPredicate(ostream);
|
value2.printAsASPPredicateBody(ostream);
|
||||||
ostream << "." << std::endl;
|
ostream << ")." << std::endl;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -205,11 +205,11 @@ void TranslatorASP::translate(std::ostream &ostream) const
|
|||||||
const auto &value1 = i->value();
|
const auto &value1 = i->value();
|
||||||
const auto &value2 = j->value();
|
const auto &value2 = j->value();
|
||||||
|
|
||||||
ostream << ":- ";
|
ostream << "mutex(";
|
||||||
value1.printAsASPHoldsPredicate(ostream);
|
value1.printAsASPPredicateBody(ostream);
|
||||||
ostream << ", ";
|
ostream << ", ";
|
||||||
value2.printAsASPHoldsPredicate(ostream);
|
value2.printAsASPPredicateBody(ostream);
|
||||||
ostream << "." << std::endl;
|
ostream << ")." << std::endl;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -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
|
void Value::printAsSAS(std::ostream &ostream) const
|
||||||
{
|
{
|
||||||
if (m_sign == Value::Sign::Positive)
|
if (m_sign == Value::Sign::Positive)
|
||||||
|
Reference in New Issue
Block a user