Skip to content

Commit

Permalink
[DEV] Wind compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Oct 5, 2023
1 parent c242069 commit 1d20d99
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 59 deletions.
4 changes: 2 additions & 2 deletions src/libs/antares/study/area/area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
{
load.series->timeseriesNumbers.clear();
solar.series->timeseriesNumbers.clear();
wind.series.tsNumbers.clear();
wind.series.timeseriesNumbers.clear();
hydro.series->timeseriesNumbers.clear();
for (auto& namedLink : links)
{
Expand All @@ -287,7 +287,7 @@ void Area::resizeAllTimeseriesNumbers(uint n)
{
load.series->timeseriesNumbers.resize(1, n);
solar.series->timeseriesNumbers.resize(1, n);
wind.series.tsNumbers.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 @@ -815,11 +815,6 @@ void AreaListEnsureDataSolarTimeSeries(AreaList* l);
*/
void AreaListEnsureDataSolarPrepro(AreaList* l);

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

/*!
** \brief Ensure data for wind prepro are initialized
*/
Expand Down
14 changes: 1 addition & 13 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
if (!options.loadOnlyNeeded || !area.wind.prepro) // Series
{
buffer.clear() << study.folderInput << SEP << "wind" << SEP << "series";
ret = DataSeriesWindLoadFromFolder(study, area.wind.series, area.id, buffer.c_str())
ret = area.wind.series.timeSeriesLoadFromFolder(study, area.id, buffer.c_str(), "wind_")
&& ret;
}

Expand Down Expand Up @@ -1036,7 +1036,6 @@ void AreaList::ensureDataIsInitialized(Parameters& params, bool loadOnlyNeeded)
{
AreaListEnsureDataLoadTimeSeries(this);
AreaListEnsureDataSolarTimeSeries(this);
AreaListEnsureDataWindTimeSeries(this);
AreaListEnsureDataHydroTimeSeries(this);
AreaListEnsureDataThermalTimeSeries(this);
AreaListEnsureDataRenewableTimeSeries(this);
Expand Down Expand Up @@ -1288,17 +1287,6 @@ void AreaListEnsureDataSolarPrepro(AreaList* l)
});
}

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

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

void AreaListEnsureDataWindPrepro(AreaList* l)
{
/* Asserts */
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 @@ -84,7 +84,7 @@ void storeTimeseriesNumbersForHydro(Solver::IResultWriter& writer, const Area& a

void storeTimeseriesNumbersForWind(Solver::IResultWriter& writer, const Area& area)
{
genericStoreTimeseriesNumbers(writer, area.wind.series.tsNumbers, area.id, "wind");
genericStoreTimeseriesNumbers(writer, area.wind.series.timeseriesNumbers, area.id, "wind");
}

void storeTimeseriesNumbersForThermal(Solver::IResultWriter& writer, const Area& area)
Expand Down
22 changes: 11 additions & 11 deletions src/libs/antares/study/parts/common/series.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,55 @@ int TimeSeries::timeSeriesLoadFromFolder(Study& s,

int ret = 1;
buffer.clear() << folder << SEP << filename << areaID << '.' << s.inputExtension;
ret = coefficients.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &s.dataBuffer) && ret;
ret = timeSeries.loadFromCSVFile(buffer, 1, HOURS_PER_YEAR, &s.dataBuffer) && ret;

if (s.usedByTheSolver && s.parameters.derated)
coefficients.averageTimeseries();
timeSeries.averageTimeseries();

tsNumbers.clear();
timeseriesNumbers.clear();

return ret;
}

int TimeSeries::timeSeriesSaveToFolder(const AreaName& areaID, const std::string& folder,
const std::string& filename)
const std::string& filename) const
{
Clob buffer;
int ret = 1;
buffer.clear() << folder << SEP << filename << areaID << ".txt";
ret = coefficients.saveToCSVFile(buffer, 0) && ret;
ret = timeSeries.saveToCSVFile(buffer, 0) && ret;

return ret;
}

void TimeSeries::reset()
{
coefficients.reset(1, HOURS_PER_YEAR);
timeSeries.reset(1, HOURS_PER_YEAR);
}

double TimeSeries::getCoefficient(uint32_t year, uint32_t hourInYear) const
{
return coefficients[tsNumbers[year]][hourInYear];
return timeSeries[*timeseriesNumbers[year]][hourInYear];
}

double* TimeSeries::getColumn(uint32_t year) const
{
return coefficients[tsNumbers[year]];
return timeSeries[*timeseriesNumbers[year]];
}

bool TimeSeries::forceReload(bool reload) const
{
return coefficients.forceReload(reload);
return timeSeries.forceReload(reload);
}

void TimeSeries::markAsModified() const
{
coefficients.markAsModified();
timeSeries.markAsModified();
}

uint64_t TimeSeries::memoryUsage() const
{
return coefficients.memoryUsage();
return timeSeries.memoryUsage();
}

bool DataSeriesCommon::forceReload(bool reload) const
Expand Down
7 changes: 4 additions & 3 deletions src/libs/antares/study/parts/common/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class TimeSeries
{
public:
typedef Matrix<uint32_t> TSNumbers;

/*!
** \brief Load series from a file
**
Expand All @@ -61,7 +62,7 @@ class TimeSeries
** \return A non-zero value if the operation succeeded, 0 otherwise
*/
int timeSeriesSaveToFolder(const AreaName& areaID, const std::string& folder,
const std::string& filename);
const std::string& filename) const;

double getCoefficient(uint32_t year, uint32_t hourInYear) const;
double* getColumn(uint32_t year) const;
Expand All @@ -72,8 +73,8 @@ class TimeSeries
void markAsModified() const;
uint64_t memoryUsage() const;

Matrix<double, int32_t> coefficients;
TSNumbers tsNumbers;
Matrix<double, int32_t> timeSeries;
TSNumbers timeseriesNumbers;
};

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

