From c1497ed629d3c5c0ff4643fa5a22c78598ced4a0 Mon Sep 17 00:00:00 2001 From: Abdoulbari ZAKIR Date: Mon, 18 Sep 2023 15:47:11 +0200 Subject: [PATCH] Psitive/Negative UnsuppliedEnergy --- src/solver/optimisation/AreaBalance.cpp | 4 +- src/solver/optimisation/FictitiousLoad.cpp | 3 +- .../optimisation/constraint_builder.cpp | 20 ++++++++ src/solver/optimisation/constraint_builder.h | 48 +++++++++---------- 4 files changed, 45 insertions(+), 30 deletions(-) diff --git a/src/solver/optimisation/AreaBalance.cpp b/src/solver/optimisation/AreaBalance.cpp index a18d56073f..368431ac9b 100644 --- a/src/solver/optimisation/AreaBalance.cpp +++ b/src/solver/optimisation/AreaBalance.cpp @@ -63,8 +63,8 @@ void AreaBalance::add(int pdt, int pays) exportPaliers(*problemeHebdo, builder, pays); builder.HydProd(pays, -1.0) .Pumping(pays, 1.0) - .include(Variable::PositiveUnsuppliedEnergy(pays), -1.0) - .include(Variable::NegativeUnsuppliedEnergy(pays), 1.0); + .PositiveUnsuppliedEnergy(pays, -1.0) + .NegativeUnsuppliedEnergy(pays, 1.0); shortTermStorageBalance( problemeHebdo->ShortTermStorage[pays], builder, CorrespondanceVarNativesVarOptim); diff --git a/src/solver/optimisation/FictitiousLoad.cpp b/src/solver/optimisation/FictitiousLoad.cpp index 7913299243..63dea251d3 100644 --- a/src/solver/optimisation/FictitiousLoad.cpp +++ b/src/solver/optimisation/FictitiousLoad.cpp @@ -26,8 +26,7 @@ void FictitiousLoad::add(int pdt, int pays) builder.updateHourWithinWeek(pdt); exportPaliers(*problemeHebdo, builder, pays); auto coeff = problemeHebdo->DefaillanceNegativeUtiliserHydro[pays] ? -1 : 0; - builder.HydProd(pays, coeff) - .include(Variable::NegativeUnsuppliedEnergy(pays), 1.0); + builder.HydProd(pays, coeff).NegativeUnsuppliedEnergy(pays, 1.0); builder.lessThan(); builder.build(); diff --git a/src/solver/optimisation/constraint_builder.cpp b/src/solver/optimisation/constraint_builder.cpp index 77fbbe460a..4f55dbf73a 100644 --- a/src/solver/optimisation/constraint_builder.cpp +++ b/src/solver/optimisation/constraint_builder.cpp @@ -234,6 +234,26 @@ ConstraintBuilder& ConstraintBuilder::FinalStorage(unsigned int index, return *this; } +ConstraintBuilder& ConstraintBuilder::PositiveUnsuppliedEnergy(unsigned int index, + double coeff, + int shift, + bool wrap, + int delta) +{ + AddVariable(GetVariableManager(shift, wrap, delta).PositiveUnsuppliedEnergy(index), coeff); + return *this; +} + +ConstraintBuilder& ConstraintBuilder::NegativeUnsuppliedEnergy(unsigned int index, + double coeff, + int shift, + bool wrap, + int delta) +{ + AddVariable(GetVariableManager(shift, wrap, delta).NegativeUnsuppliedEnergy(index), coeff); + return *this; +} + ConstraintBuilder& ConstraintBuilder::LayerStorage(unsigned area, unsigned layer, double coeff, diff --git a/src/solver/optimisation/constraint_builder.h b/src/solver/optimisation/constraint_builder.h index a52d9f0e73..b15c0379de 100644 --- a/src/solver/optimisation/constraint_builder.h +++ b/src/solver/optimisation/constraint_builder.h @@ -13,22 +13,6 @@ namespace Variable { -struct SingleIndex -{ - explicit SingleIndex(unsigned index) : index(index) - { - } - unsigned index; -}; - -struct PositiveUnsuppliedEnergy : public SingleIndex -{ - using SingleIndex::SingleIndex; -}; -struct NegativeUnsuppliedEnergy : public SingleIndex -{ - using SingleIndex::SingleIndex; -}; class VariableManager { @@ -138,13 +122,22 @@ class VariableManager return NumeroDeVariableDeTrancheDeStock[area][layer]; } + int PositiveUnsuppliedEnergy(unsigned int index) const + { + return nativeOptimVar.NumeroDeVariableDefaillancePositive[index]; + } + + int NegativeUnsuppliedEnergy(unsigned int index) const + { + return nativeOptimVar.NumeroDeVariableDefaillanceNegative[index]; + } + private: const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar; const std::vector& NumeroDeVariableStockFinal; const std::vector>& NumeroDeVariableDeTrancheDeStock; }; -using Variables = std::variant; class ConstraintVisitor { public: @@ -157,15 +150,6 @@ class ConstraintVisitor { } - int operator()(const PositiveUnsuppliedEnergy& v) const - { - return nativeOptimVar.NumeroDeVariableDefaillancePositive[v.index]; - } - int operator()(const NegativeUnsuppliedEnergy& v) const - { - return nativeOptimVar.NumeroDeVariableDefaillanceNegative[v.index]; - } - private: const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar; const std::vector& NumeroDeVariableStockFinal; @@ -312,6 +296,18 @@ class ConstraintBuilder int shift = 0, bool wrap = false, int delta = 0); + + ConstraintBuilder& PositiveUnsuppliedEnergy(unsigned int index, + double coeff, + int shift = 0, + bool wrap = false, + int delta = 0); + + ConstraintBuilder& NegativeUnsuppliedEnergy(unsigned int index, + double coeff, + int shift = 0, + bool wrap = false, + int delta = 0); ConstraintBuilder& LayerStorage(unsigned area, unsigned layer, double coeff,