Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/remove problem hebdo from constraint builder lib #178

Open
wants to merge 43 commits into
base: New-Antares-Emulator-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
433b799
start
a-zakir Sep 2, 2023
bca6733
add FictitiousLoad
a-zakir Sep 2, 2023
adbd363
shortTermStorageLevel
a-zakir Sep 2, 2023
79136ac
flowDissociation
a-zakir Sep 2, 2023
60ea81c
bindingConstraintHour
a-zakir Sep 2, 2023
e4298f9
ghost
a-zakir Sep 3, 2023
c96df9c
this is not only about constraint builder
a-zakir Sep 3, 2023
1af5ead
pay attention to the time step
a-zakir Sep 3, 2023
1d33989
specific issue
a-zakir Sep 3, 2023
3f9f115
bug free
a-zakir Sep 3, 2023
7b2406e
smooth green?
a-zakir Sep 3, 2023
3b0c0d5
M&M
a-zakir Sep 3, 2023
bcc63e7
Max Pumping ok?
a-zakir Sep 3, 2023
a2de6d7
Area Hydro Level (_-_)
a-zakir Sep 3, 2023
b7b022c
finally
a-zakir Sep 3, 2023
317bdb5
basic
a-zakir Sep 3, 2023
fcef054
tiny
a-zakir Sep 3, 2023
2364b35
clean code
a-zakir Sep 4, 2023
507e355
add {PMin,PMax}DispatchableGeneration
a-zakir Sep 5, 2023
854ca38
clean code
a-zakir Sep 5, 2023
3029f79
ConsistenceNODU ok
a-zakir Sep 5, 2023
78dab46
NbUnitsOutageLessThanNbUnitsStop
a-zakir Sep 5, 2023
22862bd
NbDispUnitsMinBoundSinceMinUpTime
a-zakir Sep 5, 2023
afd0808
MinDownTime
a-zakir Sep 5, 2023
89584b0
setup Access Control
a-zakir Sep 6, 2023
d7e197d
remove comments
a-zakir Sep 6, 2023
a956ab9
remove comments
a-zakir Sep 6, 2023
34e9559
treat major code smells
a-zakir Sep 6, 2023
c81b801
treat major code smells 2
a-zakir Sep 6, 2023
1e65059
more on major code smells
a-zakir Sep 6, 2023
692a8a8
update after review
a-zakir Sep 7, 2023
7f8054d
about objects lifetime
a-zakir Sep 11, 2023
5a047c0
(does not compile) cut into small pieces
a-zakir Sep 11, 2023
b40aec7
part 1: introduce constraints data objects
a-zakir Sep 11, 2023
7af3ab7
Mismatch
a-zakir Sep 11, 2023
6ab2a54
problemHebdo removed from contraintBuilder
a-zakir Sep 12, 2023
b6b77b8
build csr_quadratic_problem constraints with the constraint Builder
a-zakir Sep 12, 2023
46a6b96
update flowDissociation
a-zakir Sep 12, 2023
1df8de9
big update
a-zakir Sep 12, 2023
ee1186e
reshape Start-Up Cost Constraints
a-zakir Sep 12, 2023
9d935ec
add empty line
a-zakir Sep 12, 2023
5cece36
start debug session
a-zakir Sep 15, 2023
1ab00ba
secure refs
a-zakir Sep 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/solver/optimisation/AreaBalance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "AreaBalance.h"

static void shortTermStorageBalance(const ::ShortTermStorage::AREA_INPUT& shortTermStorageInput,
ConstraintBuilder& constraintBuilder,
std::vector<int>& InjectionVariable,
std::vector<int>& WithdrawalVariable)
{
for (const auto& storage : shortTermStorageInput)
{
unsigned index = storage.clusterGlobalIndex;
if (const int varInjection = InjectionVariable[index]; varInjection >= 0)
{
constraintBuilder.include(Variable::ShortTermStorageInjection(index), 1.0);
}
if (const int varWithdrawal = WithdrawalVariable[index]; varWithdrawal >= 0)
{
constraintBuilder.include(Variable::ShortTermStorageWithdrawal(index), -1.0);
}
}
}

