Skip to content

Commit

Permalink
Remove RenouvelableParPalier from global variable (#1659)
Browse files Browse the repository at this point in the history
* [DEV] Remove RenouvelableParPalier from alea

* [DEV] Changed arg of valueAtTimeStep

* [DEV] use year for valueAtTimeStep calls

* [DEV] Removed RenouvelableParPalier from struct

* [FIX] warning

* [FIX] args hour, year for valueAtTimeStep

* [FIX] Remove unused var

* [DEV] Try Eolien for output var

* [FIX] Arg name for hourInYear

* [FIX] Compile

* [DEV] Add getIndex

* [DEV] Remove Eolien

* [DEV] Consommation

* [DEV] Remove Consommation from struct

* [DEV] Remove Hydraulique

* [DEV] Remove (long) conversion for getIndex

* [FIX] Replace wind with load

* [DEV] Guillaume comments

* [DEV] Solar

* [DEV] Remove NumeroChroniquesTireesParPays, struct NUMERO_CHRONIQUES_TIREES_PAR_PAYS

* [DEV] Rename getAvailablePower with getCoefficient

* [DEV] Use getCoefficient instead of scratchpad for wind

* [DEV] Use getCoefficient instead of scratchpad for solar and load

* [DEV] remove ts from scratchpad

* [DEV] problem.year as year

* [DEV] Code smell

* [DEV] Code smell 2

* [DEV] Code smell const lambda

* [DEV] Code smell const

* [DEV] getColumn

* [FIX] Results

* [FIX] windSeries

* [FIX] Use double*

* [FIX] const
  • Loading branch information
payetvin authored Oct 4, 2023
1 parent f22064c commit 715d884
Show file tree
Hide file tree
Showing 28 changed files with 123 additions and 176 deletions.
6 changes: 1 addition & 5 deletions src/libs/antares/study/area/scratchpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ namespace Antares
{
namespace Data
{
AreaScratchpad::TimeseriesData::TimeseriesData(Area& area) :
load(area.load.series->timeSeries), solar(area.solar.series->timeSeries), wind(area.wind.series->timeSeries)
{
}

AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area) : ts(area)
AreaScratchpad::AreaScratchpad(const StudyRuntimeInfos& rinfos, Area& area)
{
// alias to the simulation mode
auto mode = rinfos.mode;
Expand Down
15 changes: 0 additions & 15 deletions src/libs/antares/study/area/scratchpad.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ class AreaScratchpad final
//! Sum of all fatal hors hydro
double miscGenSum[HOURS_PER_YEAR];

//! Timeseries
struct TimeseriesData
{
TimeseriesData(Area& area);
//! Alias to the load time-series
const TSMatrix& load;
//! Alias to the solar time-series
const TSMatrix& solar;
//! Alias to the wind time-series
const TSMatrix& wind;
};

//! Timeseries
TimeseriesData ts;

bool hydroHasMod;

//! if sum(365)[pumpMaxP * pumpMaxE] > 0. then pumpHasMod = true
Expand Down
5 changes: 5 additions & 0 deletions src/libs/antares/study/parts/hydro/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,10 @@ uint64_t DataSeriesHydro::memoryUsage() const
return sizeof(double) + ror.memoryUsage() + storage.memoryUsage() + mingen.memoryUsage();
}

unsigned int DataSeriesHydro::getIndex(unsigned int year) const
{
return (count != 1) ? timeseriesNumbers[0][year] : 0;
}

} // namespace Data
} // namespace Antares
2 changes: 2 additions & 0 deletions src/libs/antares/study/parts/hydro/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class DataSeriesHydro
*/
void checkMinGenTsNumber(Study& s, const AreaName& areaID);

unsigned int getIndex(unsigned int year) const;

