Skip to content

Commit

Permalink
add HydroPowerGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Sep 19, 2023
1 parent 8ed7085 commit 688b36d
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 40 deletions.
2 changes: 2 additions & 0 deletions src/solver/optimisation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ set(RTESOLVER_OPT
BindingConstraintDayGroup.cpp
BindingConstraintWeekGroup.h
BindingConstraintWeekGroup.cpp
HydroPowerGroup.h
HydroPowerGroup.cpp

)

Expand Down
47 changes: 19 additions & 28 deletions src/solver/optimisation/HydroPower.cpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,42 @@
#include "HydroPower.h"

void HydroPower::add(int pays)
void HydroPower::add(int pays, std::shared_ptr<HydroPowerData> data)
{
bool presenceHydro
= problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable;
bool TurbEntreBornes = problemeHebdo->CaracteristiquesHydrauliques[pays].TurbinageEntreBornes;

const int NombreDePasDeTempsPourUneOptimisation
= problemeHebdo->NombreDePasDeTempsPourUneOptimisation;
if (presenceHydro && !TurbEntreBornes)
= builder->data->NombreDePasDeTempsPourUneOptimisation;
if (data->presenceHydro && !data->TurbEntreBornes)
{
if (bool presencePompage
= problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable)
if (data->presencePompage)
{
problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
data->NumeroDeContrainteEnergieHydraulique[pays] = builder->data->nombreDeContraintes;

const double pumpingRatio
= problemeHebdo->CaracteristiquesHydrauliques[pays].PumpingRatio;
const double pumpingRatio = data->pumpingRatio;
for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
builder.include(Variable::HydProd(pays), 1.0)
.include(Variable::Pumping(pays), -pumpingRatio);
builder->updateHourWithinWeek(pdt);
builder->include(NewVariable::HydProd(pays), 1.0)
.include(NewVariable::Pumping(pays), -pumpingRatio);
}
}
else
{
for (int pdt = 0; pdt < NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
builder.include(Variable::HydProd(pays), 1.0);
builder->updateHourWithinWeek(pdt);
builder->include(NewVariable::HydProd(pays), 1.0);
}
}
problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
data->NumeroDeContrainteEnergieHydraulique[pays] = builder->data->nombreDeContraintes;

builder.equalTo();
builder->equalTo();
{
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
namer.UpdateTimeStep(problemeHebdo->weekInTheYear);
namer.HydroPower(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
ConstraintNamer namer(builder->data->NomDesContraintes, builder->data->NamedProblems);
namer.UpdateArea(builder->data->NomsDesPays[pays]);
namer.UpdateTimeStep(builder->data->weekInTheYear);
namer.HydroPower(builder->data->nombreDeContraintes);
}
builder.build();
builder->build();
}
else
problemeHebdo->NumeroDeContrainteEnergieHydraulique[pays] = -1;
data->NumeroDeContrainteEnergieHydraulique[pays] = -1;
}
17 changes: 13 additions & 4 deletions src/solver/optimisation/HydroPower.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
#pragma once
#include "constraint_builder.h"
#include "new_constraint_builder.h"
struct HydroPowerData
{
const bool& presenceHydro;
const int& TurbEntreBornes;
const bool& presencePompage;
const int& NombreDePasDeTempsPourUneOptimisation;
std::vector<int>& NumeroDeContrainteEnergieHydraulique;
const double& pumpingRatio;
};

class HydroPower : private Constraint
class HydroPower : private NewConstraint
{
public:
using Constraint::Constraint;
void add(int pays);
using NewConstraint::NewConstraint;
void add(int pays, std::shared_ptr<HydroPowerData> data);
};
26 changes: 26 additions & 0 deletions src/solver/optimisation/HydroPowerGroup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "HydroPowerGroup.h"
#include "new_constraint_builder_utils.h"

