Skip to content

Commit

Permalink
Remove global var NumeroChroniquesTireesParGroup (#1714)
Browse files Browse the repository at this point in the history
* [DEV] Use group timeseries instead of global var
  • Loading branch information
payetvin authored Oct 24, 2023
1 parent 67d9d1d commit 80a78bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
11 changes: 0 additions & 11 deletions src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
1 change: 0 additions & 1 deletion src/solver/simulation/sim_allocation_tableaux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
19 changes: 15 additions & 4 deletions src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,26 @@ 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();
for (unsigned constraintIndex = 0; constraintIndex != constraintCount; ++constraintIndex)
{
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())
Expand Down Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion src/solver/simulation/sim_extern_variables_globales.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

/* Valeurs generees de maniere aleatoire */
extern std::vector<std::vector<NUMERO_CHRONIQUES_TIREES_PAR_INTERCONNEXION>> NumeroChroniquesTireesParInterconnexion;
extern std::vector<std::map<std::string, unsigned>> NumeroChroniquesTireesParGroup;

/* Resultats */
/*-Economique-*/
Expand Down
2 changes: 0 additions & 2 deletions src/solver/simulation/sim_variables_globales.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@
std::vector<std::vector<NUMERO_CHRONIQUES_TIREES_PAR_INTERCONNEXION>> NumeroChroniquesTireesParInterconnexion;

std::vector<std::vector<double>> transitMoyenInterconnexionsRecalculQuadratique;

std::vector<std::map<std::string, unsigned>> NumeroChroniquesTireesParGroup; //Vector size = num_parallel_year

0 comments on commit 80a78bb

Please sign in to comment.