From 9df21bc1acd17e1f69f7ae72c237426c2defe6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Mon, 20 Nov 2023 15:34:56 +0100 Subject: [PATCH] Allow absence of group attribute for binding constraints (#1769) * Add "default" to binding constraint group if empty * Move "default" to constructors * Remove empty group error --- .../study/binding_constraint/BindingConstraint.h | 2 +- .../binding_constraint/BindingConstraintLoader.cpp | 13 ------------- .../binding_constraint/BindingConstraintSaver.cpp | 4 +--- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/libs/antares/study/binding_constraint/BindingConstraint.h b/src/libs/antares/study/binding_constraint/BindingConstraint.h index 4ab74f57bb..14a71447a2 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraint.h +++ b/src/libs/antares/study/binding_constraint/BindingConstraint.h @@ -410,7 +410,7 @@ class BindingConstraint final : public Yuni::NonCopyable //! Comments YString pComments; //! Group - std::string group_; + std::string group_ = "default"; void clear(); diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp index 2fc30e1b82..805e0f7afc 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintLoader.cpp @@ -152,19 +152,6 @@ std::vector> BindingConstraintLoader::load(En << "]: Invalid operator [less,greater,equal,both]"; return {}; } - if (bc->group_.empty()) - { - if (env.version >= version870) - { - logs.error() << env.iniFilename << ": in [" << env.section->name - << "]: Missing mandatory binding constraint group"; - return {}; - } - else // In studies versions < 870, binding constraints have no group. From version 870, antares requires constraints to have a group. - { - bc->group_ = "default"; - } - } // The binding constraint can not be enabled if there is no weight in the table if (bc->pLinkWeights.empty() && bc->pClusterWeights.empty()) diff --git a/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp b/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp index bdc9efb741..187241b3ff 100644 --- a/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp +++ b/src/libs/antares/study/binding_constraint/BindingConstraintSaver.cpp @@ -20,9 +20,7 @@ bool BindingConstraintSaver::saveToEnv(EnvForSaving& env, const BindingConstrain env.section->add("operator", BindingConstraint::OperatorToCString(bindingConstraint->pOperator)); env.section->add("filter-year-by-year", datePrecisionIntoString(bindingConstraint->pFilterYearByYear)); env.section->add("filter-synthesis", datePrecisionIntoString(bindingConstraint->pFilterSynthesis)); - - if (!bindingConstraint->group().empty()) - env.section->add("group", bindingConstraint->group()); + env.section->add("group", bindingConstraint->group()); if (!bindingConstraint->pComments.empty()) env.section->add("comments", bindingConstraint->pComments);