// Constraint definitions
void AreaBalance::add(int pdt, int pays, AreaBalanceData& data)
{
// /** can be done without this --- keep it for now**/
// data.NumeroDeContrainteDesBilansPays[pays] = builder.data.nombreDeContraintes;

// /******/
// // TODO improve this

// ConstraintNamer namer(builder.data.NomDesContraintes, builder.data.NamedProblems);
// namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
// namer.UpdateArea(builder.data.NomsDesPays[pays]);
// namer.AreaBalance(builder.data.nombreDeContraintes);

// builder.updateHourWithinWeek(pdt);

// int interco = data.IndexDebutIntercoOrigine[pays];
// while (interco >= 0)
// {
// builder.include(Variable::NTCDirect(interco), 1.0);
// interco = data.IndexSuivantIntercoOrigine[interco];
// }

// interco = data.IndexDebutIntercoExtremite[pays];
// while (interco >= 0)
// {
// builder.include(Variable::NTCDirect(interco), -1.0);
// interco = data.IndexSuivantIntercoExtremite[interco];
// }

// exportPaliers(data.PaliersThermiquesDuPays, builder);
// builder.include(Variable::HydProd(pays), -1.0)
// .include(Variable::Pumping(pays), 1.0)
// .include(Variable::PositiveUnsuppliedEnergy(pays), -1.0)
// .include(Variable::NegativeUnsuppliedEnergy(pays), 1.0);

// shortTermStorageBalance(
// data.ShortTermStorage[pays], builder, data.InjectionVariable, data.WithdrawalVariable);

// builder.equalTo();
// builder.build();
logs.info() << "" << data.NumeroDeContrainteDesBilansPays[pays] << "\n";
int a = 13;
int b = a / 33;
}
46 changes: 46 additions & 0 deletions src/solver/optimisation/AreaBalance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once
#include "constraint_builder.h"

struct AreaBalanceData
{
AreaBalanceData(std::vector<int>& NumeroDeContrainteDesBilansPays,
std::vector<int>& InjectionVariable,
std::vector<int>& WithdrawalVariable,
const std::vector<int>& IndexDebutIntercoOrigine,
const std::vector<int>& IndexSuivantIntercoOrigine,
const std::vector<int>& IndexDebutIntercoExtremite,
const std::vector<int>& IndexSuivantIntercoExtremite,
const PALIERS_THERMIQUES& PaliersThermiquesDuPays,
const std::vector<::ShortTermStorage::AREA_INPUT>& ShortTermStorage)

:
NumeroDeContrainteDesBilansPays(NumeroDeContrainteDesBilansPays),
InjectionVariable(InjectionVariable),
WithdrawalVariable(WithdrawalVariable),
IndexDebutIntercoOrigine(IndexDebutIntercoOrigine),
IndexSuivantIntercoOrigine(IndexSuivantIntercoOrigine),
IndexDebutIntercoExtremite(IndexDebutIntercoExtremite),
IndexSuivantIntercoExtremite(IndexSuivantIntercoExtremite),
PaliersThermiquesDuPays(PaliersThermiquesDuPays),
ShortTermStorage(ShortTermStorage)
{
}

std::vector<int>& NumeroDeContrainteDesBilansPays;
std::vector<int>& InjectionVariable;
std::vector<int>& WithdrawalVariable;
const std::vector<int>& IndexDebutIntercoOrigine;
const std::vector<int>& IndexSuivantIntercoOrigine;
const std::vector<int>& IndexDebutIntercoExtremite;
const std::vector<int>& IndexSuivantIntercoExtremite;
const PALIERS_THERMIQUES& PaliersThermiquesDuPays;
const std::vector<::ShortTermStorage::AREA_INPUT>& ShortTermStorage;
};

class AreaBalance : private Constraint
{
public:
using Constraint::Constraint;

void add(int pdt, int pays, AreaBalanceData& data);
};
28 changes: 28 additions & 0 deletions src/solver/optimisation/AreaHydroLevel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "AreaHydroLevel.h"

void AreaHydroLevel::add(int pays, int pdt, AreaHydroLevelData& data)
{
data.NumeroDeContrainteDesNiveauxPays[pays] = builder.data.nombreDeContraintes;
if (data.SuiviNiveauHoraire)
{
builder.updateHourWithinWeek(pdt).include(Variable::HydroLevel(pays), 1.0);
if (pdt > 0)
{
builder.updateHourWithinWeek(pdt - 1).include(Variable::HydroLevel(pays), -1.0);
}
ConstraintNamer namer(builder.data.NomDesContraintes, builder.data.NamedProblems);

namer.UpdateArea(builder.data.NomsDesPays[pays]);
namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.AreaHydroLevel(builder.data.nombreDeContraintes);
data.NumeroDeContrainteDesNiveauxPays[pays] = builder.data.nombreDeContraintes;
builder.updateHourWithinWeek(pdt)
.include(Variable::HydProd(pays), 1.0)
.include(Variable::Pumping(pays), -data.PumpingRatio)
.include(Variable::Overflow(pays), 1.)
.equalTo()
.build();
}
else
data.NumeroDeContrainteDesNiveauxPays[pays] = -1;
}
16 changes: 16 additions & 0 deletions src/solver/optimisation/AreaHydroLevel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "constraint_builder.h"

struct AreaHydroLevelData
{
std::vector<int>& NumeroDeContrainteDesNiveauxPays;
const bool& SuiviNiveauHoraire;
const double& PumpingRatio;
};

