diff --git a/src/solver/optimisation/CMakeLists.txt b/src/solver/optimisation/CMakeLists.txt
index 4d23d3ef89..4ca7205048 100644
--- a/src/solver/optimisation/CMakeLists.txt
+++ b/src/solver/optimisation/CMakeLists.txt
@@ -19,8 +19,6 @@ set(RTESOLVER_OPT
opt_numero_de_jour_du_pas_de_temps.cpp
opt_construction_variables_optimisees_quadratique.cpp
opt_decompte_variables_et_contraintes.cpp
- opt_construction_matrice_des_contraintes_cas_quadratique.cpp
- opt_construction_matrice_des_contraintes_cas_lineaire.cpp
opt_construction_matrice_des_contraintes_outils.cpp
opt_gestion_des_bornes_cas_lineaire.cpp
opt_verification_presence_reserve_jmoins1.cpp
@@ -29,7 +27,6 @@ set(RTESOLVER_OPT
opt_liberation_problemes_simplexe.cpp
opt_restaurer_les_donnees.cpp
opt_gestion_des_couts_cas_quadratique.cpp
- opt_construction_contraintes_couts_demarrage.cpp
opt_construction_variables_couts_demarrages.cpp
opt_gestion_des_bornes_couts_demarrage.cpp
opt_gestion_des_couts_couts_demarrage.cpp
@@ -66,13 +63,22 @@ set(RTESOLVER_OPT
adequacy_patch_csr/csr_quadratic_problem.cpp
adequacy_patch_csr/count_constraints_variables.h
adequacy_patch_csr/count_constraints_variables.cpp
+ adequacy_patch_csr/constraints/CsrFlowDissociation.h
+ adequacy_patch_csr/constraints/CsrFlowDissociation.cpp
+ adequacy_patch_csr/constraints/CsrAreaBalance.h
+ adequacy_patch_csr/constraints/CsrAreaBalance.cpp
+ adequacy_patch_csr/constraints/CsrBindingConstraintHour.h
+ adequacy_patch_csr/constraints/CsrBindingConstraintHour.cpp
opt_period_string_generator_base.h
opt_rename_problem.h
opt_rename_problem.cpp
+
constraints/ConstraintBuilder.cpp
constraints/ConstraintBuilder.h
+ constraints/constraint_builder_utils.cpp
+ constraints/constraint_builder_utils.h
constraints/AreaBalance.h
constraints/AreaBalance.cpp
constraints/FictitiousLoad.h
@@ -120,6 +126,50 @@ set(RTESOLVER_OPT
constraints/MinDownTime.h
constraints/MinDownTime.cpp
+ ProblemMatrixEssential.h
+ ProblemMatrixEssential.cpp
+ LinearProblemMatrixStartUpCosts.h
+ LinearProblemMatrixStartUpCosts.cpp
+ LinearProblemMatrix.h
+ LinearProblemMatrix.cpp
+ QuadraticProblemMatrix.h
+ QuadraticProblemMatrix.cpp
+ constraints/ConstraintGroup.h
+ constraints/Group1.h
+ constraints/Group1.cpp
+ constraints/BindingConstraintDayGroup.h
+ constraints/BindingConstraintDayGroup.cpp
+ constraints/BindingConstraintWeekGroup.h
+ constraints/BindingConstraintWeekGroup.cpp
+ constraints/HydroPowerGroup.h
+ constraints/HydroPowerGroup.cpp
+ constraints/HydraulicSmoothingGroup.h
+ constraints/HydraulicSmoothingGroup.cpp
+ constraints/MinMaxHydroPowerGroup.h
+ constraints/MinMaxHydroPowerGroup.cpp
+ constraints/MaxPumpingGroup.h
+ constraints/MaxPumpingGroup.cpp
+ constraints/AreaHydroLevelGroup.h
+ constraints/AreaHydroLevelGroup.cpp
+ constraints/FinalStockGroup.h
+ constraints/FinalStockGroup.cpp
+ constraints/AbstractStartUpCostsGroup.h
+ constraints/AbstractStartUpCostsGroup.cpp
+ constraints/PMinMaxDispatchableGenerationGroup.h
+ constraints/PMinMaxDispatchableGenerationGroup.cpp
+ constraints/ConsistenceNumberOfDispatchableUnitsGroup.h
+ constraints/ConsistenceNumberOfDispatchableUnitsGroup.cpp
+ constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h
+ constraints/NbUnitsOutageLessThanNbUnitsStopGroup.cpp
+ constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h
+ constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.cpp
+ constraints/MinDownTimeGroup.h
+ constraints/MinDownTimeGroup.cpp
+ constraints/ExchangeBalance.h
+ constraints/ExchangeBalance.cpp
+ constraints/ExchangeBalanceGroup.h
+ constraints/ExchangeBalanceGroup.cpp
+
)
diff --git a/src/solver/optimisation/LinearProblemMatrix.cpp b/src/solver/optimisation/LinearProblemMatrix.cpp
new file mode 100644
index 0000000000..47710400a4
--- /dev/null
+++ b/src/solver/optimisation/LinearProblemMatrix.cpp
@@ -0,0 +1,73 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+
+#include "LinearProblemMatrix.h"
+#include "opt_export_structure.h"
+#include "antares/solver/utils/filename.h"
+#include "opt_fonctions.h"
+#include "LinearProblemMatrixStartUpCosts.h"
+
+using namespace Antares::Data;
+
+LinearProblemMatrix::LinearProblemMatrix(PROBLEME_HEBDO* problemeHebdo,
+ ConstraintBuilder& builder) :
+ ProblemMatrixEssential(problemeHebdo),
+ builder_(builder),
+ group1_(problemeHebdo, builder),
+ bindingConstraintDayGroup_(problemeHebdo, builder),
+ bindingConstraintWeekGroup_(problemeHebdo, builder),
+ hydroPowerGroup_(problemeHebdo, builder),
+ hydraulicSmoothingGroup_(problemeHebdo, builder),
+ minMaxHydroPowerGroup_(problemeHebdo, builder),
+ maxPumpingGroup_(problemeHebdo, builder),
+ areaHydroLevelGroup_(problemeHebdo, builder),
+ finalStockGroup_(problemeHebdo, builder)
+{
+ constraintgroups_ = {&group1_,
+ &bindingConstraintDayGroup_,
+ &bindingConstraintWeekGroup_,
+ &hydroPowerGroup_,
+ &hydraulicSmoothingGroup_,
+ &minMaxHydroPowerGroup_,
+ &maxPumpingGroup_,
+ &areaHydroLevelGroup_,
+ &finalStockGroup_};
+}
+
+void LinearProblemMatrix::Run()
+{
+ InitializeProblemAResoudreCounters();
+
+ ProblemMatrixEssential::Run();
+
+ if (problemeHebdo_->OptimisationAvecCoutsDeDemarrage)
+ {
+ LinearProblemMatrixStartUpCosts(problemeHebdo_, false, builder_).Run();
+ }
+
+ return;
+}
diff --git a/src/solver/optimisation/LinearProblemMatrix.h b/src/solver/optimisation/LinearProblemMatrix.h
new file mode 100644
index 0000000000..be06c0f04b
--- /dev/null
+++ b/src/solver/optimisation/LinearProblemMatrix.h
@@ -0,0 +1,63 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+#pragma once
+#include "opt_structure_probleme_a_resoudre.h"
+#include "sim_structure_probleme_economique.h"
+#include "ProblemMatrixEssential.h"
+#include "constraints/ConstraintGroup.h"
+#include "constraints/Group1.h"
+#include "constraints/BindingConstraintDayGroup.h"
+#include "constraints/BindingConstraintWeekGroup.h"
+#include "constraints/HydroPowerGroup.h"
+#include "constraints/HydraulicSmoothingGroup.h"
+#include "constraints/MinMaxHydroPowerGroup.h"
+#include "constraints/MaxPumpingGroup.h"
+#include "constraints/AreaHydroLevelGroup.h"
+#include "constraints/FinalStockGroup.h"
+
+#include
+
+using namespace Antares::Data;
+class LinearProblemMatrix : public ProblemMatrixEssential
+{
+public:
+ explicit LinearProblemMatrix(PROBLEME_HEBDO* problemeHebdo, ConstraintBuilder& builder);
+
+ void Run() override;
+
+private:
+ ConstraintBuilder& builder_;
+ Group1 group1_;
+ BindingConstraintDayGroup bindingConstraintDayGroup_;
+ BindingConstraintWeekGroup bindingConstraintWeekGroup_;
+ HydroPowerGroup hydroPowerGroup_;
+ HydraulicSmoothingGroup hydraulicSmoothingGroup_;
+ MinMaxHydroPowerGroup minMaxHydroPowerGroup_;
+ MaxPumpingGroup maxPumpingGroup_;
+ AreaHydroLevelGroup areaHydroLevelGroup_;
+ FinalStockGroup finalStockGroup_;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/LinearProblemMatrixStartUpCosts.cpp b/src/solver/optimisation/LinearProblemMatrixStartUpCosts.cpp
new file mode 100644
index 0000000000..3c175329b9
--- /dev/null
+++ b/src/solver/optimisation/LinearProblemMatrixStartUpCosts.cpp
@@ -0,0 +1,47 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+#pragma once
+#include "LinearProblemMatrixStartUpCosts.h"
+using namespace Antares::Data;
+
+LinearProblemMatrixStartUpCosts::LinearProblemMatrixStartUpCosts(PROBLEME_HEBDO* problemeHebdo,
+ bool Simulation,
+ ConstraintBuilder& builder) :
+ ProblemMatrixEssential(problemeHebdo),
+ simulation_(Simulation),
+ pMinMaxDispatchableGenerationGroup_(problemeHebdo, simulation_, builder),
+ consistenceNumberOfDispatchableUnitsGroup_(problemeHebdo, simulation_, builder),
+ nbUnitsOutageLessThanNbUnitsStopGroup_(problemeHebdo, simulation_, builder),
+ nbDispUnitsMinBoundSinceMinUpTimeGroup_(problemeHebdo, simulation_, builder),
+ minDownTimeGroup_(problemeHebdo, simulation_, builder)
+{
+ constraintgroups_ = {&pMinMaxDispatchableGenerationGroup_,
+ &consistenceNumberOfDispatchableUnitsGroup_,
+ &nbUnitsOutageLessThanNbUnitsStopGroup_,
+ &nbDispUnitsMinBoundSinceMinUpTimeGroup_,
+ &minDownTimeGroup_};
+}
diff --git a/src/solver/optimisation/LinearProblemMatrixStartUpCosts.h b/src/solver/optimisation/LinearProblemMatrixStartUpCosts.h
new file mode 100644
index 0000000000..840e37368d
--- /dev/null
+++ b/src/solver/optimisation/LinearProblemMatrixStartUpCosts.h
@@ -0,0 +1,58 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+#pragma once
+#include "opt_structure_probleme_a_resoudre.h"
+#include "sim_structure_probleme_economique.h"
+#include "constraints/ConstraintGroup.h"
+#include "ProblemMatrixEssential.h"
+#include "opt_structure_probleme_a_resoudre.h"
+
+#include "constraints/PMinMaxDispatchableGenerationGroup.h"
+#include "constraints/ConsistenceNumberOfDispatchableUnitsGroup.h"
+#include "constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h"
+#include "constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h"
+#include "constraints/MinDownTimeGroup.h"
+
+#include
+
+using namespace Antares::Data;
+
+class LinearProblemMatrixStartUpCosts : public ProblemMatrixEssential
+{
+public:
+ explicit LinearProblemMatrixStartUpCosts(PROBLEME_HEBDO* problemeHebdo,
+ bool Simulation,
+ ConstraintBuilder& builder);
+
+private:
+ bool simulation_ = false;
+ PMinMaxDispatchableGenerationGroup pMinMaxDispatchableGenerationGroup_;
+ ConsistenceNumberOfDispatchableUnitsGroup consistenceNumberOfDispatchableUnitsGroup_;
+ NbUnitsOutageLessThanNbUnitsStopGroup nbUnitsOutageLessThanNbUnitsStopGroup_;
+ NbDispUnitsMinBoundSinceMinUpTimeGroup nbDispUnitsMinBoundSinceMinUpTimeGroup_;
+ MinDownTimeGroup minDownTimeGroup_;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/ProblemMatrixEssential.cpp b/src/solver/optimisation/ProblemMatrixEssential.cpp
new file mode 100644
index 0000000000..84a6e21567
--- /dev/null
+++ b/src/solver/optimisation/ProblemMatrixEssential.cpp
@@ -0,0 +1,47 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+#include "ProblemMatrixEssential.h"
+
+ProblemMatrixEssential::ProblemMatrixEssential(PROBLEME_HEBDO* problemeHebdo) :
+ problemeHebdo_(problemeHebdo)
+{
+}
+
+void ProblemMatrixEssential::Run()
+{
+ for (auto& group : constraintgroups_)
+ {
+ group->BuildConstraints();
+ }
+}
+
+void ProblemMatrixEssential::InitializeProblemAResoudreCounters()
+{
+ auto& ProblemeAResoudre = problemeHebdo_->ProblemeAResoudre;
+ ProblemeAResoudre->NombreDeContraintes = 0;
+ ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = 0;
+}
diff --git a/src/solver/optimisation/ProblemMatrixEssential.h b/src/solver/optimisation/ProblemMatrixEssential.h
new file mode 100644
index 0000000000..8a44989d32
--- /dev/null
+++ b/src/solver/optimisation/ProblemMatrixEssential.h
@@ -0,0 +1,42 @@
+/*
+** Copyright 2007-2023 RTE
+** Authors: Antares_Simulator Team
+**
+** This file is part of Antares_Simulator.
+**
+** Antares_Simulator is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** There are special exceptions to the terms and conditions of the
+** license as they are applied to this software. View the full text of
+** the exceptions in file COPYING.txt in the directory of this software
+** distribution
+**
+** 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
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with Antares_Simulator. If not, see .
+**
+** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
+*/
+#pragma once
+#include "opt_structure_probleme_a_resoudre.h"
+#include "sim_structure_probleme_economique.h"
+#include "constraints/ConstraintGroup.h"
+
+class ProblemMatrixEssential
+{
+public:
+ explicit ProblemMatrixEssential(PROBLEME_HEBDO* problemeHebdo);
+
+ virtual void Run();
+
+ void InitializeProblemAResoudreCounters();
+ PROBLEME_HEBDO* problemeHebdo_;
+ std::vector constraintgroups_;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/QuadraticProblemMatrix.cpp b/src/solver/optimisation/QuadraticProblemMatrix.cpp
new file mode 100644
index 0000000000..cd6d5c2d09
--- /dev/null
+++ b/src/solver/optimisation/QuadraticProblemMatrix.cpp
@@ -0,0 +1,8 @@
+#include "QuadraticProblemMatrix.h"
+
+void QuadraticProblemMatrix::Run()
+{
+ InitializeProblemAResoudreCounters();
+
+ ProblemMatrixEssential::Run();
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/QuadraticProblemMatrix.h b/src/solver/optimisation/QuadraticProblemMatrix.h
new file mode 100644
index 0000000000..5ed3686c1c
--- /dev/null
+++ b/src/solver/optimisation/QuadraticProblemMatrix.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "opt_structure_probleme_a_resoudre.h"
+
+#include "../simulation/simulation.h"
+#include "../simulation/sim_structure_donnees.h"
+#include "../simulation/sim_extern_variables_globales.h"
+#include "opt_fonctions.h"
+#include "constraints/ExchangeBalanceGroup.h"
+#include "ProblemMatrixEssential.h"
+
+class QuadraticProblemMatrix : public ProblemMatrixEssential
+{
+public:
+ QuadraticProblemMatrix(PROBLEME_HEBDO* problem_hebdo, ConstraintBuilder& builder) :
+ ProblemMatrixEssential(problem_hebdo), exchangeBalanceGroup_(problem_hebdo, builder)
+ {
+ constraintgroups_ = {&exchangeBalanceGroup_};
+ }
+
+ void Run() override;
+
+private:
+ ExchangeBalanceGroup exchangeBalanceGroup_;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.cpp b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.cpp
new file mode 100644
index 0000000000..c06536d897
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.cpp
@@ -0,0 +1,66 @@
+#include "CsrAreaBalance.h"
+
+void CsrAreaBalance::add()
+{
+ for (uint32_t Area = 0; Area < data.NombreDePays; ++Area)
+ {
+ if (data.areaMode[Area] != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
+ continue;
+
+ // + ENS
+ builder.updateHourWithinWeek(data.hour).PositiveUnsuppliedEnergy(Area, 1.0);
+
+ // - export flows
+ int Interco = data.IndexDebutIntercoOrigine[Area];
+ while (Interco >= 0)
+ {
+ if (data.extremityAreaMode[Interco] != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
+ {
+ Interco = data.IndexSuivantIntercoOrigine[Interco];
+ continue;
+ }
+
+ // flow (A->2)
+ builder.NTCDirect(Interco, -1.0);
+
+ logs.debug() << "S-Interco number: [" << std::to_string(Interco) << "] between: ["
+ << builder.data.NomsDesPays[Area] << "]-["
+ << builder.data.NomsDesPays[data.PaysExtremiteDeLInterconnexion[Interco]]
+ << "]";
+
+ Interco = data.IndexSuivantIntercoOrigine[Interco];
+ }
+
+ // or + import flows
+ Interco = data.IndexDebutIntercoExtremite[Area];
+ while (Interco >= 0)
+ {
+ if (data.originAreaMode[Interco] != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
+ {
+ Interco = data.IndexSuivantIntercoExtremite[Interco];
+ continue;
+ }
+ // flow (2 -> A)
+ builder.NTCDirect(Interco, 1.0);
+
+ logs.debug() << "E-Interco number: [" << std::to_string(Interco) << "] between: ["
+ << builder.data.NomsDesPays[Area] << "]-["
+ << builder.data.NomsDesPays[data.PaysOrigineDeLInterconnexion[Interco]]
+ << "]";
+
+ Interco = data.IndexSuivantIntercoExtremite[Interco];
+ }
+
+ // - Spilled Energy
+ builder.NegativeUnsuppliedEnergy(Area, -1.0);
+
+ data.numberOfConstraintCsrAreaBalance[Area] = builder.data.nombreDeContraintes;
+
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(data.hour);
+ namer.UpdateArea(builder.data.NomsDesPays[Area]);
+ namer.CsrAreaBalance(builder.data.nombreDeContraintes);
+ builder.equalTo();
+ builder.build();
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.h b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.h
new file mode 100644
index 0000000000..c3270974aa
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrAreaBalance.h
@@ -0,0 +1,33 @@
+#pragma once
+#include "../../constraints/ConstraintBuilder.h"
+
+#include "../../../simulation/adequacy_patch_runtime_data.h"
+struct CsrAreaBalanceData
+{
+ const std::vector& areaMode;
+ const int hour;
+ const std::vector& IndexDebutIntercoOrigine;
+ const std::vector& IndexSuivantIntercoOrigine;
+ const std::vector& IndexDebutIntercoExtremite;
+ const std::vector& IndexSuivantIntercoExtremite;
+
+ const std::vector& originAreaMode;
+ const std::vector& extremityAreaMode;
+ const std::vector& PaysOrigineDeLInterconnexion;
+ const std::vector& PaysExtremiteDeLInterconnexion;
+ std::map& numberOfConstraintCsrAreaBalance;
+ const uint32_t NombreDePays;
+};
+
+class CsrAreaBalance : private ConstraintFactory
+{
+public:
+ CsrAreaBalance(ConstraintBuilder& builder, CsrAreaBalanceData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
+ void add();
+
+private:
+ CsrAreaBalanceData& data;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.cpp b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.cpp
new file mode 100644
index 0000000000..0088cc4985
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.cpp
@@ -0,0 +1,41 @@
+#include "CsrBindingConstraintHour.h"
+
+void CsrBindingConstraintHour::add(int CntCouplante)
+{
+ if (data.MatriceDesContraintesCouplantes[CntCouplante].TypeDeContrainteCouplante
+ != CONTRAINTE_HORAIRE)
+ return;
+
+ int NbInterco = data.MatriceDesContraintesCouplantes[CntCouplante]
+ .NombreDInterconnexionsDansLaContrainteCouplante;
+ builder.updateHourWithinWeek(data.hour);
+
+ for (int Index = 0; Index < NbInterco; Index++)
+ {
+ int Interco
+ = data.MatriceDesContraintesCouplantes[CntCouplante].NumeroDeLInterconnexion[Index];
+ double Poids
+ = data.MatriceDesContraintesCouplantes[CntCouplante].PoidsDeLInterconnexion[Index];
+
+ if (data.originAreaMode[Interco] == Data::AdequacyPatch::physicalAreaInsideAdqPatch
+ && data.extremityAreaMode[Interco] == Data::AdequacyPatch::physicalAreaInsideAdqPatch)
+ {
+ builder.NTCDirect(Interco, Poids);
+ }
+ }
+
+ if (builder.NumberOfVariables()
+ > 0) // current binding constraint contains an interco type 2<->2
+ {
+ data.numberOfConstraintCsrHourlyBinding[CntCouplante] = builder.data.nombreDeContraintes;
+
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(data.hour);
+ namer.CsrBindingConstraintHour(
+ builder.data.nombreDeContraintes,
+ data.MatriceDesContraintesCouplantes[CntCouplante].NomDeLaContrainteCouplante);
+ builder.SetOperator(
+ data.MatriceDesContraintesCouplantes[CntCouplante].SensDeLaContrainteCouplante);
+ builder.build();
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.h b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.h
new file mode 100644
index 0000000000..c6ea7a2f70
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrBindingConstraintHour.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "../../constraints/ConstraintBuilder.h"
+
+#include "../../../simulation/adequacy_patch_runtime_data.h"
+
+struct CsrBindingConstraintHourData
+{
+ const std::vector MatriceDesContraintesCouplantes;
+ const std::vector& originAreaMode;
+ const std::vector& extremityAreaMode;
+ const int hour;
+ std::map& numberOfConstraintCsrHourlyBinding;
+};
+
+class CsrBindingConstraintHour : private ConstraintFactory
+{
+public:
+ CsrBindingConstraintHour(ConstraintBuilder& builder,
+ CsrBindingConstraintHourData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
+ void add(int CntCouplante);
+
+private:
+ CsrBindingConstraintHourData& data;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.cpp b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.cpp
new file mode 100644
index 0000000000..eb96d52ccf
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.cpp
@@ -0,0 +1,33 @@
+#include "CsrFlowDissociation.h"
+
+void CsrFlowDissociation::add()
+{
+ builder.updateHourWithinWeek(data.hour);
+
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(data.hour);
+ // constraint: Flow = Flow_direct - Flow_indirect (+ loop flow) for links between nodes
+ // of type 2.
+ for (uint32_t interco = 0; interco < data.NombreDInterconnexions; interco++)
+ {
+ if (data.originAreaMode[interco] == Antares::Data::AdequacyPatch::physicalAreaInsideAdqPatch
+ && data.extremityAreaMode[interco]
+ == Antares::Data::AdequacyPatch::physicalAreaInsideAdqPatch)
+ {
+ builder.NTCDirect(interco, 1.0)
+ .IntercoDirectCost(interco, -1.0)
+ .IntercoIndirectCost(interco, 1.0);
+
+ data.numberOfConstraintCsrFlowDissociation[interco]
+ = builder.data.nombreDeContraintes;
+
+ const auto& origin
+ = builder.data.NomsDesPays[data.PaysOrigineDeLInterconnexion[interco]];
+ const auto& destination
+ = builder.data.NomsDesPays[data.PaysExtremiteDeLInterconnexion[interco]];
+ namer.CsrFlowDissociation(builder.data.nombreDeContraintes, origin, destination);
+ builder.equalTo();
+ builder.build();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.h b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.h
new file mode 100644
index 0000000000..7591990a04
--- /dev/null
+++ b/src/solver/optimisation/adequacy_patch_csr/constraints/CsrFlowDissociation.h
@@ -0,0 +1,28 @@
+#pragma once
+#include "../../constraints/ConstraintBuilder.h"
+
+#include "../../../simulation/adequacy_patch_runtime_data.h"
+struct CsrFlowDissociationData
+{
+ std::map& numberOfConstraintCsrFlowDissociation;
+ const uint32_t NombreDInterconnexions;
+
+ const std::vector& originAreaMode;
+ const std::vector& extremityAreaMode;
+
+ const std::vector& PaysOrigineDeLInterconnexion;
+ const std::vector& PaysExtremiteDeLInterconnexion;
+ const int hour;
+};
+class CsrFlowDissociation : private ConstraintFactory
+{
+public:
+ CsrFlowDissociation(ConstraintBuilder& builder, CsrFlowDissociationData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
+ void add();
+
+private:
+ CsrFlowDissociationData& data;
+};
diff --git a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.cpp b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.cpp
index 90ac4709c1..a6c276dfe2 100644
--- a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.cpp
+++ b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.cpp
@@ -33,65 +33,34 @@
#include "csr_quadratic_problem.h"
#include "hourly_csr_problem.h"
#include "sim_structure_probleme_economique.h"
+#include "constraints/CsrFlowDissociation.h"
+#include "constraints/CsrAreaBalance.h"
+#include "constraints/CsrBindingConstraintHour.h"
+#include "../constraints/constraint_builder_utils.h"
using namespace Antares::Data;
namespace Antares::Solver::Optimization
{
-void CsrQuadraticProblem::setConstraintsOnFlows(std::vector& Pi, std::vector& Colonne)
+
+void CsrQuadraticProblem::setConstraintsOnFlows(ConstraintBuilder& builder)
{
int hour = hourlyCsrProblem_.triggeredHour;
- const CORRESPONDANCES_DES_VARIABLES& CorrespondanceVarNativesVarOptim
- = problemeHebdo_->CorrespondanceVarNativesVarOptim[hour];
-
- // constraint: Flow = Flow_direct - Flow_indirect (+ loop flow) for links between nodes of
- // type 2.
- for (uint32_t Interco = 0; Interco < problemeHebdo_->NombreDInterconnexions; Interco++)
- {
- if (problemeHebdo_->adequacyPatchRuntimeData->originAreaMode[Interco]
- == Antares::Data::AdequacyPatch::physicalAreaInsideAdqPatch
- && problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode[Interco]
- == Antares::Data::AdequacyPatch::physicalAreaInsideAdqPatch)
- {
- int NombreDeTermes = 0;
- int var = CorrespondanceVarNativesVarOptim.NumeroDeVariableDeLInterconnexion[Interco];
- if (var >= 0)
- {
- Pi[NombreDeTermes] = 1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
- var = CorrespondanceVarNativesVarOptim
- .NumeroDeVariableCoutOrigineVersExtremiteDeLInterconnexion[Interco];
- if (var >= 0)
- {
- Pi[NombreDeTermes] = -1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
- var = CorrespondanceVarNativesVarOptim
- .NumeroDeVariableCoutExtremiteVersOrigineDeLInterconnexion[Interco];
- if (var >= 0)
- {
- Pi[NombreDeTermes] = 1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
-
- hourlyCsrProblem_.numberOfConstraintCsrFlowDissociation[Interco]
- = problemeAResoudre_.NombreDeContraintes;
-
- std::string NomDeLaContrainte = "flow=d-i, Interco:" + std::to_string(Interco);
- logs.debug() << "C Interco: " << problemeAResoudre_.NombreDeContraintes << ": "
- << NomDeLaContrainte;
-
- OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
- &problemeAResoudre_, Pi, Colonne, NombreDeTermes, '=');
- }
- }
+ //!\ TODO not associated problemHebdo && probleamAressoudre
+ CsrFlowDissociationData csrFlowDissociationData
+ = {.numberOfConstraintCsrFlowDissociation
+ = hourlyCsrProblem_.numberOfConstraintCsrFlowDissociation,
+ .NombreDInterconnexions = problemeHebdo_->NombreDInterconnexions,
+ .originAreaMode = problemeHebdo_->adequacyPatchRuntimeData->originAreaMode,
+ .extremityAreaMode = problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode,
+ .PaysOrigineDeLInterconnexion = problemeHebdo_->PaysOrigineDeLInterconnexion,
+ .PaysExtremiteDeLInterconnexion = problemeHebdo_->PaysExtremiteDeLInterconnexion,
+ .hour = hour};
+ CsrFlowDissociation csrFlowDissociation(builder, csrFlowDissociationData);
+ csrFlowDissociation.add();
}
-void CsrQuadraticProblem::setNodeBalanceConstraints(std::vector& Pi, std::vector& Colonne)
+void CsrQuadraticProblem::setNodeBalanceConstraints(ConstraintBuilder& builder)
{
int hour = hourlyCsrProblem_.triggeredHour;
const CORRESPONDANCES_DES_VARIABLES& CorrespondanceVarNativesVarOptim
@@ -104,161 +73,43 @@ void CsrQuadraticProblem::setNodeBalanceConstraints(std::vector& Pi, std
// ENS_init(node A) + net_position_init(node A) – spillage_init(node A)
// for all areas inside adequacy patch
- for (uint32_t Area = 0; Area < problemeHebdo_->NombreDePays; ++Area)
- {
- if (problemeHebdo_->adequacyPatchRuntimeData->areaMode[Area]
- != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
- continue;
-
- // + ENS
- int NombreDeTermes = 0;
- int var = CorrespondanceVarNativesVarOptim.NumeroDeVariableDefaillancePositive[Area];
- if (var >= 0)
- {
- Pi[NombreDeTermes] = 1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
-
- // - export flows
- int Interco = problemeHebdo_->IndexDebutIntercoOrigine[Area];
- while (Interco >= 0)
- {
- if (problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode[Interco]
- != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
- {
- Interco = problemeHebdo_->IndexSuivantIntercoOrigine[Interco];
- continue;
- }
-
- var = CorrespondanceVarNativesVarOptim
- .NumeroDeVariableDeLInterconnexion[Interco]; // flow (A->2)
- if (var >= 0)
- {
- Pi[NombreDeTermes] = -1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- logs.debug()
- << "S-Interco number: [" << std::to_string(Interco) << "] between: ["
- << problemeHebdo_->NomsDesPays[Area] << "]-["
- << problemeHebdo_
- ->NomsDesPays[problemeHebdo_->PaysExtremiteDeLInterconnexion[Interco]]
- << "]";
- }
- Interco = problemeHebdo_->IndexSuivantIntercoOrigine[Interco];
- }
-
- // or + import flows
- Interco = problemeHebdo_->IndexDebutIntercoExtremite[Area];
- while (Interco >= 0)
- {
- if (problemeHebdo_->adequacyPatchRuntimeData->originAreaMode[Interco]
- != Data::AdequacyPatch::physicalAreaInsideAdqPatch)
- {
- Interco = problemeHebdo_->IndexSuivantIntercoExtremite[Interco];
- continue;
- }
- var = CorrespondanceVarNativesVarOptim
- .NumeroDeVariableDeLInterconnexion[Interco]; // flow (2 -> A)
- if (var >= 0)
- {
- Pi[NombreDeTermes] = 1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- logs.debug()
- << "E-Interco number: [" << std::to_string(Interco) << "] between: ["
- << problemeHebdo_->NomsDesPays[Area] << "]-["
- << problemeHebdo_
- ->NomsDesPays[problemeHebdo_->PaysOrigineDeLInterconnexion[Interco]]
- << "]";
- }
- Interco = problemeHebdo_->IndexSuivantIntercoExtremite[Interco];
- }
-
- // - Spilled Energy
- var = CorrespondanceVarNativesVarOptim.NumeroDeVariableDefaillanceNegative[Area];
- if (var >= 0)
- {
- Pi[NombreDeTermes] = -1.0;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
-
- hourlyCsrProblem_.numberOfConstraintCsrAreaBalance[Area]
- = problemeAResoudre_.NombreDeContraintes;
-
- std::string NomDeLaContrainte
- = "Area Balance, Area:" + std::to_string(Area) + "; " + problemeHebdo_->NomsDesPays[Area];
-
- logs.debug() << "C: " << problemeAResoudre_.NombreDeContraintes << ": "
- << NomDeLaContrainte;
-
- OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
- &problemeAResoudre_, Pi, Colonne, NombreDeTermes, '=');
- }
+ CsrAreaBalanceData csrAreaBalanceData{
+ .areaMode = problemeHebdo_->adequacyPatchRuntimeData->areaMode,
+ .hour = hour,
+ .IndexDebutIntercoOrigine = problemeHebdo_->IndexDebutIntercoOrigine,
+ .IndexSuivantIntercoOrigine = problemeHebdo_->IndexSuivantIntercoOrigine,
+ .IndexDebutIntercoExtremite = problemeHebdo_->IndexDebutIntercoExtremite,
+ .IndexSuivantIntercoExtremite = problemeHebdo_->IndexSuivantIntercoExtremite,
+ .originAreaMode = problemeHebdo_->adequacyPatchRuntimeData->originAreaMode,
+ .extremityAreaMode = problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode,
+ .PaysOrigineDeLInterconnexion = problemeHebdo_->PaysOrigineDeLInterconnexion,
+ .PaysExtremiteDeLInterconnexion = problemeHebdo_->PaysExtremiteDeLInterconnexion,
+ .numberOfConstraintCsrAreaBalance = hourlyCsrProblem_.numberOfConstraintCsrAreaBalance,
+ .NombreDePays = problemeHebdo_->NombreDePays};
+
+ CsrAreaBalance csrAreaBalance(builder, csrAreaBalanceData);
+ csrAreaBalance.add();
}
-void CsrQuadraticProblem::setBindingConstraints(std::vector& Pi, std::vector& Colonne)
+void CsrQuadraticProblem::setBindingConstraints(ConstraintBuilder& builder)
{
int hour = hourlyCsrProblem_.triggeredHour;
- // Special case of the binding constraints
+ CsrBindingConstraintHourData csrBindingConstraintHourData = {
+ .MatriceDesContraintesCouplantes = problemeHebdo_->MatriceDesContraintesCouplantes,
+ .originAreaMode = problemeHebdo_->adequacyPatchRuntimeData->originAreaMode,
+ .extremityAreaMode = problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode,
+ .hour = hour,
+ .numberOfConstraintCsrHourlyBinding = hourlyCsrProblem_.numberOfConstraintCsrHourlyBinding};
+
+ CsrBindingConstraintHour csrBindingConstraintHour(
+ builder, csrBindingConstraintHourData); // Special case of the binding constraints
for (uint32_t CntCouplante = 0; CntCouplante < problemeHebdo_->NombreDeContraintesCouplantes;
CntCouplante++)
{
- const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
- = problemeHebdo_->MatriceDesContraintesCouplantes[CntCouplante];
-
- if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HORAIRE)
- continue;
-
- int NbInterco
- = MatriceDesContraintesCouplantes.NombreDInterconnexionsDansLaContrainteCouplante;
- int NombreDeTermes = 0;
- for (int Index = 0; Index < NbInterco; Index++)
- {
- int Interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[Index];
- double Poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[Index];
-
- if (problemeHebdo_->adequacyPatchRuntimeData->originAreaMode[Interco]
- == Data::AdequacyPatch::physicalAreaInsideAdqPatch
- && problemeHebdo_->adequacyPatchRuntimeData->extremityAreaMode[Interco]
- == Data::AdequacyPatch::physicalAreaInsideAdqPatch)
- {
- int var = problemeHebdo_->CorrespondanceVarNativesVarOptim[hour]
- .NumeroDeVariableDeLInterconnexion[Interco];
-
- if (var >= 0)
- {
- Pi[NombreDeTermes] = Poids;
- Colonne[NombreDeTermes] = var;
- NombreDeTermes++;
- }
- }
- }
-
- if (NombreDeTermes > 0) // current binding constraint contains an interco type 2<->2
- {
- hourlyCsrProblem_.numberOfConstraintCsrHourlyBinding[CntCouplante]
- = problemeAResoudre_.NombreDeContraintes;
-
- std::string NomDeLaContrainte
- = "bc::hourly::" + std::to_string(hour)
- + "::" + MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante;
-
- logs.debug() << "C (bc): " << problemeAResoudre_.NombreDeContraintes << ": "
- << NomDeLaContrainte;
-
- OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
- &problemeAResoudre_,
- Pi,
- Colonne,
- NombreDeTermes,
- MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante);
- }
+ csrBindingConstraintHour.add(CntCouplante);
}
}
-
void CsrQuadraticProblem::buildConstraintMatrix()
{
logs.debug() << "[CSR] constraint list:";
@@ -268,10 +119,13 @@ void CsrQuadraticProblem::buildConstraintMatrix()
problemeAResoudre_.NombreDeContraintes = 0;
problemeAResoudre_.NombreDeTermesDansLaMatriceDesContraintes = 0;
+ auto builder_data = NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(
+ problemeHebdo_, problemeAResoudre_);
- setConstraintsOnFlows(Pi, Colonne);
- setNodeBalanceConstraints(Pi, Colonne);
- setBindingConstraints(Pi, Colonne);
+ auto builder = ConstraintBuilder(builder_data);
+ setConstraintsOnFlows(builder);
+ setNodeBalanceConstraints(builder);
+ setBindingConstraints(builder);
}
} // namespace Antares::Solver::Optimization
diff --git a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h
index cd8931ae48..9a61499978 100644
--- a/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h
+++ b/src/solver/optimisation/adequacy_patch_csr/csr_quadratic_problem.h
@@ -27,6 +27,7 @@
#pragma once
+#include "../constraints/ConstraintBuilder.h"
class HourlyCSRProblem;
namespace Antares::Solver::Optimization
@@ -47,9 +48,9 @@ class CsrQuadraticProblem
PROBLEME_ANTARES_A_RESOUDRE& problemeAResoudre_;
HourlyCSRProblem& hourlyCsrProblem_;
- void setConstraintsOnFlows(std::vector& Pi, std::vector& Colonne);
- void setNodeBalanceConstraints(std::vector& Pi, std::vector& Colonne);
- void setBindingConstraints(std::vector& Pi, std::vector& Colonne);
+ void setConstraintsOnFlows(ConstraintBuilder& builder);
+ void setNodeBalanceConstraints(ConstraintBuilder& builder);
+ void setBindingConstraints(ConstraintBuilder& builder);
};
} //namespace Antares::Solver::Optimization
diff --git a/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.cpp b/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.cpp
new file mode 100644
index 0000000000..5fdda2ed32
--- /dev/null
+++ b/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.cpp
@@ -0,0 +1,7 @@
+#include "AbstractStartUpCostsGroup.h"
+
+StartUpCostsData AbstractStartUpCostsGroup::GetStartUpCostsDataFromProblemHebdo()
+{
+ return {.PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .Simulation = simulation_};
+}
diff --git a/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.h b/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.h
new file mode 100644
index 0000000000..0d5758f09e
--- /dev/null
+++ b/src/solver/optimisation/constraints/AbstractStartUpCostsGroup.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "PMinDispatchableGeneration.h"
+#include "PMaxDispatchableGeneration.h"
+
+class AbstractStartUpCostsGroup : public ConstraintGroup
+{
+public:
+ AbstractStartUpCostsGroup(PROBLEME_HEBDO* problemeHebdo,
+ bool simulation,
+ ConstraintBuilder& builder) :
+ simulation_(simulation), ConstraintGroup(problemeHebdo, builder)
+ {
+ }
+
+ void BuildConstraints() = 0;
+
+ bool simulation_ = false;
+ StartUpCostsData GetStartUpCostsDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/AreaBalance.cpp b/src/solver/optimisation/constraints/AreaBalance.cpp
index 2a39f3be83..8dbefe56f8 100644
--- a/src/solver/optimisation/constraints/AreaBalance.cpp
+++ b/src/solver/optimisation/constraints/AreaBalance.cpp
@@ -7,45 +7,43 @@ static void shortTermStorageBalance(const ::ShortTermStorage::AREA_INPUT& shortT
{
unsigned index = storage.clusterGlobalIndex;
constraintBuilder.ShortTermStorageInjection(index, 1.0)
- .ShortTermStorageWithdrawal(index, -1.0);
+ .ShortTermStorageWithdrawal(index, -1.0);
}
}
void AreaBalance::add(int pdt, int pays)
{
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesBilansPays[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContrainteDesBilansPays[pays]
+ = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.AreaBalance(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.AreaBalance(builder.data.nombreDeContraintes);
- builder.updateHourWithinWeek(pdt);
+ builder.updateHourWithinWeek(pdt);
- int interco = problemeHebdo->IndexDebutIntercoOrigine[pays];
- while (interco >= 0)
- {
+ int interco = data.IndexDebutIntercoOrigine[pays];
+ while (interco >= 0)
+ {
builder.NTCDirect(interco, 1.0);
- interco = problemeHebdo->IndexSuivantIntercoOrigine[interco];
- }
+ interco = data.IndexSuivantIntercoOrigine[interco];
+ }
- interco = problemeHebdo->IndexDebutIntercoExtremite[pays];
+ interco = data.IndexDebutIntercoExtremite[pays];
while (interco >= 0)
{
builder.NTCDirect(interco, -1.0);
- interco = problemeHebdo->IndexSuivantIntercoExtremite[interco];
+ interco = data.IndexSuivantIntercoExtremite[interco];
}
- exportPaliers(*problemeHebdo, builder, pays);
+ ExportPaliers(data.PaliersThermiquesDuPays[pays], builder);
builder.HydProd(pays, -1.0)
.Pumping(pays, 1.0)
.PositiveUnsuppliedEnergy(pays, -1.0)
.NegativeUnsuppliedEnergy(pays, 1.0);
- shortTermStorageBalance(problemeHebdo->ShortTermStorage[pays], builder);
+ shortTermStorageBalance(data.ShortTermStorage[pays], builder);
builder.equalTo();
builder.build();
diff --git a/src/solver/optimisation/constraints/AreaBalance.h b/src/solver/optimisation/constraints/AreaBalance.h
index a800a288ed..fa44ced8c9 100644
--- a/src/solver/optimisation/constraints/AreaBalance.h
+++ b/src/solver/optimisation/constraints/AreaBalance.h
@@ -1,18 +1,37 @@
#pragma once
#include "ConstraintBuilder.h"
+struct AreaBalanceData
+{
+ std::vector& CorrespondanceCntNativesCntOptim;
+ const std::vector& IndexDebutIntercoOrigine;
+ const std::vector& IndexSuivantIntercoOrigine;
+ const std::vector& IndexDebutIntercoExtremite;
+ const std::vector& IndexSuivantIntercoExtremite;
+ const std::vector& PaliersThermiquesDuPays;
+ const std::vector<::ShortTermStorage::AREA_INPUT>& ShortTermStorage;
+};
+
/*!
* represent 'Area Balance' constraint type
*/
-class AreaBalance : private ConstraintFactory
+
+class AreaBalance : public ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ AreaBalance(ConstraintBuilder& builder, AreaBalanceData& 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);
-};
\ No newline at end of file
+
+private:
+ AreaBalanceData& data;
+};
diff --git a/src/solver/optimisation/constraints/AreaHydroLevel.cpp b/src/solver/optimisation/constraints/AreaHydroLevel.cpp
index 228620b519..e6105f5d97 100644
--- a/src/solver/optimisation/constraints/AreaHydroLevel.cpp
+++ b/src/solver/optimisation/constraints/AreaHydroLevel.cpp
@@ -2,31 +2,29 @@
void AreaHydroLevel::add(int pays, int pdt)
{
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
- if (problemeHebdo->CaracteristiquesHydrauliques[pays].SuiviNiveauHoraire)
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContrainteDesNiveauxPays[pays]
+ = builder.data.nombreDeContraintes;
+ if (data.CaracteristiquesHydrauliques[pays].SuiviNiveauHoraire)
{
builder.updateHourWithinWeek(pdt).HydroLevel(pays, 1.0);
if (pdt > 0)
{
builder.updateHourWithinWeek(pdt - 1).HydroLevel(pays, -1.0);
}
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.AreaHydroLevel(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.AreaHydroLevel(builder.data.nombreDeContraintes);
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContrainteDesNiveauxPays[pays]
+ = builder.data.nombreDeContraintes;
builder.updateHourWithinWeek(pdt)
.HydProd(pays, 1.0)
- .Pumping(pays, -problemeHebdo->CaracteristiquesHydrauliques[pays].PumpingRatio)
+ .Pumping(pays, -data.CaracteristiquesHydrauliques[pays].PumpingRatio)
.Overflow(pays, 1.)
.equalTo()
.build();
}
else
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays] = -1;
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContrainteDesNiveauxPays[pays] = -1;
}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/AreaHydroLevel.h b/src/solver/optimisation/constraints/AreaHydroLevel.h
index 2af93b076c..b7afc7ce91 100644
--- a/src/solver/optimisation/constraints/AreaHydroLevel.h
+++ b/src/solver/optimisation/constraints/AreaHydroLevel.h
@@ -1,13 +1,23 @@
#pragma once
#include "ConstraintBuilder.h"
+struct AreaHydroLevelData
+{
+ std::vector& CorrespondanceCntNativesCntOptim;
+ const std::vector CaracteristiquesHydrauliques;
+};
+
/*!
* represent 'Area Hydraulic Level' constraint type
*/
+
class AreaHydroLevel : private ConstraintFactory
{
- public:
- using ConstraintFactory::ConstraintFactory;
+public:
+ AreaHydroLevel(ConstraintBuilder& builder, AreaHydroLevelData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -15,4 +25,7 @@ class AreaHydroLevel : private ConstraintFactory
* @param pays : area
*/
void add(int pays, int pdt);
-};
\ No newline at end of file
+
+private:
+ AreaHydroLevelData& data;
+};
diff --git a/src/solver/optimisation/constraints/AreaHydroLevelGroup.cpp b/src/solver/optimisation/constraints/AreaHydroLevelGroup.cpp
new file mode 100644
index 0000000000..04a24721fc
--- /dev/null
+++ b/src/solver/optimisation/constraints/AreaHydroLevelGroup.cpp
@@ -0,0 +1,21 @@
+#include "AreaHydroLevelGroup.h"
+
+AreaHydroLevelData AreaHydroLevelGroup::GetAreaHydroLevelData()
+{
+ return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques};
+}
+
+void AreaHydroLevelGroup::BuildConstraints()
+{
+ auto areaHydroLevelData = GetAreaHydroLevelData();
+ AreaHydroLevel areaHydroLevel(builder_, areaHydroLevelData);
+
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ areaHydroLevel.add(pays, pdt);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/AreaHydroLevelGroup.h b/src/solver/optimisation/constraints/AreaHydroLevelGroup.h
new file mode 100644
index 0000000000..3fe6cce0fd
--- /dev/null
+++ b/src/solver/optimisation/constraints/AreaHydroLevelGroup.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "AreaHydroLevel.h"
+
+class AreaHydroLevelGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ AreaHydroLevelData GetAreaHydroLevelData();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/BindingConstraintDay.cpp b/src/solver/optimisation/constraints/BindingConstraintDay.cpp
index d55a7edb15..1c8fce5a33 100644
--- a/src/solver/optimisation/constraints/BindingConstraintDay.cpp
+++ b/src/solver/optimisation/constraints/BindingConstraintDay.cpp
@@ -3,7 +3,7 @@
void BindingConstraintDay::add(int cntCouplante)
{
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
- = problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
+ = data.MatriceDesContraintesCouplantes[cntCouplante];
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_JOURNALIERE)
return;
@@ -13,14 +13,12 @@ void BindingConstraintDay::add(int cntCouplante)
= MatriceDesContraintesCouplantes.NombreDePaliersDispatchDansLaContrainteCouplante;
const int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
- const int NombreDePasDeTempsDUneJournee = problemeHebdo->NombreDePasDeTempsDUneJournee;
+ = builder.data.NombreDePasDeTempsPourUneOptimisation;
+ const int NombreDePasDeTempsDUneJournee = data.NombreDePasDeTempsDUneJournee;
int pdtDebut = 0;
while (pdtDebut < NombreDePasDeTempsPourUneOptimisation)
{
- int jour = problemeHebdo->NumeroDeJourDuPasDeTemps[pdtDebut];
- CORRESPONDANCES_DES_CONTRAINTES_JOURNALIERES& CorrespondanceCntNativesCntOptimJournalieres
- = problemeHebdo->CorrespondanceCntNativesCntOptimJournalieres[jour];
+ int jour = data.NumeroDeJourDuPasDeTemps[pdtDebut];
for (int index = 0; index < nbInterco; index++)
{
@@ -31,15 +29,14 @@ void BindingConstraintDay::add(int cntCouplante)
for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
builder.updateHourWithinWeek(pdt).NTCDirect(
- interco, poids, offset, problemeHebdo->NombreDePasDeTemps);
+ interco, poids, offset, builder.data.NombreDePasDeTemps);
}
}
for (int index = 0; index < nbClusters; index++)
{
int pays = MatriceDesContraintesCouplantes.PaysDuPalierDispatch[index];
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays = data.PaliersThermiquesDuPays[pays];
const int palier
= PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques
[MatriceDesContraintesCouplantes.NumeroDuPalierDispatch[index]];
@@ -49,21 +46,22 @@ void BindingConstraintDay::add(int cntCouplante)
for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
builder.updateHourWithinWeek(pdt).DispatchableProduction(
- palier, poids, offset, problemeHebdo->NombreDePasDeTemps);
+ palier, poids, offset, builder.data.NombreDePasDeTemps);
}
}
- CorrespondanceCntNativesCntOptimJournalieres
+ data.CorrespondanceCntNativesCntOptimJournalieres[jour]
.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ = builder.data.nombreDeContraintes;
- char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
- builder.SetOperator(op);
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateTimeStep(jour);
- namer.BindingConstraintDay(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
+ builder.SetOperator(MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante);
+ {
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(jour);
+ namer.BindingConstraintDay(builder.data.nombreDeContraintes,
+ MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
+ }
builder.build();
- pdtDebut += problemeHebdo->NombreDePasDeTempsDUneJournee;
+ pdtDebut += data.NombreDePasDeTempsDUneJournee;
}
}
diff --git a/src/solver/optimisation/constraints/BindingConstraintDay.h b/src/solver/optimisation/constraints/BindingConstraintDay.h
index 1fff7b54a7..2a40873d1f 100644
--- a/src/solver/optimisation/constraints/BindingConstraintDay.h
+++ b/src/solver/optimisation/constraints/BindingConstraintDay.h
@@ -1,17 +1,35 @@
#pragma once
#include "ConstraintBuilder.h"
+struct BindingConstraintDayData
+{
+ const std::vector& MatriceDesContraintesCouplantes;
+ const std::vector& PaliersThermiquesDuPays;
+ std::vector&
+ CorrespondanceCntNativesCntOptimJournalieres;
+ const int32_t& NombreDePasDeTempsDUneJournee;
+ std::vector& NumeroDeJourDuPasDeTemps;
+};
+
/*!
* represent 'Daily Binding Constraint' type
*/
+
class BindingConstraintDay : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ BindingConstraintDay(ConstraintBuilder& builder,
+ BindingConstraintDayData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param cntCouplante : the binding constraint number
*/
void add(int cntCouplante);
+
+private:
+ BindingConstraintDayData& data;
};
diff --git a/src/solver/optimisation/constraints/BindingConstraintDayGroup.cpp b/src/solver/optimisation/constraints/BindingConstraintDayGroup.cpp
new file mode 100644
index 0000000000..00370f942f
--- /dev/null
+++ b/src/solver/optimisation/constraints/BindingConstraintDayGroup.cpp
@@ -0,0 +1,23 @@
+#include "BindingConstraintDayGroup.h"
+#include "constraint_builder_utils.h"
+
+BindingConstraintDayData BindingConstraintDayGroup::GetBindingConstraintDayDataFromProblemHebdo()
+{
+ return {.MatriceDesContraintesCouplantes = problemeHebdo_->MatriceDesContraintesCouplantes,
+ .PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .CorrespondanceCntNativesCntOptimJournalieres
+ = problemeHebdo_->CorrespondanceCntNativesCntOptimJournalieres,
+ .NombreDePasDeTempsDUneJournee = problemeHebdo_->NombreDePasDeTempsDUneJournee,
+ .NumeroDeJourDuPasDeTemps = problemeHebdo_->NumeroDeJourDuPasDeTemps};
+}
+
+void BindingConstraintDayGroup::BuildConstraints()
+{
+ auto bindingConstraintDayData = GetBindingConstraintDayDataFromProblemHebdo();
+ BindingConstraintDay bindingConstraintDay(builder_, bindingConstraintDayData);
+ for (uint32_t cntCouplante = 0; cntCouplante < problemeHebdo_->NombreDeContraintesCouplantes;
+ cntCouplante++)
+ {
+ bindingConstraintDay.add(cntCouplante);
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/BindingConstraintDayGroup.h b/src/solver/optimisation/constraints/BindingConstraintDayGroup.h
new file mode 100644
index 0000000000..faacea3b79
--- /dev/null
+++ b/src/solver/optimisation/constraints/BindingConstraintDayGroup.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "BindingConstraintDay.h"
+
+class BindingConstraintDayGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ BindingConstraintDayData GetBindingConstraintDayDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/BindingConstraintHour.cpp b/src/solver/optimisation/constraints/BindingConstraintHour.cpp
index d6dfe999ac..0777c19cf9 100644
--- a/src/solver/optimisation/constraints/BindingConstraintHour.cpp
+++ b/src/solver/optimisation/constraints/BindingConstraintHour.cpp
@@ -2,12 +2,12 @@
void BindingConstraintHour::add(int pdt, int cntCouplante)
{
+ data.CorrespondanceCntNativesCntOptim[pdt]
+ .NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
+ = builder.data.nombreDeContraintes;
+
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
- = problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ = data.MatriceDesContraintesCouplantes[cntCouplante];
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HORAIRE)
return;
@@ -21,9 +21,8 @@ void BindingConstraintHour::add(int pdt, int cntCouplante)
const int interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[index];
const double poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[index];
const int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco[index];
-
builder.updateHourWithinWeek(pdt).NTCDirect(
- interco, poids, offset, problemeHebdo->NombreDePasDeTemps);
+ interco, poids, offset, builder.data.NombreDePasDeTemps);
}
// Thermal clusters
@@ -32,22 +31,22 @@ void BindingConstraintHour::add(int pdt, int cntCouplante)
for (int index = 0; index < nbClusters; index++)
{
const int pays = MatriceDesContraintesCouplantes.PaysDuPalierDispatch[index];
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays = data.PaliersThermiquesDuPays[pays];
const int palier = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques
[MatriceDesContraintesCouplantes.NumeroDuPalierDispatch[index]];
const double poids = MatriceDesContraintesCouplantes.PoidsDuPalierDispatch[index];
const int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLePalierDispatch[index];
builder.updateHourWithinWeek(pdt).DispatchableProduction(
- palier, poids, offset, problemeHebdo->NombreDePasDeTemps);
+ palier, poids, offset, builder.data.NombreDePasDeTemps);
}
- char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
- builder.SetOperator(op);
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.BindingConstraintHour(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
+ builder.SetOperator(MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante);
+ {
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.BindingConstraintHour(builder.data.nombreDeContraintes,
+ MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
+ }
builder.build();
}
diff --git a/src/solver/optimisation/constraints/BindingConstraintHour.h b/src/solver/optimisation/constraints/BindingConstraintHour.h
index bad823047d..7da7ccf188 100644
--- a/src/solver/optimisation/constraints/BindingConstraintHour.h
+++ b/src/solver/optimisation/constraints/BindingConstraintHour.h
@@ -1,18 +1,31 @@
#pragma once
-#include "ConstraintBuilder.h"
+#include "ConstraintBuilder.h"
+struct BindingConstraintHourData
+{
+ const std::vector& MatriceDesContraintesCouplantes;
+ std::vector& CorrespondanceCntNativesCntOptim;
+ const std::vector& PaliersThermiquesDuPays;
+};
/*!
* represent 'Hourly Binding Constraint' type
*/
class BindingConstraintHour : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ BindingConstraintHour(ConstraintBuilder& builder,
+ BindingConstraintHourData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pdt : timestep
* @param cntCouplante : the binding constraint number
*/
- void add(int pdt, int cntCouplante);
+ void add(int pdt, int cntCouplante);
+
+ private:
+ BindingConstraintHourData& data;
};
diff --git a/src/solver/optimisation/constraints/BindingConstraintWeek.cpp b/src/solver/optimisation/constraints/BindingConstraintWeek.cpp
index 4524c2702b..c7e7d113ac 100644
--- a/src/solver/optimisation/constraints/BindingConstraintWeek.cpp
+++ b/src/solver/optimisation/constraints/BindingConstraintWeek.cpp
@@ -2,11 +2,10 @@
void BindingConstraintWeek::add(int cntCouplante)
{
+ int semaine = builder.data.weekInTheYear;
+
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
- = problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
- int semaine = problemeHebdo->weekInTheYear;
- CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondanceCntNativesCntOptimHebdomadaires
- = problemeHebdo->CorrespondanceCntNativesCntOptimHebdomadaires;
+ = data.MatriceDesContraintesCouplantes[cntCouplante];
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HEBDOMADAIRE)
return;
@@ -20,40 +19,36 @@ void BindingConstraintWeek::add(int cntCouplante)
int interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[index];
double poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[index];
int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco[index];
- for (int pdt = 0; pdt < problemeHebdo->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ for (int pdt = 0; pdt < builder.data.NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt).NTCDirect(
- interco, poids, offset, problemeHebdo->NombreDePasDeTemps);
+ interco, poids, offset, builder.data.NombreDePasDeTemps);
}
}
- for (int index = 0; index < nbClusters; index++)
+ for (int index = 0; index < nbClusters; index++)
+ {
+ int pays = MatriceDesContraintesCouplantes.PaysDuPalierDispatch[index];
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays = data.PaliersThermiquesDuPays[pays];
+ const int palier = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques
+ [MatriceDesContraintesCouplantes.NumeroDuPalierDispatch[index]];
+ double poids = MatriceDesContraintesCouplantes.PoidsDuPalierDispatch[index];
+ int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLePalierDispatch[index];
+ for (int pdt = 0; pdt < builder.data.NombreDePasDeTempsPourUneOptimisation; pdt++)
{
- int pays = MatriceDesContraintesCouplantes.PaysDuPalierDispatch[index];
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques
- [MatriceDesContraintesCouplantes.NumeroDuPalierDispatch[index]];
- double poids = MatriceDesContraintesCouplantes.PoidsDuPalierDispatch[index];
- int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLePalierDispatch[index];
- for (int pdt = 0; pdt < problemeHebdo->NombreDePasDeTempsPourUneOptimisation; pdt++)
- {
builder.updateHourWithinWeek(pdt).DispatchableProduction(
- palier, poids, offset, problemeHebdo->NombreDePasDeTemps);
- }
+ palier, poids, offset, builder.data.NombreDePasDeTemps);
}
+ }
- char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
- builder.SetOperator(op);
+ builder.SetOperator(MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante);
- CorrespondanceCntNativesCntOptimHebdomadaires
- .NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
+ = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
namer.UpdateTimeStep(semaine);
- namer.BindingConstraintWeek(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
+ namer.BindingConstraintWeek(builder.data.nombreDeContraintes,
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
builder.build();
-}
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/BindingConstraintWeek.h b/src/solver/optimisation/constraints/BindingConstraintWeek.h
index b94698e5d0..8d689e7e94 100644
--- a/src/solver/optimisation/constraints/BindingConstraintWeek.h
+++ b/src/solver/optimisation/constraints/BindingConstraintWeek.h
@@ -1,17 +1,31 @@
#pragma once
#include "ConstraintBuilder.h"
+struct BindingConstraintWeekData
+{
+ const std::vector& MatriceDesContraintesCouplantes;
+ const std::vector& PaliersThermiquesDuPays;
+ std::vector& NumeroDeContrainteDesContraintesCouplantes;
+};
/*!
* represent 'Hourly Binding Constraint' type
*/
+
class BindingConstraintWeek : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ BindingConstraintWeek(ConstraintBuilder& builder,
+ BindingConstraintWeekData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param cntCouplante : the binding constraint number
*/
void add(int cntCouplante);
-};
\ No newline at end of file
+
+private:
+ BindingConstraintWeekData& data;
+};
diff --git a/src/solver/optimisation/constraints/BindingConstraintWeekGroup.cpp b/src/solver/optimisation/constraints/BindingConstraintWeekGroup.cpp
new file mode 100644
index 0000000000..714879d9ae
--- /dev/null
+++ b/src/solver/optimisation/constraints/BindingConstraintWeekGroup.cpp
@@ -0,0 +1,30 @@
+#include "BindingConstraintWeekGroup.h"
+#include "constraint_builder_utils.h"
+
+BindingConstraintWeekData BindingConstraintWeekGroup::GetBindingConstraintWeekDataFromProblemHebdo()
+{
+ return {.MatriceDesContraintesCouplantes = problemeHebdo_->MatriceDesContraintesCouplantes,
+ .PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .NumeroDeContrainteDesContraintesCouplantes
+ = problemeHebdo_->CorrespondanceCntNativesCntOptimHebdomadaires
+ .NumeroDeContrainteDesContraintesCouplantes};
+}
+
+void BindingConstraintWeekGroup::BuildConstraints()
+{
+ auto bindingConstraintWeekData = GetBindingConstraintWeekDataFromProblemHebdo();
+ BindingConstraintWeek bindingConstraintWeek(builder_, bindingConstraintWeekData);
+
+ if (problemeHebdo_->NombreDePasDeTempsPourUneOptimisation
+ > problemeHebdo_->NombreDePasDeTempsDUneJournee)
+ {
+ CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondanceCntNativesCntOptimHebdomadaires
+ = problemeHebdo_->CorrespondanceCntNativesCntOptimHebdomadaires;
+ for (uint32_t cntCouplante = 0;
+ cntCouplante < problemeHebdo_->NombreDeContraintesCouplantes;
+ cntCouplante++)
+ {
+ bindingConstraintWeek.add(cntCouplante);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/BindingConstraintWeekGroup.h b/src/solver/optimisation/constraints/BindingConstraintWeekGroup.h
new file mode 100644
index 0000000000..0ce3ce7c5c
--- /dev/null
+++ b/src/solver/optimisation/constraints/BindingConstraintWeekGroup.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "BindingConstraintWeek.h"
+
+class BindingConstraintWeekGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ BindingConstraintWeekData GetBindingConstraintWeekDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp
index 03119ed030..1be75e7501 100644
--- a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp
+++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.cpp
@@ -1,19 +1,14 @@
#include "ConsistenceNumberOfDispatchableUnits.h"
-void ConsistenceNumberOfDispatchableUnits::add(int pays,
- int cluster,
- int clusterIndex,
- int pdt,
- bool Simulation)
+void ConsistenceNumberOfDispatchableUnits::add(int pays, int index, int pdt)
{
- if (!Simulation)
+ if (!data.Simulation)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
-
int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
+ = builder.data.NombreDePasDeTempsPourUneOptimisation;
+ auto cluster = data.PaliersThermiquesDuPays[pays]
+ .NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
int Pdtmoins1 = pdt - 1;
if (Pdtmoins1 < 0)
Pdtmoins1 = NombreDePasDeTempsPourUneOptimisation + Pdtmoins1;
@@ -29,19 +24,20 @@ void ConsistenceNumberOfDispatchableUnits::add(int pays,
if (builder.NumberOfVariables() > 0)
{
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.ConsistenceNODU(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.ConsistenceNODU(
+ builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
builder.build();
}
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage += 4;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 4;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.h b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.h
index 43af772514..3d94e51ec8 100644
--- a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.h
+++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnits.h
@@ -7,7 +7,11 @@
class ConsistenceNumberOfDispatchableUnits : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ ConsistenceNumberOfDispatchableUnits(ConstraintBuilder& builder,
+ StartUpCostsData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
@@ -15,5 +19,8 @@ class ConsistenceNumberOfDispatchableUnits : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ StartUpCostsData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.cpp b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.cpp
new file mode 100644
index 0000000000..0a2f62db44
--- /dev/null
+++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.cpp
@@ -0,0 +1,24 @@
+#include "ConsistenceNumberOfDispatchableUnitsGroup.h"
+#include "ConsistenceNumberOfDispatchableUnits.h"
+
+/**
+ * @brief build ConsistenceNumberOfDispatchableUnits constraints with
+ * respect to default order
+ */
+void ConsistenceNumberOfDispatchableUnitsGroup::BuildConstraints()
+{
+ auto data = GetStartUpCostsDataFromProblemHebdo();
+ ConsistenceNumberOfDispatchableUnits consistenceNumberOfDispatchableUnits(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays
+ = problemeHebdo_->PaliersThermiquesDuPays[pays];
+ for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
+ {
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ consistenceNumberOfDispatchableUnits.add(pays, index, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.h b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.h
new file mode 100644
index 0000000000..aef716a127
--- /dev/null
+++ b/src/solver/optimisation/constraints/ConsistenceNumberOfDispatchableUnitsGroup.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "AbstractStartUpCostsGroup.h"
+#include "ConstraintGroup.h"
+
+/**
+ * @brief Group of ConsistenceNumberOfDispatchableUnits constraints
+ *
+ */
+
+class ConsistenceNumberOfDispatchableUnitsGroup : public AbstractStartUpCostsGroup
+{
+public:
+ using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;
+
+ void BuildConstraints() override;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConstraintBuilder.cpp b/src/solver/optimisation/constraints/ConstraintBuilder.cpp
index 195d8dad30..b9bb7bf0fc 100644
--- a/src/solver/optimisation/constraints/ConstraintBuilder.cpp
+++ b/src/solver/optimisation/constraints/ConstraintBuilder.cpp
@@ -2,13 +2,9 @@
void ConstraintBuilder::build()
{
- std::vector& Pi = problemeAResoudre.Pi;
- std::vector& Colonne = problemeAResoudre.Colonne;
-
if (nombreDeTermes_ > 0)
{
- OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
- &problemeAResoudre, Pi, Colonne, nombreDeTermes_, operator_);
+ OPT_ChargerLaContrainteDansLaMatriceDesContraintes();
}
nombreDeTermes_ = 0;
}
@@ -16,7 +12,7 @@ void ConstraintBuilder::build()
int ConstraintBuilder::GetShiftedTimeStep(int offset, int delta) const
{
int pdt = hourInWeek_ + offset;
- const int nbTimeSteps = problemeHebdo.NombreDePasDeTempsPourUneOptimisation;
+ const int nbTimeSteps = data.NombreDePasDeTempsPourUneOptimisation;
if (const bool shifted_timestep = offset != 0; shifted_timestep)
{
@@ -34,67 +30,54 @@ int ConstraintBuilder::GetShiftedTimeStep(int offset, int delta) const
void ConstraintBuilder::AddVariable(int varIndex, double coeff)
{
- std::vector& Pi = problemeAResoudre.Pi;
- std::vector& Colonne = problemeAResoudre.Colonne;
if (varIndex >= 0)
{
- Pi[nombreDeTermes_] = coeff;
- Colonne[nombreDeTermes_] = varIndex;
+ data.Pi[nombreDeTermes_] = coeff;
+ data.Colonne[nombreDeTermes_] = varIndex;
nombreDeTermes_++;
}
}
-
-Variable::VariableManager ConstraintBuilder::GetVariableManager(int offset, int delta) const
+NewVariable::VariableManager ConstraintBuilder::GetVariableManager(int offset,
+ int delta) const
{
auto pdt = GetShiftedTimeStep(offset, delta);
- return Variable::VariableManager(varNative[pdt],
- problemeHebdo.NumeroDeVariableStockFinal,
- problemeHebdo.NumeroDeVariableDeTrancheDeStock);
+ return NewVariable::VariableManager(data.CorrespondanceVarNativesVarOptim[pdt],
+ data.NumeroDeVariableStockFinal,
+ data.NumeroDeVariableDeTrancheDeStock);
}
-
ConstraintBuilder& ConstraintBuilder::DispatchableProduction(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ double coeff,
+ int offset,
+ int delta)
{
AddVariable(GetVariableManager(offset, delta).DispatchableProduction(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::NumberOfDispatchableUnits(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::NumberOfDispatchableUnits(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).NumberOfDispatchableUnits(index), coeff);
+ AddVariable(GetVariableManager(0, 0).NumberOfDispatchableUnits(index), coeff);
return *this;
}
ConstraintBuilder& ConstraintBuilder::NumberStoppingDispatchableUnits(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ double coeff)
{
- AddVariable(GetVariableManager(offset, delta).NumberStoppingDispatchableUnits(index), coeff);
+ AddVariable(GetVariableManager(0, 0).NumberStoppingDispatchableUnits(index), coeff);
return *this;
}
ConstraintBuilder& ConstraintBuilder::NumberStartingDispatchableUnits(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ double coeff)
{
- AddVariable(GetVariableManager(offset, delta).NumberStartingDispatchableUnits(index), coeff);
+ AddVariable(GetVariableManager(0, 0).NumberStartingDispatchableUnits(index), coeff);
return *this;
}
ConstraintBuilder& ConstraintBuilder::NumberBreakingDownDispatchableUnits(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ double coeff)
{
- AddVariable(GetVariableManager(offset, delta).NumberBreakingDownDispatchableUnits(index),
- coeff);
+ AddVariable(GetVariableManager(0, 0).NumberBreakingDownDispatchableUnits(index), coeff);
return *this;
}
@@ -107,39 +90,27 @@ ConstraintBuilder& ConstraintBuilder::NTCDirect(unsigned int index,
return *this;
}
-ConstraintBuilder& ConstraintBuilder::IntercoDirectCost(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::IntercoDirectCost(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).IntercoDirectCost(index), coeff);
+ AddVariable(GetVariableManager(0, 0).IntercoDirectCost(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::IntercoIndirectCost(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::IntercoIndirectCost(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).IntercoIndirectCost(index), coeff);
+ AddVariable(GetVariableManager(0, 0).IntercoIndirectCost(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::ShortTermStorageInjection(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::ShortTermStorageInjection(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).ShortTermStorageInjection(index), coeff);
+ AddVariable(GetVariableManager(0, 0).ShortTermStorageInjection(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::ShortTermStorageWithdrawal(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::ShortTermStorageWithdrawal(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).ShortTermStorageWithdrawal(index), coeff);
+ AddVariable(GetVariableManager(0, 0).ShortTermStorageWithdrawal(index), coeff);
return *this;
}
@@ -152,93 +123,103 @@ ConstraintBuilder& ConstraintBuilder::ShortTermStorageLevel(unsigned int index,
return *this;
}
-ConstraintBuilder& ConstraintBuilder::HydProd(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::HydProd(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).HydProd(index), coeff);
+ AddVariable(GetVariableManager(0, 0).HydProd(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::HydProdDown(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::HydProdDown(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).HydProdDown(index), coeff);
+ AddVariable(GetVariableManager(0, 0).HydProdDown(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::HydProdUp(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::HydProdUp(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).HydProdUp(index), coeff);
+ AddVariable(GetVariableManager(0, 0).HydProdUp(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::Pumping(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::Pumping(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).Pumping(index), coeff);
+ AddVariable(GetVariableManager(0, 0).Pumping(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::HydroLevel(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::HydroLevel(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).HydroLevel(index), coeff);
+ AddVariable(GetVariableManager(0, 0).HydroLevel(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::Overflow(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::Overflow(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).Overflow(index), coeff);
+ AddVariable(GetVariableManager(0, 0).Overflow(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::FinalStorage(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::FinalStorage(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).FinalStorage(index), coeff);
+ AddVariable(GetVariableManager(0, 0).FinalStorage(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::PositiveUnsuppliedEnergy(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::PositiveUnsuppliedEnergy(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).PositiveUnsuppliedEnergy(index), coeff);
+ AddVariable(GetVariableManager(0, 0).PositiveUnsuppliedEnergy(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::NegativeUnsuppliedEnergy(unsigned int index,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::NegativeUnsuppliedEnergy(unsigned int index, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).NegativeUnsuppliedEnergy(index), coeff);
+ AddVariable(GetVariableManager(0, 0).NegativeUnsuppliedEnergy(index), coeff);
return *this;
}
-ConstraintBuilder& ConstraintBuilder::LayerStorage(unsigned area,
- unsigned layer,
- double coeff,
- int offset,
- int delta)
+ConstraintBuilder& ConstraintBuilder::LayerStorage(unsigned area, unsigned layer, double coeff)
{
- AddVariable(GetVariableManager(offset, delta).LayerStorage(area, layer), coeff);
+ AddVariable(GetVariableManager(0, 0).LayerStorage(area, layer), coeff);
return *this;
}
+
+void ConstraintBuilder::OPT_ChargerLaContrainteDansLaMatriceDesContraintes()
+{
+ data.IndicesDebutDeLigne[data.nombreDeContraintes]
+ = data.nombreDeTermesDansLaMatriceDeContrainte;
+ for (int i = 0; i < nombreDeTermes_; i++)
+ {
+ data.CoefficientsDeLaMatriceDesContraintes[data.nombreDeTermesDansLaMatriceDeContrainte]
+ = data.Pi[i];
+ data.IndicesColonnes[data.nombreDeTermesDansLaMatriceDeContrainte] = data.Colonne[i];
+ data.nombreDeTermesDansLaMatriceDeContrainte++;
+ if (data.nombreDeTermesDansLaMatriceDeContrainte
+ == data.NombreDeTermesAllouesDansLaMatriceDesContraintes)
+ {
+ OPT_AugmenterLaTailleDeLaMatriceDesContraintes();
+ }
+ }
+ data.NombreDeTermesDesLignes[data.nombreDeContraintes] = nombreDeTermes_;
+
+ data.Sens[data.nombreDeContraintes] = operator_;
+ data.nombreDeContraintes++;
+
+ return;
+}
+
+void ConstraintBuilder::OPT_AugmenterLaTailleDeLaMatriceDesContraintes()
+{
+ int NbTermes = data.NombreDeTermesAllouesDansLaMatriceDesContraintes;
+ NbTermes += data.IncrementDAllocationMatriceDesContraintes;
+
+ logs.info();
+ logs.info() << " Expected Number of Non-zero terms in Problem Matrix : increased to : "
+ << NbTermes;
+ logs.info();
+
+ data.CoefficientsDeLaMatriceDesContraintes.resize(NbTermes);
+
+ data.IndicesColonnes.resize(NbTermes);
+
+ data.NombreDeTermesAllouesDansLaMatriceDesContraintes = NbTermes;
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConstraintBuilder.h b/src/solver/optimisation/constraints/ConstraintBuilder.h
index 0ef7bf5675..86fde5b4f1 100644
--- a/src/solver/optimisation/constraints/ConstraintBuilder.h
+++ b/src/solver/optimisation/constraints/ConstraintBuilder.h
@@ -8,7 +8,7 @@
#include
-namespace Variable
+namespace NewVariable
{
/*!
@@ -20,7 +20,7 @@ class VariableManager
VariableManager(const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar,
const std::vector& NumeroDeVariableStockFinal,
const std::vector>& NumeroDeVariableDeTrancheDeStock) :
- nativeOptimVar(nativeOptimVar),
+ nativeOptimVar_(nativeOptimVar),
NumeroDeVariableStockFinal(NumeroDeVariableStockFinal),
NumeroDeVariableDeTrancheDeStock(NumeroDeVariableDeTrancheDeStock)
{
@@ -28,88 +28,90 @@ class VariableManager
int DispatchableProduction(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDuPalierThermique[index];
+ return nativeOptimVar_.NumeroDeVariableDuPalierThermique[index];
}
int NumberOfDispatchableUnits(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDuNombreDeGroupesEnMarcheDuPalierThermique[index];
+ return nativeOptimVar_.NumeroDeVariableDuNombreDeGroupesEnMarcheDuPalierThermique[index];
}
int NumberStoppingDispatchableUnits(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDuNombreDeGroupesQuiSArretentDuPalierThermique[index];
+ return nativeOptimVar_
+ .NumeroDeVariableDuNombreDeGroupesQuiSArretentDuPalierThermique[index];
}
int NumberStartingDispatchableUnits(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDuNombreDeGroupesQuiDemarrentDuPalierThermique[index];
+ return nativeOptimVar_
+ .NumeroDeVariableDuNombreDeGroupesQuiDemarrentDuPalierThermique[index];
}
int NumberBreakingDownDispatchableUnits(unsigned int index) const
{
- return nativeOptimVar
+ return nativeOptimVar_
.NumeroDeVariableDuNombreDeGroupesQuiTombentEnPanneDuPalierThermique[index];
}
int NTCDirect(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDeLInterconnexion[index];
+ return nativeOptimVar_.NumeroDeVariableDeLInterconnexion[index];
}
int IntercoDirectCost(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableCoutOrigineVersExtremiteDeLInterconnexion[index];
+ return nativeOptimVar_.NumeroDeVariableCoutOrigineVersExtremiteDeLInterconnexion[index];
}
int IntercoIndirectCost(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableCoutExtremiteVersOrigineDeLInterconnexion[index];
+ return nativeOptimVar_.NumeroDeVariableCoutExtremiteVersOrigineDeLInterconnexion[index];
}
int ShortTermStorageInjection(unsigned int index) const
{
- return nativeOptimVar.SIM_ShortTermStorage.InjectionVariable[index];
+ return nativeOptimVar_.SIM_ShortTermStorage.InjectionVariable[index];
}
int ShortTermStorageWithdrawal(unsigned int index) const
{
- return nativeOptimVar.SIM_ShortTermStorage.WithdrawalVariable[index];
+ return nativeOptimVar_.SIM_ShortTermStorage.WithdrawalVariable[index];
}
int ShortTermStorageLevel(unsigned int index) const
{
- return nativeOptimVar.SIM_ShortTermStorage.LevelVariable[index];
+ return nativeOptimVar_.SIM_ShortTermStorage.LevelVariable[index];
}
int HydProd(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesDeLaProdHyd[index];
+ return nativeOptimVar_.NumeroDeVariablesDeLaProdHyd[index];
}
int HydProdDown(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesVariationHydALaBaisse[index];
+ return nativeOptimVar_.NumeroDeVariablesVariationHydALaBaisse[index];
}
int HydProdUp(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesVariationHydALaHausse[index];
+ return nativeOptimVar_.NumeroDeVariablesVariationHydALaHausse[index];
}
int Pumping(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesDePompage[index];
+ return nativeOptimVar_.NumeroDeVariablesDePompage[index];
}
int HydroLevel(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesDeNiveau[index];
+ return nativeOptimVar_.NumeroDeVariablesDeNiveau[index];
}
int Overflow(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariablesDeDebordement[index];
+ return nativeOptimVar_.NumeroDeVariablesDeDebordement[index];
}
int FinalStorage(unsigned int index) const
@@ -124,21 +126,47 @@ class VariableManager
int PositiveUnsuppliedEnergy(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDefaillancePositive[index];
+ return nativeOptimVar_.NumeroDeVariableDefaillancePositive[index];
}
int NegativeUnsuppliedEnergy(unsigned int index) const
{
- return nativeOptimVar.NumeroDeVariableDefaillanceNegative[index];
+ return nativeOptimVar_.NumeroDeVariableDefaillanceNegative[index];
}
private:
- const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar;
+ const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar_;
const std::vector& NumeroDeVariableStockFinal;
const std::vector>& NumeroDeVariableDeTrancheDeStock;
};
+} // namespace NewVariable
-} // namespace Variable
+// TODO God struct should be decomposed
+class ConstraintBuilderData
+{
+public:
+ std::vector& Pi;
+ std::vector& Colonne;
+ int& nombreDeContraintes;
+ int& nombreDeTermesDansLaMatriceDeContrainte;
+ std::vector& IndicesDebutDeLigne;
+ std::vector& CoefficientsDeLaMatriceDesContraintes;
+ std::vector& IndicesColonnes;
+ int& NombreDeTermesAllouesDansLaMatriceDesContraintes; // TODO Check if ref is needed
+ std::vector& NombreDeTermesDesLignes;
+ std::string& Sens;
+ int& IncrementDAllocationMatriceDesContraintes;
+ const std::vector& CorrespondanceVarNativesVarOptim;
+ const int32_t& NombreDePasDeTempsPourUneOptimisation;
+ const std::vector& NumeroDeVariableStockFinal;
+ const std::vector>& NumeroDeVariableDeTrancheDeStock;
+ std::vector& NomDesContraintes;
+ const bool& NamedProblems;
+ const std::vector& NomsDesPays;
+ const uint32_t& weekInTheYear;
+ const uint32_t& NombreDePasDeTemps;
+ uint32_t* NbTermesContraintesPourLesCoutsDeDemarrage = nullptr;
+};
/*! \verbatim
this class build up the business object 'Constraint',
@@ -155,12 +183,8 @@ finally the build() method gather all variables and put them into the matrix
class ConstraintBuilder
{
public:
- ConstraintBuilder(
- PROBLEME_HEBDO& problemeHebdo,
- const std::vector& CorrespondanceVarNativesVarOptim) :
- problemeHebdo(problemeHebdo),
- problemeAResoudre(*problemeHebdo.ProblemeAResoudre),
- varNative(CorrespondanceVarNativesVarOptim)
+ ConstraintBuilder() = delete;
+ explicit ConstraintBuilder(ConstraintBuilderData& data) : data(data)
{
}
@@ -183,85 +207,48 @@ class ConstraintBuilder
int offset = 0,
int delta = 0);
- ConstraintBuilder& NumberOfDispatchableUnits(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& NumberOfDispatchableUnits(unsigned int index, double coeff);
- ConstraintBuilder& NumberStoppingDispatchableUnits(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& NumberStoppingDispatchableUnits(unsigned int index, double coeff);
- ConstraintBuilder& NumberStartingDispatchableUnits(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& NumberStartingDispatchableUnits(unsigned int index, double coeff);
- ConstraintBuilder& NumberBreakingDownDispatchableUnits(unsigned int index,
- double coeff,
- int offset = 0,
-
- int delta = 0);
+ ConstraintBuilder& NumberBreakingDownDispatchableUnits(unsigned int index, double coeff);
ConstraintBuilder& NTCDirect(unsigned int index, double coeff, int offset = 0, int delta = 0);
- ConstraintBuilder& IntercoDirectCost(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& IntercoDirectCost(unsigned int index, double coeff);
- ConstraintBuilder& IntercoIndirectCost(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& IntercoIndirectCost(unsigned int index, double coeff);
- ConstraintBuilder& ShortTermStorageInjection(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& ShortTermStorageInjection(unsigned int index, double coeff);
- ConstraintBuilder& ShortTermStorageWithdrawal(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& ShortTermStorageWithdrawal(unsigned int index, double coeff);
ConstraintBuilder& ShortTermStorageLevel(unsigned int index,
double coeff,
int offset = 0,
int delta = 0);
- ConstraintBuilder& HydProd(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& HydProd(unsigned int index, double coeff);
+
+ ConstraintBuilder& HydProdDown(unsigned int index, double coeff);
- ConstraintBuilder& HydProdDown(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& HydProdUp(unsigned int index, double coeff);
- ConstraintBuilder& HydProdUp(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& Pumping(unsigned int index, double coeff);
- ConstraintBuilder& Pumping(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& HydroLevel(unsigned int index, double coeff);
- ConstraintBuilder& HydroLevel(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& Overflow(unsigned int index, double coeff);
- ConstraintBuilder& Overflow(unsigned int index, double coeff, int offset = 0, int delta = 0);
+ ConstraintBuilder& FinalStorage(unsigned int index, double coeff);
- ConstraintBuilder& FinalStorage(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& PositiveUnsuppliedEnergy(unsigned int index, double coeff);
- ConstraintBuilder& PositiveUnsuppliedEnergy(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
- ConstraintBuilder& NegativeUnsuppliedEnergy(unsigned int index,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& NegativeUnsuppliedEnergy(unsigned int index, double coeff);
- ConstraintBuilder& LayerStorage(unsigned area,
- unsigned layer,
- double coeff,
- int offset = 0,
- int delta = 0);
+ ConstraintBuilder& LayerStorage(unsigned area, unsigned layer, double coeff);
//@}
class ConstraintBuilderInvalidOperator : public std::runtime_error
@@ -331,10 +318,12 @@ class ConstraintBuilder
return nombreDeTermes_;
}
+ ConstraintBuilderData& data;
+
private:
- PROBLEME_HEBDO& problemeHebdo;
- PROBLEME_ANTARES_A_RESOUDRE& problemeAResoudre;
- const std::vector& varNative;
+ void OPT_ChargerLaContrainteDansLaMatriceDesContraintes();
+
+ void OPT_AugmenterLaTailleDeLaMatriceDesContraintes();
unsigned int hourInWeek_ = 0;
@@ -350,34 +339,52 @@ class ConstraintBuilder
* @param delta: number of time steps for the variable
* @return VariableManager object
*/
- Variable::VariableManager GetVariableManager(int offset = 0, int delta = 0) const;
+ NewVariable::VariableManager GetVariableManager(int offset = 0, int delta = 0) const;
};
/*! factory class to build a Constraint */
class ConstraintFactory
{
public:
- explicit ConstraintFactory(PROBLEME_HEBDO* problemeHebdo) :
- problemeHebdo(problemeHebdo),
- builder(*problemeHebdo, problemeHebdo->CorrespondanceVarNativesVarOptim)
+ ConstraintFactory() = delete;
+ explicit ConstraintFactory(ConstraintBuilder& builder) : builder(builder)
{
}
-
- PROBLEME_HEBDO* problemeHebdo;
- ConstraintBuilder builder;
+ ConstraintBuilder& builder;
};
// Helper functions
-inline void exportPaliers(const PROBLEME_HEBDO& problemeHebdo,
- ConstraintBuilder& constraintBuilder,
- int pays)
+inline void ExportPaliers(const PALIERS_THERMIQUES& PaliersThermiquesDuPays,
+ ConstraintBuilder& newConstraintBuilder)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays = problemeHebdo.PaliersThermiquesDuPays[pays];
-
for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
{
const int palier
= PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
- constraintBuilder.DispatchableProduction(palier, -1.0);
+ newConstraintBuilder.DispatchableProduction(palier, -1.0);
}
}
+
+class BindingConstraintData
+{
+public:
+ const char& TypeDeContrainteCouplante;
+ const int& NombreDInterconnexionsDansLaContrainteCouplante;
+ const std::vector& NumeroDeLInterconnexion;
+ const std::vector& PoidsDeLInterconnexion;
+ const std::vector& OffsetTemporelSurLInterco;
+ const int& NombreDePaliersDispatchDansLaContrainteCouplante;
+ const std::vector& PaysDuPalierDispatch;
+ const std::vector& NumeroDuPalierDispatch;
+ const std::vector& PoidsDuPalierDispatch;
+ const std::vector& OffsetTemporelSurLePalierDispatch;
+ const char& SensDeLaContrainteCouplante;
+ const char* const& NomDeLaContrainteCouplante;
+ const std::vector& PaliersThermiquesDuPays;
+};
+
+struct StartUpCostsData
+{
+ const std::vector& PaliersThermiquesDuPays;
+ bool Simulation;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ConstraintGroup.h b/src/solver/optimisation/constraints/ConstraintGroup.h
new file mode 100644
index 0000000000..559839b431
--- /dev/null
+++ b/src/solver/optimisation/constraints/ConstraintGroup.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "sim_structure_probleme_economique.h"
+#include "../opt_structure_probleme_a_resoudre.h"
+#include "constraint_builder_utils.h"
+
+class ConstraintGroup
+{
+public:
+ explicit ConstraintGroup(PROBLEME_HEBDO* problemeHebdo, ConstraintBuilder& builder) :
+ problemeHebdo_(problemeHebdo), builder_(builder)
+ {
+ }
+
+ virtual void BuildConstraints() = 0;
+ PROBLEME_HEBDO* problemeHebdo_;
+ ConstraintBuilder& builder_;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ExchangeBalance.cpp b/src/solver/optimisation/constraints/ExchangeBalance.cpp
new file mode 100644
index 0000000000..4a01aa28f2
--- /dev/null
+++ b/src/solver/optimisation/constraints/ExchangeBalance.cpp
@@ -0,0 +1,24 @@
+#include "ExchangeBalance.h"
+
+void ExchangeBalance::add(uint32_t pays)
+{
+ builder.updateHourWithinWeek(0);
+
+ 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];
+ }
+
+ data.NumeroDeContrainteDeSoldeDEchange[pays] = builder.data.nombreDeContraintes;
+ builder.equalTo();
+ builder.build();
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ExchangeBalance.h b/src/solver/optimisation/constraints/ExchangeBalance.h
new file mode 100644
index 0000000000..1115736953
--- /dev/null
+++ b/src/solver/optimisation/constraints/ExchangeBalance.h
@@ -0,0 +1,27 @@
+
+#pragma once
+#include "ConstraintBuilder.h"
+
+struct ExchangeBalanceData
+{
+ const std::vector& IndexDebutIntercoOrigine;
+ const std::vector& IndexSuivantIntercoOrigine;
+ const std::vector& IndexDebutIntercoExtremite;
+ const std::vector& IndexSuivantIntercoExtremite;
+ std::vector& NumeroDeContrainteDeSoldeDEchange;
+};
+
+class ExchangeBalance : private ConstraintFactory
+{
+public:
+ ExchangeBalance(ConstraintBuilder& builder, ExchangeBalanceData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
+
+ // TODO transform data to ref
+ void add(uint32_t pays);
+
+private:
+ ExchangeBalanceData& data;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ExchangeBalanceGroup.cpp b/src/solver/optimisation/constraints/ExchangeBalanceGroup.cpp
new file mode 100644
index 0000000000..e1601ef050
--- /dev/null
+++ b/src/solver/optimisation/constraints/ExchangeBalanceGroup.cpp
@@ -0,0 +1,20 @@
+#include "ExchangeBalanceGroup.h"
+
+ExchangeBalanceData ExchangeBalanceGroup::GetExchangeBalanceDataFromProblemHebdo()
+{
+ return {.IndexDebutIntercoOrigine = problemeHebdo_->IndexDebutIntercoOrigine,
+ .IndexSuivantIntercoOrigine = problemeHebdo_->IndexSuivantIntercoOrigine,
+ .IndexDebutIntercoExtremite = problemeHebdo_->IndexDebutIntercoExtremite,
+ .IndexSuivantIntercoExtremite = problemeHebdo_->IndexSuivantIntercoExtremite,
+ .NumeroDeContrainteDeSoldeDEchange = problemeHebdo_->NumeroDeContrainteDeSoldeDEchange};
+}
+
+void ExchangeBalanceGroup::BuildConstraints()
+{
+ auto data = GetExchangeBalanceDataFromProblemHebdo();
+ ExchangeBalance exchangeBalance(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays - 1; pays++)
+ {
+ exchangeBalance.add(pays);
+ }
+}
diff --git a/src/solver/optimisation/constraints/ExchangeBalanceGroup.h b/src/solver/optimisation/constraints/ExchangeBalanceGroup.h
new file mode 100644
index 0000000000..0e5d55cc00
--- /dev/null
+++ b/src/solver/optimisation/constraints/ExchangeBalanceGroup.h
@@ -0,0 +1,14 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "ExchangeBalance.h"
+
+class ExchangeBalanceGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+ void BuildConstraints() override;
+
+private:
+ ExchangeBalanceData GetExchangeBalanceDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/FictitiousLoad.cpp b/src/solver/optimisation/constraints/FictitiousLoad.cpp
index 2a818dbed9..ab08866d4b 100644
--- a/src/solver/optimisation/constraints/FictitiousLoad.cpp
+++ b/src/solver/optimisation/constraints/FictitiousLoad.cpp
@@ -3,20 +3,18 @@
void FictitiousLoad::add(int pdt, int pays)
{
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContraintePourEviterLesChargesFictives[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContraintePourEviterLesChargesFictives[pays]
+ = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.FictiveLoads(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.FictiveLoads(builder.data.nombreDeContraintes);
builder.updateHourWithinWeek(pdt);
- exportPaliers(*problemeHebdo, builder, pays);
- auto coeff = problemeHebdo->DefaillanceNegativeUtiliserHydro[pays] ? -1 : 0;
+ ExportPaliers(data.PaliersThermiquesDuPays[pays], builder);
+ auto coeff = data.DefaillanceNegativeUtiliserHydro[pays] ? -1 : 0;
builder.HydProd(pays, coeff).NegativeUnsuppliedEnergy(pays, 1.0);
builder.lessThan();
diff --git a/src/solver/optimisation/constraints/FictitiousLoad.h b/src/solver/optimisation/constraints/FictitiousLoad.h
index 077f3cfba5..3d2980aff4 100644
--- a/src/solver/optimisation/constraints/FictitiousLoad.h
+++ b/src/solver/optimisation/constraints/FictitiousLoad.h
@@ -2,13 +2,24 @@
#pragma once
#include "ConstraintBuilder.h"
+struct FictitiousLoadData
+{
+ std::vector& CorrespondanceCntNativesCntOptim;
+ const std::vector& PaliersThermiquesDuPays;
+ const std::vector& DefaillanceNegativeUtiliserHydro;
+};
+
+
/*!
* represent 'Fictitious Load' constraint type
*/
class FictitiousLoad : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ FictitiousLoad(ConstraintBuilder& builder, FictitiousLoadData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -16,4 +27,7 @@ class FictitiousLoad : private ConstraintFactory
* @param pays : area
*/
void add(int pdt, int pays);
+
+private:
+ FictitiousLoadData& data;
};
diff --git a/src/solver/optimisation/constraints/FinalStockEquivalent.cpp b/src/solver/optimisation/constraints/FinalStockEquivalent.cpp
index a00c9bd55a..6a0bf09fca 100644
--- a/src/solver/optimisation/constraints/FinalStockEquivalent.cpp
+++ b/src/solver/optimisation/constraints/FinalStockEquivalent.cpp
@@ -2,22 +2,21 @@
void FinalStockEquivalent::add(int pays)
{
- const auto pdt = problemeHebdo->NombreDePasDeTempsPourUneOptimisation - 1;
- if (problemeHebdo->CaracteristiquesHydrauliques[pays].AccurateWaterValue
- && problemeHebdo->CaracteristiquesHydrauliques[pays].DirectLevelAccess)
+ const auto pdt = builder.data.NombreDePasDeTempsPourUneOptimisation - 1;
+ if (data.CaracteristiquesHydrauliques[pays].AccurateWaterValue
+ && data.CaracteristiquesHydrauliques[pays].DirectLevelAccess)
{ /* equivalence constraint : StockFinal- Niveau[T]= 0*/
- problemeHebdo->NumeroDeContrainteEquivalenceStockFinal[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ data.NumeroDeContrainteEquivalenceStockFinal[pays] = builder.data.nombreDeContraintes;
+ ConstraintNamer namer(builder.data.NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.FinalStockEquivalent(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.FinalStockEquivalent(builder.data.nombreDeContraintes);
builder.updateHourWithinWeek(pdt)
.FinalStorage(pays, 1.0)
- .updateHourWithinWeek(problemeHebdo->NombreDePasDeTempsPourUneOptimisation - 1)
+ .updateHourWithinWeek(builder.data.NombreDePasDeTempsPourUneOptimisation - 1)
.HydroLevel(pays, -1.0)
.equalTo()
.build();
diff --git a/src/solver/optimisation/constraints/FinalStockEquivalent.h b/src/solver/optimisation/constraints/FinalStockEquivalent.h
index 19eb89985f..a7f221748d 100644
--- a/src/solver/optimisation/constraints/FinalStockEquivalent.h
+++ b/src/solver/optimisation/constraints/FinalStockEquivalent.h
@@ -1,17 +1,29 @@
#pragma once
#include "ConstraintBuilder.h"
+struct FinalStockEquivalentData
+{
+ const std::vector CaracteristiquesHydrauliques;
+ std::vector& NumeroDeContrainteEquivalenceStockFinal;
+};
+
/*!
* represent 'Final Stock Equivalent' constraint type
*/
class FinalStockEquivalent : private ConstraintFactory
{
- public:
- using ConstraintFactory::ConstraintFactory;
-
+public:
+ FinalStockEquivalent(ConstraintBuilder& builder,
+ FinalStockEquivalentData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
+
+private:
+ FinalStockEquivalentData& data;
};
diff --git a/src/solver/optimisation/constraints/FinalStockExpression.cpp b/src/solver/optimisation/constraints/FinalStockExpression.cpp
index 083936ae9b..2f82912abe 100644
--- a/src/solver/optimisation/constraints/FinalStockExpression.cpp
+++ b/src/solver/optimisation/constraints/FinalStockExpression.cpp
@@ -2,9 +2,9 @@
void FinalStockExpression::add(int pays)
{
- const auto pdt = problemeHebdo->NombreDePasDeTempsPourUneOptimisation - 1;
+ const auto pdt = builder.data.NombreDePasDeTempsPourUneOptimisation - 1;
- if (problemeHebdo->CaracteristiquesHydrauliques[pays].AccurateWaterValue)
+ if (data.CaracteristiquesHydrauliques[pays].AccurateWaterValue)
/* expression constraint : - StockFinal +sum (stocklayers) = 0*/
{
builder.updateHourWithinWeek(pdt).FinalStorage(pays, -1.0);
@@ -12,14 +12,13 @@ void FinalStockExpression::add(int pays)
{
builder.LayerStorage(pays, layerindex, 1.0);
}
- problemeHebdo->NumeroDeContrainteExpressionStockFinal[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteExpressionStockFinal[pays] = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.FinalStockExpression(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.FinalStockExpression(builder.data.nombreDeContraintes);
builder.equalTo().build();
}
}
diff --git a/src/solver/optimisation/constraints/FinalStockExpression.h b/src/solver/optimisation/constraints/FinalStockExpression.h
index ea96c0319e..acef4edcee 100644
--- a/src/solver/optimisation/constraints/FinalStockExpression.h
+++ b/src/solver/optimisation/constraints/FinalStockExpression.h
@@ -2,16 +2,29 @@
#include "ConstraintBuilder.h"
+struct FinalStockExpressionData
+{
+ const std::vector CaracteristiquesHydrauliques;
+ std::vector& NumeroDeContrainteExpressionStockFinal;
+};
+
/*!
* represent 'Final Stock Expression' constraint type
*/
class FinalStockExpression : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ FinalStockExpression(ConstraintBuilder& builder,
+ FinalStockExpressionData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
+
+private:
+ FinalStockExpressionData& data;
};
diff --git a/src/solver/optimisation/constraints/FinalStockGroup.cpp b/src/solver/optimisation/constraints/FinalStockGroup.cpp
new file mode 100644
index 0000000000..cd1238db93
--- /dev/null
+++ b/src/solver/optimisation/constraints/FinalStockGroup.cpp
@@ -0,0 +1,31 @@
+#include "FinalStockGroup.h"
+
+FinalStockEquivalentData FinalStockGroup::GetFinalStockEquivalentData()
+{
+ return {.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NumeroDeContrainteEquivalenceStockFinal
+ = problemeHebdo_->NumeroDeContrainteEquivalenceStockFinal};
+}
+
+FinalStockExpressionData FinalStockGroup::GetFinalStockExpressionData()
+{
+ return {.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NumeroDeContrainteExpressionStockFinal
+ = problemeHebdo_->NumeroDeContrainteExpressionStockFinal};
+}
+
+void FinalStockGroup::BuildConstraints()
+{
+ auto finalStockEquivalentData = GetFinalStockEquivalentData();
+ FinalStockEquivalent finalStockEquivalent(builder_, finalStockEquivalentData);
+ auto finalStockExpressionData = GetFinalStockExpressionData();
+ FinalStockExpression finalStockExpression(builder_, finalStockExpressionData);
+
+ /* For each area with ad hoc properties, two possible sets of two additional constraints */
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ finalStockEquivalent.add(pays);
+
+ finalStockExpression.add(pays);
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/FinalStockGroup.h b/src/solver/optimisation/constraints/FinalStockGroup.h
new file mode 100644
index 0000000000..3537bdd2ad
--- /dev/null
+++ b/src/solver/optimisation/constraints/FinalStockGroup.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "FinalStockEquivalent.h"
+#include "FinalStockExpression.h"
+
+class FinalStockGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ FinalStockEquivalentData GetFinalStockEquivalentData();
+ FinalStockExpressionData GetFinalStockExpressionData();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/FlowDissociation.cpp b/src/solver/optimisation/constraints/FlowDissociation.cpp
index af172ffd11..f71560601e 100644
--- a/src/solver/optimisation/constraints/FlowDissociation.cpp
+++ b/src/solver/optimisation/constraints/FlowDissociation.cpp
@@ -2,22 +2,17 @@
void FlowDissociation::add(int pdt, int interco)
{
- if (const COUTS_DE_TRANSPORT& CoutDeTransport = problemeHebdo->CoutDeTransport[interco];
+ if (const COUTS_DE_TRANSPORT& CoutDeTransport = data.CoutDeTransport[interco];
CoutDeTransport.IntercoGereeAvecDesCouts)
{
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDeDissociationDeFlux[interco]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
-
- const auto origin
- = problemeHebdo->NomsDesPays[problemeHebdo->PaysOrigineDeLInterconnexion[interco]];
+ data.CorrespondanceCntNativesCntOptim[pdt].NumeroDeContrainteDeDissociationDeFlux[interco]
+ = builder.data.nombreDeContraintes;
+ const auto origin = builder.data.NomsDesPays[data.PaysOrigineDeLInterconnexion[interco]];
const auto destination
- = problemeHebdo->NomsDesPays[problemeHebdo->PaysExtremiteDeLInterconnexion[interco]];
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.FlowDissociation(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes, origin, destination);
+ = builder.data.NomsDesPays[data.PaysExtremiteDeLInterconnexion[interco]];
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.FlowDissociation(builder.data.nombreDeContraintes, origin, destination);
builder.updateHourWithinWeek(pdt);
builder.NTCDirect(interco, 1.0)
diff --git a/src/solver/optimisation/constraints/FlowDissociation.h b/src/solver/optimisation/constraints/FlowDissociation.h
index 27d30af947..60b19e170f 100644
--- a/src/solver/optimisation/constraints/FlowDissociation.h
+++ b/src/solver/optimisation/constraints/FlowDissociation.h
@@ -1,13 +1,26 @@
#pragma once
#include "ConstraintBuilder.h"
+struct FlowDissociationData
+{
+ std::vector& CorrespondanceCntNativesCntOptim;
+ const std::vector& CoutDeTransport;
+ const std::vector& PaysOrigineDeLInterconnexion;
+ const std::vector& PaysExtremiteDeLInterconnexion;
+};
+
+
/*!
* represent 'Flow Dissociation' constraint type
*/
+
class FlowDissociation : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ FlowDissociation(ConstraintBuilder& builder, FlowDissociationData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -15,4 +28,7 @@ class FlowDissociation : private ConstraintFactory
* @param interco : interconnection number
*/
void add(int pdt, int interco);
+
+private:
+ FlowDissociationData& data;
};
diff --git a/src/solver/optimisation/constraints/Group1.cpp b/src/solver/optimisation/constraints/Group1.cpp
new file mode 100644
index 0000000000..101e06b25e
--- /dev/null
+++ b/src/solver/optimisation/constraints/Group1.cpp
@@ -0,0 +1,86 @@
+#include "Group1.h"
+AreaBalanceData Group1::GetAreaBalanceData()
+{
+ return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .IndexDebutIntercoOrigine = problemeHebdo_->IndexDebutIntercoOrigine,
+ .IndexSuivantIntercoOrigine = problemeHebdo_->IndexSuivantIntercoOrigine,
+ .IndexDebutIntercoExtremite = problemeHebdo_->IndexDebutIntercoExtremite,
+ .IndexSuivantIntercoExtremite = problemeHebdo_->IndexSuivantIntercoExtremite,
+ .PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .ShortTermStorage = problemeHebdo_->ShortTermStorage};
+}
+
+FictitiousLoadData Group1::GetFictitiousLoadData()
+{
+ return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .DefaillanceNegativeUtiliserHydro = problemeHebdo_->DefaillanceNegativeUtiliserHydro};
+}
+
+ShortTermStorageLevelData Group1::GetShortTermStorageLevelData()
+{
+ return {
+ .CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .ShortTermStorage = problemeHebdo_->ShortTermStorage,
+ };
+}
+
+FlowDissociationData Group1::GetFlowDissociationData()
+{
+ return {.CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .CoutDeTransport = problemeHebdo_->CoutDeTransport,
+ .PaysOrigineDeLInterconnexion = problemeHebdo_->PaysOrigineDeLInterconnexion,
+ .PaysExtremiteDeLInterconnexion = problemeHebdo_->PaysExtremiteDeLInterconnexion};
+}
+
+BindingConstraintHourData Group1::GetBindingConstraintHourData()
+{
+ return
+
+ {.MatriceDesContraintesCouplantes = problemeHebdo_->MatriceDesContraintesCouplantes,
+ .CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim,
+ .PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays};
+}
+
+void Group1::BuildConstraints()
+{
+ auto areaBalanceData = GetAreaBalanceData();
+ AreaBalance areaBalance(builder_, areaBalanceData);
+
+ auto fictitiousLoadData = GetFictitiousLoadData();
+ FictitiousLoad fictitiousLoad(builder_, fictitiousLoadData);
+
+ auto shortTermStorageLevelData = GetShortTermStorageLevelData();
+ ShortTermStorageLevel shortTermStorageLevel(builder_, shortTermStorageLevelData);
+
+ auto flowDissociationData = GetFlowDissociationData();
+ FlowDissociation flowDissociation(builder_, flowDissociationData);
+
+ auto bindingConstraintHourData = GetBindingConstraintHourData();
+ BindingConstraintHour bindingConstraintHour(builder_, bindingConstraintHourData);
+
+ int nombreDePasDeTempsPourUneOptimisation
+ = problemeHebdo_->NombreDePasDeTempsPourUneOptimisation;
+
+ for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ areaBalance.add(pdt, pays);
+ fictitiousLoad.add(pdt, pays);
+ shortTermStorageLevel.add(pdt, pays);
+ }
+
+ for (uint32_t interco = 0; interco < problemeHebdo_->NombreDInterconnexions; interco++)
+ {
+ flowDissociation.add(pdt, interco);
+ }
+
+ for (uint32_t cntCouplante = 0;
+ cntCouplante < problemeHebdo_->NombreDeContraintesCouplantes;
+ cntCouplante++)
+ {
+ bindingConstraintHour.add(pdt, cntCouplante);
+ }
+ }
+}
diff --git a/src/solver/optimisation/constraints/Group1.h b/src/solver/optimisation/constraints/Group1.h
new file mode 100644
index 0000000000..a7df4606dd
--- /dev/null
+++ b/src/solver/optimisation/constraints/Group1.h
@@ -0,0 +1,22 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "AreaBalance.h"
+#include "FictitiousLoad.h"
+#include "ShortTermStorageLevel.h"
+#include "FlowDissociation.h"
+#include "BindingConstraintHour.h"
+
+class Group1 : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+ void BuildConstraints() override;
+
+private:
+ AreaBalanceData GetAreaBalanceData();
+ FictitiousLoadData GetFictitiousLoadData();
+ ShortTermStorageLevelData GetShortTermStorageLevelData();
+ FlowDissociationData GetFlowDissociationData();
+ BindingConstraintHourData GetBindingConstraintHourData();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/HydraulicSmoothingGroup.cpp b/src/solver/optimisation/constraints/HydraulicSmoothingGroup.cpp
new file mode 100644
index 0000000000..048a9ea161
--- /dev/null
+++ b/src/solver/optimisation/constraints/HydraulicSmoothingGroup.cpp
@@ -0,0 +1,38 @@
+#include "HydraulicSmoothingGroup.h"
+#include "HydroPowerSmoothingUsingVariationSum.h"
+#include "HydroPowerSmoothingUsingVariationMaxDown.h"
+#include "HydroPowerSmoothingUsingVariationMaxUp.h"
+
+void HydraulicSmoothingGroup::BuildConstraints()
+{
+ HydroPowerSmoothingUsingVariationSum hydroPowerSmoothingUsingVariationSum(builder_);
+ HydroPowerSmoothingUsingVariationMaxDown hydroPowerSmoothingUsingVariationMaxDown(builder_);
+ HydroPowerSmoothingUsingVariationMaxUp hydroPowerSmoothingUsingVariationMaxUp(builder_);
+
+ if (problemeHebdo_->TypeDeLissageHydraulique == LISSAGE_HYDRAULIQUE_SUR_SOMME_DES_VARIATIONS)
+ {
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ if (!problemeHebdo_->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
+ continue;
+
+ hydroPowerSmoothingUsingVariationSum.add(
+ pays, problemeHebdo_->NombreDePasDeTempsPourUneOptimisation);
+ }
+ }
+
+ else if (problemeHebdo_->TypeDeLissageHydraulique == LISSAGE_HYDRAULIQUE_SUR_VARIATION_MAX)
+ {
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ if (!problemeHebdo_->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
+ continue;
+
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ hydroPowerSmoothingUsingVariationMaxDown.add(pays, pdt);
+ hydroPowerSmoothingUsingVariationMaxUp.add(pays, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/HydraulicSmoothingGroup.h b/src/solver/optimisation/constraints/HydraulicSmoothingGroup.h
new file mode 100644
index 0000000000..d55d624aa7
--- /dev/null
+++ b/src/solver/optimisation/constraints/HydraulicSmoothingGroup.h
@@ -0,0 +1,13 @@
+#pragma once
+#include "ConstraintGroup.h"
+
+class HydraulicSmoothingGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/HydroPower.cpp b/src/solver/optimisation/constraints/HydroPower.cpp
index abc04f52bc..4936376218 100644
--- a/src/solver/optimisation/constraints/HydroPower.cpp
+++ b/src/solver/optimisation/constraints/HydroPower.cpp
@@ -2,46 +2,38 @@
void HydroPower::add(int pays)
{
- bool presenceHydro
- = problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable;
- bool TurbEntreBornes = problemeHebdo->CaracteristiquesHydrauliques[pays].TurbinageEntreBornes;
-
const int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
- if (presenceHydro && !TurbEntreBornes)
+ = builder.data.NombreDePasDeTempsPourUneOptimisation;
+ auto caracteristiquesHydrauliques = data.CaracteristiquesHydrauliques[pays];
+ if (caracteristiquesHydrauliques.PresenceDHydrauliqueModulable
+ && !caracteristiquesHydrauliques.TurbinageEntreBornes)
{
- if (bool presencePompage
- = problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable)
+ if (caracteristiquesHydrauliques.PresenceDePompageModulable)
{
- problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
- const double pumpingRatio
- = problemeHebdo->CaracteristiquesHydrauliques[pays].PumpingRatio;
+ const double pumpingRatio = caracteristiquesHydrauliques.PumpingRatio;
for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
{
- builder.updateHourWithinWeek(pdt);
- builder.HydProd(pays, 1.0).Pumping(pays, -pumpingRatio);
+ builder.updateHourWithinWeek(pdt).HydProd(pays, 1.0).Pumping(pays, -pumpingRatio);
}
}
else
{
for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
{
- builder.updateHourWithinWeek(pdt);
- builder.HydProd(pays, 1.0);
+ builder.updateHourWithinWeek(pdt).HydProd(pays, 1.0);
}
}
- problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
builder.equalTo();
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear);
- namer.HydroPower(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear);
+ namer.HydroPower(builder.data.nombreDeContraintes);
builder.build();
}
else
- problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays] = -1;
+ data.NumeroDeContrainteEnergieHydraulique[pays] = -1;
}
diff --git a/src/solver/optimisation/constraints/HydroPower.h b/src/solver/optimisation/constraints/HydroPower.h
index 50ecc1de14..8383a38737 100644
--- a/src/solver/optimisation/constraints/HydroPower.h
+++ b/src/solver/optimisation/constraints/HydroPower.h
@@ -1,17 +1,30 @@
#pragma once
#include "ConstraintBuilder.h"
+struct HydroPowerData
+{
+ const std::vector& CaracteristiquesHydrauliques;
+ const int& NombreDePasDeTempsPourUneOptimisation;
+ std::vector& NumeroDeContrainteEnergieHydraulique;
+};
/*!
* represent 'Hydraulic Power' constraint type
*/
+
class HydroPower : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ HydroPower(ConstraintBuilder& builder, HydroPowerData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
+
+public:
+ HydroPowerData& data;
};
diff --git a/src/solver/optimisation/constraints/HydroPowerGroup.cpp b/src/solver/optimisation/constraints/HydroPowerGroup.cpp
new file mode 100644
index 0000000000..07aa88ab24
--- /dev/null
+++ b/src/solver/optimisation/constraints/HydroPowerGroup.cpp
@@ -0,0 +1,21 @@
+#include "HydroPowerGroup.h"
+
+HydroPowerData HydroPowerGroup::GetHydroPowerDataFromProblemHebdo()
+{
+ return {
+ .CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NombreDePasDeTempsPourUneOptimisation
+ = problemeHebdo_->NombreDePasDeTempsPourUneOptimisation,
+ .NumeroDeContrainteEnergieHydraulique = problemeHebdo_->NumeroDeContrainteEnergieHydraulique};
+}
+
+void HydroPowerGroup::BuildConstraints()
+{
+ auto hydroPowerData = GetHydroPowerDataFromProblemHebdo();
+ HydroPower hydroPower(builder_, hydroPowerData);
+
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ hydroPower.add(pays);
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/HydroPowerGroup.h b/src/solver/optimisation/constraints/HydroPowerGroup.h
new file mode 100644
index 0000000000..474454e8ec
--- /dev/null
+++ b/src/solver/optimisation/constraints/HydroPowerGroup.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "HydroPower.h"
+
+class HydroPowerGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ HydroPowerData GetHydroPowerDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.cpp b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.cpp
index dbe0760d92..d9fb872fed 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.cpp
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.cpp
@@ -2,16 +2,10 @@
void HydroPowerSmoothingUsingVariationMaxDown::add(int pays, int pdt)
{
- if (!problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
- {
- return;
- }
-
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.HydroPowerSmoothingUsingVariationMaxDown(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.HydroPowerSmoothingUsingVariationMaxDown(builder.data.nombreDeContraintes);
builder.updateHourWithinWeek(pdt)
.HydProd(pays, 1.0)
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.h b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.h
index a802cf76af..6388b62e55 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.h
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxDown.h
@@ -4,15 +4,15 @@
/*!
* represent 'Hydraulic Power Smoothing Using Variation Max Down' constraint type
*/
+
class HydroPowerSmoothingUsingVariationMaxDown : private ConstraintFactory
{
public:
using ConstraintFactory::ConstraintFactory;
-
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pdt : timestep
* @param pays : area
*/
void add(int pays, int pdt);
-};
\ No newline at end of file
+};
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.cpp b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.cpp
index 5692ba998c..9e40e36cb4 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.cpp
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.cpp
@@ -2,16 +2,10 @@
void HydroPowerSmoothingUsingVariationMaxUp::add(int pays, int pdt)
{
- if (!problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
- {
- return;
- }
-
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.HydroPowerSmoothingUsingVariationMaxUp(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.HydroPowerSmoothingUsingVariationMaxUp(builder.data.nombreDeContraintes);
builder.updateHourWithinWeek(pdt)
.HydProd(pays, 1.0)
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.h b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.h
index d1d6300c81..69687a5d3b 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.h
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationMaxUp.h
@@ -15,4 +15,4 @@ class HydroPowerSmoothingUsingVariationMaxUp : private ConstraintFactory
* @param pays : area
*/
void add(int pays, int pdt);
-};
\ No newline at end of file
+};
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.cpp b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.cpp
index 898f55dfda..638d7416d3 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.cpp
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.cpp
@@ -1,24 +1,17 @@
#include "HydroPowerSmoothingUsingVariationSum.h"
-void HydroPowerSmoothingUsingVariationSum::add(int pays)
+void HydroPowerSmoothingUsingVariationSum::add(int pays,
+ const int nombreDePasDeTempsPourUneOptimisation)
{
- if (!problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
- {
- return;
- }
-
- const int nombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
{
int pdt1 = pdt + 1;
if (pdt1 >= nombreDePasDeTempsPourUneOptimisation)
pdt1 = 0;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.HydroPowerSmoothingUsingVariationSum(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.HydroPowerSmoothingUsingVariationSum(builder.data.nombreDeContraintes);
builder.updateHourWithinWeek(pdt)
.HydProd(pays, 1.0)
diff --git a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.h b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.h
index 1a671b27fd..d2f0c8ccdd 100644
--- a/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.h
+++ b/src/solver/optimisation/constraints/HydroPowerSmoothingUsingVariationSum.h
@@ -1,10 +1,10 @@
#pragma once
#include "ConstraintBuilder.h"
-
/*!
* represent 'Hydraulic Power Smoothing Using Variation Sum' constraint type
*/
+
class HydroPowerSmoothingUsingVariationSum : private ConstraintFactory
{
public:
@@ -13,5 +13,5 @@ class HydroPowerSmoothingUsingVariationSum : private ConstraintFactory
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
- void add(int pays);
-};
\ No newline at end of file
+ void add(int pays, const int nombreDePasDeTempsPourUneOptimisation);
+};
diff --git a/src/solver/optimisation/constraints/MaxHydroPower.cpp b/src/solver/optimisation/constraints/MaxHydroPower.cpp
index 80edf424a6..28a40025bb 100644
--- a/src/solver/optimisation/constraints/MaxHydroPower.cpp
+++ b/src/solver/optimisation/constraints/MaxHydroPower.cpp
@@ -2,34 +2,26 @@
void MaxHydroPower::add(int pays)
{
- bool presenceHydro
- = problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable;
- bool TurbEntreBornes = problemeHebdo->CaracteristiquesHydrauliques[pays].TurbinageEntreBornes;
- if (presenceHydro
- && (TurbEntreBornes
- || problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable))
+ if (data.CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable
+ && (data.CaracteristiquesHydrauliques[pays].TurbinageEntreBornes
+ || data.CaracteristiquesHydrauliques[pays].PresenceDePompageModulable))
{
- problemeHebdo->NumeroDeContrainteMaxEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteMaxEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
- const int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
-
- for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
+ for (int pdt = 0; pdt < builder.data.NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
builder.HydProd(pays, 1.0);
}
- problemeHebdo->NumeroDeContrainteMaxEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteMaxEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear);
- namer.MaxHydroPower(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear);
+ namer.MaxHydroPower(builder.data.nombreDeContraintes);
builder.lessThan().build();
}
else
- problemeHebdo->NumeroDeContrainteMaxEnergieHydraulique[pays] = -1;
+ data.NumeroDeContrainteMaxEnergieHydraulique[pays] = -1;
}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MaxHydroPower.h b/src/solver/optimisation/constraints/MaxHydroPower.h
index f89ae370f4..402450a074 100644
--- a/src/solver/optimisation/constraints/MaxHydroPower.h
+++ b/src/solver/optimisation/constraints/MaxHydroPower.h
@@ -1,17 +1,29 @@
#pragma once
#include "ConstraintBuilder.h"
+struct MaxHydroPowerData
+{
+ const std::vector CaracteristiquesHydrauliques;
+ const int& NombreDePasDeTempsPourUneOptimisation;
+ std::vector& NumeroDeContrainteMaxEnergieHydraulique;
+};
/*!
* represent 'Max Hydraulic Power' constraint type
*/
class MaxHydroPower : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ MaxHydroPower(ConstraintBuilder& builder, MaxHydroPowerData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
-};
\ No newline at end of file
+
+private:
+ MaxHydroPowerData& data;
+};
diff --git a/src/solver/optimisation/constraints/MaxPumping.cpp b/src/solver/optimisation/constraints/MaxPumping.cpp
index 94e68f6ed4..c0faa62b4f 100644
--- a/src/solver/optimisation/constraints/MaxPumping.cpp
+++ b/src/solver/optimisation/constraints/MaxPumping.cpp
@@ -2,27 +2,22 @@
void MaxPumping::add(int pays)
{
- if (problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable)
+ if (data.CaracteristiquesHydrauliques[pays].PresenceDePompageModulable)
{
- problemeHebdo->NumeroDeContrainteMaxPompage[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteMaxPompage[pays] = builder.data.nombreDeContraintes;
- const int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
-
- for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
+ for (int pdt = 0; pdt < builder.data.NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
builder.Pumping(pays, 1.0);
}
- problemeHebdo->NumeroDeContrainteMaxPompage[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear);
- namer.MaxPumping(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
+ data.NumeroDeContrainteMaxPompage[pays] = builder.data.nombreDeContraintes;
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear);
+ namer.MaxPumping(builder.data.nombreDeContraintes);
builder.lessThan().build();
}
else
- problemeHebdo->NumeroDeContrainteMaxPompage[pays] = -1;
+ data.NumeroDeContrainteMaxPompage[pays] = -1;
}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MaxPumping.h b/src/solver/optimisation/constraints/MaxPumping.h
index 6e1a9f4809..467e838ae0 100644
--- a/src/solver/optimisation/constraints/MaxPumping.h
+++ b/src/solver/optimisation/constraints/MaxPumping.h
@@ -1,17 +1,28 @@
#pragma once
#include "ConstraintBuilder.h"
-
+struct MaxPumpingData
+{
+ const std::vector CaracteristiquesHydrauliques;
+ std::vector& NumeroDeContrainteMaxPompage;
+};
/*!
* represent 'Max Pumping' constraint type
*/
+
class MaxPumping : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ MaxPumping(ConstraintBuilder& builder, MaxPumpingData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
-};
\ No newline at end of file
+
+private:
+ MaxPumpingData& data;
+};
diff --git a/src/solver/optimisation/constraints/MaxPumpingGroup.cpp b/src/solver/optimisation/constraints/MaxPumpingGroup.cpp
new file mode 100644
index 0000000000..455b5a72d2
--- /dev/null
+++ b/src/solver/optimisation/constraints/MaxPumpingGroup.cpp
@@ -0,0 +1,18 @@
+#include "MaxPumpingGroup.h"
+
+MaxPumpingData MaxPumpingGroup::GetMaxPumpingData()
+{
+ return {.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NumeroDeContrainteMaxPompage = problemeHebdo_->NumeroDeContrainteMaxPompage};
+}
+
+void MaxPumpingGroup::BuildConstraints()
+{
+ auto maxPumpingData = GetMaxPumpingData();
+ MaxPumping maxPumping(builder_, maxPumpingData);
+
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ maxPumping.add(pays);
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MaxPumpingGroup.h b/src/solver/optimisation/constraints/MaxPumpingGroup.h
new file mode 100644
index 0000000000..58494d921f
--- /dev/null
+++ b/src/solver/optimisation/constraints/MaxPumpingGroup.h
@@ -0,0 +1,15 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "MaxPumping.h"
+
+class MaxPumpingGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+
+ void BuildConstraints() override;
+
+private:
+ MaxPumpingData GetMaxPumpingData();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MinDownTime.cpp b/src/solver/optimisation/constraints/MinDownTime.cpp
index ca4805d007..4f9b2832e4 100644
--- a/src/solver/optimisation/constraints/MinDownTime.cpp
+++ b/src/solver/optimisation/constraints/MinDownTime.cpp
@@ -1,19 +1,19 @@
#include "MinDownTime.h"
-void MinDownTime::add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation)
+void MinDownTime::add(int pays, int index, int pdt)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
const int DureeMinimaleDArretDUnGroupeDuPalierThermique
- = PaliersThermiquesDuPays.DureeMinimaleDArretDUnGroupeDuPalierThermique[clusterIndex];
+ = data.PaliersThermiquesDuPays[pays].DureeMinimaleDArretDUnGroupeDuPalierThermique[index];
+ auto cluster
+ = data.PaliersThermiquesDuPays[pays].NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesContraintesDeDureeMinDArret[cluster] = -1;
- if (!Simulation)
+ data.CorrespondanceCntNativesCntOptim[pdt]
+ .NumeroDeContrainteDesContraintesDeDureeMinDArret[cluster]
+ = -1;
+ if (!data.Simulation)
{
int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
+ = builder.data.NombreDePasDeTempsPourUneOptimisation;
builder.updateHourWithinWeek(pdt).NumberOfDispatchableUnits(cluster, 1.0);
@@ -28,23 +28,23 @@ void MinDownTime::add(int pays, int cluster, int clusterIndex, int pdt, bool Sim
builder.lessThan();
if (builder.NumberOfVariables() > 1)
{
- CorrespondanceCntNativesCntOptim
+ data.CorrespondanceCntNativesCntOptim[pdt]
.NumeroDeContrainteDesContraintesDeDureeMinDArret[cluster]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ = builder.data.nombreDeContraintes;
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.MinDownTime(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.MinDownTime(builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
builder.build();
}
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage
+= 1 + DureeMinimaleDArretDUnGroupeDuPalierThermique;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/MinDownTime.h b/src/solver/optimisation/constraints/MinDownTime.h
index 567a766b6d..b7c29f3dd3 100644
--- a/src/solver/optimisation/constraints/MinDownTime.h
+++ b/src/solver/optimisation/constraints/MinDownTime.h
@@ -1,13 +1,23 @@
#pragma once
#include "ConstraintBuilder.h"
+struct MinDownTimeData
+{
+ const std::vector& PaliersThermiquesDuPays;
+ bool Simulation;
+ std::vector& CorrespondanceCntNativesCntOptim;
+};
+
/*!
* represent 'MinDownTime' Constraint type
*/
class MinDownTime : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ MinDownTime(ConstraintBuilder& builder, MinDownTimeData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
@@ -15,5 +25,8 @@ class MinDownTime : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ MinDownTimeData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MinDownTimeGroup.cpp b/src/solver/optimisation/constraints/MinDownTimeGroup.cpp
new file mode 100644
index 0000000000..33ebf48c8e
--- /dev/null
+++ b/src/solver/optimisation/constraints/MinDownTimeGroup.cpp
@@ -0,0 +1,30 @@
+#include "MinDownTimeGroup.h"
+
+MinDownTimeData MinDownTimeGroup::GetMinDownTimeDataFromProblemHebdo()
+{
+ return {.PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .Simulation = simulation_,
+ .CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim};
+}
+
+/**
+ * @brief build MinDownTime constraints with
+ * respect to default order
+ */
+void MinDownTimeGroup::BuildConstraints()
+{
+ auto data = GetMinDownTimeDataFromProblemHebdo();
+ MinDownTime minDownTime(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays
+ = problemeHebdo_->PaliersThermiquesDuPays[pays];
+ for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
+ {
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ minDownTime.add(pays, index, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MinDownTimeGroup.h b/src/solver/optimisation/constraints/MinDownTimeGroup.h
new file mode 100644
index 0000000000..b51f7424a7
--- /dev/null
+++ b/src/solver/optimisation/constraints/MinDownTimeGroup.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "AbstractStartUpCostsGroup.h"
+#include "ConstraintGroup.h"
+#include "MinDownTime.h"
+
+/**
+ * @brief Group of MinDownTime constraints
+ *
+ */
+
+class MinDownTimeGroup : public AbstractStartUpCostsGroup
+{
+public:
+ using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;
+
+ void BuildConstraints() override;
+
+private:
+ MinDownTimeData GetMinDownTimeDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MinHydroPower.cpp b/src/solver/optimisation/constraints/MinHydroPower.cpp
index 025542f9ba..64a4e1f9fe 100644
--- a/src/solver/optimisation/constraints/MinHydroPower.cpp
+++ b/src/solver/optimisation/constraints/MinHydroPower.cpp
@@ -2,33 +2,26 @@
void MinHydroPower::add(int pays)
{
- bool presenceHydro
- = problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable;
- bool TurbEntreBornes = problemeHebdo->CaracteristiquesHydrauliques[pays].TurbinageEntreBornes;
- if (presenceHydro
- && (TurbEntreBornes
- || problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable))
+ if (data.CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable
+ && (data.CaracteristiquesHydrauliques[pays].TurbinageEntreBornes
+ || data.CaracteristiquesHydrauliques[pays].PresenceDePompageModulable))
{
- problemeHebdo->NumeroDeContrainteMinEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteMinEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
- const int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear);
+ namer.MinHydroPower(builder.data.nombreDeContraintes);
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear);
- namer.MinHydroPower(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
- for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
+ for (int pdt = 0; pdt < data.NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
builder.HydProd(pays, 1.0);
}
- problemeHebdo->NumeroDeContrainteMinEnergieHydraulique[pays]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.NumeroDeContrainteMinEnergieHydraulique[pays] = builder.data.nombreDeContraintes;
builder.greaterThan().build();
}
else
- problemeHebdo->NumeroDeContrainteMinEnergieHydraulique[pays] = -1;
+ data.NumeroDeContrainteMinEnergieHydraulique[pays] = -1;
}
diff --git a/src/solver/optimisation/constraints/MinHydroPower.h b/src/solver/optimisation/constraints/MinHydroPower.h
index 8b7dfb1892..59359d37e3 100644
--- a/src/solver/optimisation/constraints/MinHydroPower.h
+++ b/src/solver/optimisation/constraints/MinHydroPower.h
@@ -1,18 +1,30 @@
#pragma once
#include "ConstraintBuilder.h"
+struct MinHydroPowerData
+{
+ const std::vector CaracteristiquesHydrauliques;
+ const int& NombreDePasDeTempsPourUneOptimisation;
+ std::vector& NumeroDeContrainteMinEnergieHydraulique;
+};
/*!
* represent 'Min Hydraulic Power' constraint type
*/
+
class MinHydroPower : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ MinHydroPower(ConstraintBuilder& builder, MinHydroPowerData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
*/
void add(int pays);
-};
+private:
+ MinHydroPowerData& data;
+};
diff --git a/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.cpp b/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.cpp
new file mode 100644
index 0000000000..e52cd0f6c8
--- /dev/null
+++ b/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.cpp
@@ -0,0 +1,32 @@
+#include "MinMaxHydroPowerGroup.h"
+MinHydroPowerData MinMaxHydroPowerGroup::GetMinHydroPowerData()
+{
+ return {.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NombreDePasDeTempsPourUneOptimisation
+ = problemeHebdo_->NombreDePasDeTempsPourUneOptimisation,
+ .NumeroDeContrainteMinEnergieHydraulique
+ = problemeHebdo_->NumeroDeContrainteMinEnergieHydraulique};
+}
+
+MaxHydroPowerData MinMaxHydroPowerGroup::GetMaxHydroPowerData()
+{
+ return {.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques,
+ .NombreDePasDeTempsPourUneOptimisation
+ = problemeHebdo_->NombreDePasDeTempsPourUneOptimisation,
+ .NumeroDeContrainteMaxEnergieHydraulique
+ = problemeHebdo_->NumeroDeContrainteMaxEnergieHydraulique};
+}
+
+void MinMaxHydroPowerGroup::BuildConstraints()
+{
+ auto minHydroPowerData = GetMinHydroPowerData();
+ MinHydroPower minHydroPower(builder_, minHydroPowerData);
+ auto maxHydroPowerData = GetMaxHydroPowerData();
+ MaxHydroPower maxHydroPower(builder_, maxHydroPowerData);
+
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ minHydroPower.add(pays);
+ maxHydroPower.add(pays);
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.h b/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.h
new file mode 100644
index 0000000000..516202c10f
--- /dev/null
+++ b/src/solver/optimisation/constraints/MinMaxHydroPowerGroup.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "ConstraintGroup.h"
+#include "MinHydroPower.h"
+#include "MaxHydroPower.h"
+
+class MinMaxHydroPowerGroup : public ConstraintGroup
+{
+public:
+ using ConstraintGroup::ConstraintGroup;
+
+ void BuildConstraints() override;
+
+private:
+ MinHydroPowerData GetMinHydroPowerData();
+ MaxHydroPowerData GetMaxHydroPowerData();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp
index 06a341f14d..294a274fec 100644
--- a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp
+++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.cpp
@@ -1,24 +1,19 @@
#include "NbDispUnitsMinBoundSinceMinUpTime.h"
-void NbDispUnitsMinBoundSinceMinUpTime::add(int pays,
- int cluster,
- int clusterIndex,
- int pdt,
- bool Simulation)
+void NbDispUnitsMinBoundSinceMinUpTime::add(int pays, int index, int pdt)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
+ auto cluster
+ = data.PaliersThermiquesDuPays[pays].NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
const int DureeMinimaleDeMarcheDUnGroupeDuPalierThermique
- = PaliersThermiquesDuPays.DureeMinimaleDeMarcheDUnGroupeDuPalierThermique[clusterIndex];
+ = data.PaliersThermiquesDuPays[pays].DureeMinimaleDeMarcheDUnGroupeDuPalierThermique[index];
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesContraintesDeDureeMinDeMarche[cluster]
+ data.CorrespondanceCntNativesCntOptim[pdt]
+ .NumeroDeContrainteDesContraintesDeDureeMinDeMarche[cluster]
= -1;
- if (!Simulation)
+ if (!data.Simulation)
{
int NombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
+ = builder.data.NombreDePasDeTempsPourUneOptimisation;
builder.updateHourWithinWeek(pdt).NumberOfDispatchableUnits(cluster, 1.0);
@@ -36,24 +31,24 @@ void NbDispUnitsMinBoundSinceMinUpTime::add(int pays,
builder.greaterThan();
if (builder.NumberOfVariables() > 1)
{
- CorrespondanceCntNativesCntOptim
+ data.CorrespondanceCntNativesCntOptim[pays]
.NumeroDeContrainteDesContraintesDeDureeMinDeMarche[cluster]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ = builder.data.nombreDeContraintes;
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.NbDispUnitsMinBoundSinceMinUpTime(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
builder.build();
}
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage
+= 1 + 2 * DureeMinimaleDeMarcheDUnGroupeDuPalierThermique;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.h b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.h
index ab86556a21..31441c7764 100644
--- a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.h
+++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTime.h
@@ -1,13 +1,22 @@
#pragma once
#include "ConstraintBuilder.h"
-
+struct NbDispUnitsMinBoundSinceMinUpTimeData
+{
+ const std::vector& PaliersThermiquesDuPays;
+ bool Simulation;
+ std::vector& CorrespondanceCntNativesCntOptim;
+};
/*!
* represent 'Number of Dispatchable Units Min Bound Since Min Up Time' type
*/
class NbDispUnitsMinBoundSinceMinUpTime : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ NbDispUnitsMinBoundSinceMinUpTime(ConstraintBuilder& builder,
+ NbDispUnitsMinBoundSinceMinUpTimeData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -16,5 +25,8 @@ class NbDispUnitsMinBoundSinceMinUpTime : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ NbDispUnitsMinBoundSinceMinUpTimeData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.cpp b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.cpp
new file mode 100644
index 0000000000..ef47e277ee
--- /dev/null
+++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.cpp
@@ -0,0 +1,34 @@
+#include "NbDispUnitsMinBoundSinceMinUpTimeGroup.h"
+
+NbDispUnitsMinBoundSinceMinUpTimeData
+ NbDispUnitsMinBoundSinceMinUpTimeGroup::GetNbDispUnitsMinBoundSinceMinUpTimeDataFromProblemHebdo()
+{
+ return {.PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .Simulation = simulation_,
+ .CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim};
+}
+
+/**
+ * @brief build NbUnitsOutageLessThanNbUnitsStopGroup constraints with
+ * respect to default order
+ */
+void NbDispUnitsMinBoundSinceMinUpTimeGroup::BuildConstraints()
+{
+ auto data = GetNbDispUnitsMinBoundSinceMinUpTimeDataFromProblemHebdo();
+ NbDispUnitsMinBoundSinceMinUpTime nbDispUnitsMinBoundSinceMinUpTime(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays
+ = problemeHebdo_->PaliersThermiquesDuPays[pays];
+ for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
+ {
+ if (PaliersThermiquesDuPays.DureeMinimaleDeMarcheDUnGroupeDuPalierThermique[index] <= 0)
+ continue;
+
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ nbDispUnitsMinBoundSinceMinUpTime.add(pays, index, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h
new file mode 100644
index 0000000000..547b003e2f
--- /dev/null
+++ b/src/solver/optimisation/constraints/NbDispUnitsMinBoundSinceMinUpTimeGroup.h
@@ -0,0 +1,21 @@
+#pragma once
+#include "AbstractStartUpCostsGroup.h"
+#include "ConstraintGroup.h"
+#include "NbDispUnitsMinBoundSinceMinUpTime.h"
+
+/**
+ * @brief Group of NbDispUnitsMinBoundSinceMinUpTime constraints
+ *
+ */
+
+class NbDispUnitsMinBoundSinceMinUpTimeGroup : public AbstractStartUpCostsGroup
+{
+public:
+ using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;
+
+ void BuildConstraints() override;
+
+private:
+ NbDispUnitsMinBoundSinceMinUpTimeData
+ GetNbDispUnitsMinBoundSinceMinUpTimeDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp
index 472aedc323..6062938a3a 100644
--- a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp
+++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.cpp
@@ -1,19 +1,13 @@
#include "NbUnitsOutageLessThanNbUnitsStop.h"
-void NbUnitsOutageLessThanNbUnitsStop::add(int pays,
- int cluster,
- int clusterIndex,
- int pdt,
- bool Simulation)
+void NbUnitsOutageLessThanNbUnitsStop::add(int pays, int index, int pdt)
{
- if (!Simulation)
+ if (!data.Simulation)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
-
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
- CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesContraintesDeDureeMinDeMarche[cluster]
+ auto cluster = data.PaliersThermiquesDuPays[pays]
+ .NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
+ data.CorrespondanceCntNativesCntOptim[pdt]
+ .NumeroDeContrainteDesContraintesDeDureeMinDeMarche[cluster]
= -1;
builder.updateHourWithinWeek(pdt)
@@ -23,19 +17,19 @@ void NbUnitsOutageLessThanNbUnitsStop::add(int pays,
if (builder.NumberOfVariables() > 0)
{
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.NbUnitsOutageLessThanNbUnitsStop(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
builder.build();
}
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage += 2;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.h b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.h
index 79c9f714fb..6a872e4911 100644
--- a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.h
+++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStop.h
@@ -1,13 +1,22 @@
#pragma once
#include "ConstraintBuilder.h"
-
+struct NbUnitsOutageLessThanNbUnitsStopData
+{
+ const std::vector& PaliersThermiquesDuPays;
+ bool Simulation;
+ std::vector& CorrespondanceCntNativesCntOptim;
+};
/*!
* represent 'NbUnitsOutageLessThanNbUnitsStop' type
*/
class NbUnitsOutageLessThanNbUnitsStop : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ NbUnitsOutageLessThanNbUnitsStop(ConstraintBuilder& builder,
+ NbUnitsOutageLessThanNbUnitsStopData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -16,5 +25,8 @@ class NbUnitsOutageLessThanNbUnitsStop : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ NbUnitsOutageLessThanNbUnitsStopData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.cpp b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.cpp
new file mode 100644
index 0000000000..1300f8d343
--- /dev/null
+++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.cpp
@@ -0,0 +1,32 @@
+#include "NbUnitsOutageLessThanNbUnitsStopGroup.h"
+
+NbUnitsOutageLessThanNbUnitsStopData
+ NbUnitsOutageLessThanNbUnitsStopGroup::GetNbUnitsOutageLessThanNbUnitsStopDataFromProblemHebdo()
+{
+ return {.PaliersThermiquesDuPays = problemeHebdo_->PaliersThermiquesDuPays,
+ .Simulation = simulation_,
+ .CorrespondanceCntNativesCntOptim = problemeHebdo_->CorrespondanceCntNativesCntOptim};
+}
+
+/**
+ * @brief build NbUnitsOutageLessThanNbUnitsStopGroup constraints with
+ * respect to default order
+ */
+void NbUnitsOutageLessThanNbUnitsStopGroup::BuildConstraints()
+{
+ auto data = GetNbUnitsOutageLessThanNbUnitsStopDataFromProblemHebdo();
+ NbUnitsOutageLessThanNbUnitsStop nbUnitsOutageLessThanNbUnitsStop(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays
+ = problemeHebdo_->PaliersThermiquesDuPays[pays];
+
+ for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
+ {
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ nbUnitsOutageLessThanNbUnitsStop.add(pays, index, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h
new file mode 100644
index 0000000000..21854003df
--- /dev/null
+++ b/src/solver/optimisation/constraints/NbUnitsOutageLessThanNbUnitsStopGroup.h
@@ -0,0 +1,20 @@
+#pragma once
+#include "AbstractStartUpCostsGroup.h"
+#include "ConstraintGroup.h"
+#include "NbUnitsOutageLessThanNbUnitsStop.h"
+
+/**
+ * @brief Group of NbUnitsOutageLessThanNbUnitsStop constraints
+ *
+ */
+
+class NbUnitsOutageLessThanNbUnitsStopGroup : public AbstractStartUpCostsGroup
+{
+public:
+ using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;
+
+ void BuildConstraints() override;
+
+private:
+ NbUnitsOutageLessThanNbUnitsStopData GetNbUnitsOutageLessThanNbUnitsStopDataFromProblemHebdo();
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp
index 92f4d06eed..de3a4a79c0 100644
--- a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp
+++ b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.cpp
@@ -1,17 +1,13 @@
#include "PMaxDispatchableGeneration.h"
-void PMaxDispatchableGeneration::add(int pays,
- int cluster,
- int clusterIndex,
- int pdt,
- bool Simulation)
+void PMaxDispatchableGeneration::add(int pays, int index, int pdt)
{
- if (!Simulation)
+ if (!data.Simulation)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
+ auto cluster = data.PaliersThermiquesDuPays[pays]
+ .NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
double pmaxDUnGroupeDuPalierThermique
- = PaliersThermiquesDuPays.PmaxDUnGroupeDuPalierThermique[clusterIndex];
+ = data.PaliersThermiquesDuPays[pays].PmaxDUnGroupeDuPalierThermique[cluster];
builder.updateHourWithinWeek(pdt)
.DispatchableProduction(cluster, 1.0)
@@ -19,20 +15,20 @@ void PMaxDispatchableGeneration::add(int pays,
.lessThan();
if (builder.NumberOfVariables() > 0)
{
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
namer.PMaxDispatchableGeneration(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
}
builder.build();
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage += 2;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.h b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.h
index b82c5dd196..1127ab7d6c 100644
--- a/src/solver/optimisation/constraints/PMaxDispatchableGeneration.h
+++ b/src/solver/optimisation/constraints/PMaxDispatchableGeneration.h
@@ -7,8 +7,10 @@
class PMaxDispatchableGeneration : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
-
+ PMaxDispatchableGeneration(ConstraintBuilder& builder, StartUpCostsData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
* @param pays : area
@@ -16,5 +18,8 @@ class PMaxDispatchableGeneration : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ StartUpCostsData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp b/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp
index c2fe75b9ea..5c74603c11 100644
--- a/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp
+++ b/src/solver/optimisation/constraints/PMinDispatchableGeneration.cpp
@@ -1,18 +1,14 @@
#include "PMinDispatchableGeneration.h"
-void PMinDispatchableGeneration::add(int pays,
- int cluster,
- int clusterIndex,
- int pdt,
- bool Simulation)
+void PMinDispatchableGeneration::add(int pays, int index, int pdt)
{
- if (!Simulation)
+ if (!data.Simulation)
{
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
double pminDUnGroupeDuPalierThermique
- = PaliersThermiquesDuPays.pminDUnGroupeDuPalierThermique[clusterIndex];
+ = data.PaliersThermiquesDuPays[pays].pminDUnGroupeDuPalierThermique[index];
+ auto cluster = data.PaliersThermiquesDuPays[pays]
+ .NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
builder.updateHourWithinWeek(pdt)
.DispatchableProduction(cluster, 1.0)
.NumberOfDispatchableUnits(cluster, -pminDUnGroupeDuPalierThermique)
@@ -20,19 +16,19 @@ void PMinDispatchableGeneration::add(int pays,
/*consider Adding naming constraint inside the builder*/
if (builder.NumberOfVariables() > 0)
{
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
- namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
+ namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.PMinDispatchableGeneration(
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- PaliersThermiquesDuPays.NomsDesPaliersThermiques[clusterIndex]);
+ builder.data.nombreDeContraintes,
+ data.PaliersThermiquesDuPays[pays].NomsDesPaliersThermiques[index]);
}
- builder.build();
+ builder.build();
}
else
{
- problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage += 2;
- problemeHebdo->ProblemeAResoudre->NombreDeContraintes++;
+ *builder.data.NbTermesContraintesPourLesCoutsDeDemarrage += 2;
+ builder.data.nombreDeContraintes++;
}
}
diff --git a/src/solver/optimisation/constraints/PMinDispatchableGeneration.h b/src/solver/optimisation/constraints/PMinDispatchableGeneration.h
index 58b1f36438..1064a2462c 100644
--- a/src/solver/optimisation/constraints/PMinDispatchableGeneration.h
+++ b/src/solver/optimisation/constraints/PMinDispatchableGeneration.h
@@ -7,7 +7,10 @@
class PMinDispatchableGeneration : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ PMinDispatchableGeneration(ConstraintBuilder& builder, StartUpCostsData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
/*!
* @brief Add variables to the constraint and update constraints Matrix
@@ -16,5 +19,8 @@ class PMinDispatchableGeneration : private ConstraintFactory
* @param pdt : timestep
* @param Simulation : ---
*/
- void add(int pays, int cluster, int clusterIndex, int pdt, bool Simulation);
+ void add(int pays, int index, int pdt);
+
+private:
+ StartUpCostsData& data;
};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.cpp b/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.cpp
new file mode 100644
index 0000000000..fd2b2e98ee
--- /dev/null
+++ b/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.cpp
@@ -0,0 +1,25 @@
+#include "PMinMaxDispatchableGenerationGroup.h"
+
+/**
+ * @brief build P{min,max}DispatchableGeneration constraints with
+ * respect to default order
+ */
+void PMinMaxDispatchableGenerationGroup::BuildConstraints()
+{
+ auto data = GetStartUpCostsDataFromProblemHebdo();
+ PMaxDispatchableGeneration pMaxDispatchableGeneration(builder_, data);
+ PMinDispatchableGeneration pMinDispatchableGeneration(builder_, data);
+ for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
+ {
+ const PALIERS_THERMIQUES& PaliersThermiquesDuPays
+ = problemeHebdo_->PaliersThermiquesDuPays[pays];
+ for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
+ {
+ for (int pdt = 0; pdt < problemeHebdo_->NombreDePasDeTempsPourUneOptimisation; pdt++)
+ {
+ pMaxDispatchableGeneration.add(pays, index, pdt);
+ pMinDispatchableGeneration.add(pays, index, pdt);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.h b/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.h
new file mode 100644
index 0000000000..af7405a1a6
--- /dev/null
+++ b/src/solver/optimisation/constraints/PMinMaxDispatchableGenerationGroup.h
@@ -0,0 +1,17 @@
+#pragma once
+#include "AbstractStartUpCostsGroup.h"
+#include "ConstraintGroup.h"
+#include "PMinDispatchableGeneration.h"
+#include "PMaxDispatchableGeneration.h"
+
+/**
+ * @brief Group of Pmin/PmaxDispatchableGenerationGroup constraints
+ *
+ */
+class PMinMaxDispatchableGenerationGroup : public AbstractStartUpCostsGroup
+{
+public:
+ using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;
+
+ void BuildConstraints() override;
+};
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/ShortTermStorageLevel.cpp b/src/solver/optimisation/constraints/ShortTermStorageLevel.cpp
index 46165a9f79..c02ed25edc 100644
--- a/src/solver/optimisation/constraints/ShortTermStorageLevel.cpp
+++ b/src/solver/optimisation/constraints/ShortTermStorageLevel.cpp
@@ -2,27 +2,23 @@
void ShortTermStorageLevel::add(int pdt, int pays)
{
- ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes);
- CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
- = problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
-
- const int hourInTheYear = problemeHebdo->weekInTheYear * 168 + pdt;
+ ConstraintNamer namer(builder.data.NomDesContraintes);
+ const int hourInTheYear = builder.data.weekInTheYear * 168 + pdt;
namer.UpdateTimeStep(hourInTheYear);
- namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
+ namer.UpdateArea(builder.data.NomsDesPays[pays]);
builder.updateHourWithinWeek(pdt);
- for (const auto& storage : problemeHebdo->ShortTermStorage[pays])
+ for (const auto& storage : data.ShortTermStorage[pays])
{
// L[h] - L[h-1] - efficiency * injection[h] + withdrawal[h] = inflows[h]
- namer.ShortTermStorageLevel(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
- storage.name);
+ namer.ShortTermStorageLevel(builder.data.nombreDeContraintes, storage.name);
const auto index = storage.clusterGlobalIndex;
- CorrespondanceCntNativesCntOptim.ShortTermStorageLevelConstraint[index]
- = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
+ data.CorrespondanceCntNativesCntOptim[pdt].ShortTermStorageLevelConstraint[index]
+ = builder.data.nombreDeContraintes;
builder.ShortTermStorageLevel(index, 1.0)
.ShortTermStorageLevel(
- index, -1.0, -1, problemeHebdo->NombreDePasDeTempsPourUneOptimisation)
+ index, -1.0, -1, builder.data.NombreDePasDeTempsPourUneOptimisation)
.ShortTermStorageInjection(index, -1.0 * storage.efficiency)
.ShortTermStorageWithdrawal(index, 1.0)
.equalTo()
diff --git a/src/solver/optimisation/constraints/ShortTermStorageLevel.h b/src/solver/optimisation/constraints/ShortTermStorageLevel.h
index c5377a97ce..8a01077b12 100644
--- a/src/solver/optimisation/constraints/ShortTermStorageLevel.h
+++ b/src/solver/optimisation/constraints/ShortTermStorageLevel.h
@@ -1,9 +1,23 @@
#pragma once
#include "ConstraintBuilder.h"
+struct ShortTermStorageLevelData
+{
+ std::vector& CorrespondanceCntNativesCntOptim;
+
+ const std::vector<::ShortTermStorage::AREA_INPUT>& ShortTermStorage;
+};
+
class ShortTermStorageLevel : private ConstraintFactory
{
public:
- using ConstraintFactory::ConstraintFactory;
+ ShortTermStorageLevel(ConstraintBuilder& builder,
+ ShortTermStorageLevelData& data) :
+ ConstraintFactory(builder), data(data)
+ {
+ }
void add(int pdt, int pays);
+
+private:
+ ShortTermStorageLevelData& data;
};
diff --git a/src/solver/optimisation/constraints/constraint_builder_utils.cpp b/src/solver/optimisation/constraints/constraint_builder_utils.cpp
new file mode 100644
index 0000000000..1c10a2deb8
--- /dev/null
+++ b/src/solver/optimisation/constraints/constraint_builder_utils.cpp
@@ -0,0 +1,28 @@
+#include "constraint_builder_utils.h"
+
+ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(
+ const PROBLEME_HEBDO* problemeHebdo,
+ PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre)
+{
+ return {ProblemeAResoudre.Pi,
+ ProblemeAResoudre.Colonne,
+ ProblemeAResoudre.NombreDeContraintes,
+ ProblemeAResoudre.NombreDeTermesDansLaMatriceDesContraintes,
+ ProblemeAResoudre.IndicesDebutDeLigne,
+ ProblemeAResoudre.CoefficientsDeLaMatriceDesContraintes,
+ ProblemeAResoudre.IndicesColonnes,
+ ProblemeAResoudre.NombreDeTermesAllouesDansLaMatriceDesContraintes,
+ ProblemeAResoudre.NombreDeTermesDesLignes,
+ ProblemeAResoudre.Sens,
+ ProblemeAResoudre.IncrementDAllocationMatriceDesContraintes,
+ problemeHebdo->CorrespondanceVarNativesVarOptim,
+ problemeHebdo->NombreDePasDeTempsPourUneOptimisation,
+ problemeHebdo->NumeroDeVariableStockFinal,
+ problemeHebdo->NumeroDeVariableDeTrancheDeStock,
+ ProblemeAResoudre.NomDesContraintes,
+ problemeHebdo->NamedProblems,
+ problemeHebdo->NomsDesPays,
+ problemeHebdo->weekInTheYear,
+ problemeHebdo->NombreDePasDeTemps,
+ nullptr};
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/constraints/constraint_builder_utils.h b/src/solver/optimisation/constraints/constraint_builder_utils.h
new file mode 100644
index 0000000000..0d1cd87d28
--- /dev/null
+++ b/src/solver/optimisation/constraints/constraint_builder_utils.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "ConstraintBuilder.h"
+#include
+
+ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(
+ const PROBLEME_HEBDO* problemeHebdo,
+ PROBLEME_ANTARES_A_RESOUDRE& ProblemeAResoudre);
+
+inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(
+ const PROBLEME_HEBDO* problemeHebdo,
+ std::unique_ptr& ProblemeAResoudre)
+{
+ /* not good!!!!!!!!!!*/
+ auto& problemAResoudreRef = *ProblemeAResoudre.get();
+ return NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(problemeHebdo,
+ problemAResoudreRef);
+}
+
+inline ConstraintBuilderData NewGetConstraintBuilderFromProblemHebdo(PROBLEME_HEBDO* problemeHebdo)
+{
+ auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
+ auto data = NewGetConstraintBuilderFromProblemHebdoAndProblemAResoudre(problemeHebdo,
+ ProblemeAResoudre);
+ data.NbTermesContraintesPourLesCoutsDeDemarrage
+ = &problemeHebdo->NbTermesContraintesPourLesCoutsDeDemarrage;
+ return data;
+}
diff --git a/src/solver/optimisation/opt_construction_contraintes_couts_demarrage.cpp b/src/solver/optimisation/opt_construction_contraintes_couts_demarrage.cpp
deleted file mode 100644
index 2c0c6f66b6..0000000000
--- a/src/solver/optimisation/opt_construction_contraintes_couts_demarrage.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
-** Copyright 2007-2023 RTE
-** Authors: Antares_Simulator Team
-**
-** This file is part of Antares_Simulator.
-**
-** Antares_Simulator is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** There are special exceptions to the terms and conditions of the
-** license as they are applied to this software. View the full text of
-** the exceptions in file COPYING.txt in the directory of this software
-** distribution
-**
-** 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
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with Antares_Simulator. If not, see .
-**
-** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
-*/
-
-#include "opt_structure_probleme_a_resoudre.h"
-
-#include "../simulation/sim_structure_donnees.h"
-#include "../simulation/sim_structure_probleme_economique.h"
-
-#include "opt_fonctions.h"
-#include "opt_rename_problem.h"
-#include "constraints/PMaxDispatchableGeneration.h"
-#include "constraints/PMinDispatchableGeneration.h"
-#include "constraints/ConsistenceNumberOfDispatchableUnits.h"
-#include "constraints/NbUnitsOutageLessThanNbUnitsStop.h"
-#include "constraints/NbDispUnitsMinBoundSinceMinUpTime.h"
-#include "constraints/MinDownTime.h"
-
-using namespace Antares::Data;
-
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaireCoutsDeDemarrage(
- PROBLEME_HEBDO* problemeHebdo,
- bool Simulation)
-{
- const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
-
- int nombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
-
- ConstraintNamer constraintNamer(ProblemeAResoudre->NomDesContraintes);
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- constraintNamer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
- {
- PMaxDispatchableGeneration pMaxDispatchableGeneration(problemeHebdo);
- PMinDispatchableGeneration pMinDispatchableGeneration(problemeHebdo);
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- pMaxDispatchableGeneration.add(pays, palier, index, pdt, Simulation);
- pMinDispatchableGeneration.add(pays, palier, index, pdt, Simulation);
- }
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- constraintNamer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
- {
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- ConsistenceNumberOfDispatchableUnits consistenceNumberOfDispatchableUnits(
- problemeHebdo);
- consistenceNumberOfDispatchableUnits.add(pays, palier, index, pdt, Simulation);
- }
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- NbUnitsOutageLessThanNbUnitsStop nbUnitsOutageLessThanNbUnitsStop(problemeHebdo);
-
- constraintNamer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
- {
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- nbUnitsOutageLessThanNbUnitsStop.add(pays, palier, index, pdt, Simulation);
- }
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- NbDispUnitsMinBoundSinceMinUpTime nbDispUnitsMinBoundSinceMinUpTime(problemeHebdo);
- constraintNamer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
- {
- if (PaliersThermiquesDuPays.DureeMinimaleDeMarcheDUnGroupeDuPalierThermique[index] <= 0)
- continue;
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- nbDispUnitsMinBoundSinceMinUpTime.add(pays, palier, index, pdt, Simulation);
- }
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- const PALIERS_THERMIQUES& PaliersThermiquesDuPays
- = problemeHebdo->PaliersThermiquesDuPays[pays];
- MinDownTime minDownTime(problemeHebdo);
- for (int index = 0; index < PaliersThermiquesDuPays.NombreDePaliersThermiques; index++)
- {
- const int palier
- = PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques[index];
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- minDownTime.add(pays, palier, index, pdt, Simulation);
- }
- }
- }
-
- return;
-}
diff --git a/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_lineaire.cpp b/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_lineaire.cpp
deleted file mode 100644
index fa7692a600..0000000000
--- a/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_lineaire.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
-** Copyright 2007-2023 RTE
-** Authors: Antares_Simulator Team
-**
-** This file is part of Antares_Simulator.
-**
-** Antares_Simulator is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** There are special exceptions to the terms and conditions of the
-** license as they are applied to this software. View the full text of
-** the exceptions in file COPYING.txt in the directory of this software
-** distribution
-**
-** 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
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with Antares_Simulator. If not, see .
-**
-** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
-*/
-#include "opt_structure_probleme_a_resoudre.h"
-#include "opt_export_structure.h"
-#include "antares/solver/utils/filename.h"
-#include "opt_fonctions.h"
-#include "opt_rename_problem.h"
-#include "sim_structure_probleme_economique.h"
-#include "constraints/AreaBalance.h"
-#include "constraints/FictitiousLoad.h"
-#include "constraints/ShortTermStorageLevel.h"
-#include "constraints/FlowDissociation.h"
-#include "constraints/BindingConstraintHour.h"
-#include "constraints/BindingConstraintDay.h"
-#include "constraints/BindingConstraintWeek.h"
-#include "constraints/HydroPower.h"
-#include "constraints/HydroPowerSmoothingUsingVariationSum.h"
-#include "constraints/HydroPowerSmoothingUsingVariationMaxDown.h"
-#include "constraints/HydroPowerSmoothingUsingVariationMaxUp.h"
-#include "constraints/MinHydroPower.h"
-#include "constraints/MaxHydroPower.h"
-#include "constraints/MaxPumping.h"
-#include "constraints/AreaHydroLevel.h"
-#include "constraints/FinalStockEquivalent.h"
-#include "constraints/FinalStockExpression.h"
-
-#include
-
-using namespace Antares::Data;
-
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaire(PROBLEME_HEBDO* problemeHebdo, Solver::IResultWriter& writer)
-{
- const auto& ProblemeAResoudre = problemeHebdo->ProblemeAResoudre;
-
- int nombreDePasDeTempsDUneJournee = problemeHebdo->NombreDePasDeTempsDUneJournee;
- int nombreDePasDeTempsPourUneOptimisation
- = problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
-
- ProblemeAResoudre->NombreDeContraintes = 0;
- ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = 0;
- ConstraintNamer constraintNamer(ProblemeAResoudre->NomDesContraintes);
-
- AreaBalance areaBalance(problemeHebdo);
- FictitiousLoad fictitiousLoad(problemeHebdo);
- ShortTermStorageLevel shortTermStorageLevel(problemeHebdo);
- FlowDissociation flowDissociation(problemeHebdo);
- BindingConstraintHour bindingConstraintHour(problemeHebdo);
- BindingConstraintDay bindingConstraintDay(problemeHebdo);
- BindingConstraintWeek bindingConstraintWeek(problemeHebdo);
- HydroPower hydroPower(problemeHebdo);
- HydroPowerSmoothingUsingVariationSum hydroPowerSmoothingUsingVariationSum(problemeHebdo);
- HydroPowerSmoothingUsingVariationMaxDown hydroPowerSmoothingUsingVariationMaxDown(
- problemeHebdo);
- HydroPowerSmoothingUsingVariationMaxUp hydroPowerSmoothingUsingVariationMaxUp(problemeHebdo);
-
- MinHydroPower minHydroPower(problemeHebdo);
- MaxHydroPower maxHydroPower(problemeHebdo);
-
- MaxPumping maxPumping(problemeHebdo);
-
- AreaHydroLevel areaHydroLevel(problemeHebdo);
-
- FinalStockEquivalent finalStockEquivalent(problemeHebdo);
- FinalStockExpression finalStockExpression(problemeHebdo);
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- int timeStepInYear = problemeHebdo->weekInTheYear * 168 + pdt;
- constraintNamer.UpdateTimeStep(timeStepInYear);
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- areaBalance.add(pdt, pays);
-
- fictitiousLoad.add(pdt, pays);
-
- shortTermStorageLevel.add(pdt, pays);
- }
-
- for (uint32_t interco = 0; interco < problemeHebdo->NombreDInterconnexions; interco++)
- {
- flowDissociation.add(pdt, interco);
- }
- for (uint32_t cntCouplante = 0; cntCouplante < problemeHebdo->NombreDeContraintesCouplantes;
- cntCouplante++)
- {
- bindingConstraintHour.add(pdt, cntCouplante);
- }
- }
-
- for (uint32_t cntCouplante = 0; cntCouplante < problemeHebdo->NombreDeContraintesCouplantes;
- cntCouplante++)
- {
- bindingConstraintDay.add(cntCouplante);
- }
-
- if (nombreDePasDeTempsPourUneOptimisation > nombreDePasDeTempsDUneJournee)
- {
- for (uint32_t cntCouplante = 0; cntCouplante < problemeHebdo->NombreDeContraintesCouplantes;
- cntCouplante++)
- {
- bindingConstraintWeek.add(cntCouplante);
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- hydroPower.add(pays);
- }
-
- if (problemeHebdo->TypeDeLissageHydraulique == LISSAGE_HYDRAULIQUE_SUR_SOMME_DES_VARIATIONS)
- {
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- if (!problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
- continue;
-
- hydroPowerSmoothingUsingVariationSum.add(pays);
- }
- }
- else if (problemeHebdo->TypeDeLissageHydraulique == LISSAGE_HYDRAULIQUE_SUR_VARIATION_MAX)
- {
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- if (!problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
- continue;
-
- constraintNamer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- hydroPowerSmoothingUsingVariationMaxDown.add(pays, pdt);
- hydroPowerSmoothingUsingVariationMaxUp.add(pays, pdt);
- }
- }
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- minHydroPower.add(pays);
-
- maxHydroPower.add(pays);
- }
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- maxPumping.add(pays);
- }
-
- for (int pdt = 0; pdt < nombreDePasDeTempsPourUneOptimisation; pdt++)
- {
- int timeStepInYear = problemeHebdo->weekInTheYear * 168 + pdt;
- constraintNamer.UpdateTimeStep(timeStepInYear);
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- areaHydroLevel.add(pays, pdt);
- }
- }
-
- /* For each area with ad hoc properties, two possible sets of two additional constraints */
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays; pays++)
- {
- finalStockEquivalent.add(pays);
-
- finalStockExpression.add(pays);
- }
-
- if (problemeHebdo->OptimisationAvecCoutsDeDemarrage)
- {
- OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaireCoutsDeDemarrage(problemeHebdo,
- false);
- }
-
- // Export structure
- if (problemeHebdo->ExportStructure && problemeHebdo->firstWeekOfSimulation)
- {
- OPT_ExportInterco(writer, problemeHebdo);
- OPT_ExportAreaName(writer, problemeHebdo->NomsDesPays);
- }
-
- return;
-}
diff --git a/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_quadratique.cpp b/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_quadratique.cpp
deleted file mode 100644
index b3d7399045..0000000000
--- a/src/solver/optimisation/opt_construction_matrice_des_contraintes_cas_quadratique.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-** Copyright 2007-2023 RTE
-** Authors: Antares_Simulator Team
-**
-** This file is part of Antares_Simulator.
-**
-** Antares_Simulator is free software: you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation, either version 3 of the License, or
-** (at your option) any later version.
-**
-** There are special exceptions to the terms and conditions of the
-** license as they are applied to this software. View the full text of
-** the exceptions in file COPYING.txt in the directory of this software
-** distribution
-**
-** 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
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with Antares_Simulator. If not, see .
-**
-** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
-*/
-
-#include "opt_structure_probleme_a_resoudre.h"
-
-#include "../simulation/simulation.h"
-#include "../simulation/sim_structure_donnees.h"
-#include "../simulation/sim_extern_variables_globales.h"
-#include "opt_fonctions.h"
-
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeQuadratique(PROBLEME_HEBDO* problemeHebdo)
-{
- PROBLEME_ANTARES_A_RESOUDRE* ProblemeAResoudre = problemeHebdo->ProblemeAResoudre.get();
-
- std::vector Pi(ProblemeAResoudre->NombreDeVariables, 0.);
- std::vector Colonne(ProblemeAResoudre->NombreDeVariables, 0);
-
- ProblemeAResoudre->NombreDeContraintes = 0;
- ProblemeAResoudre->NombreDeTermesDansLaMatriceDesContraintes = 0;
- const CORRESPONDANCES_DES_VARIABLES& correspondanceVarNativesVarOptim
- = problemeHebdo->CorrespondanceVarNativesVarOptim[0];
-
- for (uint32_t pays = 0; pays < problemeHebdo->NombreDePays - 1; pays++)
- {
- int nombreDeTermes = 0;
-
- int interco = problemeHebdo->IndexDebutIntercoOrigine[pays];
- while (interco >= 0)
- {
- if (int var
- = correspondanceVarNativesVarOptim.NumeroDeVariableDeLInterconnexion[interco];
- var >= 0)
- {
- Pi[nombreDeTermes] = 1.0;
- Colonne[nombreDeTermes] = var;
- nombreDeTermes++;
- }
- interco = problemeHebdo->IndexSuivantIntercoOrigine[interco];
- }
- interco = problemeHebdo->IndexDebutIntercoExtremite[pays];
- while (interco >= 0)
- {
- if (int var
- = correspondanceVarNativesVarOptim.NumeroDeVariableDeLInterconnexion[interco];
- var >= 0)
- {
- Pi[nombreDeTermes] = -1.0;
- Colonne[nombreDeTermes] = var;
- nombreDeTermes++;
- }
- interco = problemeHebdo->IndexSuivantIntercoExtremite[interco];
- }
-
- problemeHebdo->NumeroDeContrainteDeSoldeDEchange[pays]
- = ProblemeAResoudre->NombreDeContraintes;
-
- OPT_ChargerLaContrainteDansLaMatriceDesContraintes(
- ProblemeAResoudre, Pi, Colonne, nombreDeTermes, '=');
- }
-}
diff --git a/src/solver/optimisation/opt_decompte_variables_et_contraintes_couts_demarrage.cpp b/src/solver/optimisation/opt_decompte_variables_et_contraintes_couts_demarrage.cpp
index d7cae91d60..37342a4b52 100644
--- a/src/solver/optimisation/opt_decompte_variables_et_contraintes_couts_demarrage.cpp
+++ b/src/solver/optimisation/opt_decompte_variables_et_contraintes_couts_demarrage.cpp
@@ -27,6 +27,8 @@
#include "../simulation/simulation.h"
#include "../simulation/sim_extern_variables_globales.h"
+#include "LinearProblemMatrixStartUpCosts.h"
+#include "constraints/constraint_builder_utils.h"
#include "opt_fonctions.h"
@@ -35,7 +37,9 @@ void OPT_DecompteDesVariablesEtDesContraintesCoutsDeDemarrage(PROBLEME_HEBDO* pr
if (!problemeHebdo->OptimisationAvecCoutsDeDemarrage)
return;
- OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaireCoutsDeDemarrage(problemeHebdo, true);
+ auto builder_data = NewGetConstraintBuilderFromProblemHebdo(problemeHebdo);
+ ConstraintBuilder builder(builder_data);
+ LinearProblemMatrixStartUpCosts(problemeHebdo, true, builder).Run();
OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireCoutsDeDemarrage(problemeHebdo,
true);
diff --git a/src/solver/optimisation/opt_export_structure.cpp b/src/solver/optimisation/opt_export_structure.cpp
index 807ce209f6..2f292ed5b6 100644
--- a/src/solver/optimisation/opt_export_structure.cpp
+++ b/src/solver/optimisation/opt_export_structure.cpp
@@ -62,3 +62,9 @@ void OPT_ExportAreaName(Antares::Solver::IResultWriter& writer,
}
writer.addEntryFromBuffer(filename, Flot);
}
+
+void OPT_ExportStructures(PROBLEME_HEBDO* problemeHebdo, Antares::Solver::IResultWriter& writer)
+{
+ OPT_ExportInterco(writer, problemeHebdo);
+ OPT_ExportAreaName(writer, problemeHebdo->NomsDesPays);
+}
\ No newline at end of file
diff --git a/src/solver/optimisation/opt_export_structure.h b/src/solver/optimisation/opt_export_structure.h
index ef5fbca36b..e4af035092 100644
--- a/src/solver/optimisation/opt_export_structure.h
+++ b/src/solver/optimisation/opt_export_structure.h
@@ -52,5 +52,6 @@ void OPT_ExportInterco(Antares::Solver::IResultWriter& writer,
PROBLEME_HEBDO* problemeHebdo);
void OPT_ExportAreaName(Antares::Solver::IResultWriter& writer,
const std::vector& areaNames);
+void OPT_ExportStructures(PROBLEME_HEBDO* problemeHebdo, Antares::Solver::IResultWriter& writer);
#endif
diff --git a/src/solver/optimisation/opt_fonctions.h b/src/solver/optimisation/opt_fonctions.h
index e2807f0c8d..ef2439ca63 100644
--- a/src/solver/optimisation/opt_fonctions.h
+++ b/src/solver/optimisation/opt_fonctions.h
@@ -46,9 +46,6 @@ void OPT_NumeroDeJourDuPasDeTemps(PROBLEME_HEBDO*);
void OPT_NumeroDIntervalleOptimiseDuPasDeTemps(PROBLEME_HEBDO*);
void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(PROBLEME_HEBDO*);
void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeQuadratique(PROBLEME_HEBDO*);
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaire(PROBLEME_HEBDO*,
- Antares::Solver::IResultWriter& writer);
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeQuadratique(PROBLEME_HEBDO*);
void OPT_InitialiserLesPminHebdo(PROBLEME_HEBDO*);
void OPT_InitialiserLesContrainteDEnergieHydrauliqueParIntervalleOptimise(PROBLEME_HEBDO*);
void OPT_MaxDesPmaxHydrauliques(PROBLEME_HEBDO*);
@@ -118,7 +115,6 @@ void OPT_AugmenterLaTailleDeLaMatriceDesContraintes(PROBLEME_ANTARES_A_RESOUDRE*
/*------------------------------*/
-void OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaireCoutsDeDemarrage(PROBLEME_HEBDO*, bool);
void OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaireCoutsDeDemarrage(PROBLEME_HEBDO*,
bool);
void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaireCoutsDeDemarrage(PROBLEME_HEBDO*,
diff --git a/src/solver/optimisation/opt_optimisation_lineaire.cpp b/src/solver/optimisation/opt_optimisation_lineaire.cpp
index 9f6ecd77d6..0a80822a17 100644
--- a/src/solver/optimisation/opt_optimisation_lineaire.cpp
+++ b/src/solver/optimisation/opt_optimisation_lineaire.cpp
@@ -27,10 +27,12 @@
#include "sim_structure_probleme_economique.h"
#include "opt_fonctions.h"
+#include "opt_export_structure.h"
#include
#include "antares/solver/utils/filename.h"
-
+#include "LinearProblemMatrix.h"
+#include "constraints/constraint_builder_utils.h"
using namespace Antares;
using namespace Yuni;
using Antares::Solver::Optimization::OptimizationOptions;
@@ -134,7 +136,6 @@ void runThermalHeuristic(PROBLEME_HEBDO* problemeHebdo)
}
} // namespace
-
bool OPT_OptimisationLineaire(const OptimizationOptions& options,
PROBLEME_HEBDO* problemeHebdo,
const AdqPatchParams& adqPatchParams,
@@ -158,7 +159,11 @@ bool OPT_OptimisationLineaire(const OptimizationOptions& options,
OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeLineaire(problemeHebdo);
- OPT_ConstruireLaMatriceDesContraintesDuProblemeLineaire(problemeHebdo, writer);
+ auto builder_data = NewGetConstraintBuilderFromProblemHebdo(problemeHebdo);
+ ConstraintBuilder builder(builder_data);
+ LinearProblemMatrix linearProblemMatrix(problemeHebdo, builder);
+ linearProblemMatrix.Run();
+ OPT_ExportStructures(problemeHebdo, writer);
bool ret = runWeeklyOptimization(
options, problemeHebdo, adqPatchParams, writer, PREMIERE_OPTIMISATION);
diff --git a/src/solver/optimisation/opt_pilotage_optimisation_quadratique.cpp b/src/solver/optimisation/opt_pilotage_optimisation_quadratique.cpp
index b9b25318c8..3865f420d8 100644
--- a/src/solver/optimisation/opt_pilotage_optimisation_quadratique.cpp
+++ b/src/solver/optimisation/opt_pilotage_optimisation_quadratique.cpp
@@ -29,9 +29,10 @@
#include "../simulation/simulation.h"
#include "../simulation/sim_extern_variables_globales.h"
+#include "constraints/constraint_builder_utils.h"
#include "opt_fonctions.h"
-
+#include "QuadraticProblemMatrix.h"
extern "C"
{
#include "spx_fonctions.h"
@@ -42,8 +43,9 @@ bool OPT_PilotageOptimisationQuadratique(PROBLEME_HEBDO* problemeHebdo)
if (!problemeHebdo->LeProblemeADejaEteInstancie)
{
OPT_ConstruireLaListeDesVariablesOptimiseesDuProblemeQuadratique(problemeHebdo);
-
- OPT_ConstruireLaMatriceDesContraintesDuProblemeQuadratique(problemeHebdo);
+ auto builder_data = NewGetConstraintBuilderFromProblemHebdo(problemeHebdo);
+ ConstraintBuilder builder(builder_data);
+ QuadraticProblemMatrix(problemeHebdo, builder).Run();
problemeHebdo->LeProblemeADejaEteInstancie = true;
}
diff --git a/src/solver/optimisation/opt_rename_problem.cpp b/src/solver/optimisation/opt_rename_problem.cpp
index 0d90030460..44ab4cd940 100644
--- a/src/solver/optimisation/opt_rename_problem.cpp
+++ b/src/solver/optimisation/opt_rename_problem.cpp
@@ -215,6 +215,20 @@ void ConstraintNamer::FlowDissociation(unsigned int constraint,
SetLinkElementName(constraint, "FlowDissociation");
}
+void ConstraintNamer::CsrFlowDissociation(unsigned int constraint,
+ const std::string& origin,
+ const std::string& destination)
+{
+ origin_ = origin;
+ destination_ = destination;
+ SetLinkElementName(constraint, "CsrFlowDissociation");
+}
+
+void ConstraintNamer::CsrAreaBalance(unsigned int constraint)
+{
+ SetAreaElementNameHour(constraint, "CsrAreaBalance");
+}
+
void ConstraintNamer::AreaBalance(unsigned int constraint)
{
SetAreaElementNameHour(constraint, "AreaBalance");
@@ -332,6 +346,11 @@ void ConstraintNamer::BindingConstraintHour(unsigned int constraint, const std::
nameWithTimeGranularity(constraint, name, HOUR);
}
+void ConstraintNamer::CsrBindingConstraintHour(unsigned int constraint, const std::string& name)
+{
+ nameWithTimeGranularity(constraint, name, HOUR);
+}
+
void ConstraintNamer::BindingConstraintDay(unsigned int constraint, const std::string& name)
{
nameWithTimeGranularity(constraint, name, DAY);
diff --git a/src/solver/optimisation/opt_rename_problem.h b/src/solver/optimisation/opt_rename_problem.h
index 50c0ac8778..95fd7121de 100644
--- a/src/solver/optimisation/opt_rename_problem.h
+++ b/src/solver/optimisation/opt_rename_problem.h
@@ -104,6 +104,7 @@ class ConstraintNamer : public Namer
void FlowDissociation(unsigned int constraint,
const std::string& origin,
const std::string& destination);
+
void AreaBalance(unsigned int constraint);
void FictiveLoads(unsigned int constraint);
void HydroPower(unsigned int constraint);
@@ -126,6 +127,12 @@ class ConstraintNamer : public Namer
void BindingConstraintHour(unsigned int constraint, const std::string& name);
void BindingConstraintDay(unsigned int constraint, const std::string& name);
void BindingConstraintWeek(unsigned int constraint, const std::string& name);
+ void CsrFlowDissociation(unsigned int constraint,
+ const std::string& origin,
+ const std::string& destination);
+
+ void CsrAreaBalance(unsigned int constraint);
+ void CsrBindingConstraintHour(unsigned int constraint, const std::string& name);
private:
void nameWithTimeGranularity(unsigned int constraint,
diff --git a/src/solver/simulation/adequacy_patch_runtime_data.h b/src/solver/simulation/adequacy_patch_runtime_data.h
index 62971f28a3..21d379cb2f 100644
--- a/src/solver/simulation/adequacy_patch_runtime_data.h
+++ b/src/solver/simulation/adequacy_patch_runtime_data.h
@@ -31,10 +31,10 @@
#include
#include
+using adqPatchParamsMode = Antares::Data::AdequacyPatch::AdequacyPatchMode;
class AdequacyPatchRuntimeData
{
private:
- using adqPatchParamsMode = Antares::Data::AdequacyPatch::AdequacyPatchMode;
std::vector> csrTriggeredHoursPerArea_;
public: