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 41 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
11 changes: 1 addition & 10 deletions src/libs/antares/series/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ using namespace Yuni;
namespace Antares::Data

Choose a reason for hiding this comment

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

This PR contains console logs. Please review or remove them.

{

const std::vector<double> TimeSeries::emptyColumn(HOURS_PER_YEAR);

TimeSeries::TimeSeries(numbers& tsNumbers) : timeseriesNumbers(tsNumbers)
{}

Expand Down Expand Up @@ -74,24 +72,17 @@ int TimeSeries::saveToFile(const std::string& filename, bool saveEvenIfAllZero)

double TimeSeries::getCoefficient(uint32_t year, uint32_t timestep) const
{
if (timeSeries.width == 0)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return 0;
return timeSeries[getSeriesIndex(year)][timestep];
}

const double* TimeSeries::getColumn(uint32_t year) const
{
if (timeSeries.width == 0)
return emptyColumn.data();
return timeSeries[getSeriesIndex(year)];
}

uint32_t TimeSeries::getSeriesIndex(uint32_t year) const
{
if (timeSeries.width == 1)
flomnes marked this conversation as resolved.
Show resolved Hide resolved
return 0;
else
return timeseriesNumbers[0][year];
return timeseriesNumbers[0][year];
}

double* TimeSeries::operator[](uint32_t index)
Expand Down
10 changes: 5 additions & 5 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,14 @@ void Area::resizeAllTimeseriesNumbers(uint n)
}
else
{
load.series.timeseriesNumbers.resize(1, n);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explanation : now we reset (resize + assign zeros), which makes TS number zero by default. This allows to reduce the amount of code in timeseries-numbers.cpp (see changes in GenerateDeratedMode(...) for instance)

Copy link
Member

Choose a reason for hiding this comment

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

Can put this as a comment in the code ?

Copy link
Contributor Author

@guilpier-code guilpier-code Dec 22, 2023

Choose a reason for hiding this comment

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

Can put this as a comment in the code ?

What kind of comment do you want to put exactly ?
I also just made some more simplifications here, based on the fact that n is a number of years, and can never be 0 (I checked).

solar.series.timeseriesNumbers.resize(1, n);
wind.series.timeseriesNumbers.resize(1, n);
hydro.series->timeseriesNumbers.resize(1, n);
load.series.timeseriesNumbers.reset(1, n);
solar.series.timeseriesNumbers.reset(1, n);
wind.series.timeseriesNumbers.reset(1, n);
hydro.series->timeseriesNumbers.reset(1, n);
for (auto& namedLink : links)
{
AreaLink* link = namedLink.second;
link->timeseriesNumbers.resize(1, n);
link->timeseriesNumbers.reset(1, n);
}
}
thermal.resizeAllTimeseriesNumbers(n);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ namespace Antares::Data {
return constraints_;
}

void BindingConstraintGroup::fixTSNumbersWhenWidthIsOne() {
if (std::all_of(constraints_.begin(), constraints_.end(), [](auto constraint){
return constraint->RHSTimeSeries().width == 1;
})) {
timeseriesNumbers.fillColumn(0, 0);
}
}

unsigned BindingConstraintGroup::numberOfTimeseries() const {
//Assume all BC in a group have the same width
if (constraints_.empty()) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class BindingConstraintGroup {
[[nodiscard]] std::string name() { return name_; }
void add(const std::shared_ptr<BindingConstraint>& constraint);
[[nodiscard]] std::set<std::shared_ptr<BindingConstraint>> constraints() const;
void fixTSNumbersWhenWidthIsOne();
[[nodiscard]] unsigned numberOfTimeseries() const;

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ namespace Antares::Data {
void BindingConstraintGroupRepository::resizeAllTimeseriesNumbers(unsigned int nb_years) {
std::for_each(groups_.begin(), groups_.end(), [&](auto &group) {
group->timeseriesNumbers.clear();
group->timeseriesNumbers.resize(1, nb_years);
});
}

void BindingConstraintGroupRepository::fixTSNumbersWhenWidthIsOne() {
std::for_each(groups_.begin(), groups_.end(), [](auto& group) {
group->fixTSNumbersWhenWidthIsOne();
group->timeseriesNumbers.reset(1, nb_years);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class BindingConstraintGroupRepository {

void resizeAllTimeseriesNumbers(unsigned nb_years);

void fixTSNumbersWhenWidthIsOne();

BindingConstraintGroup* operator[](const std::string& name) const;

using iterator = std::vector<std::unique_ptr<BindingConstraintGroup>>::iterator;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/parts/common/cluster_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void ClusterList<ClusterT>::resizeAllTimeseriesNumbers(uint n)
}
else
{
each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.resize(1, n); });
each([&](Cluster& cluster) { cluster.series.timeseriesNumbers.reset(1, n); });
}
}
}
Expand Down
19 changes: 15 additions & 4 deletions src/libs/antares/study/parts/hydro/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,22 @@ void DataSeriesHydro::reset()
count = 1;
}

void DataSeriesHydro::resizeRORandSTORAGE(unsigned int width)
void DataSeriesHydro::resize_ROR_STORAGE_MINGEN_whenGeneratedTS(unsigned int newWidth)
{
ror.resize(width, HOURS_PER_YEAR);
storage.resize(width, DAYS_PER_YEAR);
count = width;
ror.resize(newWidth, HOURS_PER_YEAR);
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 : in case we generate hydro TS, ror and storage are generated, but not mingen.
So ror and storage are resized and completely overridden. But we must be careful with mingen TS : it is only resized, but we don't want to loose existing mingen TS given by the user :

  • If we extend mingen TS, we keep TS given by users (and fill the extra ones with a copy of the first TS)
  • if we reduce mingen TS, we can remove extra TS given by user, but we must keep the left ones intact

Copy link
Member

Choose a reason for hiding this comment

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

Can you include this as a comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you include this as a comment ?

Done

storage.resize(newWidth, DAYS_PER_YEAR);

// Resizing mingen : new extra columns are copies of the first column.
// Note that mingen has necessarily one column at least, by construction
flomnes marked this conversation as resolved.
Show resolved Hide resolved
uint mingenOriginalSize = mingen.timeSeries.width;
mingen.timeSeries.resizeWithoutDataLost(newWidth, mingen.timeSeries.height);
if (mingenOriginalSize < newWidth)
{
for (uint col = mingenOriginalSize; col < newWidth; ++col)
mingen.timeSeries.pasteToColumn(col, mingen[0]);
}

count = newWidth;
}

void DataSeriesHydro::resizeGenerationTS(unsigned int w, unsigned int h)
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/parts/hydro/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DataSeriesHydro
*/
void reset();

void resizeRORandSTORAGE(unsigned int width);
void resize_ROR_STORAGE_MINGEN_whenGeneratedTS(unsigned int width);
void resizeGenerationTS(unsigned int w, unsigned int h);

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/parts/solar/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ uint64_t Container::memoryUsage() const

void Container::resetToDefault()
{
series.timeSeries.reset();
series.reset();
if (prepro)
prepro->resetToDefault();
}
Expand Down
8 changes: 5 additions & 3 deletions src/solver/simulation/solver.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,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 @@ -323,7 +325,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 @@ -370,7 +372,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 @@ -449,7 +451,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
Loading
Loading