-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement week binding constraints group
- Loading branch information
Showing
8 changed files
with
141 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,80 @@ | ||
#include "BindingConstraintWeek.h" | ||
|
||
void BindingConstraintWeek::add(int cntCouplante) | ||
void BindingConstraintWeek::add(int cntCouplante, std::shared_ptr<BindingConstraintWeekData> data) | ||
{ | ||
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes | ||
= problemeHebdo->MatriceDesContraintesCouplantes[cntCouplante]; | ||
int semaine = problemeHebdo->weekInTheYear; | ||
CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondanceCntNativesCntOptimHebdomadaires | ||
= problemeHebdo->CorrespondanceCntNativesCntOptimHebdomadaires; | ||
if (MatriceDesContraintesCouplantes.TypeDeContrainteCouplante != CONTRAINTE_HEBDOMADAIRE) | ||
int semaine = builder->data->weekInTheYear; | ||
if (data->TypeDeContrainteCouplante != CONTRAINTE_HEBDOMADAIRE) | ||
return; | ||
|
||
const int nbInterco | ||
= MatriceDesContraintesCouplantes.NombreDInterconnexionsDansLaContrainteCouplante; | ||
const int nbClusters | ||
= MatriceDesContraintesCouplantes.NombreDePaliersDispatchDansLaContrainteCouplante; | ||
const int nbInterco = data->NombreDInterconnexionsDansLaContrainteCouplante; | ||
const int nbClusters = data->NombreDePaliersDispatchDansLaContrainteCouplante; | ||
|
||
for (int index = 0; index < nbInterco; index++) | ||
{ | ||
int interco = MatriceDesContraintesCouplantes.NumeroDeLInterconnexion[index]; | ||
double poids = MatriceDesContraintesCouplantes.PoidsDeLInterconnexion[index]; | ||
int offset = MatriceDesContraintesCouplantes.OffsetTemporelSurLInterco[index]; | ||
for (int pdt = 0; pdt < problemeHebdo->NombreDePasDeTempsPourUneOptimisation; pdt++) | ||
int interco = data->NumeroDeLInterconnexion[index]; | ||
double poids = data->PoidsDeLInterconnexion[index]; | ||
int offset = data->OffsetTemporelSurLInterco[index]; | ||
for (int pdt = 0; pdt < builder->data->NombreDePasDeTempsPourUneOptimisation; pdt++) | ||
{ | ||
builder.updateHourWithinWeek(pdt).include( | ||
Variable::NTCDirect(interco), poids, offset, true, problemeHebdo->NombreDePasDeTemps); | ||
builder->updateHourWithinWeek(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++) | ||
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 = 0; pdt < builder->data->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? | ||
if (offset >= 0) | ||
{ | ||
pdt1 = (pdt + offset) % builder->data->NombreDePasDeTempsPourUneOptimisation; | ||
} | ||
else | ||
{ | ||
builder.updateHourWithinWeek(pdt).include(Variable::DispatchableProduction(palier), | ||
poids, | ||
offset, | ||
true, | ||
problemeHebdo->NombreDePasDeTemps); | ||
pdt1 = (pdt + offset + builder->data->NombreDePasDeTemps) | ||
% builder->data->NombreDePasDeTempsPourUneOptimisation; | ||
} | ||
|
||
builder->updateHourWithinWeek(pdt1).include(NewVariable::DispatchableProduction(palier), | ||
poids, | ||
offset, | ||
false, | ||
builder->data->NombreDePasDeTemps); | ||
} | ||
} | ||
|
||
char op = MatriceDesContraintesCouplantes.SensDeLaContrainteCouplante; | ||
builder.SetOperator(op); | ||
char op = data->SensDeLaContrainteCouplante; | ||
builder->operatorRHS(op); | ||
|
||
CorrespondanceCntNativesCntOptimHebdomadaires | ||
.NumeroDeContrainteDesContraintesCouplantes[cntCouplante] | ||
= problemeHebdo->ProblemeAResoudre->NombreDeContraintes; | ||
data->NumeroDeContrainteDesContraintesCouplantes[cntCouplante] | ||
= builder->data->nombreDeContraintes; | ||
// Name | ||
{ | ||
ConstraintNamer namer(problemeHebdo->ProblemeAResoudre->NomDesContraintes, | ||
problemeHebdo->NamedProblems); | ||
namer.UpdateTimeStep(semaine); | ||
namer.BindingConstraintWeek(problemeHebdo->ProblemeAResoudre->NombreDeContraintes, | ||
MatriceDesContraintesCouplantes.NomDeLaContrainteCouplante); | ||
ConstraintNamer namer(builder->data->NomDesContraintes, builder->data->NamedProblems); | ||
namer.UpdateTimeStep(semaine); | ||
namer.BindingConstraintWeek(builder->data->nombreDeContraintes, | ||
data->NomDeLaContrainteCouplante); | ||
} | ||
builder.build(); | ||
builder->build(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
#pragma once | ||
#include "constraint_builder.h" | ||
#include "new_constraint_builder.h" | ||
|
||
class BindingConstraintWeek : private Constraint | ||
struct BindingConstraintWeekData : public BindingConstraintData | ||
{ | ||
std::vector<int>& NumeroDeContrainteDesContraintesCouplantes; | ||
}; | ||
|
||
class BindingConstraintWeek : private NewConstraint | ||
{ | ||
public: | ||
using Constraint::Constraint; | ||
void add(int cntCouplante); | ||
using NewConstraint::NewConstraint; | ||
void add(int cntCouplante, std::shared_ptr<BindingConstraintWeekData> data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "BindingConstraintWeekGroup.h" | ||
#include "new_constraint_builder_utils.h" | ||
|
||
std::shared_ptr<BindingConstraintWeekData> | ||
BindingConstraintWeekGroup::GetBindingConstraintWeekDataFromProblemHebdo(int cntCouplante) | ||
{ | ||
const CONTRAINTES_COUPLANTES& MatriceDesContraintesCouplantes | ||
= problemeHebdo_->MatriceDesContraintesCouplantes[cntCouplante]; | ||
|
||
BindingConstraintWeekData 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_->CorrespondanceCntNativesCntOptimHebdomadaires | ||
.NumeroDeContrainteDesContraintesCouplantes}; | ||
|
||
return std::make_shared<BindingConstraintWeekData>(data); | ||
} | ||
|
||
void BindingConstraintWeekGroup::Build() | ||
{ | ||
std::shared_ptr<NewConstraintBuilder> builder( | ||
NewGetConstraintBuilderFromProblemHebdo(problemeHebdo_)); | ||
BindingConstraintWeek bindingConstraintWeek(builder); | ||
|
||
if (problemeHebdo_->NombreDePasDeTempsPourUneOptimisation | ||
> problemeHebdo_->NombreDePasDeTempsDUneJournee) | ||
{ | ||
CORRESPONDANCES_DES_CONTRAINTES_HEBDOMADAIRES& CorrespondanceCntNativesCntOptimHebdomadaires | ||
= problemeHebdo_->CorrespondanceCntNativesCntOptimHebdomadaires; | ||
for (uint32_t cntCouplante = 0; | ||
cntCouplante < problemeHebdo_->NombreDeContraintesCouplantes; | ||
cntCouplante++) | ||
{ | ||
bindingConstraintWeek.add(cntCouplante, | ||
GetBindingConstraintWeekDataFromProblemHebdo(cntCouplante)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
#include "ConstraintGroup.h" | ||
#include "BindingConstraintWeek.h" | ||
|
||
class BindingConstraintWeekGroup : public ConstraintGroup | ||
{ | ||
public: | ||
using ConstraintGroup::ConstraintGroup; | ||
|
||
/*TODO Rename this*/ | ||
void Build() override; | ||
|
||
private: | ||
std::shared_ptr<BindingConstraintWeekData> GetBindingConstraintWeekDataFromProblemHebdo( | ||
int cntCouplante); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters