Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallel years cleaning : few removal of "numspace" #2128

Merged
merged 6 commits into from
Jun 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class HydroManagement final
HydroManagement(const Data::AreaList& areas,
const Data::Parameters& params,
const Date::Calendar& calendar,
unsigned int maxNbYearsInParallel,
Solver::IResultWriter& resultWriter);

//! Perform the hydro ventilation
Expand Down
2 changes: 0 additions & 2 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ double BetaVariable(double a, double b, MersenneTwister& random)
HydroManagement::HydroManagement(const Data::AreaList& areas,
const Data::Parameters& params,
const Date::Calendar& calendar,
unsigned int maxNbYearsInParallel,
Solver::IResultWriter& resultWriter):
areas_(areas),
calendar_(calendar),
parameters_(params),
maxNbYearsInParallel_(maxNbYearsInParallel),
flomnes marked this conversation as resolved.
Show resolved Hide resolved
resultWriter_(resultWriter)
{
// Ventilation results memory allocation
Expand Down
10 changes: 1 addition & 9 deletions src/solver/simulation/adequacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,7 @@ bool Adequacy::simulationBegin()
pProblemesHebdo.resize(pNbMaxPerformedYearsInParallel);
for (uint numSpace = 0; numSpace < pNbMaxPerformedYearsInParallel; numSpace++)
{
SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], 168, numSpace);
flomnes marked this conversation as resolved.
Show resolved Hide resolved

assert((uint)nbHoursInAWeek == (uint)pProblemesHebdo[numSpace].NombreDePasDeTemps
&& "inconsistency");
if ((uint)nbHoursInAWeek != (uint)pProblemesHebdo[numSpace].NombreDePasDeTemps)
{
logs.fatal() << "internal error";
return false;
}
SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], nbHoursInAWeek, numSpace);
}
}

Expand Down
8 changes: 1 addition & 7 deletions src/solver/simulation/economy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ bool Economy::simulationBegin()

for (uint numSpace = 0; numSpace < pNbMaxPerformedYearsInParallel; numSpace++)
{
SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], 168, numSpace);

if ((uint)nbHoursInAWeek != (uint)pProblemesHebdo[numSpace].NombreDePasDeTemps)
{
logs.fatal() << "internal error";
return false;
}
SIM_InitialisationProblemeHebdo(study, pProblemesHebdo[numSpace], nbHoursInAWeek, numSpace);

auto options = createOptimizationOptions(study);
weeklyOptProblems_[numSpace] = Antares::Solver::Optimization::WeeklyOptimization::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void SIM_AllocationProblemeHebdo(const Antares::Data::Study& study,
*/
void SIM_InitialisationProblemeHebdo(Antares::Data::Study& study,
PROBLEME_HEBDO& problem,
int NombreDePasDeTemps,
unsigned int NombreDePasDeTemps,
uint numspace);

void SIM_RenseignementProblemeHebdo(const Antares::Data::Study& study,
Expand Down
40 changes: 19 additions & 21 deletions src/solver/simulation/include/antares/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public:
randomNumbers& pRandomForParallelYears,
bool pPerformCalculations,
Data::Study& pStudy,
std::vector<Variable::State>& pState,
Variable::State& pState,
bool pYearByYear,
Benchmarking::DurationCollector& durationCollector,
IResultWriter& resultWriter):
Expand All @@ -75,7 +75,6 @@ public:
hydroManagement(study.areas,
study.parameters,
study.calendar,
study.maxNbYearsInParallel,
resultWriter)
{
hydroHotStart = (study.parameters.initialReservoirLevels.iniLevels == Data::irlHotStart);
Expand All @@ -96,7 +95,7 @@ private:
randomNumbers& randomForParallelYears;
bool performCalculations;
Data::Study& study;
std::vector<Variable::State>& state;
Variable::State& state;
bool yearByYear;
bool hydroHotStart;
Benchmarking::DurationCollector& pDurationCollector;
Expand Down Expand Up @@ -155,8 +154,7 @@ public:
// 1 - Applying random levels for current year
if (hydroHotStart && firstSetParallelWithAPerformedYearWasRun)
{
randomReservoirLevel = state[numSpace]
.problemeHebdo->previousYearFinalLevels.data();
randomReservoirLevel = state.problemeHebdo->previousYearFinalLevels.data();
}
else
{
Expand All @@ -177,7 +175,7 @@ public:
};

// Updating the state
state[numSpace].year = y;
state.year = y;

// 5 - Resetting all variables for the output
simulation_->variables.yearBegin(y, numSpace);
Expand All @@ -189,7 +187,7 @@ public:

OptimizationStatisticsWriter optWriter(pResultWriter, y);
yearFailed[y] = !simulation_->year(progression,
state[numSpace],
state,
numSpace,
randomForCurrentYear,
failedWeekList,
Expand All @@ -201,7 +199,7 @@ public:
// Log failing weeks
logFailedWeek(y, study, failedWeekList);

simulation_->variables.yearEndBuild(state[numSpace], y, numSpace);
simulation_->variables.yearEndBuild(state, y, numSpace);

// 7 - End of the year, this is the last stade where the variables can retrieve
// their data for this year.
Expand Down Expand Up @@ -1059,19 +1057,19 @@ void ISimulation<ImplementationType>::loopThroughYears(uint firstYear,
// continue;

auto task = std::make_shared<yearJob<ImplementationType>>(
this,
y,
set_it->yearFailed,
set_it->isFirstPerformedYearOfASet,
pFirstSetParallelWithAPerformedYearWasRun,
numSpace,
randomForParallelYears,
performCalculations,
study,
state,
pYearByYear,
pDurationCollector,
pResultWriter);
this,
y,
set_it->yearFailed,
set_it->isFirstPerformedYearOfASet,
pFirstSetParallelWithAPerformedYearWasRun,
numSpace,
randomForParallelYears,
performCalculations,
study,
state[numSpace],
pYearByYear,
pDurationCollector,
pResultWriter);
results.add(Concurrency::AddTask(*pQueueService, task));
} // End loop over years of the current set of parallel years

Expand Down
2 changes: 1 addition & 1 deletion src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void importShortTermStorages(

void SIM_InitialisationProblemeHebdo(Data::Study& study,
PROBLEME_HEBDO& problem,
int NombreDePasDeTemps,
unsigned int NombreDePasDeTemps,
uint numspace)
{
int NombrePaliers;
Expand Down
Loading