From f94134a4647481fb49e9fc0fc3ac113c541a6b63 Mon Sep 17 00:00:00 2001 From: Abdoulbari Zaher <32519851+a-zakir@users.noreply.github.com> Date: Mon, 10 Feb 2025 10:09:27 +0100 Subject: [PATCH 1/3] Feature/copilot instructions (#2609) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Florian Omnès --- .github/copilot-instructions.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000000..ad1bb408018 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1 @@ +read the instructions from file 6-Contributing.md \ No newline at end of file From 6891f9e7f087b0bbb8aeadc1598059475222f14a Mon Sep 17 00:00:00 2001 From: guilpier-code <62292552+guilpier-code@users.noreply.github.com> Date: Mon, 10 Feb 2025 13:01:04 +0100 Subject: [PATCH 2/3] Fix the upgrade from v8.8 to 9.2 of hydro power matrices [ANT-2742] (#2625) Fixes problem described in issue [ANT-2742](https://gopro-tickets.rte-france.com/browse/ANT-2742) This fix is a quick fix : code could be cleaner. Some refactoring could make code more readable when reading it again in a few months / years. In particular, we could create an interface for reading and saving this data (hydro power) and create 2 classes implementing this interface and encapsulating each case (read/write daily or hourly) --- src/libs/antares/study/area/list.cpp | 14 +++++--- .../study/include/antares/study/parameters.h | 2 +- .../antares/study/parts/hydro/container.h | 7 +++- .../parts/hydro/hydromaxtimeseriesreader.h | 2 -- .../antares/study/parts/hydro/series.h | 4 ++- src/libs/antares/study/parameters.cpp | 2 +- .../antares/study/parts/hydro/container.cpp | 30 +++++++++++----- .../parts/hydro/hydromaxtimeseriesreader.cpp | 35 ++++++++++--------- src/libs/antares/study/parts/hydro/series.cpp | 16 ++++++--- src/libs/antares/study/study.importprepro.cpp | 5 ++- 10 files changed, 76 insertions(+), 41 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 3f0cb4a12aa..3114ed74802 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -192,9 +192,12 @@ static bool AreaListSaveThermalDataToFile(const AreaList& list, const AnyString& return ini.save(filename); } -static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const AnyString& folder) +static bool AreaListSaveToFolderSingleArea(const Area& area, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax) { bool ret = true; + Clob buffer; // A specific folder for general data buffer.clear() << folder << SEP << "input" << SEP << "areas" << SEP << area.id; @@ -273,7 +276,7 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, Clob& buffer, const if (area.hydro.series) // Series { buffer.clear() << folder << SEP << "input" << SEP << "hydro" << SEP << "series"; - ret = area.hydro.series->saveToFolder(area.id, buffer) && ret; + ret = area.hydro.series->saveToFolder(area.id, buffer, hydroPmax) && ret; } } @@ -762,13 +765,16 @@ bool AreaList::saveToFolder(const AnyString& folder) const { logs.info() << "Exporting the area " << (area.index + 1) << '/' << areas.size() << ": " << area.name; - ret = AreaListSaveToFolderSingleArea(area, buffer, folder) && ret; + ret = AreaListSaveToFolderSingleArea(area, + folder, + pStudy.parameters.compatibility.hydroPmax) + && ret; }); // Hydro // The hydro files must be saved after the area has been invalidated buffer.clear() << folder << SEP << "input" << SEP << "hydro"; - ret = PartHydro::SaveToFolder(*this, buffer) && ret; + ret = PartHydro::SaveToFolder(*this, buffer, pStudy.parameters.compatibility.hydroPmax) && ret; // update nameid set updateNameIDSet(); diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index 664d574b323..410f89ae6cf 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -531,7 +531,7 @@ const char* SimulationModeToCString(SimulationMode mode); */ bool StringToSimulationMode(SimulationMode& mode, Yuni::CString<20, false> text); -const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax); +const char* CompatibilityHydroPmaxToCString(const Parameters::Compatibility::HydroPmax); bool StringToCompatibilityHydroPmax(Parameters::Compatibility::HydroPmax&, const std::string& text); } // namespace Antares::Data diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/container.h b/src/libs/antares/study/include/antares/study/parts/hydro/container.h index 91b668ba6a8..ceb93198148 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/container.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/container.h @@ -131,7 +131,9 @@ class PartHydro ** \param folder The targer folder ** \return A non-zero value if the operation succeeded, 0 otherwise */ - static bool SaveToFolder(const AreaList& areas, const AnyString& folder); + static bool SaveToFolder(const AreaList& areas, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax); /*! ** \brief Default Constructor @@ -195,6 +197,9 @@ class PartHydro double leewayUpperBound; //! Puming efficiency double pumpingEfficiency; + //! Daily max power ({generating max Power, generating max energy, pumping max power, pumping + //! max energy}x365) + Matrix dailyMaxPumpAndGen; //! Credit Modulation (default 0, 101 * 2) Matrix creditModulation; diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h b/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h index f1c4cb8e36e..6191cc509c1 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/hydromaxtimeseriesreader.h @@ -58,8 +58,6 @@ class HydroMaxTimeSeriesReader }; private: - Matrix dailyMaxPumpAndGen; - PartHydro& hydro_; std::string areaID_; std::string areaName_; diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/series.h b/src/libs/antares/study/include/antares/study/parts/hydro/series.h index c3b587c0de6..3c28e84d04c 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/series.h @@ -91,7 +91,9 @@ class DataSeriesHydro ** \param folder The target folder ** \return A non-zero value if the operation succeeded, 0 otherwise */ - bool saveToFolder(const AreaName& areaID, const AnyString& folder) const; + bool saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax hydroPmax) const; //@} TimeSeriesNumbers timeseriesNumbers; diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 60a3781bd2b..27fe1e11df4 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -208,7 +208,7 @@ const char* SimulationModeToCString(SimulationMode mode) } } -const char* CompatibilityHydroPmaxToCString(Parameters::Compatibility::HydroPmax mode) +const char* CompatibilityHydroPmaxToCString(const Parameters::Compatibility::HydroPmax mode) { switch (mode) { diff --git a/src/libs/antares/study/parts/hydro/container.cpp b/src/libs/antares/study/parts/hydro/container.cpp index 52e6ef1d83a..3a99c6b146b 100644 --- a/src/libs/antares/study/parts/hydro/container.cpp +++ b/src/libs/antares/study/parts/hydro/container.cpp @@ -465,7 +465,9 @@ bool PartHydro::validate(Study& study) return checkProperties(study) && ret; } -bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) +bool PartHydro::SaveToFolder(const AreaList& areas, + const AnyString& folder, + const Parameters::Compatibility::HydroPmax hydroPmax) { if (!folder) { @@ -524,7 +526,7 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) // Add all alpha values for each area areas.each( - [&allSections, &buffer, &folder, &ret](const Data::Area& area) + [&allSections, &buffer, &folder, &hydroPmax, &ret](const Data::Area& area) { allSections.s->add(area.id, area.hydro.interDailyBreakdown); allSections.smod->add(area.id, area.hydro.intraDailyModulation); @@ -568,13 +570,23 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder) } // max hours gen - buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP - << "maxDailyGenEnergy_" << area.id << ".txt"; - ret = area.hydro.dailyNbHoursAtGenPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; - // max hours pump - buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP - << "maxDailyPumpEnergy_" << area.id << ".txt"; - ret = area.hydro.dailyNbHoursAtPumpPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly) + { + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP + << "maxDailyGenEnergy_" << area.id << ".txt"; + ret = area.hydro.dailyNbHoursAtGenPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP + << "maxDailyPumpEnergy_" << area.id << ".txt"; + ret = area.hydro.dailyNbHoursAtPumpPmax.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + } + else + { + buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "maxpower_" + << area.id << ".txt"; + ret = area.hydro.dailyMaxPumpAndGen.saveToCSVFile(buffer, /*decimal*/ 2) && ret; + } + // credit modulations buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP << "creditmodulations_" << area.id << ".txt"; diff --git a/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp b/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp index fa2827fc883..910fb6e2367 100644 --- a/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp +++ b/src/libs/antares/study/parts/hydro/hydromaxtimeseriesreader.cpp @@ -44,7 +44,7 @@ HydroMaxTimeSeriesReader::HydroMaxTimeSeriesReader(PartHydro& hydro, areaID_(areaID), areaName_(areaName) { - dailyMaxPumpAndGen.reset(4U, DAYS_PER_YEAR, true); + hydro_.dailyMaxPumpAndGen.reset(4U, DAYS_PER_YEAR, true); } static bool checkPower(const Matrix<>& dailyMaxPumpAndGen, const std::string& areaName) @@ -88,12 +88,15 @@ bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& fo enabledModeIsChanged = true; } - ret = dailyMaxPumpAndGen.loadFromCSVFile(filePath, - 4U, - DAYS_PER_YEAR, - Matrix<>::optFixedSize, - &fileContent) + ret = hydro_.dailyMaxPumpAndGen.loadFromCSVFile(filePath, + 4U, + DAYS_PER_YEAR, + Matrix<>::optFixedSize, + &fileContent) && ret; + // Allowing the daily power matrix to be printed in case of 'save as' (even if its content + // hasn't changed since it was loaded). + hydro_.dailyMaxPumpAndGen.markAsModified(); if (enabledModeIsChanged) { @@ -102,11 +105,11 @@ bool HydroMaxTimeSeriesReader::loadDailyMaxPowersAndEnergies(const AnyString& fo } else { - ret = dailyMaxPumpAndGen.loadFromCSVFile(filePath, - 4U, - DAYS_PER_YEAR, - Matrix<>::optFixedSize, - &fileContent) + ret = hydro_.dailyMaxPumpAndGen.loadFromCSVFile(filePath, + 4U, + DAYS_PER_YEAR, + Matrix<>::optFixedSize, + &fileContent) && ret; } return ret; @@ -121,7 +124,7 @@ void HydroMaxTimeSeriesReader::copyDailyMaxEnergy() const void HydroMaxTimeSeriesReader::copyDailyMaxGenerationEnergy() const { auto& dailyNbHoursAtGenPmax = hydro_.dailyNbHoursAtGenPmax; - const auto& dailyMaxGenE = dailyMaxPumpAndGen[genMaxE]; + const auto& dailyMaxGenE = hydro_.dailyMaxPumpAndGen[genMaxE]; dailyNbHoursAtGenPmax.reset(1U, DAYS_PER_YEAR, true); @@ -131,7 +134,7 @@ void HydroMaxTimeSeriesReader::copyDailyMaxGenerationEnergy() const void HydroMaxTimeSeriesReader::copyDailyMaxPumpingEnergy() const { auto& dailyNbHoursAtPumpPmax = hydro_.dailyNbHoursAtPumpPmax; - const auto& dailyMaxPumpE = dailyMaxPumpAndGen[pumpMaxE]; + const auto& dailyMaxPumpE = hydro_.dailyMaxPumpAndGen[pumpMaxE]; dailyNbHoursAtPumpPmax.reset(1U, DAYS_PER_YEAR, true); @@ -141,10 +144,10 @@ void HydroMaxTimeSeriesReader::copyDailyMaxPumpingEnergy() const bool HydroMaxTimeSeriesReader::read(const AnyString& folder, bool usedBySolver) { bool ret = loadDailyMaxPowersAndEnergies(folder, usedBySolver); - ret = checkPower(dailyMaxPumpAndGen, areaName_) && ret; + ret = checkPower(hydro_.dailyMaxPumpAndGen, areaName_) && ret; copyDailyMaxEnergy(); - hydro_.series->buildHourlyMaxPowerFromDailyTS(dailyMaxPumpAndGen[genMaxP], - dailyMaxPumpAndGen[pumpMaxP]); + hydro_.series->buildHourlyMaxPowerFromDailyTS(hydro_.dailyMaxPumpAndGen[genMaxP], + hydro_.dailyMaxPumpAndGen[pumpMaxP]); return ret; } diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 2ae774fbdf7..998f85a1e0f 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -191,7 +191,9 @@ void DataSeriesHydro::buildHourlyMaxPowerFromDailyTS( ConvertDailyTSintoHourlyTS(DailyMaxPumpPower, maxHourlyPumpPower.timeSeries[0]); } -bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& folder) const +bool DataSeriesHydro::saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax hydroPmax) const { String buffer; buffer.clear() << folder << SEP << areaID; @@ -207,10 +209,14 @@ bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& fold ret = storage.timeSeries.saveToCSVFile(buffer, 0) && ret; buffer.clear() << folder << SEP << areaID << SEP << "mingen.txt"; ret = mingen.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; - ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; - ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + + if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly) + { + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; + ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; + ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + } return ret; } diff --git a/src/libs/antares/study/study.importprepro.cpp b/src/libs/antares/study/study.importprepro.cpp index 3cf520c5ebc..9c76418b3de 100644 --- a/src/libs/antares/study/study.importprepro.cpp +++ b/src/libs/antares/study/study.importprepro.cpp @@ -82,7 +82,10 @@ bool Study::importTimeseriesIntoInput() { logs.info() << "Importing hydro timeseries : " << areaName; buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; - ret = area->hydro.series->saveToFolder(area->id, buffer) && ret; + ret = area->hydro.series->saveToFolder(area->id, + buffer, + parameters.compatibility.hydroPmax) + && ret; ++progression; } } From 3546ddcce81bd8354d191fee12118cdf7647a194 Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Mon, 10 Feb 2025 13:02:02 +0100 Subject: [PATCH 3/3] Remove Antares_Simulator_Tests submodule (#2606) --- .github/workflows/sonarcloud.yml | 2 +- .github/workflows/ubuntu.yml | 4 ---- .github/workflows/windows-vcpkg.yml | 4 ---- .gitmodules | 4 ---- src/tests/resources/Antares_Simulator_Tests | 1 - 5 files changed, 1 insertion(+), 14 deletions(-) delete mode 160000 src/tests/resources/Antares_Simulator_Tests diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e6f1cf608fa..39b83be6164 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -103,7 +103,7 @@ jobs: - name: Init submodule run: | - git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests + git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR - name: Configure run: | diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index d0d55b14813..5af937ceffc 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -142,10 +142,6 @@ jobs: run: | echo "SIMTEST=${{ fromJson(env.SIMTEST_JSON).version }}" >> $GITHUB_ENV - - name: Init submodule Antares_Simulator_Tests - run: | - git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests - - name: Init submodule Antares_Simulator_Tests_NR run: | git submodule update --init --remote --recursive src/tests/resources/Antares_Simulator_Tests_NR diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index 7f382d8be82..0fda647b682 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -144,10 +144,6 @@ jobs: run: | echo "SIMTEST=${{ fromJson(env.SIMTEST_JSON).version }}" >> $GITHUB_ENV - - name: Init submodule Antares_Simulator_Tests - run: | - git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests - - name: Init submodule Antares_Simulator_Tests_NR run: | git submodule update --init --remote src/tests/resources/Antares_Simulator_Tests_NR diff --git a/.gitmodules b/.gitmodules index 0b11b7d0b34..24b229c190a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "src/tests/resources/Antares_Simulator_Tests"] - path = src/tests/resources/Antares_Simulator_Tests - url = https://github.com/AntaresSimulatorTeam/Antares_Simulator_Tests.git - branch = master [submodule "vcpkg"] path = vcpkg url = https://github.com/microsoft/vcpkg.git diff --git a/src/tests/resources/Antares_Simulator_Tests b/src/tests/resources/Antares_Simulator_Tests deleted file mode 160000 index 2d79167609f..00000000000 --- a/src/tests/resources/Antares_Simulator_Tests +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2d79167609fc15497085aaa7311698adb63222a2