From a15d517fa1df6f2f6fe57515dfee8984d66ae5b3 Mon Sep 17 00:00:00 2001 From: Henri Lefebvre Date: Wed, 11 Dec 2024 18:13:58 +0100 Subject: [PATCH] detect linking constraints --- .../column-and-constraint-generation/Formulation.h | 1 + .../column-and-constraint-generation/Formulation.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/lib/include/idol/robust/optimizers/column-and-constraint-generation/Formulation.h b/lib/include/idol/robust/optimizers/column-and-constraint-generation/Formulation.h index e120bc52..801b00c5 100644 --- a/lib/include/idol/robust/optimizers/column-and-constraint-generation/Formulation.h +++ b/lib/include/idol/robust/optimizers/column-and-constraint-generation/Formulation.h @@ -19,6 +19,7 @@ class idol::CCG::Formulation { Model m_master; std::vector m_second_stage_variables; std::vector m_second_stage_constraints; + std::vector m_linking_constraints; unsigned int m_n_added_scenario = 0; std::optional m_second_stage_epigraph; diff --git a/lib/src/robust/optimizers/column-and-constraint-generation/Formulation.cpp b/lib/src/robust/optimizers/column-and-constraint-generation/Formulation.cpp index 4b7fe344..23a24346 100644 --- a/lib/src/robust/optimizers/column-and-constraint-generation/Formulation.cpp +++ b/lib/src/robust/optimizers/column-and-constraint-generation/Formulation.cpp @@ -66,11 +66,17 @@ void idol::CCG::Formulation::parse_constraints() { const auto& row = m_parent.get_ctr_row(ctr); + const bool has_first_stage = std::any_of(row.begin(), row.end(), [this](const auto& term) { + return m_description.stage(term.first) == 0; + }); const bool has_second_stage = std::any_of(row.begin(), row.end(), [this](const auto& term) { return m_description.stage(term.first) > 0; }); if (has_second_stage || !m_description.uncertain_mat_coeffs(ctr).empty()) { + if (has_first_stage) { + m_linking_constraints.emplace_back(ctr); + } m_second_stage_constraints.emplace_back(ctr); continue; }