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

refactor constraint construction #1627

Merged
merged 177 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
177 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
bd394e3
Revert "(does not compile) cut into small pieces"
a-zakir Sep 11, 2023
676c0a4
aesthetic
a-zakir Sep 13, 2023
1a29e44
remove comment
a-zakir Sep 13, 2023
fa422d6
smart move
a-zakir Sep 13, 2023
cee5edb
**** move
a-zakir Sep 13, 2023
a44c65e
shallow
a-zakir Sep 13, 2023
687d879
customize error exception
a-zakir Sep 13, 2023
9433f0a
work on "group 1"
a-zakir Sep 16, 2023
ee2c51f
fix
a-zakir Sep 16, 2023
7364bd5
update
a-zakir Sep 16, 2023
f01decd
small
a-zakir Sep 18, 2023
5932373
group of constraint
a-zakir Sep 18, 2023
3c16029
from free function to class (LinearProblemMatrixBuilder)
a-zakir Sep 18, 2023
3622cfb
update LinearProblemMatrixBuilder class
a-zakir Sep 18, 2023
84b7e0e
fix
a-zakir Sep 18, 2023
a653ada
continue to group
a-zakir Sep 18, 2023
8ed7085
implement week binding constraints group
a-zakir Sep 19, 2023
688b36d
add HydroPowerGroup
a-zakir Sep 19, 2023
9b6de6c
builder as ctor parameter
a-zakir Sep 19, 2023
8256c26
builder as ctor parameter
a-zakir Sep 19, 2023
ea87d43
update
a-zakir Sep 19, 2023
1321445
clean
a-zakir Sep 19, 2023
bb5e1b6
int is not a bool
a-zakir Sep 19, 2023
b3b9c1f
add Hydro Smoothing group
a-zakir Sep 19, 2023
b2a2988
MinMaxHydroPowerGroup
a-zakir Sep 19, 2023
065632a
rename
a-zakir Sep 20, 2023
496c1bb
new MaxPumpingGroup
a-zakir Sep 20, 2023
6533cab
AreaHydroLevelGroup
a-zakir Sep 20, 2023
086f72a
God commit
a-zakir Sep 27, 2023
03c246a
new FictitiousLoad
a-zakir Sep 27, 2023
f2e6166
New ShortTermStorageLevel
a-zakir Sep 27, 2023
0c9a8ca
New FlowDissociation
a-zakir Sep 27, 2023
fced3d6
NEw BindingConstraintHour
a-zakir Sep 27, 2023
ae4b0e0
delete copies
a-zakir Sep 27, 2023
eb0d6e8
New BindingConstraintDay
a-zakir Sep 27, 2023
3651700
about includes
a-zakir Sep 27, 2023
0d1e4bc
New BindingConstraintWeek
a-zakir Sep 27, 2023
5cfa55c
includes...
a-zakir Sep 27, 2023
7377886
HydroPower
a-zakir Sep 27, 2023
76d4039
include.......
a-zakir Sep 27, 2023
fce50aa
new HydroPowerSmoothingUsingVariationSum
a-zakir Sep 27, 2023
a5fb74d
new HydroPowerSmoothingUsingVariationMaxDown
a-zakir Sep 27, 2023
9f5bccf
new HydroPowerSmoothingUsingVariationMaxUP
a-zakir Sep 27, 2023
65ee688
MinHydroPower
a-zakir Sep 27, 2023
932d5c9
MaxHydroPower
a-zakir Sep 27, 2023
6d5bef6
MaxPumping
a-zakir Sep 27, 2023
f308c96
new AreaHydroLevel
a-zakir Sep 27, 2023
63b3040
setup FinalStockGroup
a-zakir Sep 27, 2023
0cc3d45
fix
a-zakir Sep 27, 2023
62241f8
shrink method: linear problem run
a-zakir Sep 27, 2023
958ae3a
decomposition
a-zakir Sep 27, 2023
2e6352e
remove duplicated includes
a-zakir Sep 27, 2023
8ea67a8
update
a-zakir Sep 27, 2023
cbc4059
make FinalStockGroup is built
a-zakir Sep 27, 2023
d42fcca
just stay up-to-date
a-zakir Oct 6, 2023
09760f3
merge conflict fix
a-zakir Oct 6, 2023
1c62402
Merge branch 'develop' into feature/reshape-constraint-construction
a-zakir Nov 3, 2023
4a17f03
new P{Min, Max}DispatchableGeneration & PMinMaxDispatchableGeneration…
a-zakir Nov 6, 2023
312a3a5
renew StartUpCosts
a-zakir Nov 6, 2023
b599a35
add NbUnitsOutageLessThanNbUnitsStopGroup
a-zakir Nov 6, 2023
5efb48c
minuptime
a-zakir Nov 7, 2023
87ba06a
remove copy error
a-zakir Nov 7, 2023
0947de7
new LinearProblemMatrixStartUpCosts
a-zakir Nov 7, 2023
1f7eddb
fix
a-zakir Nov 7, 2023
985d063
fix 2
a-zakir Nov 7, 2023
d270e8c
update CmakeLists.txt
a-zakir Nov 7, 2023
4a30f57
fix
a-zakir Nov 7, 2023
f867b95
include errors
a-zakir Nov 7, 2023
62add4f
fix read-write data
a-zakir Nov 7, 2023
bd9a530
add documentation
a-zakir Nov 7, 2023
5aadd06
add doc for StartUpCosts group of constraints
a-zakir Nov 7, 2023
1a37a86
remove deprecated
a-zakir Nov 7, 2023
6aa9d35
work on CsrQuadraticProblem / CsrFlowDissociation
a-zakir Nov 9, 2023
737b87c
missing include
a-zakir Nov 9, 2023
cc5b442
Update CsrFlowDissociation.h
a-zakir Nov 9, 2023
7d22d33
get rid of old code
a-zakir Nov 9, 2023
b74118a
inline function
a-zakir Nov 9, 2023
a55cd5c
CsrAreaBalance new way & rename
a-zakir Nov 9, 2023
921b322
fix : CsrAreaBalance = Group
a-zakir Nov 9, 2023
690349c
logic issue
a-zakir Nov 9, 2023
a90e7bd
fix doubled NegativeUnsuppliedEnergy
a-zakir Nov 9, 2023
47c92f1
:snake: CsrBindingConstraintHour :boom:
a-zakir Nov 9, 2023
31077ac
method call syntax
a-zakir Nov 9, 2023
34f0aef
remove old logs
a-zakir Nov 10, 2023
7df7f6e
remove old code
a-zakir Nov 10, 2023
473ee98
update QuadraticProblemMatrix
a-zakir Nov 10, 2023
293e87d
remove copy error
a-zakir Nov 10, 2023
5d05312
;
a-zakir Nov 10, 2023
f00844d
unused params
a-zakir Nov 10, 2023
039e180
add return type
a-zakir Nov 10, 2023
1514cec
it's :running:
a-zakir Nov 10, 2023
d632bf3
update
a-zakir Nov 10, 2023
7e49fe6
fix
a-zakir Nov 10, 2023
6154e44
remove old Style Constraint Builder
a-zakir Nov 13, 2023
599e749
ConstraintBuilder is the New ConstraintBuilder
a-zakir Nov 13, 2023
0ed0bee
rename file
a-zakir Nov 13, 2023
072ca6e
rename classes
a-zakir Nov 13, 2023
e98d6f6
keep renaming
a-zakir Nov 13, 2023
7de521b
rename new_exportPaliers
a-zakir Nov 13, 2023
ec4772b
transform shared_ptr data to ref: first try
a-zakir Nov 13, 2023
dde5d3e
FictitiousLoadData as ref
a-zakir Nov 13, 2023
84826d5
shortTermStorageLevelData :floppy_disk:
a-zakir Nov 13, 2023
f267c9a
FlowDissociationData
a-zakir Nov 13, 2023
2922556
BindingConstraintHourData
a-zakir Nov 13, 2023
0079281
bindingConstraintDayData
a-zakir Nov 13, 2023
68ba741
BindingConstraintWeekData
a-zakir Nov 13, 2023
59c0993
HydroPowerData
a-zakir Nov 13, 2023
ca3f587
Min/Max/HydroPowerData
a-zakir Nov 13, 2023
c70a3a0
MaxPumpingData
a-zakir Nov 13, 2023
109b725
AreaHydroLevelData
a-zakir Nov 13, 2023
c4cc825
data as ctor parameter
a-zakir Nov 13, 2023
30c8257
perf issue
a-zakir Nov 13, 2023
389cec5
fix perf issue
a-zakir Nov 13, 2023
e885483
small change
a-zakir Nov 13, 2023
6d2dcd0
updates
a-zakir Nov 13, 2023
d385be6
about FlowDissociationData
a-zakir Nov 13, 2023
6a463a0
optimized loop in bindingConstraintHour
a-zakir Nov 13, 2023
4f07212
remove empty line
a-zakir Nov 13, 2023
fcc3a71
continue refactor
a-zakir Nov 13, 2023
8d84c8e
re-work binding Constraint Week Data
a-zakir Nov 13, 2023
4fd81f8
move HydroPowerData to ctor
a-zakir Nov 13, 2023
b1d4871
set data once for {Min, Max}HydroPower
a-zakir Nov 14, 2023
53b72d8
skip windows & sonar
a-zakir Nov 14, 2023
26449a2
same for MaxPumping
a-zakir Nov 14, 2023
0f39ad4
we're ok AreaHydroLevelGroup
a-zakir Nov 14, 2023
41bf732
ok FinalStockGroup
a-zakir Nov 14, 2023
65fb1fa
fix
a-zakir Nov 14, 2023
16e9f0e
update StartUpCosts Group
a-zakir Nov 14, 2023
924b649
fix constraint index
a-zakir Nov 14, 2023
fc1ccd3
changes
a-zakir Nov 14, 2023
8a6887c
CsrAreaBalance
a-zakir Nov 14, 2023
2c17e51
no shared_ptr of data anymore!
a-zakir Nov 14, 2023
213463d
test MinDownTime elsewhere
a-zakir Nov 14, 2023
c665732
test NbDispUnitsMinBoundSinceMinUpTime out of it's inner loop
a-zakir Nov 14, 2023
7908b15
test NbUnitsOutageLessThanNbUnitsStop out of it's inner loop
a-zakir Nov 14, 2023
61a1c1d
big one
a-zakir Nov 14, 2023
28c7eb1
shared????
a-zakir Nov 14, 2023
8bbd2e9
reactivate w&s
a-zakir Nov 15, 2023
c469974
reshape constraint construction (#1815)
a-zakir Dec 13, 2023
912e3d3
new & newer
a-zakir Dec 13, 2023
4212098
@guilpier-code's remark
a-zakir Dec 15, 2023
a53474a
typo
a-zakir Dec 15, 2023
f2ed940
from PR
a-zakir Dec 15, 2023
8462829
move unrelated jobs from LinearProblemMatrix
a-zakir Dec 15, 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
2 changes: 1 addition & 1 deletion src/antares-deps
Submodule antares-deps updated 1 files
+1 −1 CMakeLists.txt
75 changes: 75 additions & 0 deletions src/solver/optimisation/AreaBalance.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "AreaBalance.h"
#include "opt_rename_problem.h"

static void shortTermStorageBalance(const ::ShortTermStorage::AREA_INPUT& shortTermStorageInput,
std::shared_ptr<NewConstraintBuilder> 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(NewVariable::ShortTermStorageInjection(index), 1.0);
}
if (const int varWithdrawal = WithdrawalVariable[index]; varWithdrawal >= 0)
{
constraintBuilder->include(NewVariable::ShortTermStorageWithdrawal(index), -1.0);
}
}
}

