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

Fix mingen issues with several modifications #2395

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open

Conversation

flomnes
Copy link
Member

@flomnes flomnes commented Sep 12, 2024

  1. Remove truncation from weekly turbine credits (was done previously)
  2. Always enable monitoring of stock levels (including overflow)
  3. Take overflow into account in the "HydroPower" constraint (was done in 9.1.0)
  4. Remove recomputation of reservoir levels & overflow
  5. Correct infeasibility in hydro heuristic problem, related to mingen > 0

@flomnes flomnes changed the title Fix/overflow Fix mingen issues with several modifications Sep 12, 2024
@guilpier-code guilpier-code self-requested a review September 13, 2024 13:24
@@ -152,6 +152,9 @@ void SIM_InitialisationProblemeHebdo(Data::Study& study,

problem.CoutDeDefaillanceNegative[i] = area.thermal.spilledEnergyCost;

Copy link
Contributor

@guilpier-code guilpier-code Sep 13, 2024

Choose a reason for hiding this comment

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

It seems that removing the weekly truncation involves removing the whole block :

double weekGenerationTarget = 1.;
double marginGen = 1.;

if (area.hydro.reservoirManagement && area.hydro.useHeuristicTarget
    && not area.hydro.useLeeway)
{
     double weekTarget_tmp = 0.;
     for (uint j = 0; j < 7; ++j)
     {
          uint day = study.calendar.hours[PasDeTempsDebut + j * 24].dayYear;
         weekTarget_tmp += hydroVentilationResults[k]
                        HydrauliqueModulableQuotidien[day];
     }

     if (weekTarget_tmp != 0.)
     {
         weekGenerationTarget = weekTarget_tmp;
     }
     marginGen = weekGenerationTarget;
}

As well as the truncation coefficient marginGen / weekGenerationTarget.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean that since marginGen = weekGenerationTarget, marginGen / weekGenerationTarget is always 1 ?

Copy link
Contributor

@guilpier-code guilpier-code Sep 16, 2024

Choose a reason for hiding this comment

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

Exactly.
When we removed the troncation, we did not remove all what should have been.

Comment on lines +28 to +29
RUN_SIMPLE_TESTS: 'false'
RUN_EXTENDED_TESTS: 'false'
Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever the purpose of this change is (it could be so that CI completes and generates artefacts), we'll have not to forget reverting it.

Copy link

@@ -53,7 +53,7 @@ void H2O_J_InitialiserLesBornesdesVariables(DONNEES_MENSUELLES* DonneesMensuelle
int Var = CorrespondanceDesVariables.NumeroDeVariableTurbine[Pdt];
Xmax[Var] = TurbineMax[Pdt];

Xmin[Var] = std::min(TurbineMax[Pdt], std::max(TurbineCible[Pdt], TurbineMin[Pdt]));
Xmin[Var] = std::min(TurbineMax[Pdt], TurbineMin[Pdt]);
Copy link
Contributor

@guilpier-code guilpier-code Sep 16, 2024

Choose a reason for hiding this comment

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

So we no longer need to use TurbineCible in this function H2O_J_InitialiserLesBornesdesVariables(...).
Hence we should remove line :

const std::vector<double>& TurbineCible = DonneesMensuelles->TurbineCible;

@@ -53,7 +53,7 @@ void H2O_J_InitialiserLesBornesdesVariables(DONNEES_MENSUELLES* DonneesMensuelle
int Var = CorrespondanceDesVariables.NumeroDeVariableTurbine[Pdt];
Xmax[Var] = TurbineMax[Pdt];

Xmin[Var] = std::min(TurbineMax[Pdt], std::max(TurbineCible[Pdt], TurbineMin[Pdt]));
Xmin[Var] = std::min(TurbineMax[Pdt], TurbineMin[Pdt]);
Copy link
Contributor

Choose a reason for hiding this comment

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

About :

Xmax[Var] = TurbineMax[Pdt];
Xmin[Var] = std::min(TurbineMax[Pdt], TurbineMin[Pdt]);

It's strange that we give the lower bound of variable Turbine like this.
Reader could expect instead :

Xmin[Var] = TurbineMin[Pdt];
Xmax[Var] = TurbineMax[Pdt];

It seems that TurbineMax is not necessarily greater than TurbineMin for every day, which is strange.

Copy link
Collaborator

@nikolaredstork nikolaredstork Sep 16, 2024

Choose a reason for hiding this comment

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

I agree, since there is a precheck for each hour in checkGenerationPowerConsistency function, I don't see how TurbineMax in any situation can be lower than TurbineMin, but maybe I am wrong.

@@ -51,8 +51,6 @@ AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchP
// Here a post process particular to adq patch
post_process_list.push_back(
std::make_unique<DTGmarginForAdqPatchPostProcessCmd>(problemeHebdo_, areas, thread_number));
post_process_list.push_back(
Copy link
Contributor

@guilpier-code guilpier-code Sep 16, 2024

Choose a reason for hiding this comment

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

In the current PR presentation, it's said that the re-computation of hydro levels after weekly optimization should be removed.
And indeed, the post process class HydroLevelsUpdatePostProcessCmd was largely simplified : it now only converts levels from their adimensionnel version into MWh.
In that context, we can also see that this post-process is still called twice for modes adequacy & economy, which leads to wrong hydro levels values.

What we should do :

  • This class should therefore be renamed into HydroLevelsConversionIntoMWhCmd for more clarity.
  • Its method execute(...) should be called once (for a given simulation mode).
  • We should take advantage of this to remove boolean remixWasRun, no longer useful.
  • If it turns out the other boolean computeAnyway is not really needed, then remove it.

= area.hydro.reservoirManagement && (problem.OptimisationAuPasHebdomadaire)
&& (!area.hydro.useHeuristicTarget
|| problem.CaracteristiquesHydrauliques[i].PresenceDePompageModulable);
problem.CaracteristiquesHydrauliques[i].SuiviNiveauHoraire = area.hydro.reservoirManagement;
Copy link
Contributor

Choose a reason for hiding this comment

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

About SuiviNiveauHoraire : if this boolean equals reservoirManagement, let's call it reservoirManagement and avoid a parameter to be named in two different ways.
It would lower complexity.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree, if we go on with this change, we'll simply remove SuiviNiveauHoraire.

&& problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
{
ProblemeAResoudre->NombreDeContraintes++;
}

if (Pump && !TurbEntreBornes && !MonitorHourlyLev)
ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;
Copy link
Contributor

@guilpier-code guilpier-code Sep 17, 2024

Choose a reason for hiding this comment

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

About :

ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;

This instruction suddenly appears.
Why ? Was the previous code incorrect ?
Or is it about overflows back in the game ?
We should add a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

No the estimation of variables & constraints is incorrect. There was an underestimation, which lead to segfaults.

&& problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
{
ProblemeAResoudre->NombreDeContraintes++;
}

if (Pump && !TurbEntreBornes && !MonitorHourlyLev)
ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;
Copy link
Contributor

@guilpier-code guilpier-code Sep 17, 2024

Choose a reason for hiding this comment

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

This file contains no comment that relates a count increment to a set of constraints.
It's unclear : which increment correspond to which set of constraints ?
Besides, this way of counting constraints apart from the constraints themselves is very much error prone : it's very easy to add / remove constraints and not update the constraints count.
Adding / removing a constraint should automatically update the constraint count.

But this will be for another PR.

@@ -275,26 +275,19 @@ void OPT_InitialiserLesCoutsLineaire(PROBLEME_HEBDO* problemeHebdo,

Copy link
Contributor

Choose a reason for hiding this comment

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

We should update the comment that explains the cost we give to the hydro overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants