Skip to content

Commit

Permalink
[DEV] mingen
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 19, 2023
1 parent 7219f4e commit bd505c8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ void AreaList::removeHydroTimeseries()
each([](Data::Area& area) {
area.hydro.series->ror.reset();
area.hydro.series->storage.reset();
area.hydro.series->mingen.reset(1, HOURS_PER_YEAR);
area.hydro.series->mingen.reset();
area.hydro.series->count = 1;
});
}
Expand Down
24 changes: 14 additions & 10 deletions src/libs/antares/study/parts/hydro/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ namespace Antares
{
namespace Data
{
DataSeriesHydro::DataSeriesHydro() : ror(timeseriesNumbers), storage(timeseriesNumbers), count(0)
DataSeriesHydro::DataSeriesHydro() :
ror(timeseriesNumbers),
storage(timeseriesNumbers),
mingen(timeseriesNumbers),
count(0)
{
// Pmin was introduced in v8.6
// The previous behavior was Pmin=0
// For compatibility reasons with existing studies, mingen is set to one column of zeros
// by default
mingen.reset(1, HOURS_PER_YEAR);
mingen.reset();
}

bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& folder) const
Expand All @@ -65,7 +69,7 @@ bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& fold
buffer.clear() << folder << SEP << areaID << SEP << "mod.txt";
ret = storage.timeSeries.saveToCSVFile(buffer, 0) && ret;
buffer.clear() << folder << SEP << areaID << SEP << "mingen.txt";
ret = mingen.saveToCSVFile(buffer, 0) && ret;
ret = mingen.timeSeries.saveToCSVFile(buffer, 0) && ret;
return ret;
}
return false;
Expand All @@ -92,7 +96,7 @@ bool DataSeriesHydro::loadFromFolder(Study& study, const AreaName& areaID, const
if (study.header.version >= 860)
{
buffer.clear() << folder << SEP << areaID << SEP << "mingen." << study.inputExtension;
ret = mingen.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &study.dataBuffer) && ret;
ret = mingen.timeSeries.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &study.dataBuffer) && ret;
}