class AreaHydroLevel : private Constraint
{
public:
using Constraint::Constraint;
void add(int pays, int pdt, AreaHydroLevelData& data);
};
88 changes: 88 additions & 0 deletions src/solver/optimisation/BindingConstraintDay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "BindingConstraintDay.h"

void BindingConstraintDay::add(int cntCouplante, BindingConstraintDayData& data)
{
if (data.TypeDeContrainteCouplante != CONTRAINTE_JOURNALIERE)
return;

const int nbInterco = data.NombreDInterconnexionsDansLaContrainteCouplante;
const int nbClusters = data.NombreDePaliersDispatchDansLaContrainteCouplante;

const int NombreDePasDeTempsPourUneOptimisation
= builder.data.NombreDePasDeTempsPourUneOptimisation; // TODO
const int NombreDePasDeTempsDUneJournee = data.NombreDePasDeTempsDUneJournee;
int pdtDebut = 0;
while (pdtDebut < NombreDePasDeTempsPourUneOptimisation)
{
int jour = data.NumeroDeJourDuPasDeTemps[pdtDebut];

for (int index = 0; index < nbInterco; index++)
{
int interco = data.NumeroDeLInterconnexion[index];
double poids = data.PoidsDeLInterconnexion[index];
int offset = data.OffsetTemporelSurLInterco[index];

for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
int pdt1;
if (offset >= 0)
{
pdt1 = (pdt + offset) % builder.data.NombreDePasDeTempsPourUneOptimisation;
}
else
{
pdt1 = (pdt + offset + builder.data.NombreDePasDeTemps)
% builder.data.NombreDePasDeTempsPourUneOptimisation;
}
builder.updateHourWithinWeek(pdt1).include(
Variable::NTCDirect(interco), poids, 0, false, builder.data.NombreDePasDeTemps);
}
}

for (int index = 0; index < nbClusters; index++)
{
int pays = data.PaysDuPalierDispatch[index];
const PALIERS_THERMIQUES& PaliersThermiquesDuPays = data.PaliersThermiquesDuPays[pays];
const int palier
= PaliersThermiquesDuPays.NumeroDuPalierDansLEnsembleDesPaliersThermiques
[data.NumeroDuPalierDispatch[index]];
double poids = data.PoidsDuPalierDispatch[index];
int offset = data.OffsetTemporelSurLePalierDispatch[index];

for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
int pdt1;
if (offset >= 0)
{
pdt1 = (pdt + offset) % builder.data.NombreDePasDeTempsPourUneOptimisation;
}
else
{
pdt1 = (pdt + offset + builder.data.NombreDePasDeTemps)
% builder.data.NombreDePasDeTempsPourUneOptimisation;
}

builder.updateHourWithinWeek(pdt1).include(Variable::DispatchableProduction(palier),
poids,
0,
false,
builder.data.NombreDePasDeTemps);
}
}

data.CorrespondanceCntNativesCntOptimJournalieres[jour]
.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
= builder.data.nombreDeContraintes;

char op = data.SensDeLaContrainteCouplante;
builder.operatorRHS(op);
{
ConstraintNamer namer(builder.data.NomDesContraintes, builder.data.NamedProblems);
namer.UpdateTimeStep(jour);
namer.BindingConstraintDay(builder.data.nombreDeContraintes,
data.NomDeLaContrainteCouplante);
}
builder.build();
pdtDebut += data.NombreDePasDeTempsDUneJournee;
}
}
63 changes: 63 additions & 0 deletions src/solver/optimisation/BindingConstraintDay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once
#include "constraint_builder.h"

