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

Simplify TS numbers drawings, fix bug related to refresh & local thermal generation #1752

Merged
merged 46 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7239dc1
Simplify TS numbers draws : make data members private
guilpier-code Nov 8, 2023
8fa5257
Simplify TS numbers draws : make nbHoursADay a constant unsigned int …
guilpier-code Nov 8, 2023
106df5e
Simplify TS numbers draws : mainly extracting generated TS resizing f…
guilpier-code Nov 8, 2023
f2ebc1a
Simplify TS numbers draws : first simplification on TS numbers drawings
guilpier-code Nov 8, 2023
60cefd6
Simplify TS numbers draws : also moving hydro generated TS before TS …
guilpier-code Nov 8, 2023
4416e6b
Simplify TS numbers draws : simplifications on TS numbers drawings ab…
guilpier-code Nov 8, 2023
cdbde28
Simplify TS numbers draws : also moving thermal generated TS before T…
guilpier-code Nov 8, 2023
e45e560
Simplify TS numbers draws : fix TS number unit tests
guilpier-code Nov 8, 2023
561c156
Simplify TS numbers draws : use timeSeriesToRefres instead of timeSer…
guilpier-code Nov 9, 2023
868cd1c
[skip ci] Simplify TS numbers draws : remove useless argument
guilpier-code Nov 10, 2023
57d65e0
Simplify TS numbers draws : removing knowledge of TS acquisition mode…
guilpier-code Nov 10, 2023
123056b
Simplify TS numbers draws : removing knowledge of TS acquisition mode…
guilpier-code Nov 10, 2023
0f00962
Simplify TS numbers draws : removing knowledge of TS acquisition mode…
guilpier-code Nov 10, 2023
5a9b61e
[skip ci] Simplify TS numbers draws : removing knowledge of TS acquis…
guilpier-code Nov 10, 2023
80d5335
Simplify TS numbers draws : remove boolean (is intra modal ?) from in…
guilpier-code Nov 13, 2023
c607d9c
Simplify TS numbers draws : fix results instability
guilpier-code Nov 24, 2023
c8d6bac
Simplify TS numbers draws : remove check(), not needed anymore
guilpier-code Nov 24, 2023
610a7b6
Simplify TS numbers draws : simplify intra-modal check a bit
guilpier-code Nov 24, 2023
80aba94
Simplify TS numbers draws : simplify intra-modal check a bit
guilpier-code Nov 28, 2023
935bcc5
Simplify TS numbers draws : remove study as TS retriever classes
guilpier-code Nov 28, 2023
5568862
[skip ci] Simplify TS numbers draws : make parent class's destructor …
guilpier-code Nov 28, 2023
2433c84
Simplify TS numbers draws : remove study as a function argument
guilpier-code Nov 28, 2023
9355df0
Simplify TS numbers draws : small simplification
guilpier-code Nov 29, 2023
95c631c
Simplify TS numbers draws : test : removing empty TS management. Does…
guilpier-code Nov 30, 2023
19df9ac
Simplify TS numbers draws : resize mingen TS when hydro TS are generated
guilpier-code Dec 4, 2023
ceb8a73
Simplify TS numbers draws : move permission to have 1 TS intra-modal …
guilpier-code Dec 4, 2023
3580fe0
Simplify TS numbers draws : repair unit tests
guilpier-code Dec 4, 2023
d707e59
Simplify TS numbers draws : fixing an error on end-to-end simple stud…
guilpier-code Dec 5, 2023
47c0871
[skip ci] Simplify TS numbers draws : a bit of cleaning
guilpier-code Dec 5, 2023
4a5b20c
Simplify TS numbers draws : resetting ts numbers (instead of resizing…
guilpier-code Dec 5, 2023
d1edf1d
Simplify TS numbers draws : small simplifications
guilpier-code Dec 5, 2023
6d14a07
Simplify TS numbers draws : testing (on CI) the removal of function f…
guilpier-code Dec 5, 2023
f42bde3
Simplify TS numbers draws : if hydro TS is generated, mingen should n…
guilpier-code Dec 5, 2023
bcd83c3
Simplify TS numbers draws : when hydro TS are corrected, mingen size …
guilpier-code Dec 5, 2023
08b3609
Simplify TS numbers draws : removing fixTSNumbersWhenWidthIsOne, useless
guilpier-code Dec 5, 2023
45486ce
Merge remote-tracking branch 'remotes/origin/develop' into fix/simpli…
guilpier-code Dec 6, 2023
416a9bf
Simplify TS numbers draws : create a .cpp file and move non template …
guilpier-code Dec 6, 2023
3ef29e8
Simplify TS numbers draws : moving namespace TSGenerator from Antares…
guilpier-code Dec 6, 2023
a733e0b
Simplify TS numbers draws : range based for loop instead of iterators…
guilpier-code Dec 6, 2023
f900c39
[skip ci] Simplify TS numbers draws : range based for loop instead of…
guilpier-code Dec 6, 2023
009f3d7
Simplify TS numbers draws : simplify and clarify function checkAllEle…
guilpier-code Dec 8, 2023
470524f
Simplify TS numbers draws : a bit of cleaning due to a review
guilpier-code Dec 12, 2023
d446816
Simplify TS numbers draws : comments and simplifications after code r…
guilpier-code Dec 22, 2023
b990b4c
Merge remote-tracking branch 'remotes/origin/develop' into fix/simpli…
guilpier-code Dec 27, 2023
3104805
Simplify TS numbers draws : make code compile after merge
guilpier-code Dec 27, 2023
6fff86c
Simplify TS numbers draws : make code slightly more consistent and un…
guilpier-code Dec 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ void ISimulation<Impl>::run()

ImplementationType::setNbPerformedYearsInParallel(pNbMaxPerformedYearsInParallel);

TSGenerator::ResizeGeneratedTimeSeries(study.areas, study.parameters);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations : this is the place where we call the resizing for TS to be generated.


if (settings.tsGeneratorsOnly)
{
// Only the preprocessors can be used
Expand All @@ -318,7 +320,7 @@ void ISimulation<Impl>::run()

// Destroy the TS Generators if any
// It will export the time-series into the output in the same time
Solver::TSGenerator::DestroyAll(study);
TSGenerator::DestroyAll(study);
}
else
{
Expand Down Expand Up @@ -365,7 +367,7 @@ void ISimulation<Impl>::run()
}
// Destroy the TS Generators if any
// It will export the time-series into the output in the same time
Solver::TSGenerator::DestroyAll(study);
TSGenerator::DestroyAll(study);

// Post operations
{
Expand Down Expand Up @@ -444,7 +446,7 @@ void ISimulation<Impl>::regenerateTimeSeries(uint year)
// * The option "Preprocessor" is checked in the interface _and_ year == 0
// * Both options "Preprocessor" and "Refresh" are checked in the interface
// _and_ the refresh must be done for the given year (always done for the first year).
using namespace Solver::TSGenerator;
using namespace TSGenerator;
// Load
if (pData.haveToRefreshTSLoad && (year % pData.refreshIntervalLoad == 0))
{
Expand Down
40 changes: 10 additions & 30 deletions src/solver/simulation/timeseries-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,36 +392,28 @@ bool checkInterModalConsistencyForArea(Area& area,
int indexTS = ts_to_tsIndex.at(timeSeriesLoad);
if (isTSintermodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesLoad : area.load.series.timeSeries.width;
listNumberTsOverArea.push_back(nbTimeSeries);
listNumberTsOverArea.push_back(area.load.series.timeSeries.width);
}

// Solar : Add solar's number of TS in area ...
indexTS = ts_to_tsIndex.at(timeSeriesSolar);
if (isTSintermodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesSolar : area.solar.series.timeSeries.width;
listNumberTsOverArea.push_back(nbTimeSeries);
listNumberTsOverArea.push_back(area.solar.series.timeSeries.width);
}

// Wind : Add wind's number of TS in area ...
indexTS = ts_to_tsIndex.at(timeSeriesWind);
if (isTSintermodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesWind : area.wind.series.timeSeries.width;
listNumberTsOverArea.push_back(nbTimeSeries);
listNumberTsOverArea.push_back(area.wind.series.timeSeries.width);
}

// Hydro : Add hydro's number of TS in area ...
indexTS = ts_to_tsIndex.at(timeSeriesHydro);
if (isTSintermodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesHydro : area.hydro.series->TScount();
listNumberTsOverArea.push_back(nbTimeSeries);
listNumberTsOverArea.push_back(area.hydro.series->TScount());
}

// Thermal : Add thermal's number of TS of each cluster in area ...
Expand All @@ -432,9 +424,7 @@ bool checkInterModalConsistencyForArea(Area& area,
for (uint j = 0; j != clusterCount; ++j)
{
auto& cluster = *(area.thermal.clusters[j]);
uint nbTimeSeries = isTSgenerated[indexTS] ? parameters.nbTimeSeriesThermal
: cluster.series.timeSeries.width;
listNumberTsOverArea.push_back(nbTimeSeries);
listNumberTsOverArea.push_back(cluster.series.timeSeries.width);
}
}

Expand Down Expand Up @@ -595,10 +585,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array<bool, timeSeriesCount>& i

if (!isTSintramodal[indexTS])
{
uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS]
: area.load.series.timeSeries.width;
area.load.series.timeseriesNumbers[0][year]
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.load.series.timeSeries.width));
}

// -------------
Expand All @@ -608,10 +596,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array<bool, timeSeriesCount>& i

if (!isTSintramodal[indexTS])
{
uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS]
: area.solar.series.timeSeries.width;
area.solar.series.timeseriesNumbers[0][year]
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.solar.series.timeSeries.width));
}

