From e7c21b02c880e18b17858bfc00d6b449f1533175 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Tue, 21 Nov 2023 16:35:08 +0100 Subject: [PATCH 1/9] Version 8.8.0-rc4 --- docs/CHANGELOG.md | 7 +++++++ src/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3c60087b2f..36932b2c72 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,13 @@ Antares Changelog * Solver logs can be enabled either by the command-line option (--solver-logs) or in the generaldata.ini by setting solver-logs = true under the optimization section [(#1717)](https://github.com/AntaresSimulatorTeam/Antares_Simulator/pull/1717) +8.8.0-rc4 (11/2023) +-------------------- +## Bugfixes +* Take variable status (integer/continuous) into account for MILP (#1778) +* Named MPS - fix duplicated "ranged" binding constraints (#1569) +* Fix output variable PROFIT for thermal clusters (#1767) + 8.8.0-rc3 (11/2023) -------------------- ## Bugfixes diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 878d934250..20e76e32c6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set(ANTARES_VERSION_REVISION 0) # Beta release set(ANTARES_BETA 0) -set(ANTARES_RC 3) +set(ANTARES_RC 4) set(ANTARES_VERSION_YEAR 2023) From 7833a860284a36d489fbc3356c1f13268212bf17 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Thu, 23 Nov 2023 13:27:44 +0100 Subject: [PATCH 2/9] RC=5, fix changelog --- docs/CHANGELOG.md | 4 ++++ src/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 36932b2c72..722632448f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,10 @@ Antares Changelog ## New Features * Solver logs can be enabled either by the command-line option (--solver-logs) or in the generaldata.ini by setting solver-logs = true under the optimization section [(#1717)](https://github.com/AntaresSimulatorTeam/Antares_Simulator/pull/1717) +8.8.0-rc5 (11/2023) +-------------------- +## Bugfixes +* Fix missing assets 8.8.0-rc4 (11/2023) -------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20e76e32c6..fea824a54a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set(ANTARES_VERSION_REVISION 0) # Beta release set(ANTARES_BETA 0) -set(ANTARES_RC 4) +set(ANTARES_RC 5) set(ANTARES_VERSION_YEAR 2023) From 26fd35eda6ed56768b90ed561d11ba09e11c5917 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Fri, 8 Dec 2023 17:45:54 +0100 Subject: [PATCH 3/9] Add E2E tests on MILP + CBC --- .github/workflows/ubuntu.yml | 9 +++++++++ .github/workflows/windows-vcpkg.yml | 9 +++++++++ simtest.json | 2 +- src/tests/CMakeLists.txt | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 0c26d71abd..fe6b63e05a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -158,6 +158,15 @@ jobs: batch-name: valid-v830 os: ${{ matrix.test-platform }} + - name: Run MILP with CBC + if: ${{ env.IS_PUSH == 'true' }} + uses: ./.github/workflows/run-tests + with: + simtest-tag: ${{steps.simtest-version.outputs.prop}} + batch-name: valid-milp + variant: "milp-cbc" + os: ${{ matrix.test-platform }} + - name: Run tests introduced in v860 if: ${{ env.IS_PUSH == 'true' }} uses: ./.github/workflows/run-tests diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index 2d880c0744..106ac88ee8 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -196,6 +196,15 @@ jobs: batch-name: valid-v830 os: ${{ matrix.test-platform }} + - name: Run MILP with CBC + if: ${{ env.IS_PUSH == 'true' }} + uses: ./.github/workflows/run-tests + with: + simtest-tag: ${{steps.simtest-version.outputs.prop}} + batch-name: valid-milp + variant: "milp-cbc" + os: ${{ matrix.test-platform }} + - name: Run tests introduced in v860 uses: ./.github/workflows/run-tests with: diff --git a/simtest.json b/simtest.json index 15a52efb72..b2207b2cf4 100644 --- a/simtest.json +++ b/simtest.json @@ -1,3 +1,3 @@ { - "version": "v8.7.2" + "version": "v8.8.0-rc1" } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3b39ab8f85..dc70427fe5 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -65,6 +65,12 @@ if(Python3_Interpreter_FOUND) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/run-study-tests" ) + add_test( + NAME milp-cbc + COMMAND Python3::Interpreter -m pytest -m json --solver-path=$ --use-ortools --ortools-solver coin + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/run-study-tests" + ) + # The Kirchhoff constraint builder is built only if BUILD_TOOLS=ON if (BUILD_TOOLS) add_test( From 628f070e69ecd28ff433034c9a78f9ecc81cd93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:44:25 +0100 Subject: [PATCH 4/9] Add `enabled` property for ST storage objects, fix bug related to saving ST objects (#1807) - Add bool property `enabled` for each ST storage object - Whenever a ST storage is not `enabled`, remove it from computations relatively early (right after loading the data), using a similar mechanism as thermal & renewable clusters - Also fix list.ini files containing only the last ST storage object because of overwrite, add unit test case - Cherry-pick of "Remove sts container (#1804)" --------- Co-authored-by: Vincent Payet Co-authored-by: payetvin <113102157+payetvin@users.noreply.github.com> --- .../parts/short-term-storage/cluster.cpp | 14 ++++-- .../study/parts/short-term-storage/cluster.h | 9 ++-- .../parts/short-term-storage/container.cpp | 47 ++++++++++++++----- .../parts/short-term-storage/container.h | 13 ++--- .../parts/short-term-storage/properties.cpp | 21 ++------- .../parts/short-term-storage/properties.h | 21 +++++---- src/libs/antares/study/runtime/runtime.cpp | 10 ++++ src/libs/antares/study/runtime/runtime.h | 1 + .../simulation/sim_calcul_economique.cpp | 18 +++---- .../economy/STStorageCashFlowByCluster.h | 8 ++-- .../economy/STStorageInjectionByCluster.h | 8 ++-- .../economy/STStorageLevelsByCluster.h | 8 ++-- .../economy/STStorageWithdrawalByCluster.h | 8 ++-- .../variable/economy/shortTermStorage.h | 17 ++++--- src/solver/variable/info.h | 2 +- .../short-term-storage-input/CMakeLists.txt | 2 +- ...pp => short-term-storage-input-output.cpp} | 36 +++++++++++--- 17 files changed, 155 insertions(+), 88 deletions(-) rename src/tests/src/libs/antares/study/short-term-storage-input/{short-term-storage-input.cpp => short-term-storage-input-output.cpp} (90%) diff --git a/src/libs/antares/study/parts/short-term-storage/cluster.cpp b/src/libs/antares/study/parts/short-term-storage/cluster.cpp index 50789c7435..9b4efcb761 100644 --- a/src/libs/antares/study/parts/short-term-storage/cluster.cpp +++ b/src/libs/antares/study/parts/short-term-storage/cluster.cpp @@ -63,8 +63,16 @@ bool STStorageCluster::loadFromSection(const IniFile::Section& section) return true; } -bool STStorageCluster::validate() +bool STStorageCluster::enabled() const { + return properties.enabled; +} + +bool STStorageCluster::validate() const +{ + if (!enabled()) + return true; + logs.debug() << "Validating properties and series for st storage: " << id; return properties.validate() && series->validate(); } @@ -76,9 +84,9 @@ bool STStorageCluster::loadSeries(const std::string& folder) const return ret; } -bool STStorageCluster::saveProperties(const std::string& path) const +void STStorageCluster::saveProperties(IniFile& ini) const { - return properties.saveToFolder(path); + properties.save(ini); } bool STStorageCluster::saveSeries(const std::string& path) const diff --git a/src/libs/antares/study/parts/short-term-storage/cluster.h b/src/libs/antares/study/parts/short-term-storage/cluster.h index 4e909962a0..3c827c7d35 100644 --- a/src/libs/antares/study/parts/short-term-storage/cluster.h +++ b/src/libs/antares/study/parts/short-term-storage/cluster.h @@ -37,18 +37,19 @@ namespace Antares::Data::ShortTermStorage class STStorageCluster { public: - bool validate(); - bool loadFromSection(const IniFile::Section& section); + bool enabled() const; + bool validate() const; + bool loadFromSection(const IniFile::Section& section); bool loadSeries(const std::string& folder) const; - bool saveProperties(const std::string& path) const; + void saveProperties(IniFile& ini) const; bool saveSeries(const std::string& path) const; std::string id; std::shared_ptr series = std::make_shared(); - Properties properties; + mutable Properties properties; }; } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/parts/short-term-storage/container.cpp b/src/libs/antares/study/parts/short-term-storage/container.cpp index 3b0cba2a36..309637e94d 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.cpp +++ b/src/libs/antares/study/parts/short-term-storage/container.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "container.h" @@ -39,7 +40,7 @@ namespace Antares::Data::ShortTermStorage bool STStorageInput::validate() const { return std::all_of(storagesByIndex.cbegin(), storagesByIndex.cend(), [](auto& cluster) { - return cluster->validate(); + return cluster.validate(); }); } @@ -61,12 +62,12 @@ bool STStorageInput::createSTStorageClustersFromIniFile(const std::string& path) if (!cluster.loadFromSection(*section)) return false; - storagesById.try_emplace(cluster.properties.name, cluster); + storagesByIndex.push_back(cluster); } - storagesByIndex.reserve(storagesById.size()); - for (auto& [id, storage] : storagesById) - storagesByIndex.push_back(&storage); + std::sort(storagesByIndex.begin(), storagesByIndex.end(), [&](const auto& a, const auto& b){ + return a.properties.name < b.properties.name; + }); return true; } @@ -80,8 +81,8 @@ bool STStorageInput::loadSeriesFromFolder(const std::string& folder) const for (auto& cluster : storagesByIndex) { - const std::string buffer(folder + SEP + cluster->id); - ret = cluster->loadSeries(buffer) && ret; + const std::string buffer(folder + SEP + cluster.id); + ret = cluster.loadSeries(buffer) && ret; } return ret; @@ -91,24 +92,44 @@ bool STStorageInput::saveToFolder(const std::string& folder) const { // create empty list.ini if there's no sts in this area Yuni::IO::Directory::Create(folder); - Yuni::IO::File::CreateEmptyFile(folder + SEP + "list.ini"); - logs.notice() << "created empty ini: " << folder + SEP + "list.ini"; + const std::string pathIni(folder + SEP + "list.ini"); + IniFile ini; - return std::all_of(storagesByIndex.cbegin(), storagesByIndex.cend(), [&folder](auto& storage) { - return storage->saveProperties(folder); + logs.debug() << "saving file " << pathIni; + + std::for_each(storagesByIndex.cbegin(), storagesByIndex.cend(), [&ini](auto& storage) { + return storage.saveProperties(ini); }); + + return ini.save(pathIni); } bool STStorageInput::saveDataSeriesToFolder(const std::string& folder) const { Yuni::IO::Directory::Create(folder); return std::all_of(storagesByIndex.cbegin(), storagesByIndex.cend(), [&folder](auto& storage) { - return storage->saveSeries(folder + SEP + storage->id); + return storage.saveSeries(folder + SEP + storage.id); }); } std::size_t STStorageInput::count() const { - return storagesByIndex.size(); + return std::count_if(storagesByIndex.begin(), + storagesByIndex.end(), + [](const STStorageCluster& st) { + return st.properties.enabled; + }); } + +uint STStorageInput::removeDisabledClusters() +{ + const auto& it = std::remove_if(storagesByIndex.begin(), storagesByIndex.end(), + [](const auto& c) { return !c.enabled(); }); + + uint disabledCount = std::distance(it, storagesByIndex.end()); + storagesByIndex.erase(it, storagesByIndex.end()); + + return disabledCount; +} + } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/parts/short-term-storage/container.h b/src/libs/antares/study/parts/short-term-storage/container.h index 00673cebcd..b53aebf60b 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.h +++ b/src/libs/antares/study/parts/short-term-storage/container.h @@ -36,18 +36,19 @@ class STStorageInput { public: bool validate() const; - // 1. Read list.ini + /// 1. Read list.ini bool createSTStorageClustersFromIniFile(const std::string& path); - // 2. Read ALL series + /// 2. Read ALL series bool loadSeriesFromFolder(const std::string& folder) const; - // Number of ST storages + /// Number of enabled ST storages, ignoring disabled ST storages std::size_t count() const; + /// erase disabled cluster from the vector + uint removeDisabledClusters(); + bool saveToFolder(const std::string& folder) const; bool saveDataSeriesToFolder(const std::string& folder) const; - - std::vector storagesByIndex; - std::map storagesById; + std::vector storagesByIndex; }; } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/parts/short-term-storage/properties.cpp b/src/libs/antares/study/parts/short-term-storage/properties.cpp index 058a8b5f3a..cce442ce98 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.cpp +++ b/src/libs/antares/study/parts/short-term-storage/properties.cpp @@ -115,23 +115,14 @@ bool Properties::loadKey(const IniFile::Property* p) return false; } + if (p->key == "enabled") + return p->value.to(this->enabled); + return false; } -bool Properties::saveToFolder(const std::string& folder) const +void Properties::save(IniFile& ini) const { - const std::string pathIni(folder + SEP + "list.ini"); - - // Make sure the folder is created - if (!Yuni::IO::Directory::Create(folder)) - { - logs.warning() << "Couldn't create dir for sts: " << folder; - return false; - } - - logs.debug() << "saving file " << pathIni; - - IniFile ini; IniFile::Section* s = ini.addSection(this->name); s->add("name", this->name); @@ -147,9 +138,7 @@ bool Properties::saveToFolder(const std::string& folder) const s->add("efficiency", this->efficiencyFactor); s->add("initialleveloptim", this->initialLevelOptim); - - - return ini.save(pathIni); + s->add("enabled", this->enabled); } bool Properties::validate() diff --git a/src/libs/antares/study/parts/short-term-storage/properties.h b/src/libs/antares/study/parts/short-term-storage/properties.h index 58e79b1241..67c402f5fc 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.h +++ b/src/libs/antares/study/parts/short-term-storage/properties.h @@ -54,25 +54,28 @@ class Properties public: bool validate(); bool loadKey(const IniFile::Property* p); - bool saveToFolder(const std::string& folder) const; + void save(IniFile& ini) const; - // Not optional Injection nominal capacity, >= 0 + /// Not optional Injection nominal capacity, >= 0 std::optional injectionNominalCapacity; - // Not optional Withdrawal nominal capacity, >= 0 + /// Not optional Withdrawal nominal capacity, >= 0 std::optional withdrawalNominalCapacity; - // Not optional Reservoir capacity in MWh, >= 0 + /// Not optional Reservoir capacity in MWh, >= 0 std::optional reservoirCapacity; - // Initial level, <= 1 + /// Initial level, <= 1 double initialLevel = initiallevelDefault; - // Bool to optimise or not initial level + /// Bool to optimise or not initial level bool initialLevelOptim = false; - // Efficiency factor between 0 and 1 + /// Efficiency factor between 0 and 1 double efficiencyFactor = 1; - // Used to sort outputs + /// Used to sort outputs Group group = Group::Other1; - // cluster name + /// cluster name std::string name; + /// Enabled ? + bool enabled = true; + static const std::map ST_STORAGE_PROPERTY_GROUP_ENUM; private: static constexpr double initiallevelDefault = .5; diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index 1a58a14f73..e7ea5bcd5f 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -293,6 +293,9 @@ bool StudyRuntimeInfos::loadFromStudy(Study& study) // Removing disabled thermal clusters from solver computations removeDisabledThermalClustersFromSolverComputations(study); + // Removing disabled short-term storage objects from solver computations + removeDisabledShortTermStorageClustersFromSolverComputations(study); + switch (gd.renewableGeneration()) { case rgClusters: @@ -423,6 +426,13 @@ void StudyRuntimeInfos::removeDisabledRenewableClustersFromSolverComputations(St }); } +void StudyRuntimeInfos::removeDisabledShortTermStorageClustersFromSolverComputations(Study& study) +{ + removeClusters( + study, "short term storage", [](Area& area) + { return area.shortTermStorage.removeDisabledClusters(); }); +} + void StudyRuntimeInfos::removeAllRenewableClustersFromSolverComputations(Study& study) { removeClusters( diff --git a/src/libs/antares/study/runtime/runtime.h b/src/libs/antares/study/runtime/runtime.h index a499f47483..10c0d54e3b 100644 --- a/src/libs/antares/study/runtime/runtime.h +++ b/src/libs/antares/study/runtime/runtime.h @@ -138,6 +138,7 @@ class StudyRuntimeInfos void initializeThermalClustersInMustRunMode(Study& study) const; void removeDisabledThermalClustersFromSolverComputations(Study& study); void removeDisabledRenewableClustersFromSolverComputations(Study& study); + void removeDisabledShortTermStorageClustersFromSolverComputations(Study& study); void removeAllRenewableClustersFromSolverComputations(Study& study); void disableAllFilters(Study& study); void checkThermalTSGeneration(Study& study); diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 201f6b9899..4ea8e6d150 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -57,15 +57,15 @@ static void importShortTermStorages( toInsert.clusterGlobalIndex = clusterGlobalIndex; // Properties - toInsert.reservoirCapacity = st->properties.reservoirCapacity.value(); - toInsert.efficiency = st->properties.efficiencyFactor; - toInsert.injectionNominalCapacity = st->properties.injectionNominalCapacity.value(); - toInsert.withdrawalNominalCapacity = st->properties.withdrawalNominalCapacity.value(); - toInsert.initialLevel = st->properties.initialLevel; - toInsert.initialLevelOptim = st->properties.initialLevelOptim; - toInsert.name = st->properties.name; - - toInsert.series = st->series; + toInsert.reservoirCapacity = st.properties.reservoirCapacity.value(); + toInsert.efficiency = st.properties.efficiencyFactor; + toInsert.injectionNominalCapacity = st.properties.injectionNominalCapacity.value(); + toInsert.withdrawalNominalCapacity = st.properties.withdrawalNominalCapacity.value(); + toInsert.initialLevel = st.properties.initialLevel; + toInsert.initialLevelOptim = st.properties.initialLevelOptim; + toInsert.name = st.properties.name; + + toInsert.series = st.series; // TODO add missing properties, or use the same struct storageIndex++; diff --git a/src/solver/variable/economy/STStorageCashFlowByCluster.h b/src/solver/variable/economy/STStorageCashFlowByCluster.h index 6ea3456132..1d85df5cb5 100644 --- a/src/solver/variable/economy/STStorageCashFlowByCluster.h +++ b/src/solver/variable/economy/STStorageCashFlowByCluster.h @@ -278,14 +278,16 @@ class STstorageCashFlowByCluster : public Variable::IVariableshortTermStorage; // Write the data for the current year - for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) + uint clusterIndex = 0; + for (const auto& cluster : shortTermStorage.storagesByIndex) { // Write the data for the current year - const auto* cluster = shortTermStorage.storagesByIndex[clusterIndex]; - results.variableCaption = cluster->properties.name; + results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex] .template buildAnnualSurveyReport(results, fileLevel, precision); + + clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageInjectionByCluster.h b/src/solver/variable/economy/STStorageInjectionByCluster.h index 31ccb7912a..07d9858481 100644 --- a/src/solver/variable/economy/STStorageInjectionByCluster.h +++ b/src/solver/variable/economy/STStorageInjectionByCluster.h @@ -280,14 +280,16 @@ class STstorageInjectionByCluster : public Variable::IVariableshortTermStorage; // Write the data for the current year - for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) + uint clusterIndex = 0; + for (const auto& cluster : shortTermStorage.storagesByIndex) { // Write the data for the current year - const auto* cluster = shortTermStorage.storagesByIndex[clusterIndex]; - results.variableCaption = cluster->properties.name; + results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex] .template buildAnnualSurveyReport(results, fileLevel, precision); + + clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageLevelsByCluster.h b/src/solver/variable/economy/STStorageLevelsByCluster.h index 2e220e08ab..6c8cc2bba1 100644 --- a/src/solver/variable/economy/STStorageLevelsByCluster.h +++ b/src/solver/variable/economy/STStorageLevelsByCluster.h @@ -280,14 +280,16 @@ class STstorageLevelsByCluster const auto& shortTermStorage = results.data.area->shortTermStorage; // Write the data for the current year - for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) + uint clusterIndex = 0; + for (const auto& cluster : shortTermStorage.storagesByIndex) { // Write the data for the current year - const auto* cluster = shortTermStorage.storagesByIndex[clusterIndex]; - results.variableCaption = cluster->properties.name; + results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex].template buildAnnualSurveyReport( results, fileLevel, precision); + + clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageWithdrawalByCluster.h b/src/solver/variable/economy/STStorageWithdrawalByCluster.h index e0887b64d8..277b133088 100644 --- a/src/solver/variable/economy/STStorageWithdrawalByCluster.h +++ b/src/solver/variable/economy/STStorageWithdrawalByCluster.h @@ -280,14 +280,16 @@ class STstorageWithdrawalByCluster const auto& shortTermStorage = results.data.area->shortTermStorage; // Write the data for the current year - for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) + uint clusterIndex = 0; + for (const auto& cluster : shortTermStorage.storagesByIndex) { // Write the data for the current year - const auto* cluster = shortTermStorage.storagesByIndex[clusterIndex]; - results.variableCaption = cluster->properties.name; + results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex].template buildAnnualSurveyReport( results, fileLevel, precision); + + clusterIndex++; } } } diff --git a/src/solver/variable/economy/shortTermStorage.h b/src/solver/variable/economy/shortTermStorage.h index 959d4a49be..0b9370ddd3 100644 --- a/src/solver/variable/economy/shortTermStorage.h +++ b/src/solver/variable/economy/shortTermStorage.h @@ -235,22 +235,25 @@ class ShortTermStorageByGroup void hourForEachArea(State& state, unsigned int numSpace) { using namespace Antares::Data::ShortTermStorage; - for (uint stsIndex = 0; stsIndex < state.area->shortTermStorage.count(); stsIndex++) - { - const auto* cluster = state.area->shortTermStorage.storagesByIndex[stsIndex]; - const uint group = groupIndex(cluster->properties.group); + const auto& shortTermStorage = state.area->shortTermStorage; + // Write the data for the current year + uint clusterIndex = 0; + for (const auto& cluster : shortTermStorage.storagesByIndex) + { + const uint group = groupIndex(cluster.properties.group); // Injection pValuesForTheCurrentYear[numSpace][3 * group][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].injection[stsIndex]; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].injection[clusterIndex]; // Withdrawal pValuesForTheCurrentYear[numSpace][3 * group + 1][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].withdrawal[stsIndex]; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].withdrawal[clusterIndex]; // Levels pValuesForTheCurrentYear[numSpace][3 * group + 2][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].level[stsIndex]; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].level[clusterIndex]; + clusterIndex++; } // Next item in the list diff --git a/src/solver/variable/info.h b/src/solver/variable/info.h index 416bbd188b..d766dafc5e 100644 --- a/src/solver/variable/info.h +++ b/src/solver/variable/info.h @@ -413,7 +413,7 @@ struct VariableAccessor if (st_storage_details) { auto& st_storage_part = results.data.area->shortTermStorage; - results.variableCaption = st_storage_part.storagesByIndex[idx]->properties.name; + results.variableCaption = st_storage_part.storagesByIndex[idx].properties.name; return true; } return true; diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt b/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt index 458fa7b28f..045e8ed944 100644 --- a/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt +++ b/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt @@ -5,7 +5,7 @@ set(src_libs_antares_study "${CMAKE_SOURCE_DIR}/libs/antares/study") # Tests on reading scenario-builder # ==================================== set(SRC_SC_BUILDER_READ - short-term-storage-input.cpp + short-term-storage-input-output.cpp ) add_executable(short-term-storage-input ${SRC_SC_BUILDER_READ}) diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp similarity index 90% rename from src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp rename to src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp index bc2c4b0f8c..fa73cc6306 100644 --- a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp +++ b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp @@ -15,6 +15,7 @@ using namespace std; using namespace Antares::Data; +namespace { std::string getFolder() { std::filesystem::path tmpDir = std::filesystem::temp_directory_path(); @@ -76,7 +77,7 @@ void createFileSeries(unsigned int size) createIndividualFileSeries(folder + SEP + "upper-rule-curve.txt", size); } -void createIniFile() +void createIniFile(bool enabled) { std::string folder = getFolder(); @@ -91,7 +92,7 @@ void createIniFile() outfile << "reservoircapacity = 31200.000000" << std::endl; outfile << "efficiency = 0.75" << std::endl; outfile << "initiallevel = 0.50000" << std::endl; - + outfile << "enabled = " << (enabled ? "true" : "false") << std::endl; outfile.close(); } @@ -129,6 +130,7 @@ void removeIniFile() std::string folder = getFolder(); std::filesystem::remove(folder + SEP + "list.ini"); } +} // ================= // The fixture @@ -244,12 +246,32 @@ BOOST_FIXTURE_TEST_CASE(check_cluster_series_load_vector, Fixture) && cluster.series->lowerRuleCurve[6392] == 0.5); } -BOOST_FIXTURE_TEST_CASE(check_container_properties_load, Fixture) +BOOST_FIXTURE_TEST_CASE(check_container_properties_enabled_load, Fixture) { - createIniFile(); + createIniFile(true); BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - BOOST_CHECK(container.storagesByIndex[0]->properties.validate()); + + auto& properties = container.storagesByIndex[0].properties; + + BOOST_CHECK(properties.enabled); + BOOST_CHECK_EQUAL(container.count(), 1); + BOOST_CHECK(properties.validate()); + + removeIniFile(); +} + +BOOST_FIXTURE_TEST_CASE(check_container_properties_disabled_load, Fixture) +{ + createIniFile(false); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + + auto& properties = container.storagesByIndex[0].properties; + + BOOST_CHECK(!properties.enabled); + BOOST_CHECK_EQUAL(container.count(), 0); + BOOST_CHECK(properties.validate()); removeIniFile(); } @@ -259,7 +281,7 @@ BOOST_FIXTURE_TEST_CASE(check_container_properties_wrong_value, Fixture) createIniFileWrongValue(); BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - BOOST_CHECK(!container.storagesByIndex[0]->properties.validate()); + BOOST_CHECK(!container.storagesByIndex[0].properties.validate()); removeIniFile(); } @@ -275,7 +297,7 @@ BOOST_FIXTURE_TEST_CASE(check_container_properties_empty_file, Fixture) BOOST_FIXTURE_TEST_CASE(check_file_save, Fixture) { - createIniFile(); + createIniFile(true); BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); From 0147dc4641a3020d3f3a56133bf04f8fe19cbee4 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:29:29 +0100 Subject: [PATCH 5/9] Changelog for v8.8.0, rc=0 --- docs/CHANGELOG.md | 53 +++++++++++++++++----------------------------- src/CMakeLists.txt | 2 +- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 722632448f..b5e9110f37 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,43 +6,13 @@ Antares Changelog ## New Features * Solver logs can be enabled either by the command-line option (--solver-logs) or in the generaldata.ini by setting solver-logs = true under the optimization section [(#1717)](https://github.com/AntaresSimulatorTeam/Antares_Simulator/pull/1717) -8.8.0-rc5 (11/2023) +8.8.0 (12/2023) -------------------- -## Bugfixes -* Fix missing assets - -8.8.0-rc4 (11/2023) --------------------- -## Bugfixes -* Take variable status (integer/continuous) into account for MILP (#1778) -* Named MPS - fix duplicated "ranged" binding constraints (#1569) -* Fix output variable PROFIT for thermal clusters (#1767) - -8.8.0-rc3 (11/2023) --------------------- -## Bugfixes -* Fix oracle-linux8 binaries missing compression feature (#1741) -8.8.0-rc2 (10/2023) --------------------- -## Build -- Fix version numbers (8b9b2b389) - -8.8.0-rc1 (10/2023) --------------------- ## New features * New "cash-flow" variable for ST storage (#1633) -* Experimental ptimization discrete variables (#670) - -## Bugfixes -* Prevent segfault during simulation, check bounds of scenario builder (#1567) -* Fix number of links in deprecated output file digest.txt (#1646) -* Fix unfeasible problem analyzer (#1527) -* [Windows only] Increase file size limit when reading file (#1674) -* Fix segfault encountered when importing logs (#1702) -* Fixes swallowed exceptions in computation thread (#1685) -* Fix writer causing a segfault with OR-Tools (#1584) -* Bug on renewable cluster (wrong group) (#1631) +* Experimental optimization with discrete variables (MILP unit-commitment mode, #670) +* Add `enabled` property for ST storage objects, fix bug related to saving ST objects (#1807) ## Improvements * Add shortcut -s for names MPS problems in CLI options (#1613) @@ -52,8 +22,25 @@ Antares Changelog * Fix wrong year number in logs upon failed year (#1672) * Always check mingen against maxPower, regardless of reservoirManagement (#1656) * New log msg when solver not found in or-tools (#1687) + +## For developers * Fix annoying error log about correlation matrices in tests (#1573) +## Bugfixes (reported by users) +* Fix output variable PROFIT for thermal clusters (#1767) +* Bug on renewable cluster (wrong group) (#1631) + +## Bugfixes (reported internally) +* Fix oracle-linux8 binaries missing compression feature (#1741) +* Named MPS - fix duplicated "ranged" binding constraints (#1569) +* Prevent segfault during simulation, check bounds of scenario builder (#1567) +* Fix number of links in deprecated output file digest.txt (#1646) +* Fix unfeasible problem analyzer (#1527) +* [Windows only] Increase file size limit when reading file (#1674) +* Fix segfault encountered when importing logs (#1702) +* Fixes swallowed exceptions in computation thread (#1685) +* Fix writer causing a segfault with OR-Tools (#1584) + ## Documentation * Create Doxygen documentation (#1650) * Update README.md (#1654) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fea824a54a..43dd3e7d51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,7 @@ set(ANTARES_VERSION_REVISION 0) # Beta release set(ANTARES_BETA 0) -set(ANTARES_RC 5) +set(ANTARES_RC 0) set(ANTARES_VERSION_YEAR 2023) From d3babfe9546e524885ae5e25443b98547c1c0f63 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:31:42 +0100 Subject: [PATCH 6/9] Add changelog --- docs/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b5e9110f37..ea7a265c6b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -33,6 +33,7 @@ Antares Changelog ## Bugfixes (reported internally) * Fix oracle-linux8 binaries missing compression feature (#1741) * Named MPS - fix duplicated "ranged" binding constraints (#1569) +* Fix save for short term storage objects (#1807) * Prevent segfault during simulation, check bounds of scenario builder (#1567) * Fix number of links in deprecated output file digest.txt (#1646) * Fix unfeasible problem analyzer (#1527) From 228a40936b056794d82ca63c837f5c25c93458ff Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:39:41 +0100 Subject: [PATCH 7/9] Partial revert --- .github/workflows/ubuntu.yml | 9 - .github/workflows/windows-vcpkg.yml | 9 - simtest.json | 2 +- .../parts/short-term-storage/cluster.cpp | 12 +- .../study/parts/short-term-storage/cluster.h | 5 +- .../parts/short-term-storage/container.cpp | 30 +- .../parts/short-term-storage/container.h | 9 +- .../parts/short-term-storage/properties.cpp | 21 +- .../parts/short-term-storage/properties.h | 21 +- src/libs/antares/study/runtime/runtime.cpp | 10 - src/libs/antares/study/runtime/runtime.h | 1 - .../economy/STStorageCashFlowByCluster.h | 6 +- .../economy/STStorageInjectionByCluster.h | 6 +- .../economy/STStorageLevelsByCluster.h | 6 +- .../economy/STStorageWithdrawalByCluster.h | 6 +- .../variable/economy/shortTermStorage.h | 15 +- src/tests/CMakeLists.txt | 6 - .../short-term-storage-input/CMakeLists.txt | 2 +- .../short-term-storage-input-output.cpp | 324 ------------------ 19 files changed, 53 insertions(+), 447 deletions(-) delete mode 100644 src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 61e1d8ce63..15d84bc5e9 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -162,15 +162,6 @@ jobs: batch-name: valid-v830 os: ${{ matrix.test-platform }} - - name: Run MILP with CBC - if: ${{ env.IS_PUSH == 'true' }} - uses: ./.github/workflows/run-tests - with: - simtest-tag: ${{steps.simtest-version.outputs.prop}} - batch-name: valid-milp - variant: "milp-cbc" - os: ${{ matrix.test-platform }} - - name: Run tests introduced in v860 if: ${{ env.IS_PUSH == 'true' }} uses: ./.github/workflows/run-tests diff --git a/.github/workflows/windows-vcpkg.yml b/.github/workflows/windows-vcpkg.yml index 85cee50659..22fd808a1f 100644 --- a/.github/workflows/windows-vcpkg.yml +++ b/.github/workflows/windows-vcpkg.yml @@ -196,15 +196,6 @@ jobs: batch-name: valid-v830 os: ${{ matrix.test-platform }} - - name: Run MILP with CBC - if: ${{ env.IS_PUSH == 'true' }} - uses: ./.github/workflows/run-tests - with: - simtest-tag: ${{steps.simtest-version.outputs.prop}} - batch-name: valid-milp - variant: "milp-cbc" - os: ${{ matrix.test-platform }} - - name: Run tests introduced in v860 uses: ./.github/workflows/run-tests with: diff --git a/simtest.json b/simtest.json index b2207b2cf4..15a52efb72 100644 --- a/simtest.json +++ b/simtest.json @@ -1,3 +1,3 @@ { - "version": "v8.8.0-rc1" + "version": "v8.7.2" } diff --git a/src/libs/antares/study/parts/short-term-storage/cluster.cpp b/src/libs/antares/study/parts/short-term-storage/cluster.cpp index 9b4efcb761..39de343f63 100644 --- a/src/libs/antares/study/parts/short-term-storage/cluster.cpp +++ b/src/libs/antares/study/parts/short-term-storage/cluster.cpp @@ -63,16 +63,8 @@ bool STStorageCluster::loadFromSection(const IniFile::Section& section) return true; } -bool STStorageCluster::enabled() const -{ - return properties.enabled; -} - bool STStorageCluster::validate() const { - if (!enabled()) - return true; - logs.debug() << "Validating properties and series for st storage: " << id; return properties.validate() && series->validate(); } @@ -84,9 +76,9 @@ bool STStorageCluster::loadSeries(const std::string& folder) const return ret; } -void STStorageCluster::saveProperties(IniFile& ini) const +bool STStorageCluster::saveProperties(const std::string& path) const { - properties.save(ini); + return properties.saveToFolder(path); } bool STStorageCluster::saveSeries(const std::string& path) const diff --git a/src/libs/antares/study/parts/short-term-storage/cluster.h b/src/libs/antares/study/parts/short-term-storage/cluster.h index 3c827c7d35..cf2573ddd0 100644 --- a/src/libs/antares/study/parts/short-term-storage/cluster.h +++ b/src/libs/antares/study/parts/short-term-storage/cluster.h @@ -37,13 +37,12 @@ namespace Antares::Data::ShortTermStorage class STStorageCluster { public: - bool enabled() const; bool validate() const; - bool loadFromSection(const IniFile::Section& section); + bool loadSeries(const std::string& folder) const; - void saveProperties(IniFile& ini) const; + bool saveProperties(const std::string& path) const; bool saveSeries(const std::string& path) const; std::string id; diff --git a/src/libs/antares/study/parts/short-term-storage/container.cpp b/src/libs/antares/study/parts/short-term-storage/container.cpp index 309637e94d..707628bc88 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.cpp +++ b/src/libs/antares/study/parts/short-term-storage/container.cpp @@ -92,16 +92,12 @@ bool STStorageInput::saveToFolder(const std::string& folder) const { // create empty list.ini if there's no sts in this area Yuni::IO::Directory::Create(folder); - const std::string pathIni(folder + SEP + "list.ini"); - IniFile ini; - - logs.debug() << "saving file " << pathIni; + Yuni::IO::File::CreateEmptyFile(folder + SEP + "list.ini"); + logs.notice() << "created empty ini: " << folder + SEP + "list.ini"; - std::for_each(storagesByIndex.cbegin(), storagesByIndex.cend(), [&ini](auto& storage) { - return storage.saveProperties(ini); + return std::all_of(storagesByIndex.cbegin(), storagesByIndex.cend(), [&folder](auto& storage) { + return storage.saveProperties(folder); }); - - return ini.save(pathIni); } bool STStorageInput::saveDataSeriesToFolder(const std::string& folder) const @@ -114,22 +110,6 @@ bool STStorageInput::saveDataSeriesToFolder(const std::string& folder) const std::size_t STStorageInput::count() const { - return std::count_if(storagesByIndex.begin(), - storagesByIndex.end(), - [](const STStorageCluster& st) { - return st.properties.enabled; - }); -} - -uint STStorageInput::removeDisabledClusters() -{ - const auto& it = std::remove_if(storagesByIndex.begin(), storagesByIndex.end(), - [](const auto& c) { return !c.enabled(); }); - - uint disabledCount = std::distance(it, storagesByIndex.end()); - storagesByIndex.erase(it, storagesByIndex.end()); - - return disabledCount; + return storagesByIndex.size(); } - } // namespace Antares::Data::ShortTermStorage diff --git a/src/libs/antares/study/parts/short-term-storage/container.h b/src/libs/antares/study/parts/short-term-storage/container.h index b53aebf60b..8fac3a8d50 100644 --- a/src/libs/antares/study/parts/short-term-storage/container.h +++ b/src/libs/antares/study/parts/short-term-storage/container.h @@ -36,15 +36,12 @@ class STStorageInput { public: bool validate() const; - /// 1. Read list.ini + // 1. Read list.ini bool createSTStorageClustersFromIniFile(const std::string& path); - /// 2. Read ALL series + // 2. Read ALL series bool loadSeriesFromFolder(const std::string& folder) const; - /// Number of enabled ST storages, ignoring disabled ST storages + // Number of ST storages std::size_t count() const; - /// erase disabled cluster from the vector - uint removeDisabledClusters(); - bool saveToFolder(const std::string& folder) const; bool saveDataSeriesToFolder(const std::string& folder) const; diff --git a/src/libs/antares/study/parts/short-term-storage/properties.cpp b/src/libs/antares/study/parts/short-term-storage/properties.cpp index cce442ce98..058a8b5f3a 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.cpp +++ b/src/libs/antares/study/parts/short-term-storage/properties.cpp @@ -115,14 +115,23 @@ bool Properties::loadKey(const IniFile::Property* p) return false; } - if (p->key == "enabled") - return p->value.to(this->enabled); - return false; } -void Properties::save(IniFile& ini) const +bool Properties::saveToFolder(const std::string& folder) const { + const std::string pathIni(folder + SEP + "list.ini"); + + // Make sure the folder is created + if (!Yuni::IO::Directory::Create(folder)) + { + logs.warning() << "Couldn't create dir for sts: " << folder; + return false; + } + + logs.debug() << "saving file " << pathIni; + + IniFile ini; IniFile::Section* s = ini.addSection(this->name); s->add("name", this->name); @@ -138,7 +147,9 @@ void Properties::save(IniFile& ini) const s->add("efficiency", this->efficiencyFactor); s->add("initialleveloptim", this->initialLevelOptim); - s->add("enabled", this->enabled); + + + return ini.save(pathIni); } bool Properties::validate() diff --git a/src/libs/antares/study/parts/short-term-storage/properties.h b/src/libs/antares/study/parts/short-term-storage/properties.h index 67c402f5fc..58e79b1241 100644 --- a/src/libs/antares/study/parts/short-term-storage/properties.h +++ b/src/libs/antares/study/parts/short-term-storage/properties.h @@ -54,28 +54,25 @@ class Properties public: bool validate(); bool loadKey(const IniFile::Property* p); - void save(IniFile& ini) const; + bool saveToFolder(const std::string& folder) const; - /// Not optional Injection nominal capacity, >= 0 + // Not optional Injection nominal capacity, >= 0 std::optional injectionNominalCapacity; - /// Not optional Withdrawal nominal capacity, >= 0 + // Not optional Withdrawal nominal capacity, >= 0 std::optional withdrawalNominalCapacity; - /// Not optional Reservoir capacity in MWh, >= 0 + // Not optional Reservoir capacity in MWh, >= 0 std::optional reservoirCapacity; - /// Initial level, <= 1 + // Initial level, <= 1 double initialLevel = initiallevelDefault; - /// Bool to optimise or not initial level + // Bool to optimise or not initial level bool initialLevelOptim = false; - /// Efficiency factor between 0 and 1 + // Efficiency factor between 0 and 1 double efficiencyFactor = 1; - /// Used to sort outputs + // Used to sort outputs Group group = Group::Other1; - /// cluster name + // cluster name std::string name; - /// Enabled ? - bool enabled = true; - static const std::map ST_STORAGE_PROPERTY_GROUP_ENUM; private: static constexpr double initiallevelDefault = .5; diff --git a/src/libs/antares/study/runtime/runtime.cpp b/src/libs/antares/study/runtime/runtime.cpp index 32128178b1..039dbea843 100644 --- a/src/libs/antares/study/runtime/runtime.cpp +++ b/src/libs/antares/study/runtime/runtime.cpp @@ -293,9 +293,6 @@ bool StudyRuntimeInfos::loadFromStudy(Study& study) // Removing disabled thermal clusters from solver computations removeDisabledThermalClustersFromSolverComputations(study); - // Removing disabled short-term storage objects from solver computations - removeDisabledShortTermStorageClustersFromSolverComputations(study); - switch (gd.renewableGeneration()) { case rgClusters: @@ -426,13 +423,6 @@ void StudyRuntimeInfos::removeDisabledRenewableClustersFromSolverComputations(St }); } -void StudyRuntimeInfos::removeDisabledShortTermStorageClustersFromSolverComputations(Study& study) -{ - removeClusters( - study, "short term storage", [](Area& area) - { return area.shortTermStorage.removeDisabledClusters(); }); -} - void StudyRuntimeInfos::removeAllRenewableClustersFromSolverComputations(Study& study) { removeClusters( diff --git a/src/libs/antares/study/runtime/runtime.h b/src/libs/antares/study/runtime/runtime.h index e70f9f223a..bd44257269 100644 --- a/src/libs/antares/study/runtime/runtime.h +++ b/src/libs/antares/study/runtime/runtime.h @@ -138,7 +138,6 @@ class StudyRuntimeInfos void initializeThermalClustersInMustRunMode(Study& study) const; void removeDisabledThermalClustersFromSolverComputations(Study& study); void removeDisabledRenewableClustersFromSolverComputations(Study& study); - void removeDisabledShortTermStorageClustersFromSolverComputations(Study& study); void removeAllRenewableClustersFromSolverComputations(Study& study); void disableAllFilters(Study& study); void checkThermalTSGeneration(Study& study); diff --git a/src/solver/variable/economy/STStorageCashFlowByCluster.h b/src/solver/variable/economy/STStorageCashFlowByCluster.h index 1d85df5cb5..bbde229c33 100644 --- a/src/solver/variable/economy/STStorageCashFlowByCluster.h +++ b/src/solver/variable/economy/STStorageCashFlowByCluster.h @@ -278,16 +278,14 @@ class STstorageCashFlowByCluster : public Variable::IVariableshortTermStorage; // Write the data for the current year - uint clusterIndex = 0; - for (const auto& cluster : shortTermStorage.storagesByIndex) + for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) { // Write the data for the current year + const auto& cluster = shortTermStorage.storagesByIndex[clusterIndex]; results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex] .template buildAnnualSurveyReport(results, fileLevel, precision); - - clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageInjectionByCluster.h b/src/solver/variable/economy/STStorageInjectionByCluster.h index 07d9858481..280c179b89 100644 --- a/src/solver/variable/economy/STStorageInjectionByCluster.h +++ b/src/solver/variable/economy/STStorageInjectionByCluster.h @@ -280,16 +280,14 @@ class STstorageInjectionByCluster : public Variable::IVariableshortTermStorage; // Write the data for the current year - uint clusterIndex = 0; - for (const auto& cluster : shortTermStorage.storagesByIndex) + for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) { // Write the data for the current year + const auto& cluster = shortTermStorage.storagesByIndex[clusterIndex]; results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex] .template buildAnnualSurveyReport(results, fileLevel, precision); - - clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageLevelsByCluster.h b/src/solver/variable/economy/STStorageLevelsByCluster.h index 6c8cc2bba1..4ae6ddc09b 100644 --- a/src/solver/variable/economy/STStorageLevelsByCluster.h +++ b/src/solver/variable/economy/STStorageLevelsByCluster.h @@ -280,16 +280,14 @@ class STstorageLevelsByCluster const auto& shortTermStorage = results.data.area->shortTermStorage; // Write the data for the current year - uint clusterIndex = 0; - for (const auto& cluster : shortTermStorage.storagesByIndex) + for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) { // Write the data for the current year + const auto& cluster = shortTermStorage.storagesByIndex[clusterIndex]; results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex].template buildAnnualSurveyReport( results, fileLevel, precision); - - clusterIndex++; } } } diff --git a/src/solver/variable/economy/STStorageWithdrawalByCluster.h b/src/solver/variable/economy/STStorageWithdrawalByCluster.h index 277b133088..bc39d8c70b 100644 --- a/src/solver/variable/economy/STStorageWithdrawalByCluster.h +++ b/src/solver/variable/economy/STStorageWithdrawalByCluster.h @@ -280,16 +280,14 @@ class STstorageWithdrawalByCluster const auto& shortTermStorage = results.data.area->shortTermStorage; // Write the data for the current year - uint clusterIndex = 0; - for (const auto& cluster : shortTermStorage.storagesByIndex) + for (uint clusterIndex = 0; clusterIndex < nbClusters_; ++clusterIndex) { // Write the data for the current year + const auto& cluster = shortTermStorage.storagesByIndex[clusterIndex]; results.variableCaption = cluster.properties.name; results.variableUnit = VCardType::Unit(); pValuesForTheCurrentYear[numSpace][clusterIndex].template buildAnnualSurveyReport( results, fileLevel, precision); - - clusterIndex++; } } } diff --git a/src/solver/variable/economy/shortTermStorage.h b/src/solver/variable/economy/shortTermStorage.h index 0b9370ddd3..77aab56a7a 100644 --- a/src/solver/variable/economy/shortTermStorage.h +++ b/src/solver/variable/economy/shortTermStorage.h @@ -235,25 +235,22 @@ class ShortTermStorageByGroup void hourForEachArea(State& state, unsigned int numSpace) { using namespace Antares::Data::ShortTermStorage; - const auto& shortTermStorage = state.area->shortTermStorage; - - // Write the data for the current year - uint clusterIndex = 0; - for (const auto& cluster : shortTermStorage.storagesByIndex) + for (uint stsIndex = 0; stsIndex < state.area->shortTermStorage.count(); stsIndex++) { + const auto& cluster = state.area->shortTermStorage.storagesByIndex[stsIndex]; const uint group = groupIndex(cluster.properties.group); + // Injection pValuesForTheCurrentYear[numSpace][3 * group][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].injection[clusterIndex]; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].injection[stsIndex]; // Withdrawal pValuesForTheCurrentYear[numSpace][3 * group + 1][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].withdrawal[clusterIndex]; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].withdrawal[stsIndex]; // Levels pValuesForTheCurrentYear[numSpace][3 * group + 2][state.hourInTheYear] - += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].level[clusterIndex]; - clusterIndex++; + += state.hourlyResults->ShortTermStorage[state.hourInTheWeek].level[stsIndex]; } // Next item in the list diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8342eab075..576254bc91 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -65,12 +65,6 @@ if(Python3_Interpreter_FOUND) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/run-study-tests" ) - add_test( - NAME milp-cbc - COMMAND Python3::Interpreter -m pytest -m json --solver-path=$ --use-ortools --ortools-solver coin - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/run-study-tests" - ) - add_test( NAME parallel COMMAND Python3::Interpreter -m pytest -m json --solver-path=$ --force-parallel diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt b/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt index 045e8ed944..458fa7b28f 100644 --- a/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt +++ b/src/tests/src/libs/antares/study/short-term-storage-input/CMakeLists.txt @@ -5,7 +5,7 @@ set(src_libs_antares_study "${CMAKE_SOURCE_DIR}/libs/antares/study") # Tests on reading scenario-builder # ==================================== set(SRC_SC_BUILDER_READ - short-term-storage-input-output.cpp + short-term-storage-input.cpp ) add_executable(short-term-storage-input ${SRC_SC_BUILDER_READ}) diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp deleted file mode 100644 index fa73cc6306..0000000000 --- a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input-output.cpp +++ /dev/null @@ -1,324 +0,0 @@ -#define BOOST_TEST_MODULE "test short term storage" -#define BOOST_TEST_DYN_LINK - -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include -#include - -#include "container.h" - -#define SEP Yuni::IO::Separator - -using namespace std; -using namespace Antares::Data; - -namespace { -std::string getFolder() -{ - std::filesystem::path tmpDir = std::filesystem::temp_directory_path(); - return tmpDir.string(); -} - -void resizeFillVectors(ShortTermStorage::Series& series, double value, unsigned int size) -{ - series.maxInjectionModulation.resize(size, value); - series.maxWithdrawalModulation.resize(size, value); - series.inflows.resize(size, value); - series.lowerRuleCurve.resize(size, value); - series.upperRuleCurve.resize(size, value); -} - -void createIndividualFileSeries(const std::string& path, double value, unsigned int size) -{ - std::ofstream outfile(path); - - for (unsigned int i = 0; i < size; i++) - outfile << value << std::endl; - - outfile.close(); -} - -void createIndividualFileSeries(const std::string& path, unsigned int size) -{ - std::ofstream outfile; - outfile.open(path, std::ofstream::out | std::ofstream::trunc); - - for (unsigned int i = 0; i < size; i++) - { - double value = i * 0.0001; - outfile << value << std::endl; - } - - outfile.close(); -} - -void createFileSeries(double value, unsigned int size) -{ - std::string folder = getFolder(); - - createIndividualFileSeries(folder + SEP + "PMAX-injection.txt", value, size); - createIndividualFileSeries(folder + SEP + "PMAX-withdrawal.txt", value, size); - createIndividualFileSeries(folder + SEP + "inflows.txt", value, size); - createIndividualFileSeries(folder + SEP + "lower-rule-curve.txt", value, size); - createIndividualFileSeries(folder + SEP + "upper-rule-curve.txt", value, size); -} - -void createFileSeries(unsigned int size) -{ - std::string folder = getFolder(); - - createIndividualFileSeries(folder + SEP + "PMAX-injection.txt", size); - createIndividualFileSeries(folder + SEP + "PMAX-withdrawal.txt", size); - createIndividualFileSeries(folder + SEP + "inflows.txt", size); - createIndividualFileSeries(folder + SEP + "lower-rule-curve.txt", size); - createIndividualFileSeries(folder + SEP + "upper-rule-curve.txt", size); -} - -void createIniFile(bool enabled) -{ - std::string folder = getFolder(); - - std::ofstream outfile; - outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); - - outfile << "[area]" << std::endl; - outfile << "name = area" << std::endl; - outfile << "group = PSP_open" << std::endl; - outfile << "injectionnominalcapacity = 870.000000" << std::endl; - outfile << "withdrawalnominalcapacity = 900.000000" << std::endl; - outfile << "reservoircapacity = 31200.000000" << std::endl; - outfile << "efficiency = 0.75" << std::endl; - outfile << "initiallevel = 0.50000" << std::endl; - outfile << "enabled = " << (enabled ? "true" : "false") << std::endl; - outfile.close(); -} - -void createIniFileWrongValue() -{ - std::string folder = getFolder(); - - std::ofstream outfile; - outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); - - outfile << "[area]" << std::endl; - outfile << "name = area" << std::endl; - outfile << "group = abcde" << std::endl; - outfile << "injectionnominalcapacity = -870.000000" << std::endl; - outfile << "withdrawalnominalcapacity = -900.000000" << std::endl; - outfile << "reservoircapacity = -31200.000000" << std::endl; - outfile << "efficiency = 4" << std::endl; - outfile << "initiallevel = -0.50000" << std::endl; - - outfile.close(); -} - -void createEmptyIniFile() -{ - std::string folder = getFolder(); - - std::ofstream outfile; - outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); - - outfile.close(); -} - -void removeIniFile() -{ - std::string folder = getFolder(); - std::filesystem::remove(folder + SEP + "list.ini"); -} -} - -// ================= -// The fixture -// ================= -struct Fixture -{ - Fixture(const Fixture & f) = delete; - Fixture(const Fixture && f) = delete; - Fixture & operator= (const Fixture & f) = delete; - Fixture& operator= (const Fixture && f) = delete; - Fixture() = default; - ~Fixture() - { - std::filesystem::remove(folder + SEP + "PMAX-injection.txt"); - std::filesystem::remove(folder + SEP + "PMAX-withdrawal.txt"); - std::filesystem::remove(folder + SEP + "inflows.txt"); - std::filesystem::remove(folder + SEP + "lower-rule-curve.txt"); - std::filesystem::remove(folder + SEP + "upper-rule-curve.txt"); - } - - std::string folder = getFolder(); - - ShortTermStorage::Series series; - ShortTermStorage::Properties properties; - ShortTermStorage::STStorageCluster cluster; - ShortTermStorage::STStorageInput container; -}; - - -// ================== -// Tests section -// ================== - -BOOST_AUTO_TEST_SUITE(s) - -BOOST_FIXTURE_TEST_CASE(check_vector_sizes, Fixture) -{ - resizeFillVectors(series, 0.0, 12); - BOOST_CHECK(!series.validate()); - - resizeFillVectors(series, 0.0, 8760); - BOOST_CHECK(series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading, Fixture) -{ - createFileSeries(1.0, 8760); - - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(series.validate()); - BOOST_CHECK(series.inflows[0] == 1 && series.maxInjectionModulation[8759] == 1 - && series.upperRuleCurve[1343] == 1); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_different_values, Fixture) -{ - createFileSeries(8760); - - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_negative_value, Fixture) -{ - createFileSeries(-247.0, 8760); - - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(!series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_too_big, Fixture) -{ - createFileSeries(1.0, 9000); - - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_too_small, Fixture) -{ - createFileSeries(1.0, 100); - - BOOST_CHECK(!series.loadFromFolder(folder)); - BOOST_CHECK(!series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_empty, Fixture) -{ - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(!series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_series_vector_fill, Fixture) -{ - series.fillDefaultSeriesIfEmpty(); - BOOST_CHECK(series.validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_cluster_series_vector_fill, Fixture) -{ - BOOST_CHECK(cluster.loadSeries(folder)); - BOOST_CHECK(cluster.series->validate()); -} - -BOOST_FIXTURE_TEST_CASE(check_cluster_series_load_vector, Fixture) -{ - createFileSeries(0.5, 8760); - - BOOST_CHECK(cluster.loadSeries(folder)); - BOOST_CHECK(cluster.series->validate()); - BOOST_CHECK(cluster.series->maxWithdrawalModulation[0] == 0.5 - && cluster.series->inflows[2756] == 0.5 - && cluster.series->lowerRuleCurve[6392] == 0.5); -} - -BOOST_FIXTURE_TEST_CASE(check_container_properties_enabled_load, Fixture) -{ - createIniFile(true); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - - auto& properties = container.storagesByIndex[0].properties; - - BOOST_CHECK(properties.enabled); - BOOST_CHECK_EQUAL(container.count(), 1); - BOOST_CHECK(properties.validate()); - - removeIniFile(); -} - -BOOST_FIXTURE_TEST_CASE(check_container_properties_disabled_load, Fixture) -{ - createIniFile(false); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - - auto& properties = container.storagesByIndex[0].properties; - - BOOST_CHECK(!properties.enabled); - BOOST_CHECK_EQUAL(container.count(), 0); - BOOST_CHECK(properties.validate()); - - removeIniFile(); -} - -BOOST_FIXTURE_TEST_CASE(check_container_properties_wrong_value, Fixture) -{ - createIniFileWrongValue(); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - BOOST_CHECK(!container.storagesByIndex[0].properties.validate()); - - removeIniFile(); -} - -BOOST_FIXTURE_TEST_CASE(check_container_properties_empty_file, Fixture) -{ - createEmptyIniFile(); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - - removeIniFile(); -} - -BOOST_FIXTURE_TEST_CASE(check_file_save, Fixture) -{ - createIniFile(true); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - - removeIniFile(); - - BOOST_CHECK(container.saveToFolder(folder)); - - BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); - - removeIniFile(); -} - -BOOST_FIXTURE_TEST_CASE(check_series_save, Fixture) -{ - resizeFillVectors(series, 0.123456789, 8760); - - BOOST_CHECK(series.saveToFolder(folder)); - resizeFillVectors(series, 0, 0); - - BOOST_CHECK(series.loadFromFolder(folder)); - BOOST_CHECK(series.validate()); -} - -BOOST_AUTO_TEST_SUITE_END() From e69406fc5f60dc7c4c4f3de22419e97cd11e4053 Mon Sep 17 00:00:00 2001 From: Florian OMNES <26088210+flomnes@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:40:06 +0100 Subject: [PATCH 8/9] Partial revert (bis) --- .../short-term-storage-input.cpp | 302 ++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp diff --git a/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp new file mode 100644 index 0000000000..1cd15334f4 --- /dev/null +++ b/src/tests/src/libs/antares/study/short-term-storage-input/short-term-storage-input.cpp @@ -0,0 +1,302 @@ +#define BOOST_TEST_MODULE "test short term storage" +#define BOOST_TEST_DYN_LINK + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include +#include + +#include "container.h" + +#define SEP Yuni::IO::Separator + +using namespace std; +using namespace Antares::Data; + +std::string getFolder() +{ + std::filesystem::path tmpDir = std::filesystem::temp_directory_path(); + return tmpDir.string(); +} + +void resizeFillVectors(ShortTermStorage::Series& series, double value, unsigned int size) +{ + series.maxInjectionModulation.resize(size, value); + series.maxWithdrawalModulation.resize(size, value); + series.inflows.resize(size, value); + series.lowerRuleCurve.resize(size, value); + series.upperRuleCurve.resize(size, value); +} + +void createIndividualFileSeries(const std::string& path, double value, unsigned int size) +{ + std::ofstream outfile(path); + + for (unsigned int i = 0; i < size; i++) + outfile << value << std::endl; + + outfile.close(); +} + +void createIndividualFileSeries(const std::string& path, unsigned int size) +{ + std::ofstream outfile; + outfile.open(path, std::ofstream::out | std::ofstream::trunc); + + for (unsigned int i = 0; i < size; i++) + { + double value = i * 0.0001; + outfile << value << std::endl; + } + + outfile.close(); +} + +void createFileSeries(double value, unsigned int size) +{ + std::string folder = getFolder(); + + createIndividualFileSeries(folder + SEP + "PMAX-injection.txt", value, size); + createIndividualFileSeries(folder + SEP + "PMAX-withdrawal.txt", value, size); + createIndividualFileSeries(folder + SEP + "inflows.txt", value, size); + createIndividualFileSeries(folder + SEP + "lower-rule-curve.txt", value, size); + createIndividualFileSeries(folder + SEP + "upper-rule-curve.txt", value, size); +} + +void createFileSeries(unsigned int size) +{ + std::string folder = getFolder(); + + createIndividualFileSeries(folder + SEP + "PMAX-injection.txt", size); + createIndividualFileSeries(folder + SEP + "PMAX-withdrawal.txt", size); + createIndividualFileSeries(folder + SEP + "inflows.txt", size); + createIndividualFileSeries(folder + SEP + "lower-rule-curve.txt", size); + createIndividualFileSeries(folder + SEP + "upper-rule-curve.txt", size); +} + +void createIniFile() +{ + std::string folder = getFolder(); + + std::ofstream outfile; + outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); + + outfile << "[area]" << std::endl; + outfile << "name = area" << std::endl; + outfile << "group = PSP_open" << std::endl; + outfile << "injectionnominalcapacity = 870.000000" << std::endl; + outfile << "withdrawalnominalcapacity = 900.000000" << std::endl; + outfile << "reservoircapacity = 31200.000000" << std::endl; + outfile << "efficiency = 0.75" << std::endl; + outfile << "initiallevel = 0.50000" << std::endl; + + outfile.close(); +} + +void createIniFileWrongValue() +{ + std::string folder = getFolder(); + + std::ofstream outfile; + outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); + + outfile << "[area]" << std::endl; + outfile << "name = area" << std::endl; + outfile << "group = abcde" << std::endl; + outfile << "injectionnominalcapacity = -870.000000" << std::endl; + outfile << "withdrawalnominalcapacity = -900.000000" << std::endl; + outfile << "reservoircapacity = -31200.000000" << std::endl; + outfile << "efficiency = 4" << std::endl; + outfile << "initiallevel = -0.50000" << std::endl; + + outfile.close(); +} + +void createEmptyIniFile() +{ + std::string folder = getFolder(); + + std::ofstream outfile; + outfile.open(folder + SEP + "list.ini", std::ofstream::out | std::ofstream::trunc); + + outfile.close(); +} + +void removeIniFile() +{ + std::string folder = getFolder(); + std::filesystem::remove(folder + SEP + "list.ini"); +} + +// ================= +// The fixture +// ================= +struct Fixture +{ + Fixture(const Fixture & f) = delete; + Fixture(const Fixture && f) = delete; + Fixture & operator= (const Fixture & f) = delete; + Fixture& operator= (const Fixture && f) = delete; + Fixture() = default; + ~Fixture() + { + std::filesystem::remove(folder + SEP + "PMAX-injection.txt"); + std::filesystem::remove(folder + SEP + "PMAX-withdrawal.txt"); + std::filesystem::remove(folder + SEP + "inflows.txt"); + std::filesystem::remove(folder + SEP + "lower-rule-curve.txt"); + std::filesystem::remove(folder + SEP + "upper-rule-curve.txt"); + } + + std::string folder = getFolder(); + + ShortTermStorage::Series series; + ShortTermStorage::Properties properties; + ShortTermStorage::STStorageCluster cluster; + ShortTermStorage::STStorageInput container; +}; + + +// ================== +// Tests section +// ================== + +BOOST_AUTO_TEST_SUITE(s) + +BOOST_FIXTURE_TEST_CASE(check_vector_sizes, Fixture) +{ + resizeFillVectors(series, 0.0, 12); + BOOST_CHECK(!series.validate()); + + resizeFillVectors(series, 0.0, 8760); + BOOST_CHECK(series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading, Fixture) +{ + createFileSeries(1.0, 8760); + + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(series.validate()); + BOOST_CHECK(series.inflows[0] == 1 && series.maxInjectionModulation[8759] == 1 + && series.upperRuleCurve[1343] == 1); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_different_values, Fixture) +{ + createFileSeries(8760); + + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_negative_value, Fixture) +{ + createFileSeries(-247.0, 8760); + + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(!series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_too_big, Fixture) +{ + createFileSeries(1.0, 9000); + + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_too_small, Fixture) +{ + createFileSeries(1.0, 100); + + BOOST_CHECK(!series.loadFromFolder(folder)); + BOOST_CHECK(!series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_folder_loading_empty, Fixture) +{ + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(!series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_series_vector_fill, Fixture) +{ + series.fillDefaultSeriesIfEmpty(); + BOOST_CHECK(series.validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_cluster_series_vector_fill, Fixture) +{ + BOOST_CHECK(cluster.loadSeries(folder)); + BOOST_CHECK(cluster.series->validate()); +} + +BOOST_FIXTURE_TEST_CASE(check_cluster_series_load_vector, Fixture) +{ + createFileSeries(0.5, 8760); + + BOOST_CHECK(cluster.loadSeries(folder)); + BOOST_CHECK(cluster.series->validate()); + BOOST_CHECK(cluster.series->maxWithdrawalModulation[0] == 0.5 + && cluster.series->inflows[2756] == 0.5 + && cluster.series->lowerRuleCurve[6392] == 0.5); +} + +BOOST_FIXTURE_TEST_CASE(check_container_properties_load, Fixture) +{ + createIniFile(); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + BOOST_CHECK(container.storagesByIndex[0].properties.validate()); + + removeIniFile(); +} + +BOOST_FIXTURE_TEST_CASE(check_container_properties_wrong_value, Fixture) +{ + createIniFileWrongValue(); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + BOOST_CHECK(!container.storagesByIndex[0].properties.validate()); + + removeIniFile(); +} + +BOOST_FIXTURE_TEST_CASE(check_container_properties_empty_file, Fixture) +{ + createEmptyIniFile(); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + + removeIniFile(); +} + +BOOST_FIXTURE_TEST_CASE(check_file_save, Fixture) +{ + createIniFile(); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + + removeIniFile(); + + BOOST_CHECK(container.saveToFolder(folder)); + + BOOST_CHECK(container.createSTStorageClustersFromIniFile(folder)); + + removeIniFile(); +} + +BOOST_FIXTURE_TEST_CASE(check_series_save, Fixture) +{ + resizeFillVectors(series, 0.123456789, 8760); + + BOOST_CHECK(series.saveToFolder(folder)); + resizeFillVectors(series, 0, 0); + + BOOST_CHECK(series.loadFromFolder(folder)); + BOOST_CHECK(series.validate()); +} + +BOOST_AUTO_TEST_SUITE_END() From 3f48f9217d1b1112997e6a77e544b8eb2fbfa9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= <26088210+flomnes@users.noreply.github.com> Date: Thu, 21 Dec 2023 11:50:08 +0100 Subject: [PATCH 9/9] Update docs/CHANGELOG.md Co-authored-by: abdoulbari zakir <32519851+a-zakir@users.noreply.github.com> --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ea7a265c6b..99c6395eaa 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,7 +11,7 @@ Antares Changelog ## New features * New "cash-flow" variable for ST storage (#1633) -* Experimental optimization with discrete variables (MILP unit-commitment mode, #670) +* Experimental optimization with discrete variables (MILP unit-commitment mode #670) * Add `enabled` property for ST storage objects, fix bug related to saving ST objects (#1807) ## Improvements