Removed fluents section (to be derived from variables instead).

This commit is contained in:
Patrick Lühne 2016-05-23 14:22:33 +02:00
parent 03ae0dc301
commit 0724963c32

View File

@ -63,35 +63,6 @@ void TranslatorASP::translate(std::ostream &ostream) const
{ {
checkSupport(); checkSupport();
std::vector<const Value *> fluents;
const auto &variables = m_description.variables();
std::for_each(variables.cbegin(), variables.cend(),
[&](const auto &variable)
{
const auto &values = variable.values();
std::for_each(values.cbegin(), values.cend(),
[&](const auto &value)
{
if (value == Value::None)
return;
const auto match = std::find_if(fluents.cbegin(), fluents.cend(),
[&](const auto &fluent)
{
return value.name() == fluent->name();
});
// Dont add fluents if their negated form has already been added
if (match != fluents.cend())
return;
fluents.push_back(&value);
});
});
ostream << "% initial state" << std::endl; ostream << "% initial state" << std::endl;
const auto &initialStateFacts = m_description.initialState().facts(); const auto &initialStateFacts = m_description.initialState().facts();
@ -124,14 +95,33 @@ void TranslatorASP::translate(std::ostream &ostream) const
}); });
ostream << std::endl; ostream << std::endl;
ostream << "% fluents" << std::endl; ostream << "% variables";
std::for_each(fluents.cbegin(), fluents.cend(), const auto &variables = m_description.variables();
[&](const auto *fluent)
std::for_each(variables.cbegin(), variables.cend(),
[&](const auto &variable)
{ {
ostream << "fluent("; const auto &values = variable.values();
fluent->printAsASP(ostream);
BOOST_ASSERT(!values.empty());
ostream << std::endl << "variable(";
variable.printNameAsASP(ostream);
ostream << ")." << std::endl; ostream << ")." << std::endl;
std::for_each(values.cbegin(), values.cend(),
[&](const auto &value)
{
ostream << "variableValue(";
variable.printNameAsASP(ostream);
ostream << ", ";
if (value == Value::None)
ostream << "noneValue";
else
value.printAsASPPredicateBody(ostream);
ostream << ")." << std::endl;
});
}); });
ostream << std::endl; ostream << std::endl;
@ -177,34 +167,6 @@ void TranslatorASP::translate(std::ostream &ostream) const
}); });
}); });
ostream << std::endl;
ostream << "% variables";
std::for_each(variables.cbegin(), variables.cend(),
[&](const auto &variable)
{
const auto &values = variable.values();
BOOST_ASSERT(!values.empty());
ostream << std::endl << "variable(";
variable.printNameAsASP(ostream);
ostream << ")." << std::endl;
std::for_each(values.cbegin(), values.cend(),
[&](const auto &value)
{
ostream << "variableValue(";
variable.printNameAsASP(ostream);
ostream << ", ";
if (value == Value::None)
ostream << "noneValue";
else
value.printAsASPPredicateBody(ostream);
ostream << ")." << std::endl;
});
});
ostream << std::endl; ostream << std::endl;
ostream << "% mutex groups"; ostream << "% mutex groups";