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

Collect hydro validation errors #2204

Merged
merged 43 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8abf571
Small refactor on hydro final checks (#2192)
flomnes Jun 26, 2024
899f2c9
HydroErrorsCollector
a-zakir Jun 26, 2024
5cb7f71
update
a-zakir Jun 26, 2024
4a93e61
update
a-zakir Jun 27, 2024
e1b2794
update
a-zakir Jun 27, 2024
b0952f8
fix
a-zakir Jun 27, 2024
082860e
logic
a-zakir Jun 27, 2024
a78dfc4
update
a-zakir Jun 27, 2024
63d6bb6
fix
a-zakir Jun 27, 2024
fd387a0
fix test
a-zakir Jun 27, 2024
bb397bb
fix app
a-zakir Jun 27, 2024
b1f086f
update
a-zakir Jun 27, 2024
094ca38
update
a-zakir Jun 27, 2024
1939315
add param
a-zakir Jun 27, 2024
0c574ff
update
a-zakir Jun 27, 2024
9968b06
update namespace
a-zakir Jun 27, 2024
4edf2d4
add include
a-zakir Jun 27, 2024
5fe27cf
update member var
a-zakir Jun 27, 2024
1c0ee43
update namespace
a-zakir Jun 27, 2024
9b4a09c
update
a-zakir Jun 28, 2024
e5a8085
update
a-zakir Jun 28, 2024
3419127
update
a-zakir Jun 28, 2024
eb94414
fix
a-zakir Jun 28, 2024
ad58ea1
fix
a-zakir Jun 28, 2024
dbb743b
change container
a-zakir Jun 28, 2024
f1c846d
Merge remote-tracking branch 'github/develop' into feature/hydro-erro…
flomnes Jul 1, 2024
37aac75
Format
flomnes Jul 1, 2024
18afdbb
update
a-zakir Jul 1, 2024
8885fa7
update
a-zakir Jul 1, 2024
fda4e11
update
a-zakir Jul 1, 2024
967cea2
fix
a-zakir Jul 1, 2024
2b657ee
fix
a-zakir Jul 1, 2024
5add173
update includes
a-zakir Jul 1, 2024
131e068
Update src/solver/hydro/management/HydroInputsChecker.cpp
a-zakir Jul 1, 2024
db0561c
update
a-zakir Jul 1, 2024
0d047fb
update
a-zakir Jul 1, 2024
5292428
test
a-zakir Jul 1, 2024
d0e15f2
update
a-zakir Jul 2, 2024
60a9774
filter keys
a-zakir Jul 2, 2024
c2b21cc
revert
a-zakir Jul 2, 2024
ace4ab2
update
a-zakir Jul 2, 2024
9e22ab3
update
a-zakir Jul 2, 2024
f77b6e1
Complete hydro logs (#2221)
flomnes Jul 2, 2024
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: 0 additions & 2 deletions src/libs/antares/study/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ set(SRC_STUDY_PART_HYDRO
include/antares/study/parts/hydro/allocation.h
include/antares/study/parts/hydro/allocation.hxx
parts/hydro/allocation.cpp
include/antares/study/parts/hydro/finalLevelValidator.h
parts/hydro/finalLevelValidator.cpp
include/antares/study/parts/hydro/hydromaxtimeseriesreader.h
parts/hydro/hydromaxtimeseriesreader.cpp
)
Expand Down
6 changes: 4 additions & 2 deletions src/solver/hydro/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ set(SRC_MANAGEMENT
management/MinGenerationScaling.cpp
include/antares/solver/hydro/management/HydroInputsChecker.h
management/HydroInputsChecker.cpp
include/antares/solver/hydro/management/hydro-final-reservoir-level-functions.h
management/hydro-final-reservoir-level-functions.cpp
include/antares/solver/hydro/management/HydroErrorsCollector.h
management/HydroErrorsCollector.cpp
include/antares/solver/hydro/management/finalLevelValidator.h
management/finalLevelValidator.cpp
)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
** Copyright 2007-2024, RTE (https://www.rte-france.com)
** See AUTHORS.txt
** SPDX-License-Identifier: MPL-2.0
** This file is part of Antares-Simulator,
** Adequacy and Performance assessment for interconnected energy networks.
**
** Antares_Simulator is free software: you can redistribute it and/or modify
** it under the terms of the Mozilla Public Licence 2.0 as published by
** the Mozilla Foundation, either version 2 of the License, or
** (at your option) any later version.
**
** Antares_Simulator is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** Mozilla Public Licence 2.0 for more details.
**
** You should have received a copy of the Mozilla Public Licence 2.0
** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/

#pragma once
#include <map>
#include <string>

namespace Antares
{
class HydroErrorsCollector
{
public:
HydroErrorsCollector() = default;
void Collect(const std::string& area_name, const std::string& message);
void Collect(const std::string& message);
void CheckForFatalErrors() const;

private:
std::map<std::string, unsigned int> area_errors_counter_;
bool errors_limit_reached_ = false;
bool stop_ = false;
// std::vector<std::string> fatal_errors_;
};
} // namespace Antares
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#pragma once
#include <antares/study/area/area.h>
#include "antares/date/date.h"
#include "antares/solver/hydro/management/HydroErrorsCollector.h"
#include "antares/solver/hydro/management/MinGenerationScaling.h"
#include "antares/solver/hydro/management/PrepareInflows.h"
#include "antares/study/study.h"
Expand All @@ -33,31 +34,31 @@ class HydroInputsChecker
public:
explicit HydroInputsChecker(Antares::Data::Study& study);
void Execute(uint year);
void CheckForFatalErrors() const;
void CheckFinalReservoirLevelsConfiguration(uint year);

private:
Data::AreaList& areas_;
const Data::Parameters& parameters_;
const Date::Calendar& calendar_;
Data::SimulationMode simulationMode_;
const uint firstYear_;
const uint endYear_;
PrepareInflows prepareInflows_;
MinGenerationScaling minGenerationScaling_;
const Data::TimeSeries::TS& scenarioInitialHydroLevels_;
const Data::TimeSeries::TS& scenarioFinalHydroLevels_;
HydroErrorsCollector errorCollector_;

//! return false if checkGenerationPowerConsistency or checkMinGeneration returns false
bool checkMonthlyMinGeneration(uint year, const Data::Area& area) const;
bool checkMonthlyMinGeneration(uint year, const Data::Area& area);
//! check Yearly minimum generation is lower than available inflows
bool checkYearlyMinGeneration(uint year, const Data::Area& area) const;
bool checkYearlyMinGeneration(uint year, const Data::Area& area);
//! check Weekly minimum generation is lower than available inflows
bool checkWeeklyMinGeneration(uint year, const Data::Area& area) const;
bool checkWeeklyMinGeneration(uint year, const Data::Area& area);
//! check Hourly minimum generation is lower than available inflows
bool checkGenerationPowerConsistency(uint year) const;
bool checkGenerationPowerConsistency(uint year);
//! return false if checkGenerationPowerConsistency or checkMinGeneration returns false
bool checksOnGenerationPowerBounds(uint year) const;
bool checksOnGenerationPowerBounds(uint year);
//! check minimum generation is lower than available inflows
bool checkMinGeneration(uint year) const;
bool checkMinGeneration(uint year);
};

} // namespace Antares
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,30 @@
*/
#pragma once

#include "antares/solver/hydro/management/HydroErrorsCollector.h"
#include "antares/study/parts/hydro/container.h"

namespace Antares::Data
namespace Antares
{
namespace Data
{
class PartHydro;
}

namespace Solver
{
class FinalLevelValidator
{
public:
FinalLevelValidator(PartHydro& hydro,
FinalLevelValidator(Antares::Data::PartHydro& hydro,
unsigned int areaIndex,
const AreaName areaName,
const Antares::Data::AreaName areaName,
double initialLevel,
double finalLevel,
const unsigned int year,
const unsigned int lastSimulationDay,
const unsigned int firstMonthOfSimulation);
const unsigned int firstMonthOfSimulation,
HydroErrorsCollector& errorCollector);
bool check();
bool finalLevelFineForUse();

Expand All @@ -62,12 +69,16 @@ class FinalLevelValidator
unsigned int firstMonthOfSimulation_ = 0;

// Data from area
PartHydro& hydro_;
Antares::Data::PartHydro& hydro_;
unsigned int areaIndex_;
const AreaName areaName_;
const Antares::Data::AreaName areaName_;
double initialLevel_;
double finalLevel_;

bool finalLevelFineForUse_ = false;

// area input errors
HydroErrorsCollector& errorCollector_;
};
} // namespace Antares::Data
} // namespace Solver
} // namespace Antares

This file was deleted.

36 changes: 36 additions & 0 deletions src/solver/hydro/management/HydroErrorsCollector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "antares/solver/hydro/management/HydroErrorsCollector.h"

#include <yuni/core/logs.h>

#include "antares/antares/fatal-error.h"

namespace Antares
{
void HydroErrorsCollector::Collect(const std::string& area_name, const std::string& message)
{
logs.error() << "In Area " << area_name << " " << message;
area_errors_counter_[area_name]++;
errors_limit_reached_ = area_errors_counter_[area_name] > 10;
stop_ = true;

if (errors_limit_reached_)
{
throw FatalError("Hydro validation has failed !");
}
a-zakir marked this conversation as resolved.
Show resolved Hide resolved
}

void HydroErrorsCollector::Collect(const std::string& message)
{
logs.error() << message;
stop_ = true;
}

void HydroErrorsCollector::CheckForFatalErrors() const
{
if (stop_ || errors_limit_reached_)
{
throw FatalError("Hydro validation has failed !");
}
a-zakir marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace Antares
Loading
Loading