// -------------
Expand All @@ -621,10 +607,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array<bool, timeSeriesCount>& i

if (!isTSintramodal[indexTS])
{
uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS]
: area.wind.series.timeSeries.width;
area.wind.series.timeseriesNumbers[0][year]
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.wind.series.timeSeries.width));
}

// -------------
Expand All @@ -634,10 +618,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array<bool, timeSeriesCount>& i

if (!isTSintramodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS] : area.hydro.series->ror.timeSeries.width;
area.hydro.series->timeseriesNumbers[0][year]
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * area.hydro.series->TScount()));
}

// -------------
Expand All @@ -655,10 +637,8 @@ void drawAndStoreTSnumbersForNOTintraModal(const array<bool, timeSeriesCount>& i
{
if (!isTSintramodal[indexTS])
{
uint nbTimeSeries = isTSgenerated[indexTS] ? nbTimeseriesByMode[indexTS]
: cluster->series.timeSeries.width;
cluster->series.timeseriesNumbers[0][year] = (uint32_t)(
floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
floor(study.runtime->random[seedTimeseriesNumbers].next() * cluster->series.timeSeries.width));
}
}
}
Expand Down
13 changes: 5 additions & 8 deletions src/solver/ts-generator/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
#include <antares/writer/i_writer.h>
#include "xcast/xcast.h"