std::shared_ptr<HydroPowerData> HydroPowerGroup::GetHydroPowerDataFromProblemHebdo(uint32_t pays)
{
HydroPowerData data
= {problemeHebdo_->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable,
problemeHebdo_->CaracteristiquesHydrauliques[pays].TurbinageEntreBornes,
problemeHebdo_->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable,
problemeHebdo_->NombreDePasDeTempsPourUneOptimisation,
problemeHebdo_->NumeroDeContrainteEnergieHydraulique,
problemeHebdo_->CaracteristiquesHydrauliques[pays].PumpingRatio};
return std::make_shared<HydroPowerData>(data);
}

void HydroPowerGroup::Build()
{
std::shared_ptr<NewConstraintBuilder> builder(
NewGetConstraintBuilderFromProblemHebdo(problemeHebdo_));
HydroPower hydroPower(builder);

for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
{
hydroPower.add(pays, GetHydroPowerDataFromProblemHebdo(pays));
}
}
15 changes: 15 additions & 0 deletions src/solver/optimisation/HydroPowerGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once
#include "ConstraintGroup.h"
#include "HydroPower.h"

class HydroPowerGroup : public ConstraintGroup
{
public:
using ConstraintGroup::ConstraintGroup;

/*TODO Rename this*/
void Build() override;

private:
std::shared_ptr<HydroPowerData> GetHydroPowerDataFromProblemHebdo(uint32_t pays);
};
6 changes: 0 additions & 6 deletions src/solver/optimisation/LinearProblemMatrixBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ void LinearProblemMatrixBuilder::Run()
ConstraintNamer constraintNamer(ProblemeAResoudre->NomDesContraintes,
problemeHebdo_->NamedProblems);

HydroPower hydroPower(problemeHebdo_);
HydroPowerSmoothingUsingVariationSum hydroPowerSmoothingUsingVariationSum(problemeHebdo_);
HydroPowerSmoothingUsingVariationMaxDown hydroPowerSmoothingUsingVariationMaxDown(
problemeHebdo_);
Expand All @@ -89,11 +88,6 @@ void LinearProblemMatrixBuilder::Run()
group->Build();
}

for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
{
hydroPower.add(pays);
}

if (problemeHebdo_->TypeDeLissageHydraulique == LISSAGE_HYDRAULIQUE_SUR_SOMME_DES_VARIATIONS)
{
for (uint32_t pays = 0; pays < problemeHebdo_->NombreDePays; pays++)
Expand Down
8 changes: 6 additions & 2 deletions src/solver/optimisation/LinearProblemMatrixBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "Group1.h"
#include "BindingConstraintDayGroup.h"
#include "BindingConstraintWeekGroup.h"
#include "HydroPowerGroup.h"

#include <antares/study.h>

Expand All @@ -43,9 +44,11 @@ class LinearProblemMatrixBuilder
writer_(writer),
group1_(problemeHebdo),
bindingConstraintDayGroup_(problemeHebdo),
bindingConstraintWeekGroup_(problemeHebdo)
bindingConstraintWeekGroup_(problemeHebdo),
hydroPowerGroup_(problemeHebdo)
{
constraintgroups_ = {&group1_, &bindingConstraintDayGroup_, &bindingConstraintWeekGroup_};
constraintgroups_ = {
&group1_, &bindingConstraintDayGroup_, &bindingConstraintWeekGroup_, &hydroPowerGroup_};
}

void Run();
Expand All @@ -54,6 +57,7 @@ class LinearProblemMatrixBuilder
Group1 group1_;
BindingConstraintDayGroup bindingConstraintDayGroup_;
BindingConstraintWeekGroup bindingConstraintWeekGroup_;
HydroPowerGroup hydroPowerGroup_;
std::vector<ConstraintGroup*> constraintgroups_;
PROBLEME_HEBDO* problemeHebdo_;
Solver::IResultWriter& writer_;
Expand Down

0 comments on commit 688b36d

Please sign in to comment.