From 0724963c32d9c6928accb81ba694ba7846cd38a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 23 May 2016 14:22:33 +0200 Subject: [PATCH] Removed fluents section (to be derived from variables instead). --- src/plasp/sas/TranslatorASP.cpp | 86 +++++++++------------------------ 1 file changed, 24 insertions(+), 62 deletions(-) diff --git a/src/plasp/sas/TranslatorASP.cpp b/src/plasp/sas/TranslatorASP.cpp index f50d693..194fcf7 100644 --- a/src/plasp/sas/TranslatorASP.cpp +++ b/src/plasp/sas/TranslatorASP.cpp @@ -63,35 +63,6 @@ void TranslatorASP::translate(std::ostream &ostream) const { checkSupport(); - std::vector 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(); - }); - - // Don’t add fluents if their negated form has already been added - if (match != fluents.cend()) - return; - - fluents.push_back(&value); - }); - }); - ostream << "% initial state" << std::endl; const auto &initialStateFacts = m_description.initialState().facts(); @@ -124,14 +95,33 @@ void TranslatorASP::translate(std::ostream &ostream) const }); ostream << std::endl; - ostream << "% fluents" << std::endl; + ostream << "% variables"; - std::for_each(fluents.cbegin(), fluents.cend(), - [&](const auto *fluent) + const auto &variables = m_description.variables(); + + std::for_each(variables.cbegin(), variables.cend(), + [&](const auto &variable) { - ostream << "fluent("; - fluent->printAsASP(ostream); + 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; @@ -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 << "% mutex groups";