if (study.usedByTheSolver)
Expand All @@ -103,7 +107,7 @@ bool DataSeriesHydro::loadFromFolder(Study& study, const AreaName& areaID, const
<< "`: empty matrix detected. Fixing it with default values";
ror.reset();
storage.reset();
mingen.reset(1, HOURS_PER_YEAR);
mingen.reset();
}
else
{
Expand Down Expand Up @@ -165,9 +169,9 @@ bool DataSeriesHydro::loadFromFolder(Study& study, const AreaName& areaID, const

void DataSeriesHydro::checkMinGenTsNumber(Study& study, const AreaName& areaID)
{
if (mingen.width != storage.timeSeries.width)
if (mingen.timeSeries.width != storage.timeSeries.width)
{
if (mingen.width > 1)
if (mingen.timeSeries.width > 1)
{
logs.fatal() << "Hydro: `" << areaID
<< "`: The matrices Minimum Generation must "
Expand All @@ -176,9 +180,9 @@ void DataSeriesHydro::checkMinGenTsNumber(Study& study, const AreaName& areaID)
}
else
{
mingen.resizeWithoutDataLost(count, mingen.height);
mingen.timeSeries.resizeWithoutDataLost(count, mingen.timeSeries.height);
for (uint x = 1; x < count; ++x)
mingen.pasteToColumn(x, mingen[0]);
mingen.timeSeries.pasteToColumn(x, mingen[0]);
Area* areaToInvalidate = study.areas.find(areaID);
if (areaToInvalidate)
{
Expand Down Expand Up @@ -213,7 +217,7 @@ void DataSeriesHydro::reset()
{
ror.reset();
storage.reset();
mingen.reset(1, HOURS_PER_YEAR);
mingen.reset();
count = 1;
}

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 @@ -130,7 +130,7 @@ class DataSeriesHydro
**
** Merely a matrix of TimeSeriesCount * HOURS_PER_YEAR values
*/
TimeSeries::TS mingen;
TimeSeries mingen;

/*!
** \brief The number of time-series
Expand Down
16 changes: 5 additions & 11 deletions src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,9 @@ void HydroManagement::minGenerationScaling(uint numSpace, uint year) const
{
areas_.each([this, &numSpace, &year](Data::Area& area)
{
uint z = area.index;

auto& mingenmatrix = area.hydro.series->mingen;
auto tsIndex = area.hydro.series->getIndex(year);
auto const& srcmingen = mingenmatrix[tsIndex < mingenmatrix.width ? tsIndex : 0];
auto const& srcmingen = area.hydro.series->mingen.getColumn(year);

uint z = area.index;
auto& data = tmpDataByArea_[numSpace][z];
double totalYearMingen = 0.0;

Expand Down Expand Up @@ -266,10 +263,8 @@ bool HydroManagement::checkYearlyMinGeneration(uint numSpace, uint tsIndex, cons

bool HydroManagement::checkWeeklyMinGeneration(uint tsIndex, Data::Area& area) const
{
auto& inflowsmatrix = area.hydro.series->storage;
auto& mingenmatrix = area.hydro.series->mingen;
auto const& srcinflows = inflowsmatrix.getColumn(tsIndex);
auto const& srcmingen = mingenmatrix[tsIndex < mingenmatrix.width ? tsIndex : 0];
auto const& srcinflows = area.hydro.series->storage.getColumn(tsIndex);
auto const& srcmingen = area.hydro.series->mingen.getColumn(tsIndex);
// Weekly minimum generation <= Weekly inflows for each week
for (uint week = 0; week < calendar_.maxWeeksInYear - 1; ++week)
{
Expand Down Expand Up @@ -303,8 +298,7 @@ bool HydroManagement::checkWeeklyMinGeneration(uint tsIndex, Data::Area& area) c
bool HydroManagement::checkHourlyMinGeneration(uint tsIndex, Data::Area& area) const
{
// Hourly minimum generation <= hourly inflows for each hour
auto& mingenmatrix = area.hydro.series->mingen;
auto const& srcmingen = mingenmatrix[tsIndex < mingenmatrix.width ? tsIndex : 0];
auto const& srcmingen = area.hydro.series->mingen.getColumn(tsIndex);
auto const& maxPower = area.hydro.maxPower;
auto const& maxP = maxPower[Data::PartHydro::genMaxP];

Expand Down
4 changes: 1 addition & 3 deletions src/solver/simulation/sim_calcul_economique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,9 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
{
auto& area = *study.areas.byIndex[k];
auto& hydroSeries = area.hydro.series;
uint tsIndex = hydroSeries->getIndex(year);

auto const& srcinflows = hydroSeries->storage.getColumn(year);
auto& mingenmatrix = hydroSeries->mingen;
auto const& srcmingen = mingenmatrix[tsIndex < mingenmatrix.width ? tsIndex : 0];
auto const& srcmingen = hydroSeries->mingen.getColumn(year);
for (uint j = 0; j < problem.NombreDePasDeTemps; ++j)
{
problem.CaracteristiquesHydrauliques[k].MingenHoraire[j]
Expand Down
2 changes: 1 addition & 1 deletion src/ui/action/handler/antares-study/area/timeseries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bool DataTimeseries::performWL(Context& ctx)
{
ctx.area->hydro.series->ror.timeSeries = source->hydro.series->ror.timeSeries;
ctx.area->hydro.series->storage.timeSeries = source->hydro.series->storage.timeSeries;
ctx.area->hydro.series->mingen = source->hydro.series->mingen;
ctx.area->hydro.series->mingen.timeSeries = source->hydro.series->mingen.timeSeries;

ctx.area->hydro.series->count = source->hydro.series->count;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class TimeSeriesHydroMinGen final : public ATimeSeries
private:
void internalAreaChanged(Antares::Data::Area* area) override
{
matrix((area && CurrentStudyIsValid()) ? &(area->hydro.series->mingen) : NULL);
matrix((area && CurrentStudyIsValid()) ? &(area->hydro.series->mingen.timeSeries) : NULL);
Renderer::ARendererArea::internalAreaChanged(area);
}
};
Expand Down

0 comments on commit bd505c8

Please sign in to comment.