From 80a78bba1921ff599352532cf5d05cc81e81e188 Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Tue, 24 Oct 2023 17:09:17 +0200 Subject: [PATCH] Remove global var NumeroChroniquesTireesParGroup (#1714) * [DEV] Use group timeseries instead of global var --- .../alea_tirage_au_sort_chroniques.cpp | 11 ----------- .../simulation/sim_allocation_tableaux.cpp | 1 - .../simulation/sim_calcul_economique.cpp | 19 +++++++++++++++---- .../sim_extern_variables_globales.h | 1 - .../simulation/sim_variables_globales.cpp | 2 -- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp b/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp index 3739933de0..64c1aa43ef 100644 --- a/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp +++ b/src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp @@ -53,15 +53,4 @@ void ApplyRandomTSnumbers(const Study& study, ptchro.TransmissionCapacities = (directWidth != 1) ? link->timeseriesNumbers[0][year] : 0; // zero-based } - - // ------------------------------ - //Binding constraints - // ------------------------------ - //Setting 0 for time_series of width 0 is done when using the value. - //To do this here we would have to check every BC for its width - for (const auto& group: study.bindingConstraintsGroups) { - [[maybe_unused]] auto number_of_ts_numbers = group->timeseriesNumbers.height; - assert(year < number_of_ts_numbers); //If only 1 ts_number we suppose only one TS. Any "year" will be converted to "0" later - NumeroChroniquesTireesParGroup[numSpace][group->name()] = group->timeseriesNumbers[0][year]; - } } diff --git a/src/solver/simulation/sim_allocation_tableaux.cpp b/src/solver/simulation/sim_allocation_tableaux.cpp index 3967b0fbd5..c9178da041 100644 --- a/src/solver/simulation/sim_allocation_tableaux.cpp +++ b/src/solver/simulation/sim_allocation_tableaux.cpp @@ -50,6 +50,5 @@ void SIM_AllocationTableaux(const Data::Study& study) for (uint numSpace = 0; numSpace < study.maxNbYearsInParallel; numSpace++) NumeroChroniquesTireesParInterconnexion[numSpace].resize(intercoCount); - NumeroChroniquesTireesParGroup.resize(study.maxNbYearsInParallel); AllocateResultsForEconomicMode(study); } diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index c9a64ab22d..a24e2c83e8 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -318,8 +318,10 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, problem.LeProblemeADejaEteInstancie = false; } -void preparerBindingConstraint(const PROBLEME_HEBDO &problem, uint numSpace, int PasDeTempsDebut, - const BindingConstraintsRepository &bindingConstraints, const uint weekFirstDay, int pasDeTemps) +void preparerBindingConstraint(const PROBLEME_HEBDO &problem, int PasDeTempsDebut, + const BindingConstraintsRepository &bindingConstraints, + const BindingConstraintGroupRepository &bcgroups, + const uint weekFirstDay, int pasDeTemps) { auto activeContraints = bindingConstraints.activeContraints(); const auto constraintCount = activeContraints.size(); @@ -327,8 +329,15 @@ void preparerBindingConstraint(const PROBLEME_HEBDO &problem, uint numSpace, int { auto bc = activeContraints[constraintIndex]; assert(bc->RHSTimeSeries().width && "Invalid constraint data width"); + + uint tsIndexForBc = 0; + auto* group = bcgroups[bc->group()]; + if (group) + tsIndexForBc = group->timeseriesNumbers[0][problem.year]; + //If there is only one TS, always select it. - const auto ts_number = bc->RHSTimeSeries().width == 1 ? 0 : NumeroChroniquesTireesParGroup[numSpace][bc->group()]; + const auto ts_number = bc->RHSTimeSeries().width == 1 ? 0 : tsIndexForBc; + auto& timeSeries = bc->RHSTimeSeries(); double const* column = timeSeries[ts_number]; switch (bc->type()) @@ -565,7 +574,9 @@ void SIM_RenseignementProblemeHebdo(const Study& study, ntc.ValeurDeLoopFlowOrigineVersExtremite[k] = lnk.parameters[fhlLoopFlow][hourInYear]; } } - preparerBindingConstraint(problem, numSpace, PasDeTempsDebut, study.bindingConstraints, weekFirstDay, hourInWeek); + preparerBindingConstraint(problem, PasDeTempsDebut, + study.bindingConstraints, study.bindingConstraintsGroups, + weekFirstDay, hourInWeek); const uint dayInTheYear = study.calendar.hours[hourInYear].dayYear; diff --git a/src/solver/simulation/sim_extern_variables_globales.h b/src/solver/simulation/sim_extern_variables_globales.h index 421e8db76e..737626593f 100644 --- a/src/solver/simulation/sim_extern_variables_globales.h +++ b/src/solver/simulation/sim_extern_variables_globales.h @@ -32,7 +32,6 @@ /* Valeurs generees de maniere aleatoire */ extern std::vector> NumeroChroniquesTireesParInterconnexion; -extern std::vector> NumeroChroniquesTireesParGroup; /* Resultats */ /*-Economique-*/ diff --git a/src/solver/simulation/sim_variables_globales.cpp b/src/solver/simulation/sim_variables_globales.cpp index e5fe936dc6..78b6e6250c 100644 --- a/src/solver/simulation/sim_variables_globales.cpp +++ b/src/solver/simulation/sim_variables_globales.cpp @@ -31,5 +31,3 @@ std::vector> NumeroChroniquesTireesParInterconnexion; std::vector> transitMoyenInterconnexionsRecalculQuadratique; - -std::vector> NumeroChroniquesTireesParGroup; //Vector size = num_parallel_year