Skip to content

Commit

Permalink
Revert "(does not compile) cut into small pieces"
Browse files Browse the repository at this point in the history
This reverts commit 5a047c0.
  • Loading branch information
a-zakir committed Sep 11, 2023
1 parent 5a047c0 commit bd394e3
Show file tree
Hide file tree
Showing 27 changed files with 299 additions and 397 deletions.
31 changes: 18 additions & 13 deletions src/solver/optimisation/AreaBalance.cpp
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
#include "AreaBalance.h"

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

// Constraint definitions
void AreaBalance::add(int pdt,
int pays,
std::vector<int>& NumeroDeContrainteDesBilansPays,
std::vector<int>& InjectionVariable,
std::vector<int>& WithdrawalVariable)
void AreaBalance::add(int pdt, int pays)
{
/** can be done without this --- keep it for now**/
NumeroDeContrainteDesBilansPays[pays] = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
CORRESPONDANCES_DES_VARIABLES& CorrespondanceVarNativesVarOptim
= problemeHebdo->CorrespondanceVarNativesVarOptim[pdt];
CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
= problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesBilansPays[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;

/******/
// TODO improve this
Expand Down Expand Up @@ -62,7 +67,7 @@ void AreaBalance::add(int pdt,
.include(Variable::NegativeUnsuppliedEnergy(pays), 1.0);

shortTermStorageBalance(
problemeHebdo->ShortTermStorage[pays], builder, InjectionVariable, WithdrawalVariable);
problemeHebdo->ShortTermStorage[pays], builder, CorrespondanceVarNativesVarOptim);

builder.equalTo();
builder.build();
Expand Down
6 changes: 1 addition & 5 deletions src/solver/optimisation/AreaBalance.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ class AreaBalance : private Constraint
public:
using Constraint::Constraint;

void add(int pdt,
int pays,
std::vector<int>& NumeroDeContrainteDesBilansPays,
std::vector<int>& InjectionVariable,
std::vector<int>& WithdrawalVariable);
void add(int pdt, int pays);
};
13 changes: 9 additions & 4 deletions src/solver/optimisation/AreaHydroLevel.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "AreaHydroLevel.h"

void AreaHydroLevel::add(int pays, int pdt, std::vector<int>& NumeroDeContrainteDesNiveauxPays)
void AreaHydroLevel::add(int pays, int pdt)
{
NumeroDeContrainteDesNiveauxPays[pays] = problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
const auto& CorrespondanceVarNativesVarOptim
= problemeHebdo->CorrespondanceVarNativesVarOptim[pdt];
CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
= problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
if (problemeHebdo->CaracteristiquesHydrauliques[pays].SuiviNiveauHoraire)
{
builder.updateHourWithinWeek(pdt).include(Variable::HydroLevel(pays), 1.0);
Expand All @@ -16,7 +21,7 @@ void AreaHydroLevel::add(int pays, int pdt, std::vector<int>& NumeroDeContrainte
namer.UpdateArea(problemeHebdo->NomsDesPays[pays]);
namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
namer.AreaHydroLevel(problemeHebdo->ProblemeAResoudre->NombreDeContraintes);
NumeroDeContrainteDesNiveauxPays[pays]
CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
builder.updateHourWithinWeek(pdt)
.include(Variable::HydProd(pays), 1.0)
Expand All @@ -27,5 +32,5 @@ void AreaHydroLevel::add(int pays, int pdt, std::vector<int>& NumeroDeContrainte
.build();
}
else
NumeroDeContrainteDesNiveauxPays[pays] = -1;
CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesNiveauxPays[pays] = -1;
}
2 changes: 1 addition & 1 deletion src/solver/optimisation/AreaHydroLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ class AreaHydroLevel : private Constraint
{
public:
using Constraint::Constraint;
void add(int pays, int pdt, std::vector<int>& NumeroDeContrainteDesNiveauxPays);
void add(int pays, int pdt);
};
34 changes: 19 additions & 15 deletions src/solver/optimisation/BindingConstraintDay.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#include "BindingConstraintDay.h"

void BindingConstraintDay::add(int cntCouplante, BindingConstraintDayData& data)
void BindingConstraintDay::add(int cntCouplante)
{
if (data.TypeDeContrainteCouplante != CONTRAINTE_JOURNALIERE)
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
= problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_JOURNALIERE)
return;

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

const int NombreDePasDeTempsPourUneOptimisation
= problemeHebdo->NombreDePasDeTempsPourUneOptimisation; // TODO
Expand All @@ -15,14 +19,14 @@ void BindingConstraintDay::add(int cntCouplante, BindingConstraintDayData& data)
while (pdtDebut < NombreDePasDeTempsPourUneOptimisation)
{
int jour = problemeHebdo->NumeroDeJourDuPasDeTemps[pdtDebut];
auto& CorrespondanceCntNativesCntOptimJournalieres
= data.CorrespondanceCntNativesCntOptimJournalieres[jour];
CORRESPONDANCES_DES_CONTRAINTES_JOURNALIERES& CorrespondanceCntNativesCntOptimJournalieres
= problemeHebdo->CorrespondanceCntNativesCntOptimJournalieres[jour];

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

for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
Expand All @@ -43,14 +47,14 @@ void BindingConstraintDay::add(int cntCouplante, BindingConstraintDayData& data)

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

for (int pdt = pdtDebut; pdt < pdtDebut + NombreDePasDeTempsDUneJournee; pdt++)
{
Expand Down Expand Up @@ -80,14 +84,14 @@ void BindingConstraintDay::add(int cntCouplante, BindingConstraintDayData& data)
std::vector<double*>& AdresseOuPlacerLaValeurDesCoutsMarginaux
= problemeHebdo->ProblemeAResoudre->AdresseOuPlacerLaValeurDesCoutsMarginaux;

char op = data.SensDeLaContrainteCouplante;
char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
builder.operatorRHS(op);
{
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
namer.UpdateTimeStep(jour);
namer.BindingConstraintDay(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
data.NomDeLaContrainteCouplante);
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
}
builder.build();
pdtDebut += problemeHebdo->NombreDePasDeTempsDUneJournee;
Expand Down
8 changes: 1 addition & 7 deletions src/solver/optimisation/BindingConstraintDay.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#pragma once
#include "constraint_builder.h"

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

void BindingConstraintHour::add(int pdt, int cntCouplante, BindingConstraintHourData& data)
void BindingConstraintHour::add(int pdt, int cntCouplante)
{
data.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
= problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
CORRESPONDANCES_DES_CONTRAINTES& CorrespondanceCntNativesCntOptim
= problemeHebdo->CorrespondanceCntNativesCntOptim[pdt];
CorrespondanceCntNativesCntOptim.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;

if (data.TypeDeContrainteCouplante != CONTRAINTE_HORAIRE)
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HORAIRE)
return;

builder.updateHourWithinWeek(pdt);
// Links
const int nbInterco = data.NombreDInterconnexionsDansLaContrainteCouplante;
const int nbInterco
= MatriceDesContraintesCouplantes.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];
const int interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[index];
const double poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[index];
const int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco[index];
int pdt1;
if (offset >= 0)
{
Expand All @@ -32,17 +37,17 @@ void BindingConstraintHour::add(int pdt, int cntCouplante, BindingConstraintHour
}

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

if (offset >= 0)
Expand All @@ -62,14 +67,14 @@ void BindingConstraintHour::add(int pdt, int cntCouplante, BindingConstraintHour
problemeHebdo->NombreDePasDeTemps);
}

char op = data.SensDeLaContrainteCouplante;
char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
builder.operatorRHS(op);
{
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
namer.UpdateTimeStep(problemeHebdo->weekInTheYear * 168 + pdt);
namer.BindingConstraintHour(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
data.NomDeLaContrainteCouplante);
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
}
builder.build();
}
6 changes: 1 addition & 5 deletions src/solver/optimisation/BindingConstraintHour.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#pragma once
#include "constraint_builder.h"
struct BindingConstraintHourData : public BindingConstraintData
{
std::vector<int>& NumeroDeContrainteDesContraintesCouplantes;
}

class BindingConstraintHour : private Constraint
{
public:
using Constraint::Constraint;
void add(int pdt, int cntCouplante, BindingConstraintHourData& data);
void add(int pdt, int cntCouplante);
};
69 changes: 37 additions & 32 deletions src/solver/optimisation/BindingConstraintWeek.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
#include "BindingConstraintWeek.h"

void BindingConstraintWeek::add(int cntCouplante, BindingConstraintWeekData& data)
void BindingConstraintWeek::add(int cntCouplante)
{
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
= problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante];
int semaine = problemeHebdo->weekInTheYear;
auto& NumeroDeContrainteDesContraintesCouplantes
= data.NumeroDeContrainteDesContraintesCouplantes;
if (data.TypeDeContrainteCouplante != CONTRAINTE_HEBDOMADAIRE)
CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondanceCntNativesCntOptimHebdomadaires
= problemeHebdo->CorrespondanceCntNativesCntOptimHebdomadaires;
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HEBDOMADAIRE)
return;

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

for (int index = 0; index < nbInterco; index++)
{
int interco = data.NumeroDeLInterconnexion[index];
double poids = data.PoidsDeLInterconnexion[index];
int offset = data.OffsetTemporelSurLInterco[index];
int interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[index];
double poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[index];
int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco[index];
for (int pdt = 0; pdt < problemeHebdo->NombreDePasDeTempsPourUneOptimisation; pdt++)
{
builder.updateHourWithinWeek(pdt);
Expand All @@ -36,16 +40,16 @@ void BindingConstraintWeek::add(int cntCouplante, BindingConstraintWeekData& dat

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

builder.updateHourWithinWeek(pdt); // useless?
Expand All @@ -64,21 +68,22 @@ void BindingConstraintWeek::add(int cntCouplante, BindingConstraintWeekData& dat
offset,
false,
problemeHebdo->NombreDePasDeTemps);
}
}
}

char op = data.SensDeLaContrainteCouplante;
builder.operatorRHS(op);
char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante;
builder.operatorRHS(op);

NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
// Name
{
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
namer.UpdateTimeStep(semaine);
namer.BindingConstraintWeek(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
data.NomDeLaContrainteCouplante);
}
CorrespondanceCntNativesCntOptimHebdomadaires
.NumeroDeContrainteDesContraintesCouplantes[cntCouplante]
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes;
// Name
{
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);
namer.UpdateTimeStep(semaine);
namer.BindingConstraintWeek(problemeHebdo->ProblemeAResoudre->NombreDeContraintes,
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante);
}
builder.build();
}
Loading

0 comments on commit bd394e3

Please sign in to comment.