Skip to content

Commit

Permalink
Psitive/Negative UnsuppliedEnergy
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Sep 18, 2023
1 parent f02c5af commit c1497ed
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/solver/optimisation/AreaBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/solver/optimisation/FictitiousLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions src/solver/optimisation/constraint_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
48 changes: 22 additions & 26 deletions src/solver/optimisation/constraint_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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<int>& NumeroDeVariableStockFinal;
const std::vector<std::vector<int>>& NumeroDeVariableDeTrancheDeStock;
};

using Variables = std::variant<PositiveUnsuppliedEnergy, NegativeUnsuppliedEnergy>;
class ConstraintVisitor
{
public:
Expand All @@ -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<int>& NumeroDeVariableStockFinal;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c1497ed

Please sign in to comment.