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 accurate remix hydro #2599

Open
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
cb98071
Save results for overflow
flomnes Aug 1, 2024
58aec04
Disable tests (windows)
flomnes Aug 1, 2024
fa1653a
Try boost fix
flomnes Aug 1, 2024
27aa0bd
Disable tests
flomnes Aug 1, 2024
2c96b63
Remove truncation
Aug 1, 2024
38473a4
Change overflow cost
Aug 1, 2024
b01a028
Change overflow cost
Aug 2, 2024
28999d9
Save results for overflow
flomnes Aug 1, 2024
a138d8b
Change overflow cost
Aug 1, 2024
39793d9
Change overflow cost
Aug 2, 2024
b050671
Fix infeasibility in H2O_J problem
flomnes Sep 11, 2024
ac97a13
Remove HydroLevelsUpdatePostProcessCmd, etc.
flomnes Sep 11, 2024
862c092
Add overflow cost
flomnes Sep 11, 2024
de425d1
SuiviNiveauHoraire = true
flomnes Sep 11, 2024
8c4508b
Remove unused class computeTimeStepLevel
flomnes Sep 11, 2024
53f4417
Merge remote-tracking branch 'github/develop' into fix/overflow
Sep 12, 2024
606fde2
Post-merge
Sep 12, 2024
dec51f4
Merge remote-tracking branch 'github/fix/overflow' into fix/overflow
Sep 12, 2024
c9848a8
Merge remote-tracking branch 'github/develop' into fix/overflow
Sep 12, 2024
ba54eed
Remove forgotten HydroLevelsUpdatePostProcessCmd
Sep 12, 2024
69d4ef7
Fix
Sep 12, 2024
792b1f6
Cout de remplissage
Sep 12, 2024
f04faf9
Counting
Sep 12, 2024
0f1e82b
Re-introduce computingHydroLevels, only for scaling
Sep 12, 2024
4245407
CoutDeRemplissage
Sep 12, 2024
0b08645
Fix
flomnes Sep 13, 2024
6398513
Merge remote-tracking branch 'github/develop' into fix/overflow
flomnes Sep 13, 2024
53bdf5f
Disable some tests
flomnes Sep 13, 2024
a67c089
Add reset for levelCost
flomnes Sep 16, 2024
4189a3e
Add load for levelCost
flomnes Sep 16, 2024
1d00468
Merge remote-tracking branch 'origin/develop' into HEAD
flomnes Jan 13, 2025
3808849
Fix build
flomnes Jan 13, 2025
b99e64b
Remove truncation
Juliette-Gerbaux Jan 14, 2025
045774a
Add logs
Jan 14, 2025
8116596
Edit logs
Jan 14, 2025
fa0b208
Edit logs
Jan 15, 2025
8c0da95
Change rhs hydro constraint
Jan 22, 2025
ae5e81a
Add efficiency and reservoir management
Jan 23, 2025
2944608
Increase tolerance
Jan 23, 2025
924d0e4
Time remix hydro
Jan 24, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ on:
env:
GITHUB_TOKEN: ${{ github.token }}
IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }}
RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }}
RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }}
RUN_SIMPLE_TESTS: 'false'
RUN_EXTENDED_TESTS: 'false'
REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}}
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
triplet: x64-linux
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ on:
env:
GITHUB_TOKEN: ${{ github.token }}
IS_RELEASE: ${{ github.event_name == 'workflow_dispatch' }}
RUN_SIMPLE_TESTS: ${{ github.event_name == 'push' || inputs.run-tests == 'true' }}
RUN_EXTENDED_TESTS: ${{ github.event_name == 'schedule' || inputs.run-tests == 'true' }}
RUN_SIMPLE_TESTS: 'false'
RUN_EXTENDED_TESTS: 'false'
REF: ${{ inputs.target_branch =='' && github.ref || inputs.target_branch}}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ class PartHydro

std::vector<std::optional<double>> deltaBetweenFinalAndInitialLevels;

double overflowCost = 0.;
double levelCost = 0.;