logprefix.clear() << "Wind: area '" << area.name << "': ";
ret = ApplyToMatrix(errors, logprefix, *area.wind.series, col, tsGenCountWind) && ret;
ret = ApplyToMatrix(errors, logprefix, area.wind.series, col, tsGenCountWind) && ret;
}
return ret;
}
}
}
2 changes: 1 addition & 1 deletion src/libs/antares/study/study.importprepro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool Study::importTimeseriesIntoInput()
areas.each([&](const Data::Area& area) {
logs.info() << "Importing wind timeseries : " << area.name;
buffer.clear() << folderInput << SEP << "wind" << SEP << "series";
ret = DataSeriesWindSaveToFolder(area.wind.series, area.id, buffer.c_str()) && ret;
area.wind.series.timeSeriesSaveToFolder(area.id, buffer.c_str(), "wind_") && ret;
++progression;
});
}
Expand Down
1 change: 0 additions & 1 deletion src/solver/ts-generator/xcast/predicate.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public:

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ struct Fixture

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

// Solar : set the nb of ready made TS
nbReadyMadeTS = 9;
Expand Down Expand Up @@ -197,7 +197,7 @@ BOOST_FIXTURE_TEST_CASE(on_area3_and_on_year_7__wind_TS_number_5_is_chosen__read
BOOST_CHECK_EQUAL(my_rule.wind.get_value(yearNumber.to<uint>(), area_3->index), tsNumber.to<uint>());

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

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

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

// Solar : set the nb of ready made TS
nbReadyMadeTS = 9;
Expand Down
20 changes: 10 additions & 10 deletions src/tests/src/solver/simulation/tests-ts-numbers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same
area->load.series->timeSeries.resize(5, 1); // Ready made TS for load

// ... Wind
area->wind.series->timeSeries.resize(5, 1); // Ready made TS for wind
area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind

// ... Thermal
study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal
Expand All @@ -433,7 +433,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same
// TS number checks
uint year = 0;
uint drawnTsNbForLoad = area->load.series->timeseriesNumbers[0][year];
BOOST_CHECK_EQUAL(area->wind.series->timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(area->wind.series.timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(thCluster_1->series->timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(thCluster_2->series->timeseriesNumbers[0][year], drawnTsNbForLoad);
}
Expand All @@ -455,7 +455,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same
area->load.series->timeSeries.resize(1, 1); // Ready made TS for load

// ... Wind
area->wind.series->timeSeries.resize(5, 1); // Ready made TS for wind
area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind

// ... Thermal
study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal
Expand All @@ -471,7 +471,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__same
// TS number checks
uint year = 0;
uint drawnTsNbForLoad = area->load.series->timeseriesNumbers[0][year];
BOOST_CHECK_EQUAL(area->wind.series->timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(area->wind.series.timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(thCluster_1->series->timeseriesNumbers[0][year], drawnTsNbForLoad);
BOOST_CHECK_EQUAL(thCluster_2->series->timeseriesNumbers[0][year], drawnTsNbForLoad);
}
Expand All @@ -493,7 +493,7 @@ BOOST_AUTO_TEST_CASE(one_area__load_wind_thermal_are_turned_to_inter_modal__diff
area->load.series->timeSeries.resize(5, 1); // Ready made TS for load

// ... Wind
area->wind.series->timeSeries.resize(5, 1); // Ready made TS for wind
area->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind

// ... Thermal
study->parameters.timeSeriesToRefresh |= timeSeriesThermal; // Generated TS for thermal
Expand Down Expand Up @@ -624,7 +624,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_
// ... Load
area_1->load.series->timeSeries.resize(5, 1); // Ready made TS for load
// ... Wind
area_1->wind.series->timeSeries.resize(5, 1); // Ready made TS for wind
area_1->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind
// ... Thermal
auto thCluster_area_1 = addClusterToArea<ThermalCluster>(area_1, "th-cluster-area-1");

Expand All @@ -637,7 +637,7 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_
// ... Load
area_2->load.series->timeSeries.resize(5, 1); // Ready made TS for load
// ... Wind
area_2->wind.series->timeSeries.resize(5, 1); // Ready made TS for wind
area_2->wind.series.timeSeries.resize(5, 1); // Ready made TS for wind
// ... Thermal
auto thCluster_area_2 = addClusterToArea<ThermalCluster>(area_2, "th-cluster-area-2");

Expand All @@ -651,8 +651,8 @@ BOOST_AUTO_TEST_CASE(load_wind_thermal_in_intra_and_inter_modal____check_all_ts_
uint year = 0;
uint referenceLoadTsNumber = area_1->load.series->timeseriesNumbers[0][year];
BOOST_CHECK_EQUAL(area_2->load.series->timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(area_1->wind.series->timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(area_2->wind.series->timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(area_1->wind.series.timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(area_2->wind.series.timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(thCluster_area_1->series->timeseriesNumbers[0][year], referenceLoadTsNumber);
BOOST_CHECK_EQUAL(thCluster_area_2->series->timeseriesNumbers[0][year], referenceLoadTsNumber);
}
Expand Down Expand Up @@ -701,7 +701,7 @@ BOOST_AUTO_TEST_CASE(check_all_drawn_ts_numbers_are_bounded_between_0_and_nb_of_
// TS number checks : each energy drawn ts numbers are up-bounded with the number of TS of the related energy
uint year = 0;
uint loadTsNumber = area->load.series->timeseriesNumbers[0][year];
uint windTsNumber = area->wind.series->timeseriesNumbers[0][year];
uint windTsNumber = area->wind.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];
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 @@ -149,8 +149,8 @@ bool DataTimeseries::performWL(Context& ctx)
}
case Data::timeSeriesWind:
{
ctx.area->wind.series->timeSeries = source->wind.series->timeSeries;
source->wind.series->timeSeries.unloadFromMemory();
ctx.area->wind.series.timeSeries = source->wind.series.timeSeries;
source->wind.series.timeSeries.unloadFromMemory();
break;
}
case Data::timeSeriesHydro:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class TimeSeriesWind final : public ATimeSeries
protected:
virtual void internalAreaChanged(Antares::Data::Area* area)
{
matrix((area && CurrentStudyIsValid()) ? &(area->wind.series->timeSeries) : NULL);
matrix((area && CurrentStudyIsValid()) ? &(area->wind.series.timeSeries) : NULL);
Renderer::ARendererArea::internalAreaChanged(area);
}
};
Expand Down

0 comments on commit 1d20d99

Please sign in to comment.