struct BindingConstraintDayData : public BindingConstraintData
{
BindingConstraintDayData(BindingConstraintDayData& data) :
BindingConstraintData(data),
CorrespondanceCntNativesCntOptimJournalieres(
data.CorrespondanceCntNativesCntOptimJournalieres),
NombreDePasDeTempsDUneJournee(data.NombreDePasDeTempsDUneJournee),
NumeroDeJourDuPasDeTemps(data.NumeroDeJourDuPasDeTemps)
{
}
BindingConstraintDayData(const char& TypeDeContrainteCouplante,
const int& NombreDInterconnexionsDansLaContrainteCouplante,
const std::vector<int>& NumeroDeLInterconnexion,
const std::vector<double>& PoidsDeLInterconnexion,
const std::vector<int>& OffsetTemporelSurLInterco,
const int& NombreDePaliersDispatchDansLaContrainteCouplante,
const std::vector<int>& PaysDuPalierDispatch,
const std::vector<int>& NumeroDuPalierDispatch,
const std::vector<double>& PoidsDuPalierDispatch,
const std::vector<int>& OffsetTemporelSurLePalierDispatch,
const char& SensDeLaContrainteCouplante,
const char* const& NomDeLaContrainteCouplante,
const std::vector<PALIERS_THERMIQUES>& PaliersThermiquesDuPays,
std::vector<CORRESPONDANCES_DES_CONTRAINTES_JOURNALIERES>&
CorrespondanceCntNativesCntOptimJournalieres,
const int32_t& NombreDePasDeTempsDUneJournee,
std::vector<int32_t>& NumeroDeJourDuPasDeTemps) :
BindingConstraintData(TypeDeContrainteCouplante,
NombreDInterconnexionsDansLaContrainteCouplante,
NumeroDeLInterconnexion,
PoidsDeLInterconnexion,
OffsetTemporelSurLInterco,
NombreDePaliersDispatchDansLaContrainteCouplante,
PaysDuPalierDispatch,
NumeroDuPalierDispatch,
PoidsDuPalierDispatch,
OffsetTemporelSurLePalierDispatch,
SensDeLaContrainteCouplante,
NomDeLaContrainteCouplante,
PaliersThermiquesDuPays),
CorrespondanceCntNativesCntOptimJournalieres(CorrespondanceCntNativesCntOptimJournalieres),
NombreDePasDeTempsDUneJournee(NombreDePasDeTempsDUneJournee),
NumeroDeJourDuPasDeTemps(NumeroDeJourDuPasDeTemps)
{
}

// std::vector<std::vector<int>&>& CorrespondanceCntNativesCntOptimJournalieres;
std::vector<CORRESPONDANCES_DES_CONTRAINTES_JOURNALIERES>&
CorrespondanceCntNativesCntOptimJournalieres;

const int32_t& NombreDePasDeTempsDUneJournee;

std::vector<int32_t>& NumeroDeJourDuPasDeTemps;
};
class BindingConstraintDay : private Constraint
{
public:
using Constraint::Constraint;
void add(int cntCouplante, BindingConstraintDayData& data);
};
73 changes: 73 additions & 0 deletions src/solver/optimisation/BindingConstraintHour.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "BindingConstraintHour.h"

void BindingConstraintHour::add(int pdt, int cntCouplante, BindingConstraintHourData& data)
{
data.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
= builder.data.nombreDeContraintes;

if (data.TypeDeContrainteCouplante != CONTRAINTE_HORAIRE)
return;

builder.updateHourWithinWeek(pdt);
// Links
const int nbInterco = data.NombreDInterconnexionsDansLaContrainteCouplante;
for (int index = 0; index < nbInterco; index++)
{
const int interco = data.NumeroDeLInterconnexion[index];
const double poids = data.PoidsDeLInterconnexion[index];
const int offset = data.OffsetTemporelSurLInterco[index];
int pdt1;
if (offset >= 0)
{
pdt1 = (pdt + offset) % builder.data.NombreDePasDeTempsPourUneOptimisation;
}
else
{
pdt1 = (pdt + offset + builder.data.NombreDePasDeTemps)
% builder.data.NombreDePasDeTempsPourUneOptimisation;
}

builder.updateHourWithinWeek(pdt1).include(
Variable::NTCDirect(interco), poids, 0, false, builder.data.NombreDePasDeTemps);
}

// Thermal clusters
const int nbClusters = data.NombreDePaliersDispatchDansLaContrainteCouplante;
for (int index = 0; index < nbClusters; index++)
{
const int pays = data.PaysDuPalierDispatch[index];
const PALIERS_THERMIQUES& PaliersThermiquesDuPays = data.PaliersThermiquesDuPays[pays];
const int palier
= PaliersThermiquesDuPays
.NumeroDuPalierDansLEnsembleDesPaliersThermiques[data.NumeroDuPalierDispatch[index]];
const double poids = data.PoidsDuPalierDispatch[index];
const int offset = data.OffsetTemporelSurLePalierDispatch[index];
int pdt1;

if (offset >= 0)
{
pdt1 = (pdt + offset) % builder.data.NombreDePasDeTempsPourUneOptimisation;
}
else
{
pdt1 = (pdt + offset + builder.data.NombreDePasDeTemps)
% builder.data.NombreDePasDeTempsPourUneOptimisation;
}

builder.updateHourWithinWeek(pdt1).include(Variable::DispatchableProduction(palier),
poids,
0,
false,
builder.data.NombreDePasDeTemps);
}

char op = data.SensDeLaContrainteCouplante;
builder.operatorRHS(op);
{
ConstraintNamer namer(builder.data.NomDesContraintes, builder.data.NamedProblems);
namer.UpdateTimeStep(builder.data.weekInTheYear * 168 + pdt);
namer.BindingConstraintHour(builder.data.nombreDeContraintes,
data.NomDeLaContrainteCouplante);
}
builder.build();
}
Loading