From 9651e22ad21fa5870472717b1c79dd769d30c8a1 Mon Sep 17 00:00:00 2001 From: sylvmara Date: Wed, 30 Oct 2024 18:05:47 +0100 Subject: [PATCH] Added the option to output the delta in number of active groups by cluster by adding delta-cluster = true in generaldata.ini => outputs --- .../study/include/antares/study/parameters.h | 6 +++ src/libs/antares/study/load.cpp | 1 + src/libs/antares/study/parameters.cpp | 6 +++ .../opt_optimisation_lineaire.cpp | 53 ++++++++++++++++++- .../sim_structure_probleme_economique.h | 1 + .../simulation/sim_calcul_economique.cpp | 1 + 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/libs/antares/study/include/antares/study/parameters.h b/src/libs/antares/study/include/antares/study/parameters.h index 0df3a8b157..b729023f08 100644 --- a/src/libs/antares/study/include/antares/study/parameters.h +++ b/src/libs/antares/study/include/antares/study/parameters.h @@ -332,6 +332,12 @@ class Parameters final //! Store the sampled timeseries numbers bool storeTimeseriesNumbers; //@} + + //! \name Delta Cluster + //@{ + //! Output the delta of groups inside clusters for each hour of each mode + bool deltaClusterOutput; + //@} /*! ** \brief Read-only mode diff --git a/src/libs/antares/study/load.cpp b/src/libs/antares/study/load.cpp index 3a756333f3..bd06c721a1 100644 --- a/src/libs/antares/study/load.cpp +++ b/src/libs/antares/study/load.cpp @@ -106,6 +106,7 @@ void Study::parameterFiller(const StudyLoadOptions& options) parameters.timeSeriesToArchive = 0; parameters.storeTimeseriesNumbers = false; parameters.synthesis = false; + parameters.deltaClusterOutput = false; } if (options.loadOnlyNeeded && !parameters.timeSeriesToGenerate) diff --git a/src/libs/antares/study/parameters.cpp b/src/libs/antares/study/parameters.cpp index 8beca3503a..012ae0cd8e 100644 --- a/src/libs/antares/study/parameters.cpp +++ b/src/libs/antares/study/parameters.cpp @@ -303,6 +303,8 @@ void Parameters::reset() // readonly readonly = false; synthesis = true; + //Outputing the delta of the number of groups that are on inside each clusters + deltaClusterOutput = false; // Hydro heuristic policy hydroHeuristicPolicy.hhPolicy = hhpAccommodateRuleCurves; @@ -623,6 +625,10 @@ static bool SGDIntLoadFamily_Output(Parameters& d, { return value.to(d.synthesis); } + if (key == "delta-cluster") + { + return value.to(d.deltaClusterOutput); + } if (key == "hydro-debug") { return value.to(d.hydroDebug); diff --git a/src/solver/optimisation/opt_optimisation_lineaire.cpp b/src/solver/optimisation/opt_optimisation_lineaire.cpp index 99669ad1ea..570b12a816 100644 --- a/src/solver/optimisation/opt_optimisation_lineaire.cpp +++ b/src/solver/optimisation/opt_optimisation_lineaire.cpp @@ -224,6 +224,32 @@ bool OPT_OptimisationLineaire(const OptimizationOptions& options, writer, PREMIERE_OPTIMISATION, simulationObserver); + if (problemeHebdo->exportDeltaClusters) + { + int NombreDePasDeTempsProblemeHebdo = problemeHebdo->NombreDePasDeTemps; + for (int pays = 0; pays < problemeHebdo->NombreDePays; pays++) + { + RESULTATS_HORAIRES& ResultatsHoraires = problemeHebdo->ResultatsHoraires[pays]; + std::vector& ProductionThermique = ResultatsHoraires.ProductionThermique; + PALIERS_THERMIQUES& PaliersThermiquesDuPays + = problemeHebdo->PaliersThermiquesDuPays[pays]; + const std::string fileName = problemeHebdo->NomsDesPays[pays] + std::string("_week") + std::to_string(problemeHebdo->weekInTheYear) + "_beforeHeuristic.txt"; + std::string content; + content += "clusterName_PdtHebdo NombreDeGroupesEnMarcheDuPalier NombreDeGroupesQuiDemarrentDuPalier NombreDeGroupesQuiSArretentDuPalier \r\n"; + for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++) + { + for (int pdtHebdo = 0; pdtHebdo < NombreDePasDeTempsProblemeHebdo; pdtHebdo++) + { + content += PaliersThermiquesDuPays.NomsDesPaliersThermiques[index] + "_Pdt" + std::to_string(pdtHebdo) + " "; + + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesEnMarcheDuPalier[index]) + " "; + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesQuiDemarrentDuPalier[index]) + " "; + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesQuiSArretentDuPalier[index]) + "\r\n"; + } + } + writer.addEntryFromBuffer(fileName, content); + } + } // We only need the 2nd optimization when NOT solving with integer variables // We also skip the 2nd optimization in the hidden 'Expansion' mode @@ -232,11 +258,36 @@ bool OPT_OptimisationLineaire(const OptimizationOptions& options, { // We need to adjust some stuff before running the 2nd optimisation runThermalHeuristic(problemeHebdo); - return runWeeklyOptimization(options, + ret = runWeeklyOptimization(options, problemeHebdo, writer, DEUXIEME_OPTIMISATION, simulationObserver); + if (problemeHebdo->exportDeltaClusters) + { + int NombreDePasDeTempsProblemeHebdo = problemeHebdo->NombreDePasDeTemps; + for (int pays = 0; pays < problemeHebdo->NombreDePays; pays++) + { + RESULTATS_HORAIRES& ResultatsHoraires = problemeHebdo->ResultatsHoraires[pays]; + std::vector& ProductionThermique = ResultatsHoraires.ProductionThermique; + PALIERS_THERMIQUES& PaliersThermiquesDuPays + = problemeHebdo->PaliersThermiquesDuPays[pays]; + const std::string fileName = problemeHebdo->NomsDesPays[pays] + std::string("_week") + std::to_string(problemeHebdo->weekInTheYear) + "_afterHeuristic.txt"; + std::string content; + content += "clusterName_PdtHebdo NombreDeGroupesEnMarcheDuPalier NombreDeGroupesQuiDemarrentDuPalier NombreDeGroupesQuiSArretentDuPalier \r\n"; + for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++) + { + for (int pdtHebdo = 0; pdtHebdo < NombreDePasDeTempsProblemeHebdo; pdtHebdo++) + { + content += PaliersThermiquesDuPays.NomsDesPaliersThermiques[index] + "_Pdt" + std::to_string(pdtHebdo) + " "; + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesEnMarcheDuPalier[index]) + " "; + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesQuiDemarrentDuPalier[index]) + " "; + content += std::to_string(ProductionThermique[pdtHebdo].NombreDeGroupesQuiSArretentDuPalier[index]) + "\r\n"; + } + } + writer.addEntryFromBuffer(fileName, content); + } + } } return ret; } diff --git a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h index 29dd7c38f5..bd59868e19 100644 --- a/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h +++ b/src/solver/simulation/include/antares/solver/simulation/sim_structure_probleme_economique.h @@ -524,6 +524,7 @@ struct PROBLEME_HEBDO bool exportMPSOnError = false; bool ExportStructure = false; bool NamedProblems = false; + bool exportDeltaClusters = false; uint32_t HeureDansLAnnee = 0; bool LeProblemeADejaEteInstancie = false; diff --git a/src/solver/simulation/sim_calcul_economique.cpp b/src/solver/simulation/sim_calcul_economique.cpp index 79e6635613..6139cbc03e 100644 --- a/src/solver/simulation/sim_calcul_economique.cpp +++ b/src/solver/simulation/sim_calcul_economique.cpp @@ -975,4 +975,5 @@ void SIM_RenseignementProblemeHebdo(const Study& study, problem.CaracteristiquesHydrauliques[k].ContrainteDePmaxHydrauliqueHoraireRef = problem.CaracteristiquesHydrauliques[k].ContrainteDePmaxHydrauliqueHoraire; } + problem.exportDeltaClusters = parameters.deltaClusterOutput; }