From cac555ea421521d5d1ee0ca6b756028851ae8ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 21 May 2016 03:02:12 +0200 Subject: [PATCH] Correctly aggregating fluent names now. --- src/plasp/sas/TranslatorASP.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plasp/sas/TranslatorASP.cpp b/src/plasp/sas/TranslatorASP.cpp index e2a95d1..c12ddb2 100644 --- a/src/plasp/sas/TranslatorASP.cpp +++ b/src/plasp/sas/TranslatorASP.cpp @@ -54,17 +54,29 @@ void TranslatorASP::translate(std::ostream &ostream) const { checkSupport(); - std::vector fluents; + std::vector fluents; const auto &variables = m_description.variables(); std::for_each(variables.cbegin(), variables.cend(), [&](const auto &variable) { - std::for_each(variable.values.cbegin(), variable.values.cend(), + const auto &values = variable.values; + + std::for_each(values.cbegin(), values.cend(), [&](const auto &value) { - fluents.push_back(&value); + const auto match = std::find_if(fluents.cbegin(), fluents.cend(), + [&](const auto &fluent) + { + return value.name == *fluent; + }); + + // Don’t add fluents if their negated form has already been added + if (match != fluents.cend()) + return; + + fluents.push_back(&value.name); }); }); @@ -73,9 +85,6 @@ void TranslatorASP::translate(std::ostream &ostream) const std::for_each(fluents.cbegin(), fluents.cend(), [&](const auto *fluent) { - if (fluent->sign == Value::Sign::Negative) - return; - ostream << "fluent(" << *fluent << ")." << std::endl; });