private:
static bool checkReservoirLevels(const Study& study);
static bool checkProperties(Study& study);
Expand Down
26 changes: 25 additions & 1 deletion src/libs/antares/study/parts/hydro/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ void PartHydro::reset()
powerToLevel = false;
leewayLowerBound = 1.;
leewayUpperBound = 1.;
overflowCost = 0.;
levelCost = 0.;

inflowPattern.reset(1, DAYS_PER_YEAR, true);
inflowPattern.fillColumn(0, 1.0);
Expand Down Expand Up @@ -324,6 +326,16 @@ bool PartHydro::LoadFromFolder(Study& study, const fs::path& folder)
&& ret;
}

if (IniFile::Section* section = ini.find("overflow cost"))
{
ret = loadProperties(study, section->firstProperty, path, &PartHydro::overflowCost) && ret;
}

if (IniFile::Section* section = ini.find("level cost"))
{
ret = loadProperties(study, section->firstProperty, path, &PartHydro::levelCost) && ret;
}

return ret;
}

Expand Down Expand Up @@ -494,6 +506,8 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder)
IniFile::Section* sLeewayLow;
IniFile::Section* sLeewayUp;
IniFile::Section* spumpingEfficiency;
IniFile::Section* sOverflowCost;
IniFile::Section* sLevelCost;

AllSections(IniFile& ini):
s(ini.addSection("inter-daily-breakdown")),
Expand All @@ -510,7 +524,9 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder)
sPowerToLevel(ini.addSection("power to level")),
sLeewayLow(ini.addSection("leeway low")),
sLeewayUp(ini.addSection("leeway up")),
spumpingEfficiency(ini.addSection("pumping efficiency"))
spumpingEfficiency(ini.addSection("pumping efficiency")),
sOverflowCost(ini.addSection("overflow cost")),
sLevelCost(ini.addSection("level cost"))
{
}
};
Expand Down Expand Up @@ -566,6 +582,14 @@ bool PartHydro::SaveToFolder(const AreaList& areas, const AnyString& folder)
{
allSections.sPowerToLevel->add(area.id, true);
}
if (area.hydro.overflowCost)
{
allSections.sOverflowCost->add(area.id, area.hydro.overflowCost);
}
if (area.hydro.levelCost)
{
allSections.sLevelCost->add(area.id, area.hydro.levelCost);
}

// max hours gen
buffer.clear() << folder << SEP << "common" << SEP << "capacity" << SEP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

