Skip to content

Commit

Permalink
LayerStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Sep 18, 2023
1 parent fe77c92 commit f02c5af
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/solver/optimisation/FinalStockExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void FinalStockExpression::add(int pays)
builder.updateHourWithinWeek(pdt).FinalStorage(pays, -1.0);
for (int layerindex = 0; layerindex < 100; layerindex++)
{
builder.include(Variable::LayerStorage(pays, layerindex), 1.0);
builder.LayerStorage(pays, layerindex, 1.0);
}
problemeHebdo->NumeroDeContrainteExpressionStockFinal[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
Expand Down
11 changes: 11 additions & 0 deletions src/solver/optimisation/constraint_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,17 @@ ConstraintBuilder& ConstraintBuilder::FinalStorage(unsigned int index,
return *this;
}

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

int ConstraintBuilder::getVariableIndex(const Variable::Variables& variable,
int shift,
bool wrap,
Expand Down
25 changes: 12 additions & 13 deletions src/solver/optimisation/constraint_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ struct NegativeUnsuppliedEnergy : public SingleIndex
using SingleIndex::SingleIndex;
};

struct LayerStorage
{
LayerStorage(unsigned area, unsigned layer) : area(area), layer(layer)
{
}
unsigned area, layer;
};

class VariableManager
{
public:
Expand Down Expand Up @@ -141,13 +133,18 @@ class VariableManager
return NumeroDeVariableStockFinal[index];
}

int LayerStorage(unsigned area, unsigned layer) const
{
return NumeroDeVariableDeTrancheDeStock[area][layer];
}

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

using Variables = std::variant<LayerStorage, PositiveUnsuppliedEnergy, NegativeUnsuppliedEnergy>;
using Variables = std::variant<PositiveUnsuppliedEnergy, NegativeUnsuppliedEnergy>;
class ConstraintVisitor
{
public:
Expand All @@ -160,10 +157,6 @@ class ConstraintVisitor
{
}

int operator()(const LayerStorage& v) const
{
return NumeroDeVariableDeTrancheDeStock[v.area][v.layer];
}
int operator()(const PositiveUnsuppliedEnergy& v) const
{
return nativeOptimVar.NumeroDeVariableDefaillancePositive[v.index];
Expand Down Expand Up @@ -319,6 +312,12 @@ class ConstraintBuilder
int shift = 0,
bool wrap = false,
int delta = 0);
ConstraintBuilder& LayerStorage(unsigned area,
unsigned layer,
double coeff,
int shift = 0,
bool wrap = false,
int delta = 0);

class ConstraintBuilderInvalidOperator : public std::runtime_error
{
Expand Down

0 comments on commit f02c5af

Please sign in to comment.