From 9accb36c6f8592b7effdff5c8cf72bbc33072bb6 Mon Sep 17 00:00:00 2001 From: payetvin <113102157+payetvin@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:56:17 +0200 Subject: [PATCH] Remove adequacy patch lmr [ANT-1933] (#2341) TODO: use warnings for removed parameters, only noticed used to avoid CI errors during dev --- docs/user-guide/04-migration-guides.md | 5 + docs/user-guide/solver/04-parameters.md | 20 --- src/libs/antares/exception/LoadingError.cpp | 5 - .../antares/exception/LoadingError.hpp | 6 - .../study/parameters/adq-patch-params.h | 24 +-- .../study/parameters/adq-patch-params.cpp | 52 ++---- src/solver/optimisation/CMakeLists.txt | 8 +- .../adq_patch_curtailment_sharing.cpp | 2 +- .../adequacy_patch_weekly_optimization.cpp | 78 -------- .../adq_patch_local_matching.cpp | 167 ------------------ .../optimisation/base_weekly_optimization.cpp | 78 -------- .../adequacy_patch_weekly_optimization.h | 51 ------ .../adq_patch_local_matching.h | 39 ---- .../optimisation/base_weekly_optimization.h | 61 ------- .../solver/optimisation/weekly_optimization.h | 28 +-- .../opt_gestion_des_bornes_cas_lineaire.cpp | 20 +-- .../optimisation/post_process_commands.cpp | 3 +- .../optimisation/weekly_optimization.cpp | 27 ++- src/solver/simulation/economy.cpp | 20 +-- .../simulation/adequacy_patch_runtime_data.h | 1 - .../antares/solver/simulation/economy.h | 5 +- .../adequacy_patch/adequacy_patch.cpp | 151 +--------------- .../adequacy-patch/adequacy-patch-options.cpp | 25 +-- 23 files changed, 76 insertions(+), 800 deletions(-) delete mode 100644 src/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.cpp delete mode 100644 src/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.cpp delete mode 100644 src/solver/optimisation/base_weekly_optimization.cpp delete mode 100644 src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h delete mode 100644 src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h delete mode 100644 src/solver/optimisation/include/antares/solver/optimisation/base_weekly_optimization.h diff --git a/docs/user-guide/04-migration-guides.md b/docs/user-guide/04-migration-guides.md index 729818c28f..98047dace2 100644 --- a/docs/user-guide/04-migration-guides.md +++ b/docs/user-guide/04-migration-guides.md @@ -2,6 +2,11 @@ This is a list of all recent changes that came with new Antares Simulator features. The main goal of this document is to lower the costs of changing existing interfaces, both GUI and scripts. ## v9.2.0 +### Adequacy Patch LMR +Removed following properties from **settings/generaldata.ini**. +- enable-first-step +- set-to-null-ntc-between-physical-out-for-first-step + ### (TS-generator only) TS generation for link capacities In files input/links//properties.ini, add the following properties - tsgen_direct_XXX, diff --git a/docs/user-guide/solver/04-parameters.md b/docs/user-guide/solver/04-parameters.md index fc8492a9e4..5ca79193a0 100644 --- a/docs/user-guide/solver/04-parameters.md +++ b/docs/user-guide/solver/04-parameters.md @@ -503,16 +503,6 @@ These parameters are listed under the `[adequacy patch]` section in the `.ini` f inside adequacy patch (area type 2). NTC is set to null (if true) only in the first step of adequacy patch local matching rule. NTC from physical areas outside to physical areas inside adequacy patch (set to null / local values) ---- -#### set-to-null-ntc-between-physical-out-for-first-step -[//]: # (TODO: usage is not clear) -- **Expected value:** `true` or `false` -- **Required:** no -- **Default value:** `true` -- **Usage:** Transmission capacities between physical areas outside adequacy patch (area type 1). - NTC is set to null (if true) only in the first step of adequacy patch local matching rule. - NTC between physical areas outside adequacy patch (set to null / local values) - --- #### price-taking-order [//]: # (TODO: document this parameter) @@ -543,16 +533,6 @@ _**This section is under construction**_ - **Default value:** - **Usage:** Check CSR cost function value prior and after CSR (false / true) ---- -#### enable-first-step -[//]: # (TODO: document this parameter) -_**This section is under construction**_ - -- **Expected value:** -- **Required:** **yes** -- **Default value:** -- **Usage:** - --- #### threshold-initiate-curtailment-sharing-rule [//]: # (TODO: document this parameter) diff --git a/src/libs/antares/exception/LoadingError.cpp b/src/libs/antares/exception/LoadingError.cpp index 499f0ed3f6..4a80591bef 100644 --- a/src/libs/antares/exception/LoadingError.cpp +++ b/src/libs/antares/exception/LoadingError.cpp @@ -192,11 +192,6 @@ IncompatibleHurdleCostCSR::IncompatibleHurdleCostCSR(): { } -AdqPatchDisabledLMR::AdqPatchDisabledLMR(): - LoadingError("Incompatible options LMR disabled and priceTakingOrder equal Dens") -{ -} - IncompatibleOutputOptions::IncompatibleOutputOptions(const std::string& text): LoadingError(text) { diff --git a/src/libs/antares/exception/include/antares/exception/LoadingError.hpp b/src/libs/antares/exception/include/antares/exception/LoadingError.hpp index c79b1a791e..d70820e5e9 100644 --- a/src/libs/antares/exception/include/antares/exception/LoadingError.hpp +++ b/src/libs/antares/exception/include/antares/exception/LoadingError.hpp @@ -194,12 +194,6 @@ class IncompatibleHurdleCostCSR: public LoadingError IncompatibleHurdleCostCSR(); }; -class AdqPatchDisabledLMR: public LoadingError -{ -public: - AdqPatchDisabledLMR(); -}; - class IncompatibleOutputOptions: public LoadingError { public: diff --git a/src/libs/antares/study/include/antares/study/parameters/adq-patch-params.h b/src/libs/antares/study/include/antares/study/parameters/adq-patch-params.h index 25c8b0f79b..12935ca85f 100644 --- a/src/libs/antares/study/include/antares/study/parameters/adq-patch-params.h +++ b/src/libs/antares/study/include/antares/study/parameters/adq-patch-params.h @@ -78,25 +78,6 @@ enum class AdqPatchPTO }; // enum AdqPatchPTO -struct LocalMatching -{ - bool enabled = true; - //! Transmission capacities from physical areas outside adequacy patch (area type 1) to - //! physical areas inside adequacy patch (area type 2). NTC is set to null (if true) - //! only in the first step of adequacy patch local matching rule. - bool setToZeroOutsideInsideLinks = true; - //! Transmission capacities between physical areas outside adequacy patch (area type 1). - //! NTC is set to null (if true) only in the first step of adequacy patch local matching - //! rule. - bool setToZeroOutsideOutsideLinks = true; - /*! - ** \brief Reset to default values related to local matching - */ - void reset(); - bool updateFromKeyValue(const Yuni::String& key, const Yuni::String& value); - void addProperties(IniFile::Section* section) const; -}; - class CurtailmentSharing { public: @@ -127,7 +108,10 @@ class CurtailmentSharing struct AdqPatchParams { bool enabled; - LocalMatching localMatching; + //! Transmission capacities from physical areas outside adequacy patch (area type 1) to + //! physical areas inside adequacy patch (area type 2). NTC is set to null (if true) + //! only in the first step of adequacy patch local matching rule. + bool setToZeroOutsideInsideLinks = true; CurtailmentSharing curtailmentSharing; void reset(); diff --git a/src/libs/antares/study/parameters/adq-patch-params.cpp b/src/libs/antares/study/parameters/adq-patch-params.cpp index 99d0d0db33..44e86e16b3 100644 --- a/src/libs/antares/study/parameters/adq-patch-params.cpp +++ b/src/libs/antares/study/parameters/adq-patch-params.cpp @@ -31,38 +31,23 @@ namespace Antares::Data::AdequacyPatch // Local matching // ------------------- -void LocalMatching::reset() +static bool legacyLocalMatchingKeys(const Yuni::String& key) { - setToZeroOutsideInsideLinks = true; - setToZeroOutsideOutsideLinks = true; -} - -bool LocalMatching::updateFromKeyValue(const Yuni::String& key, const Yuni::String& value) -{ - if (key == "set-to-null-ntc-from-physical-out-to-physical-in-for-first-step") - { - return value.to(setToZeroOutsideInsideLinks); - } if (key == "set-to-null-ntc-between-physical-out-for-first-step") { - return value.to(setToZeroOutsideOutsideLinks); + logs.warning() << "Parameter set-to-null-ntc-between-physical-out-for-first-step not " + "supported with this solver version, use a version < 9.2"; + return true; } if (key == "enable-first-step") { - return value.to(enabled); + logs.warning() << "Parameter enable-first-step not supported with this solver version, use " + "a version < 9.2"; + return true; } return false; } -void LocalMatching::addProperties(IniFile::Section* section) const -{ - section->add("set-to-null-ntc-from-physical-out-to-physical-in-for-first-step", - setToZeroOutsideInsideLinks); - section->add("set-to-null-ntc-between-physical-out-for-first-step", - setToZeroOutsideOutsideLinks); - section->add("enable-first-step", enabled); -} - // ----------------------- // Curtailment sharing // ----------------------- @@ -141,7 +126,7 @@ bool CurtailmentSharing::updateFromKeyValue(const Yuni::String& key, const Yuni: return value.to(thresholdVarBoundsRelaxation); } - return false; + return legacyLocalMatchingKeys(key); } const char* PriceTakingOrderToString(AdequacyPatch::AdqPatchPTO pto) @@ -175,10 +160,8 @@ void CurtailmentSharing::addProperties(IniFile::Section* section) const // ------------------------ void AdqPatchParams::reset() { - enabled = false; - - localMatching.reset(); curtailmentSharing.reset(); + setToZeroOutsideInsideLinks = true; } void AdqPatchParams::addExcludedVariables(std::vector& out) const @@ -190,12 +173,6 @@ void AdqPatchParams::addExcludedVariables(std::vector& out) const out.emplace_back("SPIL. ENRG. CSR"); out.emplace_back("DTG MRG CSR"); } - - // If the adequacy patch is enabled, but the LMR is disabled, the DENS variable shouldn't exist - if (enabled && !localMatching.enabled) - { - out.emplace_back("DENS"); - } } bool AdqPatchParams::updateFromKeyValue(const Yuni::String& key, const Yuni::String& value) @@ -204,17 +181,20 @@ bool AdqPatchParams::updateFromKeyValue(const Yuni::String& key, const Yuni::Str { return value.to(enabled); } - - return curtailmentSharing.updateFromKeyValue(key, value) - != localMatching.updateFromKeyValue(key, value); // XOR + if (key == "set-to-null-ntc-from-physical-out-to-physical-in-for-first-step") + { + return value.to(setToZeroOutsideInsideLinks); + } + return curtailmentSharing.updateFromKeyValue(key, value); } void AdqPatchParams::saveToINI(IniFile& ini) const { auto* section = ini.addSection("adequacy patch"); section->add("include-adq-patch", enabled); + section->add("set-to-null-ntc-from-physical-out-to-physical-in-for-first-step", + setToZeroOutsideInsideLinks); - localMatching.addProperties(section); curtailmentSharing.addProperties(section); } diff --git a/src/solver/optimisation/CMakeLists.txt b/src/solver/optimisation/CMakeLists.txt index a6c6f01e66..c48f935757 100644 --- a/src/solver/optimisation/CMakeLists.txt +++ b/src/solver/optimisation/CMakeLists.txt @@ -38,10 +38,6 @@ set(RTESOLVER_OPT opt_nombre_min_groupes_demarres_couts_demarrage.cpp include/antares/solver/optimisation/opt_export_structure.h opt_export_structure.cpp - include/antares/solver/optimisation/base_weekly_optimization.h - base_weekly_optimization.cpp - include/antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h - adequacy_patch_local_matching/adequacy_patch_weekly_optimization.cpp include/antares/solver/optimisation/weekly_optimization.h weekly_optimization.cpp include/antares/solver/optimisation/optim_post_process_list.h @@ -51,8 +47,6 @@ set(RTESOLVER_OPT include/antares/solver/optimisation/adequacy_patch_csr/hourly_csr_problem.h include/antares/solver/optimisation/adequacy_patch_csr/adq_patch_post_process_list.h adequacy_patch_csr/adq_patch_post_process_list.cpp - include/antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h - adequacy_patch_local_matching/adq_patch_local_matching.cpp include/antares/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.h adequacy_patch_csr/adq_patch_curtailment_sharing.cpp adequacy_patch_csr/solve_problem.cpp @@ -209,4 +203,4 @@ target_include_directories(model_antares install(DIRECTORY include/antares DESTINATION "include" -) \ No newline at end of file +) diff --git a/src/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.cpp b/src/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.cpp index 63789a5c76..0aa61a969d 100644 --- a/src/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.cpp @@ -125,7 +125,7 @@ void HourlyCSRProblem::calculateCsrParameters() // calculate netPositionInit and the RHS of the AreaBalance constraints std::tie(netPositionInit, std::ignore, std::ignore) = calculateAreaFlowBalance( problemeHebdo_, - adqPatchParams_.localMatching.setToZeroOutsideInsideLinks, + adqPatchParams_.setToZeroOutsideInsideLinks, Area, hour); double ensInit = problemeHebdo_->ResultatsHoraires[Area] diff --git a/src/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.cpp b/src/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.cpp deleted file mode 100644 index 8129d10845..0000000000 --- a/src/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2007-2024, RTE (https://www.rte-france.com) - * See AUTHORS.txt - * SPDX-License-Identifier: MPL-2.0 - * This file is part of Antares-Simulator, - * Adequacy and Performance assessment for interconnected energy networks. - * - * Antares_Simulator is free software: you can redistribute it and/or modify - * it under the terms of the Mozilla Public Licence 2.0 as published by - * the Mozilla Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Antares_Simulator is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Mozilla Public Licence 2.0 for more details. - * - * You should have received a copy of the Mozilla Public Licence 2.0 - * along with Antares_Simulator. If not, see . - */ - -#include "antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h" - -#include "antares/solver/optimisation/opt_fonctions.h" -#include "antares/solver/simulation/ISimulationObserver.h" -#include "antares/solver/simulation/adequacy_patch_runtime_data.h" -#include "antares/study/fwd.h" - -using namespace Antares::Data::AdequacyPatch; -using Antares::Constants::nbHoursInAWeek; - -namespace Antares::Solver::Optimization -{ -AdequacyPatchOptimization::AdequacyPatchOptimization(const Antares::Data::Study& study, - const OptimizationOptions& options, - PROBLEME_HEBDO* problemeHebdo, - AdqPatchParams& adqPatchParams, - uint thread_number, - IResultWriter& writer, - Simulation::ISimulationObserver& observer): - WeeklyOptimization(options, problemeHebdo, adqPatchParams, thread_number, writer, observer), - study_(study) -{ -} - -void AdequacyPatchOptimization::solve() -{ - Simulation::NullSimulationObserver nullSimulationObserver; - problemeHebdo_->adequacyPatchRuntimeData->AdequacyFirstStep = true; - OPT_OptimisationHebdomadaire(options_, - problemeHebdo_, - adqPatchParams_, - writer_, - nullSimulationObserver); - problemeHebdo_->adequacyPatchRuntimeData->AdequacyFirstStep = false; - - for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; ++pays) - { - if (problemeHebdo_->adequacyPatchRuntimeData->areaMode[pays] - == Data::AdequacyPatch::physicalAreaInsideAdqPatch) - { - problemeHebdo_->ResultatsHoraires[pays].ValeursHorairesDENS - = problemeHebdo_->ResultatsHoraires[pays].ValeursHorairesDeDefaillancePositive; - } - else - { - std::ranges::fill(problemeHebdo_->ResultatsHoraires[pays].ValeursHorairesDENS, 0); - } - } - - OPT_OptimisationHebdomadaire(options_, - problemeHebdo_, - adqPatchParams_, - writer_, - nullSimulationObserver); -} - -} // namespace Antares::Solver::Optimization diff --git a/src/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.cpp b/src/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.cpp deleted file mode 100644 index e61b843403..0000000000 --- a/src/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#include "antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h" - -#include "antares/solver/simulation/adequacy_patch_runtime_data.h" - -namespace Antares::Data::AdequacyPatch -{ -/*! - * Determines restriction type for transmission links for first step of adequacy patch, when start - * node is inside adq path (type 2). - * - * @param ExtremityNodeAdequacyPatchType uint: The adq type of the node at the end of the link. - * - * @return uint from an enumeration that describes the type of restrictions to put on this link for - * adq purposes. - */ -static NtcSetToZeroStatus_AdqPatchStep1 SetNTCForAdequacyFirstStepOriginNodeInsideAdq( - AdequacyPatchMode ExtremityNodeAdequacyPatchType) -{ - switch (ExtremityNodeAdequacyPatchType) - { - case physicalAreaInsideAdqPatch: - case physicalAreaOutsideAdqPatch: - return NtcSetToZeroStatus_AdqPatchStep1::setToZero; - default: - return NtcSetToZeroStatus_AdqPatchStep1::leaveLocalValues; - } -} - -/*! - * Determines restriction type for transmission links for first step of adequacy patch, when start - * node is outside adq path (type 1). - * - * @param ExtremityNodeAdequacyPatchType uint: The adq type of the node at the end of the link. - * - * @param setToZeroNTCfromOutToIn_AdqPatch bool: Switch to cut links from nodes outside adq patch - * (type 1) towards nodes inside adq patch (type 2). - * - * @param setToZeroNTCfromOutToOut_AdqPatch bool: Switch to cut links between nodes outside adq - * patch (type 1). - * - * @return uint from an enumeration that describes the type of restrictions to put on this link for - * adq purposes. - */ -static NtcSetToZeroStatus_AdqPatchStep1 getNTCtoZeroStatusOriginNodeOutsideAdq( - AdequacyPatchMode ExtremityNodeAdequacyPatchType, - bool setToZeroNTCfromOutToIn_AdqPatch, - bool setToZeroNTCfromOutToOut_AdqPatch) -{ - switch (ExtremityNodeAdequacyPatchType) - { - case physicalAreaInsideAdqPatch: - return setToZeroNTCfromOutToIn_AdqPatch - ? NtcSetToZeroStatus_AdqPatchStep1::setToZero - : NtcSetToZeroStatus_AdqPatchStep1::setExtremityOriginToZero; - case physicalAreaOutsideAdqPatch: - return setToZeroNTCfromOutToOut_AdqPatch - ? NtcSetToZeroStatus_AdqPatchStep1::setToZero - : NtcSetToZeroStatus_AdqPatchStep1::leaveLocalValues; - default: - return NtcSetToZeroStatus_AdqPatchStep1::leaveLocalValues; - } -} - -/*! - * Determines restriction type for transmission links for first step of adequacy patch. - * - * @param problemeHebdo PROBLEME_HEBDO*: Weekly problem structure. - * - * @param Interco int: Index of the link. - * - * @return uint from an enumeration that describes the type of restrictions to put on this link for - * adq purposes. - */ -static NtcSetToZeroStatus_AdqPatchStep1 getNTCtoZeroStatus(PROBLEME_HEBDO* problemeHebdo, - const AdqPatchParams& adqPatchParams, - int Interco) -{ - AdequacyPatchMode OriginNodeAdequacyPatchType = problemeHebdo->adequacyPatchRuntimeData - ->originAreaMode[Interco]; - AdequacyPatchMode ExtremityNodeAdequacyPatchType = problemeHebdo->adequacyPatchRuntimeData - ->extremityAreaMode[Interco]; - bool setToZeroNTCfromOutToIn_AdqPatch = adqPatchParams.localMatching - .setToZeroOutsideInsideLinks; - bool setToZeroNTCfromOutToOut_AdqPatch = adqPatchParams.localMatching - .setToZeroOutsideOutsideLinks; - - switch (OriginNodeAdequacyPatchType) - { - case physicalAreaInsideAdqPatch: - return SetNTCForAdequacyFirstStepOriginNodeInsideAdq(ExtremityNodeAdequacyPatchType); - - case physicalAreaOutsideAdqPatch: - return getNTCtoZeroStatusOriginNodeOutsideAdq(ExtremityNodeAdequacyPatchType, - setToZeroNTCfromOutToIn_AdqPatch, - setToZeroNTCfromOutToOut_AdqPatch); - default: - return NtcSetToZeroStatus_AdqPatchStep1::leaveLocalValues; - } -} - -void setNTCbounds(double& Xmax, - double& Xmin, - const VALEURS_DE_NTC_ET_RESISTANCES& ValeursDeNTC, - const int Interco, - PROBLEME_HEBDO* problemeHebdo, - const AdqPatchParams& adqPatchParams) -{ - NtcSetToZeroStatus_AdqPatchStep1 ntcToZeroStatusForAdqPatch; - - // set as default values - Xmax = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco]; - Xmin = -(ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine[Interco]); - - // set for adq patch first step - if (adqPatchParams.enabled && adqPatchParams.localMatching.enabled - && problemeHebdo->adequacyPatchRuntimeData->AdequacyFirstStep) - { - ntcToZeroStatusForAdqPatch = getNTCtoZeroStatus(problemeHebdo, adqPatchParams, Interco); - - switch (ntcToZeroStatusForAdqPatch) - { - case NtcSetToZeroStatus_AdqPatchStep1::setToZero: - { - Xmax = 0.; - Xmin = 0.; - break; - } - case NtcSetToZeroStatus_AdqPatchStep1::setOriginExtremityToZero: - { - Xmax = 0.; - Xmin = -(ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine[Interco]); - break; - } - case NtcSetToZeroStatus_AdqPatchStep1::setExtremityOriginToZero: - { - Xmax = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco]; - Xmin = 0.; - break; - } - default: - return; - } - } -} - -} // namespace Antares::Data::AdequacyPatch diff --git a/src/solver/optimisation/base_weekly_optimization.cpp b/src/solver/optimisation/base_weekly_optimization.cpp deleted file mode 100644 index 623331485e..0000000000 --- a/src/solver/optimisation/base_weekly_optimization.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2007-2024, RTE (https://www.rte-france.com) - * See AUTHORS.txt - * SPDX-License-Identifier: MPL-2.0 - * This file is part of Antares-Simulator, - * Adequacy and Performance assessment for interconnected energy networks. - * - * Antares_Simulator is free software: you can redistribute it and/or modify - * it under the terms of the Mozilla Public Licence 2.0 as published by - * the Mozilla Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Antares_Simulator is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Mozilla Public Licence 2.0 for more details. - * - * You should have received a copy of the Mozilla Public Licence 2.0 - * along with Antares_Simulator. If not, see . - */ - -#include "antares/solver/optimisation/base_weekly_optimization.h" - -#include - -#include "antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h" -#include "antares/solver/optimisation/weekly_optimization.h" - -using AdqPatchParams = Antares::Data::AdequacyPatch::AdqPatchParams; - -namespace Antares::Solver::Optimization -{ -WeeklyOptimization::WeeklyOptimization(const OptimizationOptions& options, - PROBLEME_HEBDO* problemesHebdo, - AdqPatchParams& adqPatchParams, - uint thread_number, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver): - options_(options), - problemeHebdo_(problemesHebdo), - adqPatchParams_(adqPatchParams), - thread_number_(thread_number), - writer_(writer), - simulationObserver_(simulationObserver) -{ -} - -std::unique_ptr WeeklyOptimization::create( - const Antares::Data::Study& study, - const OptimizationOptions& options, - AdqPatchParams& adqPatchParams, - PROBLEME_HEBDO* problemeHebdo, - uint thread_number, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver) -{ - if (adqPatchParams.enabled && adqPatchParams.localMatching.enabled) - { - return std::make_unique(study, - options, - problemeHebdo, - adqPatchParams, - thread_number, - writer, - simulationObserver); - } - else - { - return std::make_unique(options, - problemeHebdo, - adqPatchParams, - thread_number, - writer, - simulationObserver); - } -} - -} // namespace Antares::Solver::Optimization diff --git a/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h b/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h deleted file mode 100644 index b11bdc817a..0000000000 --- a/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#pragma once - -#include "antares/solver/simulation/sim_structure_donnees.h" -#include "antares/solver/simulation/sim_structure_probleme_economique.h" -#include "antares/study/area/area.h" - -#include "../base_weekly_optimization.h" - -using Antares::Data::AreaList; - -namespace Antares::Solver::Optimization -{ -class AdequacyPatchOptimization: public WeeklyOptimization -{ -public: - explicit AdequacyPatchOptimization(const Antares::Data::Study& study, - const OptimizationOptions& options, - PROBLEME_HEBDO* problemeHebdo, - Data::AdequacyPatch::AdqPatchParams&, - uint numSpace, - IResultWriter& writer, - Simulation::ISimulationObserver& observer); - - ~AdequacyPatchOptimization() override = default; - void solve() override; - -private: - const Antares::Data::Study& study_; -}; -} // namespace Antares::Solver::Optimization diff --git a/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h b/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h deleted file mode 100644 index eff8842d7b..0000000000 --- a/src/solver/optimisation/include/antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -** Copyright 2007-2024, RTE (https://www.rte-france.com) -** See AUTHORS.txt -** SPDX-License-Identifier: MPL-2.0 -** This file is part of Antares-Simulator, -** Adequacy and Performance assessment for interconnected energy networks. -** -** Antares_Simulator is free software: you can redistribute it and/or modify -** it under the terms of the Mozilla Public Licence 2.0 as published by -** the Mozilla Foundation, either version 2 of the License, or -** (at your option) any later version. -** -** Antares_Simulator is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** Mozilla Public Licence 2.0 for more details. -** -** You should have received a copy of the Mozilla Public Licence 2.0 -** along with Antares_Simulator. If not, see . -*/ - -#pragma once - -#include "antares/solver/simulation/sim_structure_probleme_economique.h" - -namespace Antares::Data::AdequacyPatch -{ -/*! - * Sets link bounds for first step of adequacy patch or leaves default values if adequacy patch is - * not used. - */ -void setNTCbounds(double& Xmax, - double& Xmin, - const VALEURS_DE_NTC_ET_RESISTANCES& ValeursDeNTC, - const int Interco, - PROBLEME_HEBDO* problemeHebdo, - const AdqPatchParams& adqPatchParams); - -} // namespace Antares::Data::AdequacyPatch diff --git a/src/solver/optimisation/include/antares/solver/optimisation/base_weekly_optimization.h b/src/solver/optimisation/include/antares/solver/optimisation/base_weekly_optimization.h deleted file mode 100644 index acae5d8aed..0000000000 --- a/src/solver/optimisation/include/antares/solver/optimisation/base_weekly_optimization.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2007-2024, RTE (https://www.rte-france.com) - * See AUTHORS.txt - * SPDX-License-Identifier: MPL-2.0 - * This file is part of Antares-Simulator, - * Adequacy and Performance assessment for interconnected energy networks. - * - * Antares_Simulator is free software: you can redistribute it and/or modify - * it under the terms of the Mozilla Public Licence 2.0 as published by - * the Mozilla Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * Antares_Simulator is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Mozilla Public Licence 2.0 for more details. - * - * You should have received a copy of the Mozilla Public Licence 2.0 - * along with Antares_Simulator. If not, see . - */ - -#pragma once - -#include // for "uint" definition - -#include -#include "antares/solver/simulation/ISimulationObserver.h" -#include "antares/solver/simulation/sim_structure_donnees.h" -#include "antares/solver/simulation/sim_structure_probleme_economique.h" - -namespace Antares::Solver::Optimization -{ -class WeeklyOptimization -{ -public: - virtual void solve() = 0; - virtual ~WeeklyOptimization() = default; - static std::unique_ptr create( - const Antares::Data::Study& study, - const OptimizationOptions& options, - Antares::Data::AdequacyPatch::AdqPatchParams& adqPatchParams, - PROBLEME_HEBDO* problemesHebdo, - uint numSpace, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver); - -protected: - explicit WeeklyOptimization(const OptimizationOptions& options, - PROBLEME_HEBDO* problemesHebdo, - Antares::Data::AdequacyPatch::AdqPatchParams&, - uint numSpace, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver); - Antares::Solver::Optimization::OptimizationOptions options_; - PROBLEME_HEBDO* const problemeHebdo_ = nullptr; - Antares::Data::AdequacyPatch::AdqPatchParams& adqPatchParams_; - const uint thread_number_ = 0; - IResultWriter& writer_; - std::reference_wrapper simulationObserver_; -}; -} // namespace Antares::Solver::Optimization diff --git a/src/solver/optimisation/include/antares/solver/optimisation/weekly_optimization.h b/src/solver/optimisation/include/antares/solver/optimisation/weekly_optimization.h index 2206d35a25..c1f7774d5d 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/weekly_optimization.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/weekly_optimization.h @@ -24,20 +24,26 @@ #include "antares/solver/simulation/ISimulationObserver.h" #include "antares/solver/simulation/sim_structure_probleme_economique.h" -#include "base_weekly_optimization.h" - namespace Antares::Solver::Optimization { -class DefaultWeeklyOptimization: public WeeklyOptimization + +class WeeklyOptimization { public: - explicit DefaultWeeklyOptimization(const OptimizationOptions& options, - PROBLEME_HEBDO* problemeHebdo, - Antares::Data::AdequacyPatch::AdqPatchParams&, - uint numSpace, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver); - ~DefaultWeeklyOptimization() override = default; - void solve() override; + WeeklyOptimization(const OptimizationOptions& options, + PROBLEME_HEBDO* problemeHebdo, + Antares::Data::AdequacyPatch::AdqPatchParams&, + uint numSpace, + IResultWriter& writer, + Simulation::ISimulationObserver& simulationObserver); + ~WeeklyOptimization() = default; + void solve(); + + Antares::Solver::Optimization::OptimizationOptions options_; + PROBLEME_HEBDO* const problemeHebdo_ = nullptr; + Antares::Data::AdequacyPatch::AdqPatchParams& adqPatchParams_; + const uint thread_number_ = 0; + IResultWriter& writer_; + std::reference_wrapper simulationObserver_; }; } // namespace Antares::Solver::Optimization diff --git a/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp b/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp index 398af7b814..0cc9c93258 100644 --- a/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp +++ b/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp @@ -21,7 +21,6 @@ #include -#include "antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h" #include "antares/solver/optimisation/opt_fonctions.h" #include "antares/solver/optimisation/opt_structure_probleme_a_resoudre.h" #include "antares/solver/simulation/adequacy_patch_runtime_data.h" @@ -133,17 +132,6 @@ void setBoundsForUnsuppliedEnergy(PROBLEME_HEBDO* problemeHebdo, Xmax[var] = 0.; } - // adq patch: update ENS <= DENS in 2nd run - if (adqPatchParams.enabled && adqPatchParams.localMatching.enabled - && !problemeHebdo->adequacyPatchRuntimeData->AdequacyFirstStep - && problemeHebdo->adequacyPatchRuntimeData->areaMode[pays] - == Data::AdequacyPatch::physicalAreaInsideAdqPatch) - { - Xmax[var] = std::min( - Xmax[var], - problemeHebdo->ResultatsHoraires[pays].ValeursHorairesDENS[pdtHebdo]); - } - problemeHebdo->ResultatsHoraires[pays].ValeursHorairesDeDefaillancePositive[pdtHebdo] = 0.0; @@ -249,12 +237,8 @@ void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaire(PROBLEME_HEBDO* prob int var = variableManager.NTCDirect(interco, pdtJour); const COUTS_DE_TRANSPORT& CoutDeTransport = problemeHebdo->CoutDeTransport[interco]; - AdequacyPatch::setNTCbounds(Xmax[var], - Xmin[var], - ValeursDeNTC, - interco, - problemeHebdo, - adqPatchParams); + Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[interco]; + Xmin[var] = -(ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine[interco]); if (std::isinf(Xmax[var]) && Xmax[var] > 0) { diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 3ced34ba4a..046c2cbb30 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -22,7 +22,6 @@ #include "antares/solver/optimisation/post_process_commands.h" #include "antares/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.h" -#include "antares/solver/optimisation/adequacy_patch_local_matching/adequacy_patch_weekly_optimization.h" #include "antares/solver/simulation/adequacy_patch_runtime_data.h" #include "antares/solver/simulation/common-eco-adq.h" @@ -261,7 +260,7 @@ double CurtailmentSharingPostProcessCmd::calculateDensNewAndTotalLmrViolation() { const auto [netPositionInit, densNew, totalNodeBalance] = calculateAreaFlowBalance( problemeHebdo_, - adqPatchParams_.localMatching.setToZeroOutsideInsideLinks, + adqPatchParams_.setToZeroOutsideInsideLinks, Area, hour); // adjust densNew according to the new specification/request by ELIA diff --git a/src/solver/optimisation/weekly_optimization.cpp b/src/solver/optimisation/weekly_optimization.cpp index 8f36d762d2..0cf6ec84cd 100644 --- a/src/solver/optimisation/weekly_optimization.cpp +++ b/src/solver/optimisation/weekly_optimization.cpp @@ -25,23 +25,22 @@ namespace Antares::Solver::Optimization { -DefaultWeeklyOptimization::DefaultWeeklyOptimization( - const OptimizationOptions& options, - PROBLEME_HEBDO* problemeHebdo, - AdqPatchParams& adqPatchParams, - uint thread_number, - IResultWriter& writer, - Simulation::ISimulationObserver& simulationObserver): - WeeklyOptimization(options, - problemeHebdo, - adqPatchParams, - thread_number, - writer, - simulationObserver) +WeeklyOptimization::WeeklyOptimization(const OptimizationOptions& options, + PROBLEME_HEBDO* problemeHebdo, + AdqPatchParams& adqPatchParams, + uint thread_number, + IResultWriter& writer, + Simulation::ISimulationObserver& simulationObserver): + options_(options), + problemeHebdo_(problemeHebdo), + adqPatchParams_(adqPatchParams), + thread_number_(thread_number), + writer_(writer), + simulationObserver_(simulationObserver) { } -void DefaultWeeklyOptimization::solve() +void WeeklyOptimization::solve() { OPT_OptimisationHebdomadaire(options_, problemeHebdo_, diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index 269fcd26ff..4499c339dc 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -71,7 +71,7 @@ bool Economy::simulationBegin() if (!preproOnly) { pProblemesHebdo.resize(pNbMaxPerformedYearsInParallel); - weeklyOptProblems_.resize(pNbMaxPerformedYearsInParallel); + weeklyOptProblems_.clear(); postProcessesList_.resize(pNbMaxPerformedYearsInParallel); for (uint numSpace = 0; numSpace < pNbMaxPerformedYearsInParallel; numSpace++) @@ -82,14 +82,14 @@ bool Economy::simulationBegin() numSpace); auto options = createOptimizationOptions(study); - weeklyOptProblems_[numSpace] = Antares::Solver::Optimization::WeeklyOptimization:: - create(study, - options, - study.parameters.adqPatchParams, - &pProblemesHebdo[numSpace], - numSpace, - resultWriter, - simulationObserver_.get()); + + weeklyOptProblems_.emplace_back(options, + &pProblemesHebdo[numSpace], + study.parameters.adqPatchParams, + numSpace, + resultWriter, + simulationObserver_.get()); + postProcessesList_[numSpace] = interfacePostProcessList::create( study.parameters.adqPatchParams, &pProblemesHebdo[numSpace], @@ -163,7 +163,7 @@ bool Economy::year(Progression::Task& progression, try { - weeklyOptProblems_[numSpace]->solve(); + weeklyOptProblems_[numSpace].solve(); // Runs all the post processes in the list of post-process commands optRuntimeData opt_runtime_data(state.year, w, hourInTheYear); diff --git a/src/solver/simulation/include/antares/solver/simulation/adequacy_patch_runtime_data.h b/src/solver/simulation/include/antares/solver/simulation/adequacy_patch_runtime_data.h index f91576a233..5ae0f3f5fb 100644 --- a/src/solver/simulation/include/antares/solver/simulation/adequacy_patch_runtime_data.h +++ b/src/solver/simulation/include/antares/solver/simulation/adequacy_patch_runtime_data.h @@ -42,7 +42,6 @@ class AdequacyPatchRuntimeData std::vector originAreaMode; std::vector extremityAreaMode; std::vector hurdleCostCoefficients; - bool AdequacyFirstStep = true; bool wasCSRTriggeredAtAreaHour(int area, int hour) const; void addCSRTriggeredAtAreaHour(int area, int hour); diff --git a/src/solver/simulation/include/antares/solver/simulation/economy.h b/src/solver/simulation/include/antares/solver/simulation/economy.h index 592fac59f8..0ff621e01a 100644 --- a/src/solver/simulation/include/antares/solver/simulation/economy.h +++ b/src/solver/simulation/include/antares/solver/simulation/economy.h @@ -22,7 +22,7 @@ #define __SOLVER_SIMULATION_ECONOMY_H__ #include "antares/infoCollection/StudyInfoCollector.h" -#include "antares/solver/optimisation/base_weekly_optimization.h" +#include "antares/solver/optimisation/weekly_optimization.h" #include "antares/solver/simulation/opt_time_writer.h" #include "antares/solver/simulation/solver.h" // for definition of type yearRandomNumbers #include "antares/solver/variable/economy/all.h" @@ -98,8 +98,7 @@ class Economy uint pStartTime; uint pNbMaxPerformedYearsInParallel; std::vector pProblemesHebdo; - std::vector> - weeklyOptProblems_; + std::vector weeklyOptProblems_; std::vector> postProcessesList_; IResultWriter& resultWriter; std::reference_wrapper simulationObserver_; diff --git a/src/tests/src/solver/optimisation/adequacy_patch/adequacy_patch.cpp b/src/tests/src/solver/optimisation/adequacy_patch/adequacy_patch.cpp index 377969fd5d..d4e722fd13 100644 --- a/src/tests/src/solver/optimisation/adequacy_patch/adequacy_patch.cpp +++ b/src/tests/src/solver/optimisation/adequacy_patch/adequacy_patch.cpp @@ -31,7 +31,6 @@ #include #include #include "antares/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.h" -#include "antares/solver/optimisation/adequacy_patch_local_matching/adq_patch_local_matching.h" #include "antares/study/parameters/adq-patch-params.h" static double origineExtremite = -1; @@ -39,43 +38,6 @@ static double extremiteOrigine = 5; using namespace Antares::Data::AdequacyPatch; -// NOTE -// Xmax limits the flux origin -> extremity (direct) -// -Xmin limits the flux extremity -> origin (indirect) - -std::pair setNTCboundsForOneTimeStep(AdequacyPatchMode originType, - AdequacyPatchMode extremityType, - bool SetNTCOutsideToOutsideToZero, - bool SetNTCOutsideToInsideToZero) -{ - PROBLEME_HEBDO problem; - problem.adequacyPatchRuntimeData = std::make_shared(); - problem.adequacyPatchRuntimeData->originAreaMode.resize(1); - problem.adequacyPatchRuntimeData->extremityAreaMode.resize(1); - - problem.adequacyPatchRuntimeData->originAreaMode[0] = originType; - problem.adequacyPatchRuntimeData->extremityAreaMode[0] = extremityType; - problem.adequacyPatchRuntimeData->AdequacyFirstStep = true; - - AdqPatchParams adqPatchParams; - adqPatchParams.enabled = true; - adqPatchParams.localMatching.setToZeroOutsideOutsideLinks = SetNTCOutsideToOutsideToZero; - adqPatchParams.localMatching.setToZeroOutsideInsideLinks = SetNTCOutsideToInsideToZero; - - VALEURS_DE_NTC_ET_RESISTANCES ValeursDeNTC; - ValeursDeNTC.ValeurDeNTCOrigineVersExtremite.assign(1, 0.); - ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine.assign(1, 0.); - ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[0] = origineExtremite; - ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine[0] = extremiteOrigine; - - double Xmin(0.); - double Xmax(0.); - - setNTCbounds(Xmax, Xmin, ValeursDeNTC, 0, &problem, adqPatchParams); - - return std::make_pair(Xmin, Xmax); -} - static const double flowArea0toArea1_positive = 10; static const double flowArea0toArea1_negative = -10; static const double flowArea2toArea0_positive = 30; @@ -111,8 +73,7 @@ std::pair calculateAreaFlowBalanceForOneTimeStep( problem.IndexDebutIntercoExtremite = std::vector(1); // input values - adqPatchParams.localMatching.setToZeroOutsideInsideLinks - = !includeFlowsOutsideAdqPatchToDensNew; + adqPatchParams.setToZeroOutsideInsideLinks = !includeFlowsOutsideAdqPatchToDensNew; problem.ResultatsHoraires[Area].ValeursHorairesDeDefaillancePositive[hour] = ensInit; int Interco = 1; problem.IndexDebutIntercoOrigine[Area] = Interco; @@ -131,7 +92,7 @@ std::pair calculateAreaFlowBalanceForOneTimeStep( double densNew; std::tie(netPositionInit, densNew, std::ignore) = calculateAreaFlowBalance( &problem, - adqPatchParams.localMatching.setToZeroOutsideInsideLinks, + adqPatchParams.setToZeroOutsideInsideLinks, Area, hour); @@ -143,119 +104,11 @@ AdqPatchParams createParams() AdqPatchParams p; p.enabled = true; p.curtailmentSharing.includeHurdleCost = true; - p.localMatching.enabled = true; p.curtailmentSharing.priceTakingOrder = AdqPatchPTO::isDens; return p; } -// Virtual -> Virtual (0 -> 0) -// No change in bounds is expected -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_virtual_virtual_no_change_expected) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(virtualArea, - virtualArea, - true /*SetNTCOutsideToOutsideToZero*/, - false); - BOOST_CHECK_EQUAL(Xmax, origineExtremite); - BOOST_CHECK_EQUAL(Xmin, -extremiteOrigine); -} - -// Virtual -> physical area inside adq-patch (0 -> 2) -// No change in bounds is expected -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_virtual_inside_no_change_expected) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(virtualArea, - physicalAreaInsideAdqPatch, - true /*SetNTCOutsideToOutsideToZero*/, - false); - BOOST_CHECK_EQUAL(Xmax, origineExtremite); - BOOST_CHECK_EQUAL(Xmin, -extremiteOrigine); -} - -// Virtual -> physical area outside adq-patch (0 -> 1) -// No change in bounds is expected -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_virtual_outside_no_change_expected) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(virtualArea, - physicalAreaOutsideAdqPatch, - true /*SetNTCOutsideToOutsideToZero*/, - false); - BOOST_CHECK_EQUAL(Xmax, origineExtremite); - BOOST_CHECK_EQUAL(Xmin, -extremiteOrigine); -} - -// physical area outside adq-patch -> physical area outside adq-patch (1 -> 1) -// NTC should be set to 0 in both directions -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_outside_outside_zero_expected_both_directions) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(physicalAreaOutsideAdqPatch, - physicalAreaOutsideAdqPatch, - true /*SetNTCOutsideToOutsideToZero*/, - false); - BOOST_CHECK_EQUAL(Xmax, 0); - BOOST_CHECK_EQUAL(Xmin, 0); -} - -// physical area outside adq-patch -> physical area outside adq-patch (1 -> 1) -// SetNTCOutsideToOutsideToZero = true -// NTC should be set to 0 in both directions -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_outside_outside_no_change_expected) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(physicalAreaOutsideAdqPatch, - physicalAreaOutsideAdqPatch, - false, - false); - - BOOST_CHECK_EQUAL(Xmax, origineExtremite); - BOOST_CHECK_EQUAL(Xmin, -extremiteOrigine); -} - -// physical area inside adq-patch -> physical area outside adq-patch (2 -> 1) -// NTC should be set to 0 in both directions -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_inside_outside_zero_expected_both_directions) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(physicalAreaInsideAdqPatch, - physicalAreaOutsideAdqPatch, - false, - false); - BOOST_CHECK_EQUAL(Xmax, 0); - BOOST_CHECK_EQUAL(Xmin, 0); -} - -// physical area outside adq-patch -> physical area inside adq-patch (1 -> 2) -// NTC should be set to 0 in both directions -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_outside_inside_zero_expected_both_directions) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(physicalAreaOutsideAdqPatch, - physicalAreaInsideAdqPatch, - false, - true /*SetNTCOutsideToInsideToZero*/); - BOOST_CHECK_EQUAL(Xmax, 0); - BOOST_CHECK_EQUAL(Xmin, 0); -} - -// physical area outside adq-patch -> physical area inside adq-patch (1 -> 2) -// NTC should be unchanged in direction origin->extremity (direct) -// NTC should be set to 0 in direction extremity->origin (indirect) -BOOST_AUTO_TEST_CASE(setNTCboundsForOneTimeStep_outside_inside_change_expected_one_direction) -{ - double Xmin, Xmax; - std::tie(Xmin, Xmax) = setNTCboundsForOneTimeStep(physicalAreaOutsideAdqPatch, - physicalAreaInsideAdqPatch, - false, - false); - BOOST_CHECK_EQUAL(Xmax, origineExtremite); - BOOST_CHECK_EQUAL(Xmin, 0); -} - // Area 0 is physical area inside adq-patch connected to two areas: // Area1 virtual-area, and Area2-virtual area // flow from Area0 -> Area1 is positive diff --git a/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.cpp b/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.cpp index 2368e68d13..d65d6ddbeb 100644 --- a/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.cpp +++ b/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.cpp @@ -165,29 +165,13 @@ AdequacyPatchOptions::AdequacyPatchOptions(wxWindow* parent) : button->menu(true); onPopup.bind(this, &AdequacyPatchOptions::onPopupMenuNTC, - PopupInfo(study.parameters.adqPatchParams.localMatching.setToZeroOutsideInsideLinks, + PopupInfo(study.parameters.adqPatchParams.setToZeroOutsideInsideLinks, wxT("NTC"))); button->onPopupMenu(onPopup); s->Add(label, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); s->Add(button, 0, wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pBtnNTCfromOutToInAdqPatch = button; } - // Transmission capacities (NTC) between physical areas outside adequacy patch (area type 1). - // Used in the first step of adequacy patch local matching rule. - { - label = Component::CreateLabel(this, wxT("NTC between physical areas outside adequacy patch")); - button = new Component::Button(this, wxT("Day"), "images/16x16/light_green.png"); - button->SetBackgroundColour(bgColor); - button->menu(true); - onPopup.bind(this, - &AdequacyPatchOptions::onPopupMenuNTC, - PopupInfo(study.parameters.adqPatchParams.localMatching.setToZeroOutsideOutsideLinks, - wxT("NTC"))); - button->onPopupMenu(onPopup); - s->Add(label, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - s->Add(button, 0, wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - pBtnNTCfromOutToOutAdqPatch = button; - } // PTO (Price Taking Order). User can choose between DENS and Load { label = Component::CreateLabel(this, wxT("Price taking order")); @@ -360,12 +344,7 @@ void AdequacyPatchOptions::refresh() // adequacy patch (area type 2). Used in the first step of adequacy patch local matching rule. buttonType = "ntc"; updateButton(pBtnNTCfromOutToInAdqPatch, - study.parameters.adqPatchParams.localMatching.setToZeroOutsideInsideLinks, - buttonType); - // NTC between physical areas outside adequacy patch (area type 1). Used in the first step of - // adequacy patch local matching rule. - updateButton(pBtnNTCfromOutToOutAdqPatch, - study.parameters.adqPatchParams.localMatching.setToZeroOutsideOutsideLinks, + study.parameters.adqPatchParams.setToZeroOutsideInsideLinks, buttonType); // Price taking order (PTO) for adequacy patch buttonType = "pto";