public:
/*!
** \brief Run-of-the-river - ROR (MW)
Expand Down
15 changes: 15 additions & 0 deletions src/libs/antares/study/parts/load/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ int DataSeriesLoadSaveToFolder(DataSeriesLoad* s, const AreaName& areaID, const
return 0;
}

double* DataSeriesLoad::getColumn(unsigned int year) const
{
return timeSeries[getIndex(year)];
}

double DataSeriesLoad::getCoefficient(const unsigned int year, const unsigned int hour) const
{
return timeSeries[getIndex(year)][hour];
}

unsigned int DataSeriesLoad::getIndex(unsigned int year) const
{
return (timeSeries.width != 1) ? timeseriesNumbers[0][year] : 0;
}

bool DataSeriesLoad::forceReload(bool reload) const
{
return timeSeries.forceReload(reload);
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/study/parts/load/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class DataSeriesLoad
*/
void markAsModified() const;

double* getColumn(unsigned int year) const;
double getCoefficient(const unsigned int year, const unsigned int hour) const;
unsigned int getIndex(unsigned int year) const;

public:
/*!
** \brief Time series (MW)
Expand Down
7 changes: 4 additions & 3 deletions src/libs/antares/study/parts/renewable/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,15 @@ YString Data::RenewableCluster::getTimeSeriesModeAsString() const
return "unknown";
}

double RenewableCluster::valueAtTimeStep(uint timeSeriesIndex, uint timeStepIndex) const
double RenewableCluster::valueAtTimeStep(uint hourInYear, uint year) const
{
if (!enabled)
return 0.;
uint timeSeriesIndex = (series->timeSeries.width == 1) ? 0 : series->timeseriesNumbers[0][year];

assert(timeStepIndex < series->timeSeries.height);
assert(hourInYear < series->timeSeries.height);
assert(timeSeriesIndex < series->timeSeries.width);
const double tsValue = series->timeSeries[timeSeriesIndex][timeStepIndex];
const double tsValue = series->timeSeries[timeSeriesIndex][hourInYear];
switch (tsMode)
{
case powerGeneration:
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/parts/renewable/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class RenewableCluster final : public Cluster
/* !
** Get production value at time-step ts
*/
double valueAtTimeStep(uint timeSeriesIndex, uint timeStepIndex) const;
double valueAtTimeStep(uint hourInYear, uint year) const;

