Skip to content

Commit

Permalink
reshape constraint construction (#1815)
Browse files Browse the repository at this point in the history
* rename method

* rename with respect to the default style

* remove default parameters

* fix

* update

* fix

* ShortTermStorageLevel specific case

* NTC fix

* .
  • Loading branch information
a-zakir authored Dec 13, 2023
1 parent 8bbd2e9 commit c469974
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 184 deletions.
2 changes: 1 addition & 1 deletion src/solver/optimisation/ProblemMatrixEssential.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ProblemMatrixEssential
{
for (auto& group : constraintgroups_)
{
group->Build();
group->BuildConstraints();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AbstractStartUpCostsGroup : public ConstraintGroup
{
}

void Build() = 0;
void BuildConstraints() = 0;

bool simulation_ = false;
StartUpCostsData GetStartUpCostsDataFromProblemHebdo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AreaHydroLevelData AreaHydroLevelGroup::GetAreaHydroLevelData()
.CaracteristiquesHydrauliques = problemeHebdo_->CaracteristiquesHydrauliques};
}

void AreaHydroLevelGroup::Build()
void AreaHydroLevelGroup::BuildConstraints()
{
auto areaHydroLevelData = GetAreaHydroLevelData();
AreaHydroLevel areaHydroLevel(builder_, areaHydroLevelData);
Expand Down
2 changes: 1 addition & 1 deletion src/solver/optimisation/constraints/AreaHydroLevelGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AreaHydroLevelGroup : public ConstraintGroup
using ConstraintGroup::ConstraintGroup;


void Build() override;
void BuildConstraints() override;

private:
AreaHydroLevelData GetAreaHydroLevelData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BindingConstraintDayData BindingConstraintDayGroup::GetBindingConstraintDayDataF
.NumeroDeJourDuPasDeTemps = problemeHebdo_->NumeroDeJourDuPasDeTemps};
}

void BindingConstraintDayGroup::Build()
void BindingConstraintDayGroup::BuildConstraints()
{
auto bindingConstraintDayData = GetBindingConstraintDayDataFromProblemHebdo();
BindingConstraintDay bindingConstraintDay(builder_, bindingConstraintDayData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BindingConstraintDayGroup : public ConstraintGroup
using ConstraintGroup::ConstraintGroup;


void Build() override;
void BuildConstraints() override;

private:
BindingConstraintDayData GetBindingConstraintDayDataFromProblemHebdo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BindingConstraintWeekData BindingConstraintWeekGroup::GetBindingConstraintWeekDa
.NumeroDeContrainteDesContraintesCouplantes};
}

void BindingConstraintWeekGroup::Build()
void BindingConstraintWeekGroup::BuildConstraints()
{
auto bindingConstraintWeekData = GetBindingConstraintWeekDataFromProblemHebdo();
BindingConstraintWeek bindingConstraintWeek(builder_, bindingConstraintWeekData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BindingConstraintWeekGroup : public ConstraintGroup
using ConstraintGroup::ConstraintGroup;


void Build() override;
void BuildConstraints() override;

private:
BindingConstraintWeekData GetBindingConstraintWeekDataFromProblemHebdo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @brief build ConsistenceNumberOfDispatchableUnits constraints with
* respect to default order
*/
void ConsistenceNumberOfDispatchableUnitsGroup::Build()
void ConsistenceNumberOfDispatchableUnitsGroup::BuildConstraints()
{
auto data = GetStartUpCostsDataFromProblemHebdo();
ConsistenceNumberOfDispatchableUnits consistenceNumberOfDispatchableUnits(builder_, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class ConsistenceNumberOfDispatchableUnitsGroup : public AbstractStartUpCostsGro
public:
using AbstractStartUpCostsGroup::AbstractStartUpCostsGroup;

void Build() override;
void BuildConstraints() override;
};
137 changes: 42 additions & 95 deletions src/solver/optimisation/constraints/ConstraintBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,185 +54,132 @@ ConstraintBuilder& ConstraintBuilder::DispatchableProduction(unsigned int index,
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;
}

ConstraintBuilder& ConstraintBuilder::NTCDirect(unsigned int index,
double coeff,
int offset,
int delta)
double coeff,
int offset,
int delta)
{
AddVariable(GetVariableManager(offset, delta).NTCDirect(index), coeff);
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;
}

ConstraintBuilder& ConstraintBuilder::ShortTermStorageLevel(unsigned int index,
double coeff,
int offset,
int delta)
double coeff,
int offset,
int delta)
{
AddVariable(GetVariableManager(offset, delta).ShortTermStorageLevel(index), coeff);
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;
}

Expand Down
Loading

0 comments on commit c469974

Please sign in to comment.