namespace Antares
{
namespace Solver
{
namespace TSGenerator
namespace Antares::Solver::TSGenerator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace Antares::Solver::TSGenerator
namespace Antares::TSGenerator

Copy link
Contributor Author

@guilpier-code guilpier-code Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You suggest that namespace TSGenerator should not be contained in namespace Solver.
That's right.
I moved TSGenerator from Antares::Solver to Antares (many changes).

{

void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params);

/*!
** \brief Regenerate the time-series
*/
Expand All @@ -63,9 +62,7 @@ void DestroyAll(Data::Study& study);
template<enum Data::TimeSeriesType T>
void Destroy(Data::Study& study, uint year);

} // namespace TSGenerator
} // namespace Solver
} // namespace Antares
} // namespace Antares::Solver::TSGenerator

#include "generator.hxx"

Expand Down
52 changes: 45 additions & 7 deletions src/solver/ts-generator/generator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,52 @@

#include <antares/logs/logs.h>

namespace Antares
namespace Antares::Solver::TSGenerator
{
namespace Solver
{
namespace TSGenerator

inline void ResizeGeneratedTimeSeries(Data::AreaList& areas, Data::Parameters& params)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
for (auto i = areas.begin(); i != areas.end(); ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use range-based for loop, no need for iterator.

Copy link
Contributor Author

@guilpier-code guilpier-code Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done : for this, I used each()

{
auto& area = *(i->second);

// Load
if (params.timeSeriesToGenerate & Data::timeSeriesLoad)
{
area.load.series.timeSeries.reset(params.nbTimeSeriesLoad, HOURS_PER_YEAR);
}

// Wind
if (params.timeSeriesToGenerate & Data::timeSeriesWind)
{
area.wind.series.timeSeries.reset(params.nbTimeSeriesWind, HOURS_PER_YEAR);
}

// Solar
if (params.timeSeriesToGenerate & Data::timeSeriesSolar)
{
area.solar.series.timeSeries.reset(params.nbTimeSeriesSolar, HOURS_PER_YEAR);
}

// Hydro
if (params.timeSeriesToGenerate & Data::timeSeriesHydro)
{
area.hydro.series->resizeRORandSTORAGE(params.nbTimeSeriesHydro);
}

// Thermal
auto end = area.thermal.list.mapping.end();
for (auto it = area.thermal.list.mapping.begin(); it != end; ++it)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
{
auto& cluster = *(it->second);
bool globalThermalTSgeneration = params.timeSeriesToGenerate & Data::timeSeriesThermal;
flomnes marked this conversation as resolved.
Show resolved Hide resolved
if (cluster.doWeGenerateTS(globalThermalTSgeneration))
cluster.series.timeSeries.resize(params.nbTimeSeriesThermal, HOURS_PER_YEAR);
}
}
}


// forward declaration
// Hydro - see hydro.cpp
bool GenerateHydroTimeSeries(Data::Study& study, uint year, IResultWriter& writer);
Expand Down Expand Up @@ -157,8 +197,6 @@ inline void DestroyAll(Data::Study& study)
Solver::TSGenerator::Destroy<Data::timeSeriesThermal>(study, (uint)-1);
}

} // namespace TSGenerator
} // namespace Solver
} // namespace Antares
} // namespace Antares::Solver::TSGenerator

