Skip to content

Commit

Permalink
[DEV] solar series
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 6, 2023
1 parent a0fc02c commit fb1caae
Show file tree
Hide file tree
Showing 18 changed files with 46 additions and 76 deletions.
7 changes: 2 additions & 5 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ void Area::createMissingData()

void Area::createMissingTimeSeries()
{
if (!solar.series)
solar.series = new DataSeriesSolar();
if (!hydro.series)
hydro.series = new DataSeriesHydro();
thermal.list.ensureDataTimeSeries();
Expand Down Expand Up @@ -265,13 +263,12 @@ void Area::resizeAllTimeseriesNumbers(uint n)
assert(n < 200000); // arbitrary number

// asserts
assert(solar.series and "solar.series must not be nullptr !");
assert(hydro.series and "series must not be nullptr !");

if (!n)
{
load.series.timeseriesNumbers.clear();
solar.series->timeseriesNumbers.clear();
solar.series.timeseriesNumbers.clear();
wind.series.timeseriesNumbers.clear();
hydro.series->timeseriesNumbers.clear();
for (auto& namedLink : links)
Expand All @@ -283,7 +280,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
else
{
load.series.timeseriesNumbers.resize(1, n);
solar.series->timeseriesNumbers.resize(1, n);
solar.series.timeseriesNumbers.resize(1, n);
wind.series.timeseriesNumbers.resize(1, n);
hydro.series->timeseriesNumbers.resize(1, n);
for (auto& namedLink : links)
Expand Down
5 changes: 0 additions & 5 deletions src/libs/antares/study/area/area.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,11 +800,6 @@ void AreaListClearAllLinks(AreaList* l);
*/
void AreaListEnsureDataLoadPrepro(AreaList* l);

/*!
** \brief Ensure data for load time-series are initialized
*/
void AreaListEnsureDataSolarTimeSeries(AreaList* l);

/*!
** \brief Ensure data for solar prepro are initialized
*/
Expand Down
25 changes: 5 additions & 20 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,8 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const
<< area.id;
ret = area.solar.prepro->saveToFolder(buffer) && ret;
}
if (area.solar.series) // Series
{
buffer.clear() << folder << SEP << "input" << SEP << "solar" << SEP << "series";
ret = DataSeriesSolarSaveToFolder(area.solar.series, area.id, buffer.c_str()) && ret;
}
buffer.clear() << folder << SEP << "input" << SEP << "solar" << SEP << "series";
ret = area.solar.series.timeSeriesSaveToFolder(area.id, buffer.c_str(), "solar_") && ret;
}

// Hydro
Expand Down Expand Up @@ -872,10 +869,10 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
<< area.id;
ret = area.solar.prepro->loadFromFolder(buffer) && ret;
}
if (area.solar.series && (!options.loadOnlyNeeded || !area.solar.prepro)) // Series
if (!options.loadOnlyNeeded || !area.solar.prepro) // Series
{
buffer.clear() << study.folderInput << SEP << "solar" << SEP << "series";
ret = DataSeriesSolarLoadFromFolder(study, area.solar.series, area.id, buffer.c_str())
ret = area.solar.series.timeSeriesLoadFromFolder(study, area.id, buffer.c_str(), "solar_")
&& ret;
}

Expand Down Expand Up @@ -1031,7 +1028,6 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,

void AreaList::ensureDataIsInitialized(Parameters& params, bool loadOnlyNeeded)
{
AreaListEnsureDataSolarTimeSeries(this);
AreaListEnsureDataHydroTimeSeries(this);
AreaListEnsureDataThermalTimeSeries(this);
AreaListEnsureDataRenewableTimeSeries(this);
Expand Down Expand Up @@ -1250,17 +1246,6 @@ void AreaListEnsureDataLoadPrepro(AreaList* l)
});
}

void AreaListEnsureDataSolarTimeSeries(AreaList* l)
{
/* Asserts */
assert(l);

l->each([&](Data::Area& area) {
if (!area.solar.series)
area.solar.series = new DataSeriesSolar();
});
}

