From dd54bd4149cd6c788c86131655ad47b6f9e8deff Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Fri, 15 Jul 2022 09:36:52 +0200 Subject: [PATCH 01/25] Bump to CXX 17 --- src/CMakeLists.txt | 2 ++ src/solver/variable/state.cpp | 4 ++-- src/tests/src/libs/antares/study/area/CMakeLists.txt | 1 - .../src/libs/antares/study/scenario-builder/CMakeLists.txt | 1 - 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 410b845c0a..63237bc3d4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,8 @@ include(CheckCXXCompilerFlag) include(CMakeDependentOption) include(FetchContent) +set(CMAKE_CXX_STANDARD 17) + if (DEFINED VCPKG_ROOT) include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake) endif() diff --git a/src/solver/variable/state.cpp b/src/solver/variable/state.cpp index bba46e5711..5d4e793561 100644 --- a/src/solver/variable/state.cpp +++ b/src/solver/variable/state.cpp @@ -161,9 +161,9 @@ void State::initFromThermalClusterIndex(const uint clusterAreaWideIndex, uint nu if (thermalClusterProduction > 0.) { // alias to the production of the current thermal cluster - register double p = thermalClusterProduction; + double p = thermalClusterProduction; // alias to the previous number of started units - register uint previousUnitCount = thermalCluster->unitCountLastHour[numSpace]; + uint previousUnitCount = thermalCluster->unitCountLastHour[numSpace]; // Looking for the new number of units which have been started uint newUnitCount; diff --git a/src/tests/src/libs/antares/study/area/CMakeLists.txt b/src/tests/src/libs/antares/study/area/CMakeLists.txt index c4cd28eb0d..5beb25014b 100644 --- a/src/tests/src/libs/antares/study/area/CMakeLists.txt +++ b/src/tests/src/libs/antares/study/area/CMakeLists.txt @@ -1,5 +1,4 @@ # Useful variables definitions -set(CMAKE_CXX_STANDARD 17) set(src_libs_antares_study "${CMAKE_SOURCE_DIR}/libs/antares/study") # ================================ diff --git a/src/tests/src/libs/antares/study/scenario-builder/CMakeLists.txt b/src/tests/src/libs/antares/study/scenario-builder/CMakeLists.txt index 10d72ed93b..6a7c023de9 100644 --- a/src/tests/src/libs/antares/study/scenario-builder/CMakeLists.txt +++ b/src/tests/src/libs/antares/study/scenario-builder/CMakeLists.txt @@ -1,5 +1,4 @@ # Useful variables definitions -set(CMAKE_CXX_STANDARD 17) set(src_libs_antares_study "${CMAKE_SOURCE_DIR}/libs/antares/study") # ==================================== From 5a9254e439323f94246a5626af1a7924dde736d1 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Tue, 16 Aug 2022 11:44:36 +0200 Subject: [PATCH 02/25] Clarify execution-info.ini file --- src/libs/antares/benchmarking/file_content.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/antares/benchmarking/file_content.cpp b/src/libs/antares/benchmarking/file_content.cpp index 56822d0db0..6877dd3a69 100644 --- a/src/libs/antares/benchmarking/file_content.cpp +++ b/src/libs/antares/benchmarking/file_content.cpp @@ -26,7 +26,7 @@ namespace Benchmarking void FileContent::addDurationItem(const string& name, unsigned int duration, int nbCalls) { - addItemToSection("Durations", name + "_duration", duration); - addItemToSection("Durations", name + "_nb_calls", nbCalls); + addItemToSection("durations_ms", name, duration); + addItemToSection("number_of_calls", name, nbCalls); } } From 919fc6a28ca9b00ba1d5ae632f140868e12187fd Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 14:15:33 +0200 Subject: [PATCH 03/25] 1. Make NumberOfVariables a reference var --- .../adequacy_patch_csr/construct_problem_variables.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp b/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp index d53ba569f5..d7d24fe6e2 100644 --- a/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp @@ -37,10 +37,11 @@ void constructVariableENS(PROBLEME_HEBDO* ProblemeHebdo, HOURLY_CSR_PROBLEM& hourlyCsrProblem) { - int NumberOfVariables = 0; int hour = hourlyCsrProblem.hourInWeekTriggeredCsr; PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre; ProblemeAResoudre = ProblemeHebdo->ProblemeAResoudre; + int& NumberOfVariables = ProblemeAResoudre->NombreDeVariables; + NumberOfVariables = 0; CORRESPONDANCES_DES_VARIABLES* CorrespondanceVarNativesVarOptim; CorrespondanceVarNativesVarOptim = ProblemeHebdo->CorrespondanceVarNativesVarOptim[hour]; @@ -62,7 +63,6 @@ void constructVariableENS(PROBLEME_HEBDO* ProblemeHebdo, HOURLY_CSR_PROBLEM& hou NumberOfVariables++; } } - ProblemeAResoudre->NombreDeVariables = NumberOfVariables; } void constructVariableSpilledEnergy(PROBLEME_HEBDO* ProblemeHebdo, From 653af41845716f5abb2247b39a972d3fac43f469 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 14:19:48 +0200 Subject: [PATCH 04/25] change function name CSR_DEBUG_ --- src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp index 0224d8b8cb..c7c512f913 100644 --- a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp @@ -128,7 +128,7 @@ void storeInteriorPointResults(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, } } -void CSR_DEBUG_BLAH(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre) +void CSR_DEBUG_HANDLE(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre) { int Var; @@ -177,7 +177,7 @@ void handleInteriorPointError(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, << ". hour: " << weekNb * hoursInWeek + hourlyCsrProblem.hourInWeekTriggeredCsr + 1; #ifndef NDEBUG - CSR_DEBUG_BLAH(ProblemeAResoudre); + CSR_DEBUG_HANDLE(ProblemeAResoudre); #endif } From d593fb24a3d35b4ab211b43ead5603d6ee76da3b Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 14:33:04 +0200 Subject: [PATCH 05/25] 3. test Probleme.ExistenceDUneSolution directly --- src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp index c7c512f913..83c4cb6cfe 100644 --- a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp @@ -189,8 +189,7 @@ bool ADQ_PATCH_CSR(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, PROBLEME_POINT_INTERIEUR Probleme; setInteriorPointProblem(ProblemeAResoudre, Probleme); PI_Quamin(&Probleme); // resolution - ProblemeAResoudre->ExistenceDUneSolution = Probleme.ExistenceDUneSolution; - if (ProblemeAResoudre->ExistenceDUneSolution == OUI_PI) + if (Probleme.ExistenceDUneSolution == OUI_PI) { storeInteriorPointResults(ProblemeAResoudre, hourlyCsrProblem); return true; From eda86bdfc31dca2f9d5c6f63c863fb4b2a86b313 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 15:11:52 +0200 Subject: [PATCH 06/25] 2. Slightly clearer version --- .../adequacy_patch_csr/solve_problem.cpp | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp index 83c4cb6cfe..68a6604d60 100644 --- a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp @@ -55,9 +55,10 @@ extern "C" using namespace Antares; -void setInteriorPointProblem(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, - PROBLEME_POINT_INTERIEUR& Probleme) +std::unique_ptr buildInteriorPointProblem( + PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre) { + std::unique_ptr Probleme(new PROBLEME_POINT_INTERIEUR()); int ChoixToleranceParDefautSurLAdmissibilite; int ChoixToleranceParDefautSurLaStationnarite; int ChoixToleranceParDefautSurLaComplementarite; @@ -66,40 +67,42 @@ void setInteriorPointProblem(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, ChoixToleranceParDefautSurLaStationnarite = OUI_PI; ChoixToleranceParDefautSurLaComplementarite = OUI_PI; - Probleme.NombreMaxDIterations = -1; - Probleme.CoutQuadratique = ProblemeAResoudre->CoutQuadratique; - Probleme.CoutLineaire = ProblemeAResoudre->CoutLineaire; - Probleme.X = ProblemeAResoudre->X; - Probleme.Xmin = ProblemeAResoudre->Xmin; - Probleme.Xmax = ProblemeAResoudre->Xmax; - Probleme.NombreDeVariables = ProblemeAResoudre->NombreDeVariables; - Probleme.TypeDeVariable = ProblemeAResoudre->TypeDeVariable; - - Probleme.VariableBinaire = (char*)ProblemeAResoudre->CoutsReduits; - - Probleme.NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes; - Probleme.IndicesDebutDeLigne = ProblemeAResoudre->IndicesDebutDeLigne; - Probleme.NombreDeTermesDesLignes = ProblemeAResoudre->NombreDeTermesDesLignes; - Probleme.IndicesColonnes = ProblemeAResoudre->IndicesColonnes; - Probleme.CoefficientsDeLaMatriceDesContraintes + Probleme->NombreMaxDIterations = -1; + Probleme->CoutQuadratique = ProblemeAResoudre->CoutQuadratique; + Probleme->CoutLineaire = ProblemeAResoudre->CoutLineaire; + Probleme->X = ProblemeAResoudre->X; + Probleme->Xmin = ProblemeAResoudre->Xmin; + Probleme->Xmax = ProblemeAResoudre->Xmax; + Probleme->NombreDeVariables = ProblemeAResoudre->NombreDeVariables; + Probleme->TypeDeVariable = ProblemeAResoudre->TypeDeVariable; + + Probleme->VariableBinaire = (char*)ProblemeAResoudre->CoutsReduits; + + Probleme->NombreDeContraintes = ProblemeAResoudre->NombreDeContraintes; + Probleme->IndicesDebutDeLigne = ProblemeAResoudre->IndicesDebutDeLigne; + Probleme->NombreDeTermesDesLignes = ProblemeAResoudre->NombreDeTermesDesLignes; + Probleme->IndicesColonnes = ProblemeAResoudre->IndicesColonnes; + Probleme->CoefficientsDeLaMatriceDesContraintes = ProblemeAResoudre->CoefficientsDeLaMatriceDesContraintes; - Probleme.Sens = ProblemeAResoudre->Sens; - Probleme.SecondMembre = ProblemeAResoudre->SecondMembre; + Probleme->Sens = ProblemeAResoudre->Sens; + Probleme->SecondMembre = ProblemeAResoudre->SecondMembre; - Probleme.AffichageDesTraces = NON_PI; + Probleme->AffichageDesTraces = NON_PI; - Probleme.UtiliserLaToleranceDAdmissibiliteParDefaut = ChoixToleranceParDefautSurLAdmissibilite; + Probleme->UtiliserLaToleranceDAdmissibiliteParDefaut = ChoixToleranceParDefautSurLAdmissibilite; - Probleme.UtiliserLaToleranceDeStationnariteParDefaut + Probleme->UtiliserLaToleranceDeStationnariteParDefaut = ChoixToleranceParDefautSurLaStationnarite; - Probleme.UtiliserLaToleranceDeComplementariteParDefaut + Probleme->UtiliserLaToleranceDeComplementariteParDefaut = ChoixToleranceParDefautSurLaComplementarite; - Probleme.CoutsMarginauxDesContraintes = ProblemeAResoudre->CoutsMarginauxDesContraintes; + Probleme->CoutsMarginauxDesContraintes = ProblemeAResoudre->CoutsMarginauxDesContraintes; - Probleme.CoutsMarginauxDesContraintesDeBorneInf = ProblemeAResoudre->CoutsReduits; - Probleme.CoutsMarginauxDesContraintesDeBorneSup = ProblemeAResoudre->CoutsReduits; + Probleme->CoutsMarginauxDesContraintesDeBorneInf = ProblemeAResoudre->CoutsReduits; + Probleme->CoutsMarginauxDesContraintesDeBorneSup = ProblemeAResoudre->CoutsReduits; + + return Probleme; } void setToZeroIfBelowThreshold(double* pt, int Var, HOURLY_CSR_PROBLEM& hourlyCsrProblem) @@ -186,10 +189,10 @@ bool ADQ_PATCH_CSR(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, uint weekNb, int yearNb) { - PROBLEME_POINT_INTERIEUR Probleme; - setInteriorPointProblem(ProblemeAResoudre, Probleme); - PI_Quamin(&Probleme); // resolution - if (Probleme.ExistenceDUneSolution == OUI_PI) + std::unique_ptr Probleme + = buildInteriorPointProblem(ProblemeAResoudre); + PI_Quamin(Probleme.get()); // resolution + if (Probleme->ExistenceDUneSolution == OUI_PI) { storeInteriorPointResults(ProblemeAResoudre, hourlyCsrProblem); return true; From 3525d4474aa07fef5404c2c9c4f5768509bd1604 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 15:17:16 +0200 Subject: [PATCH 07/25] 4. make hoursRequiringCurtailmentSharing const var --- src/solver/simulation/economy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index 771e07d11c..ebcc1cf6b8 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -98,7 +98,8 @@ void AdequacyPatchOptimization::solve(Variable::State& state, ::SIM_RenseignementProblemeHebdo(*problemeHebdo, state, numSpace, hourInTheYear); OPT_OptimisationHebdomadaire(problemeHebdo, numSpace); - std::set hoursRequiringCurtailmentSharing = getHoursRequiringCurtailmentSharing(numSpace); + const std::set hoursRequiringCurtailmentSharing + = getHoursRequiringCurtailmentSharing(numSpace); for (int hourInWeek : hoursRequiringCurtailmentSharing) { logs.info() << "[adq-patch] CSR triggered for Year:" << state.year + 1 From 15e10dd88a1d91a4f2ad4c87b46565ea1e5b993f Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 15:30:59 +0200 Subject: [PATCH 08/25] 5. avoid cast sumENS[i] to int! --- src/solver/optimisation/adequacy_patch.cpp | 2 +- src/solver/simulation/economy.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch.cpp b/src/solver/optimisation/adequacy_patch.cpp index 3d86c7870a..9940cc45de 100644 --- a/src/solver/optimisation/adequacy_patch.cpp +++ b/src/solver/optimisation/adequacy_patch.cpp @@ -136,7 +136,7 @@ void setNTCbounds(double& Xmax, double checkLocalMatchingRuleViolations(PROBLEME_HEBDO* ProblemeHebdo, uint weekNb) { - float threshold = ProblemeHebdo->adqPatchParams->ThresholdDisplayLocalMatchingRuleViolations; + double threshold = ProblemeHebdo->adqPatchParams->ThresholdDisplayLocalMatchingRuleViolations; double netPositionInit; double densNew; double ensInit; diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index ebcc1cf6b8..faf088a640 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -221,12 +221,12 @@ vector AdequacyPatchOptimization::calculateENSoverAllAreasForEachHour(ui std::set AdequacyPatchOptimization::identifyHoursForCurtailmentSharing(vector sumENS, uint numSpace) { - float threshold + double threshold = pProblemesHebdo[numSpace]->adqPatchParams->ThresholdInitiateCurtailmentSharingRule; std::set triggerCsrSet; for (int i = 0; i < nbHoursInAWeek; ++i) { - if ((int)sumENS[i] > threshold) + if (sumENS[i] > threshold) { triggerCsrSet.insert(i); } From 65caf6e12a8b36cc6cf4bd033c09f98a9bebdf2b Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:08:09 +0200 Subject: [PATCH 09/25] 17. move default thresholds to adequacy_patch.h --- src/libs/antares/study/fwd.h | 5 ----- src/libs/antares/study/parameters.cpp | 5 +++-- src/solver/optimisation/adequacy_patch.h | 4 ++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libs/antares/study/fwd.h b/src/libs/antares/study/fwd.h index 6a852dbe55..1a879e82e3 100644 --- a/src/libs/antares/study/fwd.h +++ b/src/libs/antares/study/fwd.h @@ -604,11 +604,6 @@ enum AdqPatchPTO }; // enum AdqPatchPTO -//! A default threshold value for initiate curtailment sharing rule -const float adqPatchDefaultValueThresholdInitiateCurtailmentSharingRule = 0.0; -//! A default threshold value for display local matching rule violations -const float adqPatchDefaultValueThresholdDisplayLocalMatchingRuleViolations = 0.0; - } // namespace AdequacyPatch } // namespace Data } // namespace Antares diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 20bb3013f0..b401a88ee0 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -43,6 +43,7 @@ #include #include #include "../solver/variable/economy/all.h" +#include "../solver/optimisation/adequacy_patch.h" #include #include @@ -237,9 +238,9 @@ void Parameters::resetThresholdsAdqPatch() { // Initialize all thresholds values for adequacy patch adqPatch.curtailmentSharing.thresholdInitiate - = adqPatchDefaultValueThresholdInitiateCurtailmentSharingRule; + = defaultValueThresholdInitiateCurtailmentSharingRule; adqPatch.curtailmentSharing.thresholdDisplayViolations - = adqPatchDefaultValueThresholdDisplayLocalMatchingRuleViolations; + = defaultValueThresholdDisplayLocalMatchingRuleViolations; } void Parameters::resetAdqPatchParameters() diff --git a/src/solver/optimisation/adequacy_patch.h b/src/solver/optimisation/adequacy_patch.h index f8a1d78972..86c161832d 100644 --- a/src/solver/optimisation/adequacy_patch.h +++ b/src/solver/optimisation/adequacy_patch.h @@ -37,6 +37,10 @@ namespace Data { namespace AdequacyPatch { +//! A default threshold value for initiate curtailment sharing rule +const double defaultValueThresholdInitiateCurtailmentSharingRule = 0.0; +//! A default threshold value for display local matching rule violations +const double defaultValueThresholdDisplayLocalMatchingRuleViolations = 0.0; /*! * Determines restriction type for transmission links for first step of adequacy patch. * From 6df6a4ef18915b732fbae614d46c0a7e11b781b9 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:14:46 +0200 Subject: [PATCH 10/25] 20. use A.size() in addArray function --- src/solver/optimisation/adequacy_patch.cpp | 4 ++-- src/solver/optimisation/adequacy_patch.h | 3 +-- src/solver/simulation/economy.cpp | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch.cpp b/src/solver/optimisation/adequacy_patch.cpp index 9940cc45de..9092b5702a 100644 --- a/src/solver/optimisation/adequacy_patch.cpp +++ b/src/solver/optimisation/adequacy_patch.cpp @@ -222,9 +222,9 @@ std::pair calculateAreaFlowBalance(PROBLEME_HEBDO* ProblemeHebdo return std::make_pair(netPositionInit, densNew); } -void addArray(std::vector& A, double* B, int num) +void addArray(std::vector& A, double* B) { - for (uint i = 0; i < num; ++i) + for (uint i = 0; i < A.size(); ++i) A[i] += B[i]; } diff --git a/src/solver/optimisation/adequacy_patch.h b/src/solver/optimisation/adequacy_patch.h index 86c161832d..c253778140 100644 --- a/src/solver/optimisation/adequacy_patch.h +++ b/src/solver/optimisation/adequacy_patch.h @@ -111,10 +111,9 @@ double checkLocalMatchingRuleViolations(PROBLEME_HEBDO* ProblemeHebdo, uint week ** ** ** ** \param A A vector ** ** \param B An array -** ** \param num An integer ** ** \return ** */ -void addArray(std::vector& A, double* B, int num); +void addArray(std::vector& A, double* B); } // end namespace Antares } // end namespace Data diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index faf088a640..f5d06884cf 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -212,8 +212,7 @@ vector AdequacyPatchOptimization::calculateENSoverAllAreasForEachHour(ui addArray(sumENS, pProblemesHebdo[numSpace] ->ResultatsHoraires[area] - ->ValeursHorairesDeDefaillancePositive, - nbHoursInAWeek); + ->ValeursHorairesDeDefaillancePositive); } return sumENS; } From 90c6f0be5a1fdfbcf34c953156091862b7686db8 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:31:41 +0200 Subject: [PATCH 11/25] 19. create dedicated method solveCSR --- src/solver/simulation/economy.cpp | 30 ++++++++++++++++++------------ src/solver/simulation/economy.h | 1 + 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/solver/simulation/economy.cpp b/src/solver/simulation/economy.cpp index f5d06884cf..e770f426d3 100644 --- a/src/solver/simulation/economy.cpp +++ b/src/solver/simulation/economy.cpp @@ -98,18 +98,7 @@ void AdequacyPatchOptimization::solve(Variable::State& state, ::SIM_RenseignementProblemeHebdo(*problemeHebdo, state, numSpace, hourInTheYear); OPT_OptimisationHebdomadaire(problemeHebdo, numSpace); - const std::set hoursRequiringCurtailmentSharing - = getHoursRequiringCurtailmentSharing(numSpace); - for (int hourInWeek : hoursRequiringCurtailmentSharing) - { - logs.info() << "[adq-patch] CSR triggered for Year:" << state.year + 1 - << " Hour:" << w * nbHoursInAWeek + hourInWeek + 1; - HOURLY_CSR_PROBLEM hourlyCsrProblem(hourInWeek, problemeHebdo); - hourlyCsrProblem.run(w, state.year); - } - double totalLmrViolation = checkLocalMatchingRuleViolations(problemeHebdo, w); - logs.info() << "[adq-patch] Year:" << state.year + 1 << " Week:" << w + 1 - << ".Total LMR violation:" << totalLmrViolation; + solveCSR(state, numSpace, w); } // No adequacy patch @@ -240,6 +229,23 @@ std::set AdequacyPatchOptimization::getHoursRequiringCurtailmentSharing(uin return identifyHoursForCurtailmentSharing(sumENS, numSpace); } +void AdequacyPatchOptimization::solveCSR(Variable::State& state, uint numSpace, uint w) +{ + auto problemeHebdo = pProblemesHebdo[numSpace]; + const std::set hoursRequiringCurtailmentSharing + = getHoursRequiringCurtailmentSharing(numSpace); + for (int hourInWeek : hoursRequiringCurtailmentSharing) + { + logs.info() << "[adq-patch] CSR triggered for Year:" << state.year + 1 + << " Hour:" << w * nbHoursInAWeek + hourInWeek + 1; + HOURLY_CSR_PROBLEM hourlyCsrProblem(hourInWeek, problemeHebdo); + hourlyCsrProblem.run(w, state.year); + } + double totalLmrViolation = checkLocalMatchingRuleViolations(problemeHebdo, w); + logs.info() << "[adq-patch] Year:" << state.year + 1 << " Week:" << w + 1 + << ".Total LMR violation:" << totalLmrViolation; +} + bool Economy::year(Progression::Task& progression, Variable::State& state, uint numSpace, diff --git a/src/solver/simulation/economy.h b/src/solver/simulation/economy.h index aa675073cf..fe78eb3ea5 100644 --- a/src/solver/simulation/economy.h +++ b/src/solver/simulation/economy.h @@ -60,6 +60,7 @@ class AdequacyPatchOptimization : public EconomyWeeklyOptimization public: AdequacyPatchOptimization(); void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint w) override; + void solveCSR(Variable::State& state, uint numSpace, uint w); vector calculateENSoverAllAreasForEachHour(uint numSpace); std::set identifyHoursForCurtailmentSharing(vector sumENS, uint numSpace); From 53528706d55f31dd288048e3079964c9ef31e2c6 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:40:59 +0200 Subject: [PATCH 12/25] 7. name change --- src/solver/simulation/economy.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/solver/simulation/economy.h b/src/solver/simulation/economy.h index fe78eb3ea5..039f73c129 100644 --- a/src/solver/simulation/economy.h +++ b/src/solver/simulation/economy.h @@ -47,7 +47,7 @@ class EconomyWeeklyOptimization { public: using Ptr = std::unique_ptr; - virtual void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint w) = 0; + virtual void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint week) = 0; void initializeProblemeHebdo(PROBLEME_HEBDO** pProblemesHebdo); static Ptr create(bool adqPatchEnabled); @@ -59,8 +59,8 @@ class AdequacyPatchOptimization : public EconomyWeeklyOptimization { public: AdequacyPatchOptimization(); - void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint w) override; - void solveCSR(Variable::State& state, uint numSpace, uint w); + void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint week) override; + void solveCSR(Variable::State& state, uint numSpace, uint week); vector calculateENSoverAllAreasForEachHour(uint numSpace); std::set identifyHoursForCurtailmentSharing(vector sumENS, uint numSpace); @@ -71,7 +71,7 @@ class NoAdequacyPatchOptimization : public EconomyWeeklyOptimization { public: NoAdequacyPatchOptimization(); - void solve(Variable::State&, int, uint numSpace, uint w) override; + void solve(Variable::State&, int, uint numSpace, uint week) override; }; class Economy From 7086560344a870fc1541e7655fa7a9009a2b0405 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:46:50 +0200 Subject: [PATCH 13/25] 8. make methods of AdequacyPatchOptimization private --- src/solver/simulation/economy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solver/simulation/economy.h b/src/solver/simulation/economy.h index 039f73c129..e7cb1ee0a0 100644 --- a/src/solver/simulation/economy.h +++ b/src/solver/simulation/economy.h @@ -61,7 +61,7 @@ class AdequacyPatchOptimization : public EconomyWeeklyOptimization AdequacyPatchOptimization(); void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint week) override; void solveCSR(Variable::State& state, uint numSpace, uint week); - +private: vector calculateENSoverAllAreasForEachHour(uint numSpace); std::set identifyHoursForCurtailmentSharing(vector sumENS, uint numSpace); std::set getHoursRequiringCurtailmentSharing(uint numSpace); From 5bdbd3546eb928700d87bab4ce25d1ab0fd5c2e8 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:54:53 +0200 Subject: [PATCH 14/25] 11. 14. 16 delete unused logs --- .../construct_problem_constraints_RHS.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp index 79917212c5..bbcda3a88e 100644 --- a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp @@ -131,9 +131,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo, // 1. The original RHS of bingding constraint SecondMembre[Cnt] = MatriceDesContraintesCouplantes->SecondMembreDeLaContrainteCouplante[hour]; - // logs.debug() << Cnt << ": Hourly bc: Existing-RHS[" << Cnt - // << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante - // << ")"; // 2. RHS part 2: flow other than 2<->2 NbInterco @@ -150,17 +147,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo, { ValueOfFlow = ProblemeHebdo->ValeursDeNTC[hour]->ValeurDuFlux[Interco]; SecondMembre[Cnt] -= ValueOfFlow * Poids; - // logs.debug() - // << Cnt << ": Hourly bc: IntercoFlow-RHS[" << Cnt - // << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante << ")" - // << ". Interco;" + std::to_string(Interco) << ". Between:[" - // << ProblemeHebdo - // ->NomsDesPays[ProblemeHebdo->PaysOrigineDeLInterconnexion[Interco]] - // << "]-[" - // << ProblemeHebdo - // ->NomsDesPays[ProblemeHebdo->PaysExtremiteDeLInterconnexion[Interco]] - // << "]" - // << ". ValueOfFlow: " << ValueOfFlow << ". Poids: " << Poids; } } @@ -190,11 +176,6 @@ void setRHSbindingConstraintsValue(PROBLEME_HEBDO* ProblemeHebdo, ->ProductionThermiqueDuPalier[IndexNumeroDuPalierDispatch]; SecondMembre[Cnt] -= ValueOfVar * Poids; - // logs.debug() << Cnt << ": Hourly bc: ThermalCluster-RHS[" << Cnt - // << "] = " << SecondMembre[Cnt] << " (CntCouplante = " << CntCouplante - // << ")" - // << ". Area:" << Area << ", Palier:" << Palier << ", Poids" << Poids - // << ", ValueOfVar:" << ValueOfVar; } if (MatriceDesContraintesCouplantes->SensDeLaContrainteCouplante == '<') { From cca06c7cb4aa29183fcf21b5c1dd0788cf3a4c61 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:56:25 +0200 Subject: [PATCH 15/25] 9. delete forward declaration of HOURLY_CSR_PROBLEM --- src/solver/simulation/sim_structure_probleme_economique.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/sim_structure_probleme_economique.h index 14782edf7b..260e7f1f13 100644 --- a/src/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/sim_structure_probleme_economique.h @@ -505,8 +505,6 @@ struct AdequacyPatchParameters float ThresholdDisplayLocalMatchingRuleViolations; }; -class HOURLY_CSR_PROBLEM; - struct PROBLEME_HEBDO { /* Business problem */ From ab253addb5358e00750e5288465f6294889fb304 Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 16:59:20 +0200 Subject: [PATCH 16/25] 15. remove Double definition. --- .../optimisation/opt_gestion_second_membre_cas_quadratique.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/solver/optimisation/opt_gestion_second_membre_cas_quadratique.cpp b/src/solver/optimisation/opt_gestion_second_membre_cas_quadratique.cpp index 17e9596c20..0d5188d13d 100644 --- a/src/solver/optimisation/opt_gestion_second_membre_cas_quadratique.cpp +++ b/src/solver/optimisation/opt_gestion_second_membre_cas_quadratique.cpp @@ -25,8 +25,6 @@ ** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions */ -const double csrSolverRelaxationRHS = 1e-3; - #include "opt_structure_probleme_a_resoudre.h" #include "../simulation/simulation.h" From 363208cfa09ca58ab48f9d1aee485bc4f4bcabcb Mon Sep 17 00:00:00 2001 From: Milos A Date: Mon, 22 Aug 2022 17:04:17 +0200 Subject: [PATCH 17/25] 12. 13 update copyright & Authors for adq-patch files --- src/solver/optimisation/adequacy_patch.cpp | 4 ++-- src/solver/optimisation/adequacy_patch.h | 4 ++-- .../adequacy_patch_csr/construct_problem_constraints_LHS.cpp | 4 ++-- .../adequacy_patch_csr/construct_problem_constraints_RHS.cpp | 4 ++-- .../adequacy_patch_csr/construct_problem_variables.cpp | 4 ++-- .../adequacy_patch_csr/set_problem_cost_function.cpp | 4 ++-- .../adequacy_patch_csr/set_variable_boundaries.cpp | 4 ++-- src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch.cpp b/src/solver/optimisation/adequacy_patch.cpp index 9092b5702a..ad4141353e 100644 --- a/src/solver/optimisation/adequacy_patch.cpp +++ b/src/solver/optimisation/adequacy_patch.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch.h b/src/solver/optimisation/adequacy_patch.h index c253778140..9e4514e77f 100644 --- a/src/solver/optimisation/adequacy_patch.h +++ b/src/solver/optimisation/adequacy_patch.h @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_LHS.cpp b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_LHS.cpp index 2257aa05d2..3acf492761 100644 --- a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_LHS.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_LHS.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp index bbcda3a88e..43cab01f5d 100644 --- a/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/construct_problem_constraints_RHS.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp b/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp index d7d24fe6e2..8421fcfd60 100644 --- a/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/construct_problem_variables.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/set_problem_cost_function.cpp b/src/solver/optimisation/adequacy_patch_csr/set_problem_cost_function.cpp index ba91f1ebba..ea05066a3f 100644 --- a/src/solver/optimisation/adequacy_patch_csr/set_problem_cost_function.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/set_problem_cost_function.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/set_variable_boundaries.cpp b/src/solver/optimisation/adequacy_patch_csr/set_variable_boundaries.cpp index 2651940c5e..2ca69fd898 100644 --- a/src/solver/optimisation/adequacy_patch_csr/set_variable_boundaries.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/set_variable_boundaries.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** diff --git a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp index 68a6604d60..690cba4dea 100644 --- a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp @@ -1,6 +1,6 @@ /* -** Copyright 2007-2018 RTE -** Authors: Antares_Simulator Team +** Copyright 2007-2022 RTE +** Authors: RTE-international / Redstork / Antares_Simulator Team ** ** This file is part of Antares_Simulator. ** From 3b4c1810d6ae4b1b856c77a65671189d0e0e67d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 23 Aug 2022 10:10:19 +0200 Subject: [PATCH 18/25] Fix missing renewable columns in districts (sets of areas) (#802) --- src/solver/variable/economy/all.h | 53 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/solver/variable/economy/all.h b/src/solver/variable/economy/all.h index c94d1d6f59..42aca7ba93 100644 --- a/src/solver/variable/economy/all.h +++ b/src/solver/variable/economy/all.h @@ -197,48 +197,51 @@ typedef // Prices Common::SpatialAggregate< DispatchableGeneration, Common::SpatialAggregate< - HydroStorage, + RenewableGeneration, Common::SpatialAggregate< - Pumping, + HydroStorage, Common::SpatialAggregate< - ReservoirLevel, + Pumping, Common::SpatialAggregate< - Inflows, + ReservoirLevel, Common::SpatialAggregate< - Overflows, + Inflows, Common::SpatialAggregate< - WaterValue, + Overflows, Common::SpatialAggregate< - HydroCost, + WaterValue, Common::SpatialAggregate< - UnsupliedEnergy, + HydroCost, Common::SpatialAggregate< - DomesticUnsuppliedEnergy, + UnsupliedEnergy, Common::SpatialAggregate< - SpilledEnergy, - // LOLD + DomesticUnsuppliedEnergy, Common::SpatialAggregate< - LOLD, + SpilledEnergy, + // LOLD Common::SpatialAggregate< - LOLP, - + LOLD, Common::SpatialAggregate< - AvailableDispatchGen, + LOLP, + Common::SpatialAggregate< - DispatchableGenMargin, + AvailableDispatchGen, Common::SpatialAggregate< - Marge, - - // Detail Prices + DispatchableGenMargin, Common::SpatialAggregate< - NonProportionalCost, // MBO 13/05/2014 - - // refs: #21 + Marge, - // Number Of Dispatched Units + // Detail Prices Common::SpatialAggregate< - NbOfDispatchedUnits // MBO 25/02/2016 - // - refs: #55 - >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + NonProportionalCost, // MBO 13/05/2014 + // - refs: #21 + + // Number Of Dispatched Units + Common::SpatialAggregate< + NbOfDispatchedUnits // MBO + // 25/02/2016 + // - refs: #55 + >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> VariablesPerSetOfAreas; typedef Variable::Join< From ac4f7f446c56ead624fc4f2d0709b3d0d9c730e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 23 Aug 2022 12:38:58 +0200 Subject: [PATCH 19/25] execution_info.ini : add OR-Tools used & solver (#820) * execution_info.ini : add OR-Tools used & solver * PR remarks --- .../antares/benchmarking/info_collectors.cpp | 22 ++++++++++++++++++- .../antares/benchmarking/info_collectors.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libs/antares/benchmarking/info_collectors.cpp b/src/libs/antares/benchmarking/info_collectors.cpp index 61231ecb57..a425b01c28 100644 --- a/src/libs/antares/benchmarking/info_collectors.cpp +++ b/src/libs/antares/benchmarking/info_collectors.cpp @@ -1,7 +1,8 @@ #include #include "info_collectors.h" #include -#include "antares/study/area/area.h" +#include +#include using namespace Antares::Data; @@ -19,6 +20,8 @@ namespace Benchmarking unitCommitmentModeToFileContent(file_content); maxNbYearsInParallelToFileContent(file_content); solverVersionToFileContent(file_content); + ORToolsUsed(file_content); + ORToolsSolver(file_content); } void StudyInfoCollector::areasCountToFileContent(FileContent& file_content) @@ -116,6 +119,23 @@ namespace Benchmarking file_content.addItemToSection("study", "antares version", version); } + void StudyInfoCollector::ORToolsUsed(FileContent& file_content) + { + const bool& ortoolsUsed = study_.parameters.ortoolsUsed; + file_content.addItemToSection("study", "ortools used", ortoolsUsed ? "true" : "false"); + } + + void StudyInfoCollector::ORToolsSolver(FileContent& file_content) + { + const bool& ortoolsUsed = study_.parameters.ortoolsUsed; + std::string ortoolsSolver = "none"; + if (ortoolsUsed) + { + ortoolsSolver = Enum::toString(study_.parameters.ortoolsEnumUsed); + } + file_content.addItemToSection("study", "ortools solver", ortoolsSolver); + } + // Collecting data optimization problem // ------------------------------------- void SimulationInfoCollector::toFileContent(FileContent& file_content) diff --git a/src/libs/antares/benchmarking/info_collectors.h b/src/libs/antares/benchmarking/info_collectors.h index ba793b4dcc..0421b0160b 100644 --- a/src/libs/antares/benchmarking/info_collectors.h +++ b/src/libs/antares/benchmarking/info_collectors.h @@ -41,6 +41,9 @@ class StudyInfoCollector void maxNbYearsInParallelToFileContent(FileContent& file_content); void solverVersionToFileContent(FileContent& file_content); + void ORToolsUsed(FileContent& file_content); + void ORToolsSolver(FileContent& file_content); + // Member data const Antares::Data::Study& study_; }; From 5a9ee2fd28492e33794ae43806c26ace8658598d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 23 Aug 2022 12:40:49 +0200 Subject: [PATCH 20/25] Fix wrong number of cores + code de-duplication (#793) * Fix wrong number of cores + code de-duplication * PR remarks + small refactor (template) --- .../windows/options/advanced/advanced.cpp | 76 ++++--------------- .../windows/options/advanced/advanced.h | 11 +-- 2 files changed, 20 insertions(+), 67 deletions(-) diff --git a/src/ui/simulator/windows/options/advanced/advanced.cpp b/src/ui/simulator/windows/options/advanced/advanced.cpp index 457a304da6..bb94630e9f 100644 --- a/src/ui/simulator/windows/options/advanced/advanced.cpp +++ b/src/ui/simulator/windows/options/advanced/advanced.cpp @@ -899,7 +899,7 @@ void AdvancedParameters::onNumberOfCores(Component::Button&, wxMenu& menu, void* it = Menu::CreateItem(&menu, wxID_ANY, text, "images/16x16/tag.png"); menu.Connect(it->GetId(), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AdvancedParameters::onSelectNCmin), + wxCommandEventHandler(AdvancedParameters::onSelectNumberOfCoresLevel), nullptr, this); @@ -908,7 +908,7 @@ void AdvancedParameters::onNumberOfCores(Component::Button&, wxMenu& menu, void* it = Menu::CreateItem(&menu, wxID_ANY, text, "images/16x16/tag.png"); menu.Connect(it->GetId(), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AdvancedParameters::onSelectNClow), + wxCommandEventHandler(AdvancedParameters::onSelectNumberOfCoresLevel), nullptr, this); @@ -918,7 +918,7 @@ void AdvancedParameters::onNumberOfCores(Component::Button&, wxMenu& menu, void* it = Menu::CreateItem(&menu, wxID_ANY, text, "images/16x16/tag.png"); menu.Connect(it->GetId(), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AdvancedParameters::onSelectNCaverage), + wxCommandEventHandler(AdvancedParameters::onSelectNumberOfCoresLevel), nullptr, this); @@ -927,7 +927,7 @@ void AdvancedParameters::onNumberOfCores(Component::Button&, wxMenu& menu, void* it = Menu::CreateItem(&menu, wxID_ANY, text, "images/16x16/tag.png"); menu.Connect(it->GetId(), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AdvancedParameters::onSelectNChigh), + wxCommandEventHandler(AdvancedParameters::onSelectNumberOfCoresLevel), nullptr, this); @@ -936,79 +936,31 @@ void AdvancedParameters::onNumberOfCores(Component::Button&, wxMenu& menu, void* it = Menu::CreateItem(&menu, wxID_ANY, text, "images/16x16/tag.png"); menu.Connect(it->GetId(), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(AdvancedParameters::onSelectNCmax), + wxCommandEventHandler(AdvancedParameters::onSelectNumberOfCoresLevel), nullptr, this); } -void AdvancedParameters::onSelectNCmin(wxCommandEvent& /* evt */) +void AdvancedParameters::onSelectNumberOfCoresLevel(Data::NumberOfCoresMode ncMode) { if (not Data::Study::Current::Valid()) return; - auto& study = *Data::Study::Current::Get(); - - if (study.parameters.nbCores.ncMode != Data::ncMin) - { - study.parameters.nbCores.ncMode = Data::ncMin; - MarkTheStudyAsModified(); - refresh(); - } -} - -void AdvancedParameters::onSelectNClow(wxCommandEvent& /* evt */) -{ - if (not Data::Study::Current::Valid()) - return; - auto& study = *Data::Study::Current::Get(); - - if (study.parameters.nbCores.ncMode != Data::ncLow) - { - study.parameters.nbCores.ncMode = Data::ncLow; - MarkTheStudyAsModified(); - refresh(); - } -} - -void AdvancedParameters::onSelectNCaverage(wxCommandEvent& /* evt */) -{ - if (not Data::Study::Current::Valid()) - return; - auto& study = *Data::Study::Current::Get(); + auto study = Data::Study::Current::Get(); - if (study.parameters.nbCores.ncMode != Data::ncAvg) + if (study->parameters.nbCores.ncMode != ncMode) { - study.parameters.nbCores.ncMode = Data::ncAvg; + study->parameters.nbCores.ncMode = ncMode; + // Force refresh for study->nbYearsParallelRaw + study->getNumberOfCores(false, 1 /* ignored */); MarkTheStudyAsModified(); refresh(); } } -void AdvancedParameters::onSelectNChigh(wxCommandEvent& /* evt */) +template +void AdvancedParameters::onSelectNumberOfCoresLevel(wxCommandEvent& /* evt */) { - if (not Data::Study::Current::Valid()) - return; - auto& study = *Data::Study::Current::Get(); - - if (study.parameters.nbCores.ncMode != Data::ncHigh) - { - study.parameters.nbCores.ncMode = Data::ncHigh; - MarkTheStudyAsModified(); - refresh(); - } -} - -void AdvancedParameters::onSelectNCmax(wxCommandEvent& /* evt */) -{ - if (not Data::Study::Current::Valid()) - return; - auto& study = *Data::Study::Current::Get(); - - if (study.parameters.nbCores.ncMode != Data::ncMax) - { - study.parameters.nbCores.ncMode = Data::ncMax; - MarkTheStudyAsModified(); - refresh(); - } + onSelectNumberOfCoresLevel(level); } void AdvancedParameters::onRenewableGenerationModelling(Component::Button&, wxMenu& menu, void*) diff --git a/src/ui/simulator/windows/options/advanced/advanced.h b/src/ui/simulator/windows/options/advanced/advanced.h index 156cf997af..a39d502abc 100644 --- a/src/ui/simulator/windows/options/advanced/advanced.h +++ b/src/ui/simulator/windows/options/advanced/advanced.h @@ -103,12 +103,13 @@ class AdvancedParameters final : public wxDialog void onSelectUCMixedIntegerLinearProblem(wxCommandEvent& evt); void onNumberOfCores(Component::Button&, wxMenu& menu, void*); - void onSelectNCmin(wxCommandEvent& evt); - void onSelectNClow(wxCommandEvent& evt); - void onSelectNCaverage(wxCommandEvent& evt); - void onSelectNChigh(wxCommandEvent& evt); - void onSelectNCmax(wxCommandEvent& evt); + template + void onSelectNumberOfCoresLevel(wxCommandEvent& evt); +private: + void onSelectNumberOfCoresLevel(Data::NumberOfCoresMode ncMode); + +public: void onRenewableGenerationModelling(Component::Button&, wxMenu& menu, void*); void onSelectRGMaggregated(wxCommandEvent& evt); void onSelectRGMrenewableClusters(wxCommandEvent& evt); From 713f167db432c29e1fa62796c4980309bc083b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Omn=C3=A8s?= Date: Tue, 23 Aug 2022 13:12:04 +0200 Subject: [PATCH 21/25] Release/8.3.1 (#818) --- docs/CHANGELOG.md | 15 +++++++++ docs/reference-guide/13-file-format.md | 44 ++++++++++++++++++++++++++ src/CMakeLists.txt | 2 +- vcpkg_manifest/vcpkg.json | 2 +- 4 files changed, 61 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index af86f2aa12..4b42aa8ced 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,21 @@ Antares Changelog ================= +v8.3.1 (08/2022) +-------------------- +### New features +- Add execution-info.ini output file, containing execution durations and study info #740 #803 #816 +- OR-Tools: set solver-specific options for XPRESS #796 + +### Bug fixes +- Fix missing renewable columns in districts (sets of areas) #802 + +### GUI +- Fix wrong number of cores in the "Run a simulation" window #793 + +### For developers +- Bump C++11 to C++17 + v8.3.0 (07/2022) -------------------- ### New features diff --git a/docs/reference-guide/13-file-format.md b/docs/reference-guide/13-file-format.md index 9d54160260..3c93e25991 100644 --- a/docs/reference-guide/13-file-format.md +++ b/docs/reference-guide/13-file-format.md @@ -1,6 +1,50 @@ # Study format changes 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. +## v8.3.1 +### Output +Add file **execution_info.ini**, containing information about the execution time for the various steps of a study, as well as study related information that affects performance. + +```ini +[durations_ms] +hydro_ventilation = 7 +mc_years = 693 +post_processing = 0 +study_loading = 51 +synthesis_export = 731 +total = 1526 +yby_export = 114 + +[number_of_calls] +hydro_ventilation = 1 +mc_years = 1 +post_processing = 1 +study_loading = 1 +synthesis_export = 1 +total = 1 +yby_export = 1 + +[optimization problem] +constraints = 1008 +non-zero coefficients = 15894 +variables = 1512 + +[study] +antares version = 831 +areas = 3 +enabled bc = 0 +enabled daily bc = 0 +enabled hourly bc = 0 +enabled thermal clusters = 1 +enabled weekly bc = 0 +links = 2 +max parallel years = 1 +ortools solver = xpress +ortools used = true +performed years = 1 +unit commitment = fast +``` + ## v8.3.0 ### Input In file **settings/generaldata.ini**, add section `adequacy patch`, with properties diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37a0aa08fb..ef3c406700 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.14) # FetchContent_MakeAvailable # Version set(ANTARES_VERSION_HI 8) set(ANTARES_VERSION_LO 3) -set(ANTARES_VERSION_REVISION 0) +set(ANTARES_VERSION_REVISION 1) set(ANTARES_VERSION_YEAR 2022) project(antares diff --git a/vcpkg_manifest/vcpkg.json b/vcpkg_manifest/vcpkg.json index 4a24af3295..48e01e8003 100644 --- a/vcpkg_manifest/vcpkg.json +++ b/vcpkg_manifest/vcpkg.json @@ -1,6 +1,6 @@ { "name": "antares-simulator", - "version-string": "8.3.0", + "version-string": "8.3.1", "dependencies": [ "wxwidgets", "boost-test" From b4ad70333fa1ee34d60c341887badbebb30bb071 Mon Sep 17 00:00:00 2001 From: Milos A Date: Wed, 24 Aug 2022 11:11:54 +0200 Subject: [PATCH 22/25] make solveCSR private method --- src/solver/simulation/economy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solver/simulation/economy.h b/src/solver/simulation/economy.h index e7cb1ee0a0..73dd53b999 100644 --- a/src/solver/simulation/economy.h +++ b/src/solver/simulation/economy.h @@ -60,8 +60,8 @@ class AdequacyPatchOptimization : public EconomyWeeklyOptimization public: AdequacyPatchOptimization(); void solve(Variable::State& state, int hourInTheYear, uint numSpace, uint week) override; - void solveCSR(Variable::State& state, uint numSpace, uint week); private: + void solveCSR(Variable::State& state, uint numSpace, uint week); vector calculateENSoverAllAreasForEachHour(uint numSpace); std::set identifyHoursForCurtailmentSharing(vector sumENS, uint numSpace); std::set getHoursRequiringCurtailmentSharing(uint numSpace); From c865631bd3cc92e4a06556d6fa7abaa26a990079 Mon Sep 17 00:00:00 2001 From: Milos A Date: Wed, 24 Aug 2022 11:14:15 +0200 Subject: [PATCH 23/25] use auto instead of std::unique_ptr --- src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp index 690cba4dea..1b9bfcb141 100644 --- a/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp +++ b/src/solver/optimisation/adequacy_patch_csr/solve_problem.cpp @@ -58,7 +58,7 @@ using namespace Antares; std::unique_ptr buildInteriorPointProblem( PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre) { - std::unique_ptr Probleme(new PROBLEME_POINT_INTERIEUR()); + auto Probleme = std::make_unique(); int ChoixToleranceParDefautSurLAdmissibilite; int ChoixToleranceParDefautSurLaStationnarite; int ChoixToleranceParDefautSurLaComplementarite; @@ -189,7 +189,7 @@ bool ADQ_PATCH_CSR(PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre, uint weekNb, int yearNb) { - std::unique_ptr Probleme + auto Probleme = buildInteriorPointProblem(ProblemeAResoudre); PI_Quamin(Probleme.get()); // resolution if (Probleme->ExistenceDUneSolution == OUI_PI) From 20d0bd33005031d514f6592b33a41fcaa2e03ed4 Mon Sep 17 00:00:00 2001 From: Milos A Date: Wed, 24 Aug 2022 11:15:16 +0200 Subject: [PATCH 24/25] float->double --- src/solver/simulation/sim_structure_probleme_economique.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/sim_structure_probleme_economique.h index 260e7f1f13..8950899df0 100644 --- a/src/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/sim_structure_probleme_economique.h @@ -501,8 +501,8 @@ struct AdequacyPatchParameters bool SaveIntermediateResults; bool IncludeHurdleCostCsr; AdqPatchPTO PriceTakingOrder; - float ThresholdInitiateCurtailmentSharingRule; - float ThresholdDisplayLocalMatchingRuleViolations; + double ThresholdInitiateCurtailmentSharingRule; + double ThresholdDisplayLocalMatchingRuleViolations; }; struct PROBLEME_HEBDO From 016444135505a02d00470b5086069adc77025439 Mon Sep 17 00:00:00 2001 From: Milos A Date: Wed, 24 Aug 2022 11:47:59 +0200 Subject: [PATCH 25/25] remove saveIntermediateResults --- docs/reference-guide/03-commands.md | 1 - src/libs/antares/study/parameters.cpp | 4 ---- src/libs/antares/study/parameters.h | 3 --- .../simulation/sim_calcul_economique.cpp | 2 -- .../sim_structure_probleme_economique.h | 1 - .../adequacy-patch/adequacy-patch-options.cpp | 19 ------------------- .../adequacy-patch/adequacy-patch-options.h | 1 - 7 files changed, 31 deletions(-) diff --git a/docs/reference-guide/03-commands.md b/docs/reference-guide/03-commands.md index 3598b9ed9d..96c95dcea0 100644 --- a/docs/reference-guide/03-commands.md +++ b/docs/reference-guide/03-commands.md @@ -220,7 +220,6 @@ Auxiliary window [Areas] Opens a window in which a choice can be made regarding - _NTC from physical areas outside to physical areas inside adequacy patch (set to null / local values)_ - _NTC between physical areas outside adequacy patch (set to null / local values)_ - _Price taking order (DENS / Load)_ -- _Save intermediate results (false / true)_ - _Include hurdle cost in CSR optimization (false / true)_ - _Thresholds:_ - _Initiate curtailment sharing rule_ diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index b401a88ee0..21543155a3 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -249,7 +249,6 @@ void Parameters::resetAdqPatchParameters() adqPatch.localMatching.setToZeroOutsideInsideLinks = true; adqPatch.localMatching.setToZeroOutsideOutsideLinks = true; adqPatch.curtailmentSharing.priceTakingOrder = Data::AdequacyPatch::AdqPatchPTO::isDens; - adqPatch.saveIntermediateResults = false; adqPatch.curtailmentSharing.includeHurdleCost = false; resetThresholdsAdqPatch(); } @@ -681,8 +680,6 @@ static bool SGDIntLoadFamily_AdqPatch(Parameters& d, return value.to(d.adqPatch.localMatching.setToZeroOutsideInsideLinks); if (key == "set-to-null-ntc-between-physical-out-for-first-step") return value.to(d.adqPatch.localMatching.setToZeroOutsideOutsideLinks); - if (key == "save-intermediate-results") - return value.to(d.adqPatch.saveIntermediateResults); // Price taking order if (key == "price-taking-order") return StringToPriceTakingOrder(value, d.adqPatch.curtailmentSharing.priceTakingOrder); @@ -1820,7 +1817,6 @@ void Parameters::saveToINI(IniFile& ini) const adqPatch.localMatching.setToZeroOutsideInsideLinks); section->add("set-to-null-ntc-between-physical-out-for-first-step", adqPatch.localMatching.setToZeroOutsideOutsideLinks); - section->add("save-intermediate-results", adqPatch.saveIntermediateResults); section->add("price-taking-order", PriceTakingOrderToString(adqPatch.curtailmentSharing.priceTakingOrder)); section->add("include-hurdle-cost-csr", adqPatch.curtailmentSharing.includeHurdleCost); diff --git a/src/libs/antares/study/parameters.h b/src/libs/antares/study/parameters.h index 2178107319..f3678ff4c5 100644 --- a/src/libs/antares/study/parameters.h +++ b/src/libs/antares/study/parameters.h @@ -542,9 +542,6 @@ class Parameters final }; CurtailmentSharing curtailmentSharing; - //! Select whether the intermediate result before the application of the curtailment - //! sharing is to be kept in the results - bool saveIntermediateResults; void addExcludedVariables(std::vector&) const; }; diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 600e80698e..274ba00496 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -72,8 +72,6 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study, = parameters.adqPatch.localMatching.setToZeroOutsideInsideLinks; problem.adqPatchParams->SetNTCOutsideToOutsideToZero = parameters.adqPatch.localMatching.setToZeroOutsideOutsideLinks; - problem.adqPatchParams->SaveIntermediateResults - = parameters.adqPatch.saveIntermediateResults; problem.adqPatchParams->PriceTakingOrder = parameters.adqPatch.curtailmentSharing.priceTakingOrder; problem.adqPatchParams->IncludeHurdleCostCsr diff --git a/src/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/sim_structure_probleme_economique.h index 8950899df0..419ca359ef 100644 --- a/src/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/sim_structure_probleme_economique.h @@ -498,7 +498,6 @@ struct AdequacyPatchParameters bool AdequacyFirstStep; bool SetNTCOutsideToInsideToZero; bool SetNTCOutsideToOutsideToZero; - bool SaveIntermediateResults; bool IncludeHurdleCostCsr; AdqPatchPTO PriceTakingOrder; double ThresholdInitiateCurtailmentSharingRule; 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 c6b453f47f..2fcf7b0f3f 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 @@ -217,21 +217,6 @@ AdequacyPatchOptions::AdequacyPatchOptions(wxWindow* parent) : s->Add(button, 0, wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); pBtnAdequacyPatchIncludeHurdleCostCsr = button; } - // Select whether the intermediate result before the application of the curtailment sharing is - // to be kept in the results - { - label = Component::CreateLabel(this, wxT("Save intermediate results")); - button = new Component::Button(this, wxT("true"), "images/16x16/light_green.png"); - button->SetBackgroundColour(bgColor); - button->menu(true); - onPopup.bind(this, - &AdequacyPatchOptions::onPopupMenuSpecify, - PopupInfo(study.parameters.adqPatch.saveIntermediateResults, wxT("true"))); - button->onPopupMenu(onPopup); - s->Add(label, 0, wxRIGHT | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - s->Add(button, 0, wxLEFT | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL); - pBtnAdequacyPatchSaveIntermediateResults = button; - } addLabelAdqPatch(this, s, wxT("Thresholds")); // Threshold values { @@ -345,10 +330,6 @@ void AdequacyPatchOptions::refresh() std::string buttonType = "specify"; // Include adequacy patch updateButton(pBtnAdequacyPatch, study.parameters.adqPatch.enabled, buttonType); - // Save intermediate results for adequacy patch - updateButton(pBtnAdequacyPatchSaveIntermediateResults, - study.parameters.adqPatch.saveIntermediateResults, - buttonType); // Include hurdle cost for CSR updateButton(pBtnAdequacyPatchIncludeHurdleCostCsr, study.parameters.adqPatch.curtailmentSharing.includeHurdleCost, diff --git a/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.h b/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.h index 888fb4a0d4..0b46bdb1a7 100644 --- a/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.h +++ b/src/ui/simulator/windows/options/adequacy-patch/adequacy-patch-options.h @@ -94,7 +94,6 @@ class AdequacyPatchOptions final : public wxDialog Component::Button* pBtnNTCfromOutToInAdqPatch; Component::Button* pBtnNTCfromOutToOutAdqPatch; Component::Button* pBtnAdequacyPatchPTO; - Component::Button* pBtnAdequacyPatchSaveIntermediateResults; Component::Button* pBtnAdequacyPatchIncludeHurdleCostCsr; wxTextCtrl* pThresholdCSRStart; wxTextCtrl* pThresholdLMRviolations;