#endif // __ANTARES_SOLVER_timeSeries_GENERATOR_HXX__
8 changes: 0 additions & 8 deletions src/solver/ts-generator/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ namespace Solver
{
namespace TSGenerator
{
static void PreproHydroInitMatrices(Data::Study& study, uint tsCount)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations : we separated resizing from generation, so we moved this code to another place (see generator.cpp)

{
study.areas.each([&](Data::Area& area) {
area.hydro.series->resizeRORandSTORAGE(tsCount);
});
}

static void PreproRoundAllEntriesPlusDerated(Data::Study& study)
{
Expand Down Expand Up @@ -155,8 +149,6 @@ bool GenerateHydroTimeSeries(Data::Study& study, uint currentYear, IResultWriter

uint nbTimeseries = study.parameters.nbTimeSeriesHydro;

PreproHydroInitMatrices(study, nbTimeseries);

long cumul = 0;

for (uint l = 0; l != nbTimeseries; ++l)
Expand Down
11 changes: 3 additions & 8 deletions src/solver/ts-generator/thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ class GeneratorTempData final

uint currentYear;

uint nbThermalTimeseries;

bool derated;

private:
Expand All @@ -89,6 +87,7 @@ class GeneratorTempData final
const T& duration);

private:
uint nbThermalTimeseries_;
const uint nbHoursPerYear = HOURS_PER_YEAR;
const uint daysPerYear = DAYS_PER_YEAR;

Expand Down Expand Up @@ -130,7 +129,7 @@ GeneratorTempData::GeneratorTempData(Data::Study& study,

archive = (0 != (parameters.timeSeriesToArchive & Data::timeSeriesThermal));

nbThermalTimeseries = parameters.nbTimeSeriesThermal;
nbThermalTimeseries_ = parameters.nbTimeSeriesThermal;

derated = parameters.derated;
}
Expand Down Expand Up @@ -251,15 +250,11 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust

if (0 == cluster.unitCount or 0 == cluster.nominalCapacity)
{
cluster.series.timeSeries.reset(1, nbHoursPerYear);

Comment on lines -254 to -255
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations : due to separation between TS resizing and generation, this code (resize) was moved elsewhere

if (archive)
writeResultsToDisk(area, cluster);
return;
}

cluster.series.timeSeries.resize(nbThermalTimeseries, nbHoursPerYear);

const auto& preproData = *(cluster.prepro);

int AUN = (int)cluster.unitCount;
Expand Down Expand Up @@ -355,7 +350,7 @@ void GeneratorTempData::operator()(Data::Area& area, Data::ThermalCluster& clust

double* dstSeries = nullptr;

const uint tsCount = nbThermalTimeseries + 2;
const uint tsCount = nbThermalTimeseries_ + 2;
for (uint tsIndex = 0; tsIndex != tsCount; ++tsIndex)
{
uint hour = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/solver/ts-generator/xcast/studydata.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ void StudyData::loadFromStudy(Data::Study& study,
logs.info() << " Added the area '" << area.name << "'";
localareas.push_back(&area);
}
else
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations : code moved elsewhere due to separation between TS resizing and generation

{
// resize and set the values for the matrix
predicate.matrix(area).reset(1, HOURS_PER_YEAR);
}
}
reloadDataFromAreaList(correlation);
}
Expand Down
Loading
Loading