From 24697e74aed24443ea2f89f72cc5c3af388f8da6 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Mon, 30 Dec 2024 17:01:22 +0100 Subject: [PATCH 1/7] Add NetPosition hourly variable --- .../optimisation/constraints/ConstraintBuilder.cpp | 6 ++++++ .../solver/optimisation/constraints/ConstraintBuilder.h | 2 ++ .../opt_construction_variables_optimisees_lineaire.cpp | 5 +++++ src/solver/optimisation/variables/VariableManagement.cpp | 9 +++++++++ src/solver/optimisation/variables/VariableManagement.h | 2 ++ .../simulation/sim_structure_probleme_economique.h | 1 + src/solver/simulation/sim_alloc_probleme_hebdo.cpp | 1 + 7 files changed, 26 insertions(+) diff --git a/src/solver/optimisation/constraints/ConstraintBuilder.cpp b/src/solver/optimisation/constraints/ConstraintBuilder.cpp index 6d7662a605..217a386749 100644 --- a/src/solver/optimisation/constraints/ConstraintBuilder.cpp +++ b/src/solver/optimisation/constraints/ConstraintBuilder.cpp @@ -49,6 +49,12 @@ ConstraintBuilder& ConstraintBuilder::DispatchableProduction(unsigned int index, return *this; } +ConstraintBuilder& ConstraintBuilder::NetPosition(unsigned int index, double coeff) +{ + AddVariable(variableManager_.NetPosition(index, hourInWeek_), coeff); + return *this; +} + ConstraintBuilder& ConstraintBuilder::NumberOfDispatchableUnits(unsigned int index, double coeff) { AddVariable(variableManager_.NumberOfDispatchableUnits(index, hourInWeek_), coeff); diff --git a/src/solver/optimisation/include/antares/solver/optimisation/constraints/ConstraintBuilder.h b/src/solver/optimisation/include/antares/solver/optimisation/constraints/ConstraintBuilder.h index 31019332d3..f7f1906373 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/constraints/ConstraintBuilder.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/constraints/ConstraintBuilder.h @@ -137,6 +137,8 @@ class ConstraintBuilder int offset = 0, int delta = 0); + ConstraintBuilder& NetPosition(unsigned int index, double coeff); + ConstraintBuilder& HydProd(unsigned int index, double coeff); ConstraintBuilder& HydProdDown(unsigned int index, double coeff); diff --git a/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp b/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp index d2e68570e9..61ddf12562 100644 --- a/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp +++ b/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp @@ -86,6 +86,11 @@ void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(PROBLEME_HEBD NombreDeVariables++; } + // NetPosition + ProblemeAResoudre->TypeDeVariable[NombreDeVariables] = VARIABLE_NON_BORNEE; + variableManager.NetPosition(pays, pdt) = NombreDeVariables; + NombreDeVariables++; + for (const auto& storage: problemeHebdo->ShortTermStorage[pays]) { const int clusterGlobalIndex = storage.clusterGlobalIndex; diff --git a/src/solver/optimisation/variables/VariableManagement.cpp b/src/solver/optimisation/variables/VariableManagement.cpp index 37d50b5f97..56ae54706f 100644 --- a/src/solver/optimisation/variables/VariableManagement.cpp +++ b/src/solver/optimisation/variables/VariableManagement.cpp @@ -156,6 +156,15 @@ int& VariableManager::ShortTermStorageCostVariationWithdrawal(unsigned int index .SIM_ShortTermStorage.CostVariationWithdrawal[index]; } +int& VariableManager::NetPosition(unsigned int index, + unsigned int hourInWeek, + int offset, + int delta) +{ + auto pdt = GetShiftedTimeStep(offset, delta, hourInWeek); + return CorrespondanceVarNativesVarOptim_[pdt].NumeroDeVariableNetPosition[index]; +} + int& VariableManager::HydProd(unsigned int index, unsigned int hourInWeek, int offset, int delta) { auto pdt = GetShiftedTimeStep(offset, delta, hourInWeek); diff --git a/src/solver/optimisation/variables/VariableManagement.h b/src/solver/optimisation/variables/VariableManagement.h index 252c4007dd..9b730f80d3 100644 --- a/src/solver/optimisation/variables/VariableManagement.h +++ b/src/solver/optimisation/variables/VariableManagement.h @@ -75,6 +75,8 @@ class VariableManager int offset = 0, int delta = 0); + int& NetPosition(unsigned int index, unsigned int hourInWeek, int offset = 0, int delta = 0); + int& HydProd(unsigned int index, unsigned int hourInWeek, int offset = 0, int delta = 0); int& HydProdDown(unsigned int index, unsigned int hourInWeek, int offset = 0, int delta = 0); 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 35051ba2d5..231b7bb66f 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 @@ -45,6 +45,7 @@ struct CORRESPONDANCES_DES_VARIABLES std::vector NumeroDeVariableDuPalierThermique; + std::vector NumeroDeVariableNetPosition; std::vector NumeroDeVariablesDeLaProdHyd; std::vector NumeroDeVariablesDePompage; diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index dd7480671c..1cd6c3e9d4 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -157,6 +157,7 @@ void SIM_AllocationProblemePasDeTemps(PROBLEME_HEBDO& problem, variablesMapping.NumeroDeVariableDuPalierThermique .assign(study.runtime.thermalPlantTotalCount, 0); + variablesMapping.NumeroDeVariableNetPosition.assign(nbPays, 0); variablesMapping.NumeroDeVariablesDeLaProdHyd.assign(nbPays, 0); variablesMapping.NumeroDeVariablesDePompage.assign(nbPays, 0); variablesMapping.NumeroDeVariablesDeNiveau.assign(nbPays, 0); From 5e40e1083f1c9359b126ff051a289c4aed3ca613 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Mon, 30 Dec 2024 17:41:16 +0100 Subject: [PATCH 2/7] Add NetPosition constraint & variable --- src/solver/optimisation/CMakeLists.txt | 2 + .../optimisation/constraints/AreaBalance.cpp | 17 +----- .../optimisation/constraints/Group1.cpp | 13 +++++ .../optimisation/constraints/NetPosition.cpp | 47 ++++++++++++++++ .../solver/optimisation/constraints/Group1.h | 2 + .../optimisation/constraints/NetPosition.h | 56 +++++++++++++++++++ .../solver/optimisation/opt_rename_problem.h | 2 + ...truction_variables_optimisees_lineaire.cpp | 1 + .../opt_decompte_variables_et_contraintes.cpp | 7 +++ .../optimisation/opt_rename_problem.cpp | 10 ++++ 10 files changed, 142 insertions(+), 15 deletions(-) create mode 100644 src/solver/optimisation/constraints/NetPosition.cpp create mode 100644 src/solver/optimisation/include/antares/solver/optimisation/constraints/NetPosition.h diff --git a/src/solver/optimisation/CMakeLists.txt b/src/solver/optimisation/CMakeLists.txt index 0d64d42e44..bd6e6c4d64 100644 --- a/src/solver/optimisation/CMakeLists.txt +++ b/src/solver/optimisation/CMakeLists.txt @@ -75,6 +75,8 @@ set(RTESOLVER_OPT include/antares/solver/optimisation/constraints/constraint_builder_utils.h include/antares/solver/optimisation/constraints/AreaBalance.h constraints/AreaBalance.cpp + include/antares/solver/optimisation/constraints/NetPosition.h + constraints/NetPosition.cpp include/antares/solver/optimisation/constraints/FictitiousLoad.h constraints/FictitiousLoad.cpp include/antares/solver/optimisation/constraints/ShortTermStorageLevel.h diff --git a/src/solver/optimisation/constraints/AreaBalance.cpp b/src/solver/optimisation/constraints/AreaBalance.cpp index c0c254854d..b35139d584 100644 --- a/src/solver/optimisation/constraints/AreaBalance.cpp +++ b/src/solver/optimisation/constraints/AreaBalance.cpp @@ -44,22 +44,9 @@ void AreaBalance::add(int pdt, int pays) builder.updateHourWithinWeek(pdt); - int interco = data.IndexDebutIntercoOrigine[pays]; - while (interco >= 0) - { - builder.NTCDirect(interco, 1.0); - interco = data.IndexSuivantIntercoOrigine[interco]; - } - - interco = data.IndexDebutIntercoExtremite[pays]; - while (interco >= 0) - { - builder.NTCDirect(interco, -1.0); - interco = data.IndexSuivantIntercoExtremite[interco]; - } - ExportPaliers(data.PaliersThermiquesDuPays[pays], builder); - builder.HydProd(pays, -1.0) + builder.NetPosition(pays, 1) + .HydProd(pays, -1.0) .Pumping(pays, 1.0) .PositiveUnsuppliedEnergy(pays, -1.0) .NegativeUnsuppliedEnergy(pays, 1.0); diff --git a/src/solver/optimisation/constraints/Group1.cpp b/src/solver/optimisation/constraints/Group1.cpp index 61de7cf2b3..bb5b5c199f 100644 --- a/src/solver/optimisation/constraints/Group1.cpp +++ b/src/solver/optimisation/constraints/Group1.cpp @@ -35,6 +35,15 @@ AreaBalanceData Group1::GetAreaBalanceData() .ShortTermStorage = problemeHebdo_->ShortTermStorage}; } +NetPositionData Group1::GetNetPositionData() +{ + return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim, + .IndexDebutIntercoOrigine = problemeHebdo_->IndexDebutIntercoOrigine, + .IndexSuivantIntercoOrigine = problemeHebdo_->IndexSuivantIntercoOrigine, + .IndexDebutIntercoExtremite = problemeHebdo_->IndexDebutIntercoExtremite, + .IndexSuivantIntercoExtremite = problemeHebdo_->IndexSuivantIntercoExtremite}; +} + FictitiousLoadData Group1::GetFictitiousLoadData() { return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim, @@ -79,6 +88,9 @@ void Group1::BuildConstraints() auto areaBalanceData = GetAreaBalanceData(); AreaBalance areaBalance(builder_, areaBalanceData); + auto netPositionData = GetNetPositionData(); + NetPosition netPosition(builder_, netPositionData); + auto fictitiousLoadData = GetFictitiousLoadData(); FictitiousLoad fictitiousLoad(builder_, fictitiousLoadData); @@ -116,6 +128,7 @@ void Group1::BuildConstraints() for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++) { areaBalance.add(pdt, pays); + netPosition.add(pdt, pays); fictitiousLoad.add(pdt, pays); shortTermStorageLevel.add(pdt, pays); shortTermStorageCostVariationInjectionBackward.add(pdt, pays); diff --git a/src/solver/optimisation/constraints/NetPosition.cpp b/src/solver/optimisation/constraints/NetPosition.cpp new file mode 100644 index 0000000000..710e9398a3 --- /dev/null +++ b/src/solver/optimisation/constraints/NetPosition.cpp @@ -0,0 +1,47 @@ +/* +** 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/constraints/NetPosition.h" + +void NetPosition::add(int pdt, int pays) +{ + int interco = data.IndexDebutIntercoOrigine[pays]; + while (interco >= 0) + { + builder.NTCDirect(interco, 1.0); + interco = data.IndexSuivantIntercoOrigine[interco]; + } + + interco = data.IndexDebutIntercoExtremite[pays]; + while (interco >= 0) + { + builder.NTCDirect(interco, -1.0); + interco = data.IndexSuivantIntercoExtremite[interco]; + } + + ConstraintNamer namer(builder.data.NomDesContraintes); + namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt); + namer.UpdateArea(builder.data.NomsDesPays[pays]); + namer.NetPosition(builder.data.nombreDeContraintes); + + builder.NetPosition(pays, 1.0); + builder.equalTo().build(); +} diff --git a/src/solver/optimisation/include/antares/solver/optimisation/constraints/Group1.h b/src/solver/optimisation/include/antares/solver/optimisation/constraints/Group1.h index c74567716e..9f866892b0 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/constraints/Group1.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/constraints/Group1.h @@ -25,6 +25,7 @@ #include "ConstraintGroup.h" #include "FictitiousLoad.h" #include "FlowDissociation.h" +#include "NetPosition.h" #include "ShortTermStorageLevel.h" class Group1: public ConstraintGroup @@ -36,6 +37,7 @@ class Group1: public ConstraintGroup private: AreaBalanceData GetAreaBalanceData(); + NetPositionData GetNetPositionData(); FictitiousLoadData GetFictitiousLoadData(); ShortTermStorageData GetShortTermStorageData(); diff --git a/src/solver/optimisation/include/antares/solver/optimisation/constraints/NetPosition.h b/src/solver/optimisation/include/antares/solver/optimisation/constraints/NetPosition.h new file mode 100644 index 0000000000..139728cee2 --- /dev/null +++ b/src/solver/optimisation/include/antares/solver/optimisation/constraints/NetPosition.h @@ -0,0 +1,56 @@ +/* +** 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 "ConstraintBuilder.h" + +struct NetPositionData +{ + std::vector& CorrespondanceCntNativesCntOptim; + const std::vector& IndexDebutIntercoOrigine; + const std::vector& IndexSuivantIntercoOrigine; + const std::vector& IndexDebutIntercoExtremite; + const std::vector& IndexSuivantIntercoExtremite; +}; + +/*! + * represent 'Net Position' constraint type + */ + +class NetPosition: public ConstraintFactory +{ +public: + NetPosition(ConstraintBuilder& builder, NetPositionData& data): + ConstraintFactory(builder), + data(data) + { + } + + /*! + * @brief Add variables to the constraint and update constraints Matrix + * @param pdt : timestep + * @param pays : area + */ + + void add(int pdt, int pays); + +private: + NetPositionData& data; +}; diff --git a/src/solver/optimisation/include/antares/solver/optimisation/opt_rename_problem.h b/src/solver/optimisation/include/antares/solver/optimisation/opt_rename_problem.h index c7c3dff284..ab526cbf04 100644 --- a/src/solver/optimisation/include/antares/solver/optimisation/opt_rename_problem.h +++ b/src/solver/optimisation/include/antares/solver/optimisation/opt_rename_problem.h @@ -114,6 +114,7 @@ class VariableNamer: public Namer void PositiveUnsuppliedEnergy(unsigned int variable); void NegativeUnsuppliedEnergy(unsigned int variable); void AreaBalance(unsigned int variable); + void NetPosition(unsigned int variable); private: void SetAreaVariableName(unsigned int variable, @@ -133,6 +134,7 @@ class ConstraintNamer: public Namer const std::string& origin, const std::string& destination); + void NetPosition(unsigned int variable); void AreaBalance(unsigned int constraint); void FictiveLoads(unsigned int constraint); void HydroPower(unsigned int constraint); diff --git a/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp b/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp index 61ddf12562..ace9a312fe 100644 --- a/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp +++ b/src/solver/optimisation/opt_construction_variables_optimisees_lineaire.cpp @@ -89,6 +89,7 @@ void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(PROBLEME_HEBD // NetPosition ProblemeAResoudre->TypeDeVariable[NombreDeVariables] = VARIABLE_NON_BORNEE; variableManager.NetPosition(pays, pdt) = NombreDeVariables; + variableNamer.NetPosition(NombreDeVariables); NombreDeVariables++; for (const auto& storage: problemeHebdo->ShortTermStorage[pays]) diff --git a/src/solver/optimisation/opt_decompte_variables_et_contraintes.cpp b/src/solver/optimisation/opt_decompte_variables_et_contraintes.cpp index 79c29c58ab..720e8bcb83 100644 --- a/src/solver/optimisation/opt_decompte_variables_et_contraintes.cpp +++ b/src/solver/optimisation/opt_decompte_variables_et_contraintes.cpp @@ -281,6 +281,13 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO* } } + // NetPosition + for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) + { + ProblemeAResoudre->NombreDeVariables += nombreDePasDeTempsPourUneOptimisation; + ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation; + } + if (problemeHebdo->OptimisationAvecCoutsDeDemarrage) { OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(problemeHebdo); diff --git a/src/solver/optimisation/opt_rename_problem.cpp b/src/solver/optimisation/opt_rename_problem.cpp index b385c0f8f5..622e8fbb09 100644 --- a/src/solver/optimisation/opt_rename_problem.cpp +++ b/src/solver/optimisation/opt_rename_problem.cpp @@ -192,6 +192,11 @@ void VariableNamer::ShortTermStorageCostVariationWithdrawal(unsigned int variabl SetShortTermStorageVariableName(variable, "CostVariationWithdrawal", shortTermStorageName); } +void VariableNamer::NetPosition(unsigned int constraint) +{ + SetAreaElementNameHour(constraint, "NetPositionVariable"); +} + void VariableNamer::HydProd(unsigned int variable) { SetAreaElementNameHour(variable, "HydProd"); @@ -275,6 +280,11 @@ void ConstraintNamer::AreaBalance(unsigned int constraint) SetAreaElementNameHour(constraint, "AreaBalance"); } +void ConstraintNamer::NetPosition(unsigned int constraint) +{ + SetAreaElementNameHour(constraint, "NetPositionConstraint"); +} + void ConstraintNamer::FictiveLoads(unsigned int constraint) { SetAreaElementNameHour(constraint, "FictiveLoads"); From 01780aaf39bcef80c5b44c529dc87bf62d19b3d4 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Mon, 30 Dec 2024 17:48:28 +0100 Subject: [PATCH 3/7] Fix coefficient --- src/solver/optimisation/constraints/NetPosition.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solver/optimisation/constraints/NetPosition.cpp b/src/solver/optimisation/constraints/NetPosition.cpp index 710e9398a3..3f5edbed75 100644 --- a/src/solver/optimisation/constraints/NetPosition.cpp +++ b/src/solver/optimisation/constraints/NetPosition.cpp @@ -42,6 +42,6 @@ void NetPosition::add(int pdt, int pays) namer.UpdateArea(builder.data.NomsDesPays[pays]); namer.NetPosition(builder.data.nombreDeContraintes); - builder.NetPosition(pays, 1.0); + builder.NetPosition(pays, -1.0); builder.equalTo().build(); } From ea05a63e94d939d7cfdf2b75ca9a0d9c193199c7 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Thu, 2 Jan 2025 17:18:48 +0100 Subject: [PATCH 4/7] Add NetPositionHoraire --- .../optimisation/opt_gestion_des_bornes_cas_lineaire.cpp | 8 ++++++++ .../solver/simulation/sim_structure_probleme_economique.h | 2 ++ src/solver/simulation/sim_alloc_probleme_hebdo.cpp | 3 +++ 3 files changed, 13 insertions(+) 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 5c507fbed7..5e6b7673f7 100644 --- a/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp +++ b/src/solver/optimisation/opt_gestion_des_bornes_cas_lineaire.cpp @@ -470,6 +470,14 @@ void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaire(PROBLEME_HEBDO* prob AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; } } + for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++) + { + int var = problemeHebdo->CorrespondanceVarNativesVarOptim[pdtHebdo] + .NumeroDeVariableNetPosition[pays]; + double* adresseDuResultat = &( + problemeHebdo->ResultatsHoraires[pays].NetPositionHoraire[pdtHebdo]); + AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = adresseDuResultat; + } } setBoundsForUnsuppliedEnergy(problemeHebdo, 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 231b7bb66f..a82eee38f5 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 @@ -439,6 +439,8 @@ struct RESULTATS_HORAIRES std::vector CoutsMarginauxHoraires; std::vector ProductionThermique; // index is pdtHebdo + std::vector NetPositionHoraire; + std::vector<::ShortTermStorage::RESULTS> ShortTermStorage; }; diff --git a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp index 1cd6c3e9d4..38d64d762e 100644 --- a/src/solver/simulation/sim_alloc_probleme_hebdo.cpp +++ b/src/solver/simulation/sim_alloc_probleme_hebdo.cpp @@ -398,6 +398,9 @@ void SIM_AllocateAreas(PROBLEME_HEBDO& problem, problem.ResultatsHoraires[k].TurbinageHoraire.assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].PompageHoraire.assign(NombreDePasDeTemps, 0.); + + problem.ResultatsHoraires[k].NetPositionHoraire.assign(NombreDePasDeTemps, 0.); + problem.ResultatsHoraires[k].CoutsMarginauxHoraires.assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].niveauxHoraires.assign(NombreDePasDeTemps, 0.); problem.ResultatsHoraires[k].valeurH2oHoraire.assign(NombreDePasDeTemps, 0.); From 9790dafede999da4fcbefc5e8d1bf874d62b2478 Mon Sep 17 00:00:00 2001 From: aalzoobi Date: Thu, 23 Jan 2025 11:22:13 +0100 Subject: [PATCH 5/7] Changements ALI --- .../optimisation/post_process_commands.cpp | 200 +++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 3ddc06ddde..003cbab2ef 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -24,6 +24,7 @@ #include "antares/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.h" #include "antares/solver/simulation/adequacy_patch_runtime_data.h" #include "antares/solver/simulation/common-eco-adq.h" +#include "antares/solver/utils/filename.h" namespace Antares::Solver::Simulation { @@ -166,6 +167,18 @@ DTGnettingAfterCSRcmd::DTGnettingAfterCSRcmd(PROBLEME_HEBDO* problemeHebdo, void DTGnettingAfterCSRcmd::execute(const optRuntimeData&) { + // for (uint hour = 0; hour < nbHoursInWeek; hour++) + // { + // if (problemeHebdo_->adequacyPatchRuntimeData->wasCSRTriggeredAtAreaHour(Area, hour);) + // { + // AdequacyPatchOptimization::solve(,hour) + // void AdequacyPatchOptimization::solve(uint weekInTheYear, int hourInTheYear) + // ::SIM_RenseignementProblemeHebdo(study_, *problemeHebdo_, weekInTheYear, thread_number_, hourInTheYear); + // OPT_OptimisationHebdomadaire(options_, problemeHebdo_, adqPatchParams_, writer_); + + // } + // } + for (uint32_t Area = 0; Area < problemeHebdo_->NombreDePays; Area++) { auto& hourlyResults = problemeHebdo_->ResultatsHoraires[Area]; @@ -259,15 +272,200 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime << ".Total LMR violation:" << totalLmrViolation; const std::set hoursRequiringCurtailmentSharing = getHoursRequiringCurtailmentSharing(); HourlyCSRProblem hourlyCsrProblem(adqPatchParams_, problemeHebdo_); + + auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo_); + // int var = variableManager_.NTCDirect(Interco, triggeredHour); + // Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] + for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ + logs.info() << "[adq-patch] Hello ValeurDeFlux BEFORE AdqP is:"<NombreDInterconnexions; ++Interco){ + // int var = variableManager.NTCDirect(Interco, hourInWeek); + // problemAresdoudre.Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] + // logs.info() << "[adq-patch] Hello NTCs"; + + // } + + + // problemAresdoudre. etc . Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] + logs.info() << "[adq-patch] CSR triggered for Year:" << year + 1 << " Hour:" << week * nbHoursInWeek + hourInWeek + 1; hourlyCsrProblem.setHour(hourInWeek); hourlyCsrProblem.run(week, year); + // To redispatch here + //problemeHebdo_[numSpace].solve(); + // OPT_OptimisationHebdomadaire(options_, problemeHebdo_, writer_, simulationObserver_.get()); + //opt_runtime_data.weeklyOptimization.problemeHebdo_.ValeursDeNTC; + + + //auto interco = opt_runtime_data.weeklyOptimization.study.runtime.Interco + //auto R = opt_runtime_data.weeklyOptimization.problemeHebdo_->ResultatsHoraires + // Here to check + // opt_runtime_data.weekly_optimization.problemeHebdo_.ValeursDeNTC; + logs.info() << "[adq-patch] CSR triggered for Year:"; + + + } + + for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ + logs.info() << "[adq-patch] Hello ValeurDeFlux After AdqP is:"<ValeursDeNTC){ + // logs.info() << "[adq-patch] Hello ValeurDeFlux AFTER adq is:"<ValeursDeNTC){ + // for (auto& v: cnxn.ValeurDeNTCOrigineVersExtremite){ + // v = v + 1; + // } + // for (auto& v: cnxn.ValeurDeNTCExtremiteVersOrigine){ + // v = v + 1; + // } + // } + + + + // // REDISPATCH + // for (int hourInWeek: hoursRequiringCurtailmentSharing){ + // for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco){ + // int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = 1; + // auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] = 1; + + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + // Xmax = f + 1; + // Xmin = f - 1; + // // auto c = b[Interco].ValeurDuFlux; + + // } + // logs.info() << "[adq-patch] Hello NTCs"; + + // } + + + // // REDISPATCH OLD Flow cons + // for (int hourInWeek: hoursRequiringCurtailmentSharing){ + // for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco){ + // // int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = 1; + // auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] = 1; + + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + // Xmax = f + 1; + // Xmin = f - 1; + // // auto c = b[Interco].ValeurDuFlux; + + // } + // logs.info() << "[adq-patch] Hello NTCs"; + + // } + + + + + + // auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo); + // for (int pdtHebdo = PremierPdtDeLIntervalle, pdtJour = 0; pdtHebdo < DernierPdtDeLIntervalle; + // pdtHebdo++, pdtJour++) + // { + // VALEURS_DE_NTC_ET_RESISTANCES& ValeursDeNTC = problemeHebdo->ValeursDeNTC[pdtHebdo]; + + // for (uint32_t interco = 0; interco < problemeHebdo->NombreDInterconnexions; interco++) + // { + // int var = variableManager.NTCDirect(interco, pdtJour); + // const COUTS_DE_TRANSPORT& CoutDeTransport = problemeHebdo->CoutDeTransport[interco]; + + // Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[interco]; + // Xmin[var] = -(ValeursDeNTC.ValeurDeNTCExtremiteVersOrigine[interco]); + + // if (std::isinf(Xmax[var]) && Xmax[var] > 0) + // { + + + + // REDISPATCH NEW Flow COnst + std::vector& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax; + std::vector& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin; + + for (int hourInWeek: hoursRequiringCurtailmentSharing){ + for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco){ + int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax[var] = problemeHebdo->ValeursDeNTC[problemeHebdo_].ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[interco]; + // auto& Xmax = problemeHebdo->ValeursDeNTC[pdtHebdo]; + // Xmax[var] = problemeHebdo_->ProblemeAResoudre.get()->Xmax[var];// .Xmax[var] = 1; + // Xmin[var] = problemeHebdo_->ProblemeAResoudre.get()->Xmin[var];// .Xmax[var] = 1; + + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[var];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + auto f = problemeHebdo_->ValeursDeNTC[hourInWeek].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + Xmax[var] = f + 1; + Xmin[var] = f - 1; + logs.info() << "Hello Inside"; + // auto c = b[Interco].ValeurDuFlux; + + } + logs.info() << "[adq-patch] Hello NTCs"; + + } + + + for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ + logs.info() << "[adq-patch] Hello ValeurDeFlux After cnxn upd is:"<NombreDePasDeTempsPourUneOptimisation; + + int DernierPdtDeLIntervalle; + for (uint pdtHebdo = 0, numeroDeLIntervalle = 0; pdtHebdo < problemeHebdo_->NombreDePasDeTemps; + pdtHebdo = DernierPdtDeLIntervalle, numeroDeLIntervalle++) + { + int PremierPdtDeLIntervalle = pdtHebdo; + DernierPdtDeLIntervalle = pdtHebdo + NombreDePasDeTempsPourUneOptimisation; + auto optPeriodStringGenerator = createOptPeriodAsString(problemeHebdo_->OptimisationAuPasHebdomadaire, + numeroDeLIntervalle, + problemeHebdo_->weekInTheYear, + problemeHebdo_->year); + // bool b = OPT_AppelDuSimplexe(opt_runtime_data.weeklyOptimization.options_, + // problemeHebdo_, + // numeroDeLIntervalle, + // 1, + // *optPeriodStringGenerator, + // opt_runtime_data.weeklyOptimization.writer_); + + } + + + for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ + logs.info() << "[adq-patch] Hello ValeurDeFlux AFTER Redispatch is:"< Date: Thu, 23 Jan 2025 11:49:53 +0100 Subject: [PATCH 6/7] =?UTF-8?q?Retour=20=C3=A0=20l'=C3=A9tat=20initial?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../optimisation/post_process_commands.cpp | 156 +++++++----------- src/solver/simulation/economy.cpp | 5 +- .../solver/simulation/base_post_process.h | 14 +- 3 files changed, 78 insertions(+), 97 deletions(-) diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 070692f586..932d198b78 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -22,6 +22,7 @@ #include "antares/solver/optimisation/post_process_commands.h" #include "antares/solver/optimisation/adequacy_patch_csr/adq_patch_curtailment_sharing.h" +#include "antares/solver/optimisation/weekly_optimization.h" #include "antares/solver/simulation/adequacy_patch_runtime_data.h" #include "antares/solver/simulation/common-eco-adq.h" #include "antares/solver/utils/filename.h" @@ -185,12 +186,13 @@ void DTGnettingAfterCSRcmd::execute(const optRuntimeData&) // { // AdequacyPatchOptimization::solve(,hour) // void AdequacyPatchOptimization::solve(uint weekInTheYear, int hourInTheYear) - // ::SIM_RenseignementProblemeHebdo(study_, *problemeHebdo_, weekInTheYear, thread_number_, hourInTheYear); + // ::SIM_RenseignementProblemeHebdo(study_, *problemeHebdo_, weekInTheYear, + // thread_number_, hourInTheYear); // OPT_OptimisationHebdomadaire(options_, problemeHebdo_, adqPatchParams_, writer_); // } // } - + for (uint32_t Area = 0; Area < problemeHebdo_->NombreDePays; Area++) { auto& hourlyResults = problemeHebdo_->ResultatsHoraires[Area]; @@ -286,47 +288,39 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime HourlyCSRProblem hourlyCsrProblem(adqPatchParams_, problemeHebdo_); auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo_); - // int var = variableManager_.NTCDirect(Interco, triggeredHour); + // int var = variableManager_.NTCDirect(Interco, triggeredHour); // Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] - for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ - logs.info() << "[adq-patch] Hello ValeurDeFlux BEFORE AdqP is:"<NombreDInterconnexions; ++Interco){ - // int var = variableManager.NTCDirect(Interco, hourInWeek); - // problemAresdoudre.Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] + // int var = variableManager.NTCDirect(Interco, hourInWeek); + // problemAresdoudre.Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] // logs.info() << "[adq-patch] Hello NTCs"; - - // } + // } - // problemAresdoudre. etc . Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] + // problemAresdoudre. etc . Xmax[var] = + // ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] logs.info() << "[adq-patch] CSR triggered for Year:" << year + 1 << " Hour:" << week * nbHoursInWeek + hourInWeek + 1; hourlyCsrProblem.setHour(hourInWeek); hourlyCsrProblem.run(week, year); // To redispatch here - //problemeHebdo_[numSpace].solve(); - // OPT_OptimisationHebdomadaire(options_, problemeHebdo_, writer_, simulationObserver_.get()); - //opt_runtime_data.weeklyOptimization.problemeHebdo_.ValeursDeNTC; - - - //auto interco = opt_runtime_data.weeklyOptimization.study.runtime.Interco - //auto R = opt_runtime_data.weeklyOptimization.problemeHebdo_->ResultatsHoraires - // Here to check - // opt_runtime_data.weekly_optimization.problemeHebdo_.ValeursDeNTC; + // problemeHebdo_[numSpace].solve(); + // OPT_OptimisationHebdomadaire(options_, problemeHebdo_, writer_, + // simulationObserver_.get()); + // opt_runtime_data.weeklyOptimization.problemeHebdo_.ValeursDeNTC; + + // auto interco = opt_runtime_data.weeklyOptimization.study.runtime.Interco + // auto R = opt_runtime_data.weeklyOptimization.problemeHebdo_->ResultatsHoraires + // Here to check + // opt_runtime_data.weekly_optimization.problemeHebdo_.ValeursDeNTC; logs.info() << "[adq-patch] CSR triggered for Year:"; - - } - for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ - logs.info() << "[adq-patch] Hello ValeurDeFlux After AdqP is:"<ValeursDeNTC){ // logs.info() << "[adq-patch] Hello ValeurDeFlux AFTER adq is:"<NombreDInterconnexions; ++Interco){ - // int var = variableManager.NTCDirect(Interco, hourInWeek); - // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = 1; - // auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] = 1; + // int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = + // 1; auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] + // = 1; - // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; - // Xmax = f + 1; - // Xmin = f - 1; + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// + // ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; Xmax = f + 1; Xmin = f - 1; // // auto c = b[Interco].ValeurDuFlux; - + // } // logs.info() << "[adq-patch] Hello NTCs"; // } - // // REDISPATCH OLD Flow cons - // for (int hourInWeek: hoursRequiringCurtailmentSharing){ + // for (int hourInWeek: hoursRequiringCurtailmentSharing){ // for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco){ - // // int var = variableManager.NTCDirect(Interco, hourInWeek); - // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = 1; - // auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] = 1; + // // int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax[Interco];// .Xmax[var] = + // 1; auto& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin[Interco];// .Xmax[var] + // = 1; - // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; - // Xmax = f + 1; - // Xmin = f - 1; + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[Interco];// + // ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; Xmax = f + 1; Xmin = f - 1; // // auto c = b[Interco].ValeurDuFlux; - + // } // logs.info() << "[adq-patch] Hello NTCs"; // } - - - - // auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo); // for (int pdtHebdo = PremierPdtDeLIntervalle, pdtJour = 0; pdtHebdo < DernierPdtDeLIntervalle; // pdtHebdo++, pdtJour++) @@ -399,53 +386,43 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime // if (std::isinf(Xmax[var]) && Xmax[var] > 0) // { - - // REDISPATCH NEW Flow COnst - std::vector& Xmax = problemeHebdo_->ProblemeAResoudre.get()->Xmax; - std::vector& Xmin = problemeHebdo_->ProblemeAResoudre.get()->Xmin; + std::vector& Xmax = problemeHebdo_->ProblemeAResoudre->Xmax; + std::vector& Xmin = problemeHebdo_->ProblemeAResoudre->Xmin; - for (int hourInWeek: hoursRequiringCurtailmentSharing){ - for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco){ - int var = variableManager.NTCDirect(Interco, hourInWeek); - // auto& Xmax[var] = problemeHebdo->ValeursDeNTC[problemeHebdo_].ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[interco]; + for (int hourInWeek: hoursRequiringCurtailmentSharing) + { + for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco) + { + int var = variableManager.NTCDirect(Interco, hourInWeek); + // auto& Xmax[var] = + // problemeHebdo->ValeursDeNTC[problemeHebdo_].ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[interco]; // auto& Xmax = problemeHebdo->ValeursDeNTC[pdtHebdo]; // Xmax[var] = problemeHebdo_->ProblemeAResoudre.get()->Xmax[var];// .Xmax[var] = 1; // Xmin[var] = problemeHebdo_->ProblemeAResoudre.get()->Xmin[var];// .Xmax[var] = 1; - // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[var];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; - auto f = problemeHebdo_->ValeursDeNTC[hourInWeek].ValeurDuFlux[Interco];// ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + // auto f = problemeHebdo_->ValeursDeNTC[Interco].ValeurDuFlux[var];// + // ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; + auto f = problemeHebdo_->ValeursDeNTC[hourInWeek].ValeurDuFlux + [Interco]; // ->ValeurDeNTCOrigineVersExtremite[Interco].ValeurDeFlux; Xmax[var] = f + 1; Xmin[var] = f - 1; - logs.info() << "Hello Inside"; + logs.info() << problemeHebdo_->ProblemeAResoudre->NomDesVariables[var]; // auto c = b[Interco].ValeurDuFlux; - } logs.info() << "[adq-patch] Hello NTCs"; - } + // // here we redispatch truly and smarlty + // OPT_OptimisationHebdomadaire(opt_runtime_data.weeklyOptimization.options_, + // problemeHebdo_, + // opt_runtime_data.weeklyOptimization.writer_, + // opt_runtime_data.weeklyOptimization.simulationObserver_); - for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ - logs.info() << "[adq-patch] Hello ValeurDeFlux After cnxn upd is:"<NombreDePasDeTempsPourUneOptimisation; @@ -455,29 +432,20 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime { int PremierPdtDeLIntervalle = pdtHebdo; DernierPdtDeLIntervalle = pdtHebdo + NombreDePasDeTempsPourUneOptimisation; - auto optPeriodStringGenerator = createOptPeriodAsString(problemeHebdo_->OptimisationAuPasHebdomadaire, - numeroDeLIntervalle, - problemeHebdo_->weekInTheYear, - problemeHebdo_->year); + auto optPeriodStringGenerator = createOptPeriodAsString( + problemeHebdo_->OptimisationAuPasHebdomadaire, + numeroDeLIntervalle, + problemeHebdo_->weekInTheYear, + problemeHebdo_->year); // bool b = OPT_AppelDuSimplexe(opt_runtime_data.weeklyOptimization.options_, // problemeHebdo_, // numeroDeLIntervalle, // 1, // *optPeriodStringGenerator, // opt_runtime_data.weeklyOptimization.writer_); - - } - - - for (auto cnxn: opt_runtime_data.weeklyOptimization.problemeHebdo_->ValeursDeNTC){ - logs.info() << "[adq-patch] Hello ValeurDeFlux AFTER Redispatch is:"<runAll(opt_runtime_data); variables.weekBegin(state); diff --git a/src/solver/simulation/include/antares/solver/simulation/base_post_process.h b/src/solver/simulation/include/antares/solver/simulation/base_post_process.h index f1e6215415..88d844de19 100644 --- a/src/solver/simulation/include/antares/solver/simulation/base_post_process.h +++ b/src/solver/simulation/include/antares/solver/simulation/base_post_process.h @@ -29,21 +29,31 @@ using namespace Antares::Data; using namespace Antares::Date; using AdqPatchParams = Antares::Data::AdequacyPatch::AdqPatchParams; +namespace Antares::Solver::Optimization +{ +class WeeklyOptimization; +}; + namespace Antares::Solver::Simulation { struct optRuntimeData { - optRuntimeData(unsigned int y, unsigned int w, unsigned int h): + optRuntimeData(unsigned int y, + unsigned int w, + unsigned int h, + Antares::Solver::Optimization::WeeklyOptimization& weeklyOptimization): year(y), week(w), - hourInTheYear(h) + hourInTheYear(h), + weeklyOptimization(weeklyOptimization) { } unsigned int year = 0; unsigned int week = 0; unsigned int hourInTheYear = 0; + Antares::Solver::Optimization::WeeklyOptimization& weeklyOptimization; }; class basePostProcessCommand From 07391320af63a862855f038156ed7c8e089e03b2 Mon Sep 17 00:00:00 2001 From: Florian OMNES Date: Thu, 23 Jan 2025 12:07:25 +0100 Subject: [PATCH 7/7] backup correspondance XXX --- src/solver/optimisation/post_process_commands.cpp | 4 ++++ .../solver/simulation/sim_structure_probleme_economique.h | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/solver/optimisation/post_process_commands.cpp b/src/solver/optimisation/post_process_commands.cpp index 932d198b78..fa324e2619 100644 --- a/src/solver/optimisation/post_process_commands.cpp +++ b/src/solver/optimisation/post_process_commands.cpp @@ -287,6 +287,8 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime const std::set hoursRequiringCurtailmentSharing = getHoursRequiringCurtailmentSharing(); HourlyCSRProblem hourlyCsrProblem(adqPatchParams_, problemeHebdo_); + auto backup = problemeHebdo_->CorrespondanceVarNativesVarOptim; + auto variableManager = VariableManagerFromProblemHebdo(problemeHebdo_); // int var = variableManager_.NTCDirect(Interco, triggeredHour); // Xmax[var] = ValeursDeNTC.ValeurDeNTCOrigineVersExtremite[Interco] @@ -390,6 +392,8 @@ void CurtailmentSharingPostProcessCmd::execute(const optRuntimeData& opt_runtime std::vector& Xmax = problemeHebdo_->ProblemeAResoudre->Xmax; std::vector& Xmin = problemeHebdo_->ProblemeAResoudre->Xmin; + problemeHebdo_->CorrespondanceVarNativesVarOptim = backup; + for (int hourInWeek: hoursRequiringCurtailmentSharing) { for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; ++Interco) 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 98fe71de52..c35ffeba50 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 @@ -36,9 +36,11 @@ struct CORRESPONDANCES_DES_VARIABLES { // Avoid accidental copies CORRESPONDANCES_DES_VARIABLES() = default; - CORRESPONDANCES_DES_VARIABLES(const CORRESPONDANCES_DES_VARIABLES&) = delete; + CORRESPONDANCES_DES_VARIABLES(const CORRESPONDANCES_DES_VARIABLES&) = default; CORRESPONDANCES_DES_VARIABLES(CORRESPONDANCES_DES_VARIABLES&&) = default; + CORRESPONDANCES_DES_VARIABLES& operator=(const CORRESPONDANCES_DES_VARIABLES&) = default; + std::vector NumeroDeVariableDeLInterconnexion; std::vector NumeroDeVariableCoutOrigineVersExtremiteDeLInterconnexion; std::vector NumeroDeVariableCoutExtremiteVersOrigineDeLInterconnexion;