AdresseOuPlacerLaValeurDesVariablesOptimisees[Var] = &(Turbine[Pdt]);
}
Expand Down
7 changes: 5 additions & 2 deletions src/solver/hydro/management/daily.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,11 @@ inline void HydroManagement::prepareDailyOptimalGenerations(
for (uint day = firstDay; day != endDay; ++day)
{
ventilationResults.HydrauliqueModulableQuotidien[day] = problem
.Turbine[dayMonth]
* reservoirCapacity;
.Turbine[dayMonth]
* reservoirCapacity
+ problem.overflows
[dayMonth]
* reservoirCapacity;

ventilationResults.NiveauxReservoirsFinJours[day] = problem.niveauxFinJours
[dayMonth];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ AdqPatchPostProcessList::AdqPatchPostProcessList(const AdqPatchParams& adqPatchP
std::make_unique<DTGnettingAfterCSRcmd>(problemeHebdo_, areas, numSpace));
post_process_list.push_back(
std::make_unique<UpdateMrgPriceAfterCSRcmd>(problemeHebdo_, areas, numSpace));
post_process_list.push_back(
std::make_unique<HydroLevelsUpdatePostProcessCmd>(problemeHebdo_, areas, true, false));
post_process_list.push_back(
std::make_unique<InterpolateWaterValuePostProcessCmd>(problemeHebdo_, areas, calendar));
post_process_list.push_back(
Expand Down
24 changes: 9 additions & 15 deletions src/solver/optimisation/opt_decompte_variables_et_contraintes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
char Pump = problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDePompageModulable;
char TurbEntreBornes = problemeHebdo->CaracteristiquesHydrauliques[pays]
.TurbinageEntreBornes;
char MonitorHourlyLev = problemeHebdo->CaracteristiquesHydrauliques[pays]
.SuiviNiveauHoraire;

if (!Pump && !TurbEntreBornes && !MonitorHourlyLev
if (!Pump && !TurbEntreBornes
&& problemeHebdo->CaracteristiquesHydrauliques[pays].PresenceDHydrauliqueModulable)
{
ProblemeAResoudre->NombreDeContraintes++;
}

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

if (Pump && !TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes += 2; /* 2 constraints bounding the overall
energy generated over the period (10a in
Expand All @@ -152,14 +152,14 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
period (10c in the reference document) */
}

if (!Pump && TurbEntreBornes && !MonitorHourlyLev)
if (!Pump && TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes++;

ProblemeAResoudre->NombreDeContraintes++;
}

if (Pump && TurbEntreBornes && !MonitorHourlyLev)
if (Pump && TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes++;

Expand All @@ -168,7 +168,7 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
ProblemeAResoudre->NombreDeContraintes++;
}

if (!Pump && TurbEntreBornes && MonitorHourlyLev)
if (!Pump && TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes++;

Expand All @@ -177,7 +177,7 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;
}

if (Pump && TurbEntreBornes && MonitorHourlyLev)
if (Pump && TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes++;

Expand All @@ -187,7 +187,7 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*

ProblemeAResoudre->NombreDeContraintes += nombreDePasDeTempsPourUneOptimisation;
}
if (Pump && !TurbEntreBornes && MonitorHourlyLev)
if (Pump && !TurbEntreBornes)
{
ProblemeAResoudre->NombreDeContraintes += 2; /* 2 constraints bounding the overall
energy generated over the period (10a in
Expand All @@ -203,12 +203,6 @@ int OPT_DecompteDesVariablesEtDesContraintesDuProblemeAOptimiser(PROBLEME_HEBDO*
variations (14a in the reference
document) */
}
if (!Pump && !TurbEntreBornes && MonitorHourlyLev)
{
const std::string areaName(problemeHebdo->NomsDesPays[pays]);
throw FatalError("Level explicit modeling requires flexible generation in area "
+ areaName);
}
}
// Short term storage
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,16 @@ void OPT_InitialiserLesBornesDesVariablesDuProblemeLineaire(PROBLEME_HEBDO* prob
}

var = variableManager.Overflow(pays, pdtJour);

problemeHebdo->ResultatsHoraires[pays].debordementsHoraires[pdtHebdo] = 0.;
if (var >= 0)
{
Xmin[var] = 0.0;
Xmax[var] = problemeHebdo->CaracteristiquesHydrauliques[pays]
.ApportNaturelHoraire[pdtHebdo];
AdresseOuPlacerLaValeurDesCoutsReduits[var] = nullptr;
AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = nullptr;
AdresseOuPlacerLaValeurDesVariablesOptimisees[var] = &problemeHebdo
->ResultatsHoraires[pays]
.debordementsHoraires
[pdtHebdo];
}

var = variableManager.HydroLevel(pays, pdtJour);
Expand Down
11 changes: 2 additions & 9 deletions src/solver/optimisation/opt_gestion_des_couts_cas_lineaire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,26 +292,19 @@ void OPT_InitialiserLesCoutsLineaire(PROBLEME_HEBDO* problemeHebdo,

*/

ProblemeAResoudre->CoutLineaire[var] = problemeHebdo->CoutDeDebordement[pays];
if (!problemeHebdo->CaracteristiquesHydrauliques[pays].AccurateWaterValue)
{
ProblemeAResoudre->CoutLineaire[var] = problemeHebdo
->CoutDeDefaillanceNegative[pays];

ProblemeAResoudre->CoutLineaire[var] += problemeHebdo
->CaracteristiquesHydrauliques[pays]
.WeeklyWaterValueStateRegular;
}
else
{
ProblemeAResoudre->CoutLineaire[var] = problemeHebdo
->CoutDeDefaillanceNegative[pays];
}
}

var = variableManager.HydroLevel(pays, pdtJour);
if (var >= 0 && var < ProblemeAResoudre->NombreDeVariables)
{
ProblemeAResoudre->CoutLineaire[var] = 0;
ProblemeAResoudre->CoutLineaire[var] = problemeHebdo->CoutDeRemplissage[pays];
}

var = variableManager.PositiveUnsuppliedEnergy(pays, pdtJour);
Expand Down
26 changes: 2 additions & 24 deletions src/solver/simulation/common-hydro-levels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,12 @@ void computingHydroLevels(const Data::AreaList& areas,
uint index = area->index;

double reservoirCapacity = area->hydro.reservoirCapacity;

std::vector<double>& inflows = problem.CaracteristiquesHydrauliques[index]
.ApportNaturelHoraire;

RESULTATS_HORAIRES& weeklyResults = problem.ResultatsHoraires[index];

std::vector<double>& turb = weeklyResults.TurbinageHoraire;

std::vector<double>& pump = weeklyResults.PompageHoraire;
double pumpingRatio = area->hydro.pumpingEfficiency;

double nivInit = problem.CaracteristiquesHydrauliques[index].NiveauInitialReservoir;
std::vector<double>& niv = weeklyResults.niveauxHoraires;

std::vector<double>& ovf = weeklyResults.debordementsHoraires;

computeTimeStepLevel
computeLvlObj(nivInit, inflows, ovf, turb, pumpingRatio, pump, reservoirCapacity);

for (uint h = 0; h < nbHoursInAWeek - 1; h++)
for (uint h = 0; h < nbHoursInAWeek; h++)
{
computeLvlObj.run();
niv[h] = computeLvlObj.getLevel() * 100 / reservoirCapacity;
computeLvlObj.prepareNextStep();
niv[h] = niv[h] * 100 / reservoirCapacity;
}

computeLvlObj.run();
niv[nbHoursInAWeek - 1] = computeLvlObj.getLevel() * 100 / reservoirCapacity;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/solver/simulation/common-hydro-remix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ static void RunAccurateShavePeaks(const Data::AreaList& areas,
const double initLevel = problem.CaracteristiquesHydrauliques[area.index]
.NiveauInitialReservoir;
const double capacity = area.hydro.reservoirCapacity;
const double efficiency = area.hydro.pumpingEfficiency;
const bool reservoir_management = area.hydro.reservoirManagement;
const auto& inflows = problem.CaracteristiquesHydrauliques[area.index]
.ApportNaturelHoraire;
const auto& ovf = weeklyResults.debordementsHoraires;
Expand All @@ -299,6 +301,8 @@ static void RunAccurateShavePeaks(const Data::AreaList& areas,
hydroPmin,
initLevel,
capacity,
efficiency,
reservoir_management,
inflows,
ovf,
pump,
Expand All @@ -317,6 +321,8 @@ void RemixHydroForAllAreas(const Data::AreaList& areas,
uint numSpace,
uint hourInYear)
{
auto started = std::chrono::high_resolution_clock::now();

if (sheddingPolicy == Data::shpShavePeaks)
{
bool result = true;
Expand Down Expand Up @@ -352,5 +358,9 @@ void RemixHydroForAllAreas(const Data::AreaList& areas,
throw assertErrException;
}
}
auto done = std::chrono::high_resolution_clock::now();
Antares::logs.notice()
<< "Remix hydro for this week took : "
<< std::chrono::duration_cast<std::chrono::nanoseconds>(done - started).count() << " ns.";
}
} // namespace Antares::Solver::Simulation
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RemixHydroOutput shavePeaksByRemixingHydro(const std::vector<double>& DispatchGe
const std::vector<double>& HydroPmin,
double init_level,
double capacity,
double efficiency,
bool reservoir_management,
const std::vector<double>& inflow,
const std::vector<double>& overflow,
const std::vector<double>& pump,
Expand Down
Loading
Loading