void AreaListEnsureDataSolarPrepro(AreaList* l)
{
/* Asserts */
Expand Down Expand Up @@ -1590,7 +1575,7 @@ void AreaList::removeHydroTimeseries()

void AreaList::removeSolarTimeseries()
{
each([&](Data::Area& area) { area.solar.series->timeSeries.reset(1, HOURS_PER_YEAR); });
each([&](Data::Area& area) { area.solar.series.timeSeries.reset(1, HOURS_PER_YEAR); });
}

void AreaList::removeWindTimeseries()
Expand Down
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/store-timeseries-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void storeTimeseriesNumbersForLoad(Solver::IResultWriter& writer, const Area& ar

void storeTimeseriesNumbersForSolar(Solver::IResultWriter& writer, const Area& area)
{
genericStoreTimeseriesNumbers(writer, area.solar.series->timeseriesNumbers, area.id, "solar");
genericStoreTimeseriesNumbers(writer, area.solar.series.timeseriesNumbers, area.id, "solar");
}

void storeTimeseriesNumbersForHydro(Solver::IResultWriter& writer, const Area& area)
Expand Down
17 changes: 6 additions & 11 deletions src/libs/antares/study/parts/solar/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,44 +38,39 @@ namespace Data
{
namespace Solar
{
Container::Container() : prepro(nullptr), series(nullptr)
{
}
Container::Container() : prepro(nullptr)
{}

Container::~Container()
{
delete prepro;
delete series;
}

bool Container::forceReload(bool reload) const
{
bool ret = true;
if (series)
ret = series->forceReload(reload) && ret;
ret = series.forceReload(reload) && ret;
if (prepro)
ret = prepro->forceReload(reload) && ret;
return ret;
}

void Container::markAsModified() const
{
if (series)
series->markAsModified();
series.markAsModified();
if (prepro)
prepro->markAsModified();
}

uint64_t Container::memoryUsage() const
{
return sizeof(Container) + ((!series) ? 0 : DataSeriesSolarMemoryUsage(series))
return sizeof(Container) + series.memoryUsage()
+ ((!prepro) ? 0 : prepro->memoryUsage());
}

void Container::resetToDefault()
{
if (series)
series->timeSeries.reset(1, HOURS_PER_YEAR);
series.timeSeries.reset();
if (prepro)
prepro->resetToDefault();
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/parts/solar/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef __ANTARES_LIBS_STUDY_PARTS_SOLAR_CONTAINER_H__
#define __ANTARES_LIBS_STUDY_PARTS_SOLAR_CONTAINER_H__

#include "series.h"
#include <antares/study/parts/common/series.h>

namespace Antares
{
Expand Down Expand Up @@ -73,7 +73,7 @@ class Container
//! Data for the pre-processor
Data::Solar::Prepro* prepro;
/*! Data for time-series */
DataSeriesSolar* series;
TimeSeries series;

}; // class Container

Expand Down
4 changes: 2 additions & 2 deletions src/libs/antares/study/scenario-builder/SolarTSNumberData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ bool solarTSNumberData::apply(Study& study)
const MatrixType::ColumnType& col = pTSNumberRules[areaIndex];

logprefix.clear() << "Solar: area '" << area.name << "': ";
ret = ApplyToMatrix(errors, logprefix, *area.solar.series, col, tsGenCountSolar) && ret;
ret = ApplyToMatrix(errors, logprefix, area.solar.series, col, tsGenCountSolar) && ret;
}
return ret;
}
}
}
3 changes: 1 addition & 2 deletions src/libs/antares/study/study.importprepro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ bool Study::importTimeseriesIntoInput()
areas.each([&](const Data::Area& area) {
logs.info() << "Importing solar timeseries : " << area.name;
buffer.clear() << folderInput << SEP << "solar" << SEP << "series";
ret
= DataSeriesSolarSaveToFolder(area.solar.series, area.id, buffer.c_str()) && ret;
ret = area.solar.series.timeSeriesSaveToFolder(area.id, buffer.c_str(), "solar_") && ret;
++progression;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/solver/hydro/management/management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void HydroManagement::prepareNetDemand(uint numSpace, uint year)
auto& data = tmpDataByArea_[numSpace][z];
const double* loadSeries = area.load.series.getColumn(year);
const double* windSeries = area.wind.series.getColumn(year);
const double* solarSeries = area.solar.series->getColumn(year);
const double* solarSeries = area.solar.series.getColumn(year);

for (uint hour = 0; hour != HOURS_PER_YEAR; ++hour)
{
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 @@ -572,7 +572,7 @@ void SIM_RenseignementProblemeHebdo(const Study& study,
auto& ror = area.hydro.series->ror;
auto loadSeries = area.load.series.getCoefficient(year, hourInYear);
auto windSeries = area.wind.series.getCoefficient(year, hourInYear);
auto solarSeries = area.solar.series->getCoefficient(year, hourInYear);
auto solarSeries = area.solar.series.getCoefficient(year, hourInYear);
auto hydroSeriesIndex = area.hydro.series->getIndex(year);

assert(&scratchpad);
Expand Down
22 changes: 11 additions & 11 deletions src/solver/simulation/timeseries-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static bool GenerateDeratedMode(Study& study)

study.areas.each([&](Area& area) {
area.load.series.timeseriesNumbers.zero();
area.solar.series->timeseriesNumbers.zero();
area.solar.series.timeseriesNumbers.zero();
area.wind.series.timeseriesNumbers.zero();
area.hydro.series->timeseriesNumbers.zero();

Expand Down Expand Up @@ -182,7 +182,7 @@ class solarAreaNumberOfTSretriever : public areaNumberOfTSretriever
}
std::vector<uint> getAreaTimeSeriesNumber(const Area& area)
{
std::vector<uint> to_return = {area.solar.series->timeSeries.width};
std::vector<uint> to_return = {area.solar.series.timeSeries.width};
return to_return;
}
uint getGeneratedTimeSeriesNumber()
Expand Down Expand Up @@ -402,7 +402,7 @@ bool checkInterModalConsistencyForArea(Area& area,
if (isTSintermodal[indexTS])
{
uint nbTimeSeries
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesSolar : area.solar.series->timeSeries.width;
= isTSgenerated[indexTS] ? parameters.nbTimeSeriesSolar : area.solar.series.timeSeries.width;
listNumberTsOverArea.push_back(nbTimeSeries);
}

Expand Down Expand Up @@ -509,11 +509,11 @@ void storeTSnumbersForIntraModal(const array<uint32_t, timeSeriesCount>& intramo
// -------------
// Solar ...
// -------------
assert(year < area.solar.series->timeseriesNumbers.height);
assert(year < area.solar.series.timeseriesNumbers.height);
indexTS = ts_to_tsIndex.at(timeSeriesSolar);

if (isTSintramodal[indexTS])
area.solar.series->timeseriesNumbers[0][year] = intramodal_draws[indexTS];
area.solar.series.timeseriesNumbers[0][year] = intramodal_draws[indexTS];

// -------------
// Wind ...
Expand Down Expand Up @@ -609,8 +609,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]
: area.solar.series.timeSeries.width;
area.solar.series.timeseriesNumbers[0][year]
= (uint32_t)(floor(study.runtime->random[seedTimeseriesNumbers].next() * nbTimeSeries));
}

Expand Down Expand Up @@ -738,7 +738,7 @@ Matrix<uint32_t>* getFirstTSnumberInterModalMatrixFoundInArea(
else
{
if (isTSintermodal[ts_to_tsIndex.at(timeSeriesSolar)])
tsNumbersMtx = &(area.solar.series->timeseriesNumbers);
tsNumbersMtx = &(area.solar.series.timeseriesNumbers);
else if (isTSintermodal[ts_to_tsIndex.at(timeSeriesWind)])
tsNumbersMtx = &(area.wind.series.timeseriesNumbers);
else if (isTSintermodal[ts_to_tsIndex.at(timeSeriesHydro)])
Expand Down Expand Up @@ -769,9 +769,9 @@ void applyMatrixDrawsToInterModalModesInArea(Matrix<uint32_t>* tsNumbersMtx,
if (isTSintermodal[ts_to_tsIndex.at(timeSeriesLoad)])
area.load.series.timeseriesNumbers[0][year] = draw;

assert(year < area.solar.series->timeseriesNumbers.height);
assert(year < area.solar.series.timeseriesNumbers.height);
if (isTSintermodal[ts_to_tsIndex.at(timeSeriesSolar)])
area.solar.series->timeseriesNumbers[0][year] = draw;
area.solar.series.timeseriesNumbers[0][year] = draw;

assert(year < area.wind.series.timeseriesNumbers.height);
if (isTSintermodal[ts_to_tsIndex.at(timeSeriesWind)])
Expand Down Expand Up @@ -826,7 +826,7 @@ static void fixTSNumbersWhenWidthIsOne(Study& study)
area.load.series.timeseriesNumbers, area.load.series.timeSeries.width, years);
// Solar
fixTSNumbersSingleAreaSingleMode(
area.solar.series->timeseriesNumbers, area.solar.series->timeSeries.width, years);
area.solar.series.timeseriesNumbers, area.solar.series.timeSeries.width, years);
// Wind
fixTSNumbersSingleAreaSingleMode(
area.wind.series.timeseriesNumbers, area.wind.series.timeSeries.width, years);
Expand Down
3 changes: 1 addition & 2 deletions src/solver/ts-generator/xcast/predicate.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ public:

Matrix<double, int32_t>& matrix(Data::Area& area) const
{
assert(area.solar.series != NULL);
return area.solar.series->timeSeries;
return area.solar.series.timeSeries;
}

Data::XCast& xcastData(Data::Area& area) const
Expand Down
4 changes: 2 additions & 2 deletions src/solver/variable/commons/solar.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ class TimeSeriesValuesSolar
{
// The current solar time-series
(void)::memcpy(pValuesForTheCurrentYear[numSpace].hour,
pArea->solar.series->getColumn(year),
sizeof(double) * pArea->solar.series->timeSeries.height);
pArea->solar.series.getColumn(year),
sizeof(double) * pArea->solar.series.timeSeries.height);
}

// Next variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ struct Fixture

// Solar : set the nb of ready made TS
nbReadyMadeTS = 9;
area_1->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_2->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_3->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_1->solar.series.timeSeries.resize(nbReadyMadeTS, 1);
area_2->solar.series.timeSeries.resize(nbReadyMadeTS, 1);
area_3->solar.series.timeSeries.resize(nbReadyMadeTS, 1);

// Hydro : set the nb of ready made TS
nbReadyMadeTS = 12;
Expand Down Expand Up @@ -213,7 +213,7 @@ BOOST_FIXTURE_TEST_CASE(on_area1_and_on_year_4__solar_TS_number_8_is_chosen__rea
BOOST_CHECK_EQUAL(my_rule.solar.get_value(yearNumber.to<uint>(), area_1->index), tsNumber.to<uint>());

BOOST_CHECK(my_rule.apply());
BOOST_CHECK_EQUAL(area_1->solar.series->timeseriesNumbers[0][yearNumber.to<uint>()], tsNumber.to<uint>() - 1);
BOOST_CHECK_EQUAL(area_1->solar.series.timeseriesNumbers[0][yearNumber.to<uint>()], tsNumber.to<uint>() - 1);
}

// =================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ struct commonFixture

// Solar : set the nb of ready made TS
nbReadyMadeTS = 9;
area_1->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_2->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_3->solar.series->timeSeries.resize(nbReadyMadeTS, 1);
area_1->solar.series.timeSeries.resize(nbReadyMadeTS, 1);
area_2->solar.series.timeSeries.resize(nbReadyMadeTS, 1);
area_3->solar.series.timeSeries.resize(nbReadyMadeTS, 1);

// Hydro : set the nb of ready made TS
nbReadyMadeTS = 12;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/src/solver/simulation/tests-ts-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ BOOST_AUTO_TEST_CASE(check_all_drawn_ts_numbers_are_bounded_between_0_and_nb_of_
uint year = 0;
uint loadTsNumber = area->load.series.timeseriesNumbers[0][year];
uint windTsNumber = area->wind.series.timeseriesNumbers[0][year];
uint solarTsNumber = area->solar.series->timeseriesNumbers[0][year];
uint solarTsNumber = area->solar.series.timeseriesNumbers[0][year];
uint hydroTsNumber = area->hydro.series->timeseriesNumbers[0][year];
uint thermalTsNumber = thCluster->series->timeseriesNumbers[0][year];
auto binding_constraints_TS_number = study->bindingConstraintsGroups["dummy"]->timeseriesNumbers[0][year];
Expand Down
4 changes: 2 additions & 2 deletions src/ui/action/handler/antares-study/area/timeseries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ bool DataTimeseries::performWL(Context& ctx)
}
case Data::timeSeriesSolar:
{
ctx.area->solar.series->timeSeries = source->solar.series->timeSeries;
source->solar.series->timeSeries.unloadFromMemory();
ctx.area->solar.series.timeSeries = source->solar.series.timeSeries;
source->solar.series.timeSeries.unloadFromMemory();
break;
}
case Data::timeSeriesWind:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class TimeSeriesSolar final : public ATimeSeries
protected:
virtual void internalAreaChanged(Antares::Data::Area* area)
{
matrix((area && CurrentStudyIsValid()) ? &(area->solar.series->timeSeries) : NULL);
matrix((area && CurrentStudyIsValid()) ? &(area->solar.series.timeSeries) : NULL);
Renderer::ARendererArea::internalAreaChanged(area);
}
};
Expand Down

0 comments on commit fb1caae

Please sign in to comment.