Skip to content

Commit

Permalink
HydroLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Sep 18, 2023
1 parent c5097de commit ed6ecbc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/solver/optimisation/AreaHydroLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ void AreaHydroLevel::add(int pays, int pdt)
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
if (problemeHebdo->CaracteristiquesHydrauliques[pays].SuiviNiveauHoraire)
{
builder.updateHourWithinWeek(pdt).include(Variable::HydroLevel(pays), 1.0);
builder.updateHourWithinWeek(pdt).HydroLevel(pays, 1.0);
if (pdt > 0)
{
builder.updateHourWithinWeek(pdt - 1).include(Variable::HydroLevel(pays), -1.0);
builder.updateHourWithinWeek(pdt - 1).HydroLevel(pays, -1.0);
}
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
Expand Down
12 changes: 6 additions & 6 deletions src/solver/optimisation/FinalStockEquivalent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ void FinalStockEquivalent::add(int pays)
namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
namer.FinalStockEquivalent(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);

builder.updateHourWithinWeek(pdt)
.include(Variable::FinalStorage(pays), 1.0)
.updateHourWithinWeek(problemeHebdo->NombreDePasDeTempsPourUneOptimisation - 1)
.include(Variable::HydroLevel(pays), -1.0)
.equalTo()
.build();
builder.updateHourWithinWeek(pdt)
.include(Variable::FinalStorage(pays), 1.0)
.updateHourWithinWeek(problemeHebdo->NombreDePasDeTempsPourUneOptimisation - 1)
.HydroLevel(pays, -1.0)
.equalTo()
.build();
}
}
10 changes: 10 additions & 0 deletions src/solver/optimisation/constraint_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ ConstraintBuilder& ConstraintBuilder::Pumping(unsigned int index,
return *this;
}

ConstraintBuilder& ConstraintBuilder::HydroLevel(unsigned int index,
double coeff,
int shift,
bool wrap,
int delta)
{
AddVariable(GetVariableManager(shift, wrap, delta).HydroLevel(index), coeff);
return *this;
}

int ConstraintBuilder::getVariableIndex(const Variable::Variables& variable,
int shift,
bool wrap,
Expand Down
27 changes: 13 additions & 14 deletions src/solver/optimisation/constraint_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ struct SingleIndex
unsigned index;
};

struct HydroLevel : public SingleIndex
{
using SingleIndex::SingleIndex;
};
struct Overflow : public SingleIndex
{
using SingleIndex::SingleIndex;
Expand Down Expand Up @@ -138,18 +134,19 @@ class VariableManager
return nativeOptimVar.NumeroDeVariablesDePompage[index];
}

int HydroLevel(unsigned int index) const
{
return nativeOptimVar.NumeroDeVariablesDeNiveau[index];
}

private:
const CORRESPONDANCES_DES_VARIABLES& nativeOptimVar;
const std::vector<int>& NumeroDeVariableStockFinal;
const std::vector<std::vector<int>>& NumeroDeVariableDeTrancheDeStock;
};

using Variables = std::variant<HydroLevel,
Overflow,
FinalStorage,
LayerStorage,
PositiveUnsuppliedEnergy,
NegativeUnsuppliedEnergy>;
using Variables = std::
variant<Overflow, FinalStorage, LayerStorage, PositiveUnsuppliedEnergy, NegativeUnsuppliedEnergy>;
class ConstraintVisitor
{
public:
Expand All @@ -162,10 +159,6 @@ class ConstraintVisitor
{
}

int operator()(const HydroLevel& v) const
{
return nativeOptimVar.NumeroDeVariablesDeNiveau[v.index];
}
int operator()(const Overflow& v) const
{
return nativeOptimVar.NumeroDeVariablesDeDebordement[v.index];
Expand Down Expand Up @@ -316,6 +309,12 @@ class ConstraintBuilder
bool wrap = false,
int delta = 0);

ConstraintBuilder& HydroLevel(unsigned int index,
double coeff,
int shift = 0,
bool wrap = false,
int delta = 0);

class ConstraintBuilderInvalidOperator : public std::runtime_error
{
public:
Expand Down

0 comments on commit ed6ecbc

Please sign in to comment.