// Constraint definitions
void AreaBalance::odd(int pays, std::shared_ptr<AreaBalanceData> data)
{
int a = 13;
int b = a * 36;
logs.info() << "int odd builder->data->nombreDeContraintes"
<< builder->data->nombreDeContraintes << "\n";
logs.info() << "int odd data->NumeroDeContrainteDesBilansPays[pays]"
<< data->NumeroDeContrainteDesBilansPays[pays] << "\n";
data->NumeroDeContrainteDesBilansPays[pays] = builder->data->nombreDeContraintes;
logs.info() << "int odd 2" << a << "\n";
}
void AreaBalance::add(int pdt, int pays, std::shared_ptr<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(NewVariable::NTCDirect(interco), 1.0);
interco = data->IndexSuivantIntercoOrigine[interco];
}

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

new_exportPaliers(data->PaliersThermiquesDuPays, builder);
builder->include(NewVariable::HydProd(pays), -1.0)
.include(NewVariable::Pumping(pays), 1.0)
.include(NewVariable::PositiveUnsuppliedEnergy(pays), -1.0)
.include(NewVariable::NegativeUnsuppliedEnergy(pays), 1.0);

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

builder->equalTo();
builder->build();
}
25 changes: 25 additions & 0 deletions src/solver/optimisation/AreaBalance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "new_constraint_builder.h"