public:
/*!
Expand Down
15 changes: 15 additions & 0 deletions src/libs/antares/study/parts/solar/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ int DataSeriesSolarSaveToFolder(DataSeriesSolar* s, const AreaName& areaID, cons
return 0;
}

double* DataSeriesSolar::getColumn(unsigned int year) const
{
return timeSeries[getIndex(year)];
}

double DataSeriesSolar::getCoefficient(const unsigned int year, const unsigned int hour) const
{
return timeSeries[getIndex(year)][hour];
}

unsigned int DataSeriesSolar::getIndex(unsigned int year) const
{
return (timeSeries.width != 1) ? timeseriesNumbers[0][year] : 0;
}

bool DataSeriesSolar::forceReload(bool reload) const
{
return timeSeries.forceReload(reload);
Expand Down
5 changes: 4 additions & 1 deletion src/libs/antares/study/parts/solar/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ class DataSeriesSolar
{
public:


bool forceReload(bool reload = false) const;

void markAsModified() const;

double* getColumn(unsigned int year) const;
double getCoefficient(const unsigned int year, const unsigned int hour) const;
unsigned int getIndex(unsigned int year) const;

public:
/*!
** \brief Time series (MW)
Expand Down
15 changes: 15 additions & 0 deletions src/libs/antares/study/parts/wind/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ int DataSeriesWindSaveToFolder(DataSeriesWind* d, const AreaName& areaID, const
return ret;
}

double* DataSeriesWind::getColumn(unsigned int year) const
{
return timeSeries[getIndex(year)];
}

double DataSeriesWind::getCoefficient(const unsigned int year, const unsigned int hour) const
{
return timeSeries[getIndex(year)][hour];
}

unsigned int DataSeriesWind::getIndex(unsigned int year) const
{
return (timeSeries.width != 1) ? timeseriesNumbers[0][year] : 0;
}

bool DataSeriesWind::forceReload(bool reload) const
{
return timeSeries.forceReload(reload);
Expand Down
4 changes: 4 additions & 0 deletions src/libs/antares/study/parts/wind/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class DataSeriesWind

void markAsModified() const;

double* getColumn(unsigned int year) const;
double getCoefficient(const unsigned int year, const unsigned int hour) const;
unsigned int getIndex(unsigned int year) const;

public:
/*!
** \brief Time series (MW)
Expand Down
60 changes: 1 addition & 59 deletions src/solver/aleatoire/alea_tirage_au_sort_chroniques.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,64 +37,6 @@ void ApplyRandomTSnumbers(const Study& study,
unsigned int year,
uint numSpace)
{
// each area
const unsigned int count = study.areas.size();
for (unsigned int areaIndex = 0; areaIndex != count; ++areaIndex)
{
// Variables - the current area
NUMERO_CHRONIQUES_TIREES_PAR_PAYS& ptchro = NumeroChroniquesTireesParPays[numSpace][areaIndex];
auto& area = *(study.areas.byIndex[areaIndex]);

// Load
{
const Data::DataSeriesLoad& data = *area.load.series;
assert(year < data.timeseriesNumbers.height);
ptchro.Consommation
= (data.timeSeries.width != 1) ? (long)data.timeseriesNumbers[0][year] : 0; // zero-based
}
// Solar
{
const Data::DataSeriesSolar& data = *area.solar.series;
assert(year < data.timeseriesNumbers.height);
ptchro.Solar
= (data.timeSeries.width != 1) ? (long)data.timeseriesNumbers[0][year] : 0; // zero-based
}
// Hydro
{
const Data::DataSeriesHydro& data = *area.hydro.series;
assert(year < data.timeseriesNumbers.height);
ptchro.Hydraulique
= (data.count != 1) ? (long)data.timeseriesNumbers[0][year] : 0; // zero-based
}
// Wind
{
const Data::DataSeriesWind& data = *area.wind.series;
assert(year < data.timeseriesNumbers.height);
ptchro.Eolien
= (data.timeSeries.width != 1) ? (long)data.timeseriesNumbers[0][year] : 0; // zero-based
}
// Renewable
{
auto end = area.renewable.list.cluster.end();
for (auto it = area.renewable.list.cluster.begin(); it != end; ++it)
{
RenewableClusterList::SharedPtr cluster = it->second;
if (!cluster->enabled)
{
continue;
}

const auto& data = *cluster->series;
assert(year < data.timeseriesNumbers.height);
unsigned int clusterIndex = cluster->areaWideIndex;

ptchro.RenouvelableParPalier[clusterIndex] = (data.timeSeries.width != 1)
? (long)data.timeseriesNumbers[0][year]
: 0; // zero-based
}
}
} // each area

// ------------------------------
// Transmission capacities
// ------------------------------
Expand All @@ -111,7 +53,7 @@ void ApplyRandomTSnumbers(const Study& study,
ptchro.TransmissionCapacities
= (directWidth != 1) ? link->timeseriesNumbers[0][year] : 0; // zero-based
}

// ------------------------------
//Binding constraints
// ------------------------------
Expand Down
4 changes: 1 addition & 3 deletions src/solver/hydro/management/daily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ inline void HydroManagement::prepareDailyOptimalGenerations(Solver::Variable::St
uint z = area.index;
assert(z < areas_.size());

auto& ptchro = NumeroChroniquesTireesParPays[numSpace][z];

auto& inflowsmatrix = area.hydro.series->storage;

auto tsIndex = (uint)ptchro.Hydraulique;
auto tsIndex = area.hydro.series->getIndex(y);
auto const& srcinflows = inflowsmatrix[tsIndex < inflowsmatrix.width ? tsIndex : 0];

auto& data = tmpDataByArea_[numSpace][z];
Expand Down
Loading

0 comments on commit 715d884

Please sign in to comment.