struct 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;
};

class AreaBalance : public NewConstraint
{
public:
using NewConstraint::NewConstraint;

void add(int pdt, int pays, std::shared_ptr<AreaBalanceData> data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must refrain, when not necessary, to use heap allocation (in particular for perf reason), and even more shared ownership (little perf but mostly for clarity sake).

Here the method will clearly not take ownership of the data, and not modify it --> it must be passed by const reference.

void add(int pdt, int pays, const AreaBalanceData& data);

Same thing everywhere in other constraint types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'v tried refs data & faced huge amount of segfault-ish bug #1617

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modify just a little bit : data->NumeroDeContrainteDesBilansPays[pays]=.....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! maybe a non const ref is needed.

Ok for the segaults issues: well, I think if we come over that again, we can find out another solution than doing heap allocation, because this should not really change the lifetime of our objects here (not completely true, they might be moved and possibly copied in a few places, but I don't think it should be an issue). Easier said than done though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sylvlecl shared what? ☺️

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

void AreaHydroLevel::add(int pays, int pdt)
{
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);
if (pdt > 0)
{
builder.updateHourWithinWeek(pdt - 1).include(Variable::HydroLevel(pays), -1.0);
}
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes,
problemeHebdo->NamedProblems);

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

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

void BindingConstraintDay::add(int cntCouplante, std::shared_ptr<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(NewVariable::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(
NewVariable::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;
}
}
19 changes: 19 additions & 0 deletions src/solver/optimisation/BindingConstraintDay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once
#include "new_constraint_builder.h"

struct BindingConstraintDayData : public BindingConstraintData
{
std::vector<CORRESPONDANCES_DES_CONTRAINTES_JOURNALIERES>&
CorrespondanceCntNativesCntOptimJournalieres;

const int32_t& NombreDePasDeTempsDUneJournee;

std::vector<int32_t>& NumeroDeJourDuPasDeTemps;
};

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

std::shared_ptr<BindingConstraintDayData>
BindingConstraintDayGroup::GetBindingConstraintDayDataFromProblemHebdo(int cntCouplante)
{
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes
= problemeHebdo_->MatriceDesContraintesCouplantes[cntCouplante];

BindingConstraintDayData data
= {MatriceDesContraintesCouplantes.TypeDeContrainteCouplante,
MatriceDesContraintesCouplantes.NombreDInterconnexionsDansLaContrainteCouplante,
MatriceDesContraintesCouplantes.NumeroDeLInterconnexion,
MatriceDesContraintesCouplantes.PoidsDeLInterconnexion,
MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco,
MatriceDesContraintesCouplantes.NombreDePaliersDispatchDansLaContrainteCouplante,
MatriceDesContraintesCouplantes.PaysDuPalierDispatch,
MatriceDesContraintesCouplantes.NumeroDuPalierDispatch,
MatriceDesContraintesCouplantes.PoidsDuPalierDispatch,
MatriceDesContraintesCouplantes.OffsetTemporelSurLePalierDispatch,
MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante,
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante,
problemeHebdo_->PaliersThermiquesDuPays,
problemeHebdo_->CorrespondanceCntNativesCntOptimJournalieres,
problemeHebdo_->NombreDePasDeTempsDUneJournee,
problemeHebdo_->NumeroDeJourDuPasDeTemps};

return std::make_shared<BindingConstraintDayData>(data);
}

void BindingConstraintDayGroup::Build()
{
BindingConstraintDay bindingConstraintDay(builder_);
for (uint32_t cntCouplante = 0; cntCouplante < problemeHebdo_->NombreDeContraintesCouplantes;
cntCouplante++)
{
bindingConstraintDay.add(cntCouplante,
GetBindingConstraintDayDataFromProblemHebdo(cntCouplante));
}
}
16 changes: 16 additions & 0 deletions src/solver/optimisation/BindingConstraintDayGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "ConstraintGroup.h"
#include "BindingConstraintDay.h"

class BindingConstraintDayGroup : public ConstraintGroup
{
public:
using ConstraintGroup::ConstraintGroup;

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

private:
std::shared_ptr<BindingConstraintDayData> GetBindingConstraintDayDataFromProblemHebdo(
int cntCouplante);
};
Loading