Antares Simulator
Power System Simulator
hydroLevelsData.h
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 #ifndef __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
22 #define __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
23 
24 #include <functional>
25 
26 #include "scBuilderDataInterface.h"
27 
28 namespace Antares::Data::ScenarioBuilder
29 {
33 class hydroLevelsData final: public dataInterface
34 {
35 public:
38 
39 public:
40  // Constructor
41 
42  hydroLevelsData(const std::string& iniFilePrefix,
43  std::function<void(Study&, MatrixType&)> applyToTarget);
44 
46 
47 
50  bool reset(const Study& study) override;
51 
52 #ifdef BUILD_UI
56  void saveToINIFile(const Study& study, Yuni::IO::File::Stream& file) const override;
57 #endif
58 
66  void setTSnumber(uint index, uint year, double value);
68 
69  uint width() const override;
70 
71  uint height() const override;
72 
73  double get_value(uint x, uint y) const;
74 
75  void set_value(uint x, uint y, double value);
76 
77  bool apply(Study& study) override;
78 
79 private:
81  MatrixType pHydroLevelsRules;
82  // prefix to be added when calling saveToINIFileHydroLevel
83  const std::string addToPrefix_;
84 
85  std::function<void(Study&, MatrixType&)> applyToTarget_;
86 
87 }; // class hydroLevelsData
88 
89 // class hydroLevelsData : inline functions
90 
91 inline void hydroLevelsData::setTSnumber(uint areaindex, uint year, double value)
92 {
93  assert(areaindex < pHydroLevelsRules.width);
94  if (year < pHydroLevelsRules.height)
95  {
96  pHydroLevelsRules[areaindex][year] = value;
97  }
98 }
99 
100 inline uint hydroLevelsData::width() const
101 {
102  return pHydroLevelsRules.width;
103 }
104 
105 inline uint hydroLevelsData::height() const
106 {
107  return pHydroLevelsRules.height;
108 }
109 
110 inline double hydroLevelsData::get_value(uint x, uint y) const
111 {
112  return pHydroLevelsRules.entry[y][x];
113 }
114 
115 inline void initLevelApply(Study& study, Matrix<double>& matrix)
116 {
117  study.scenarioInitialHydroLevels.copyFrom(matrix);
118 }
119 
120 inline void finalLevelApply(Study& study, Matrix<double>& matrix)
121 {
122  study.scenarioFinalHydroLevels.copyFrom(matrix);
123 }
124 
125 } // namespace Antares::Data::ScenarioBuilder
126 
127 #endif // __LIBS_STUDY_SCENARIO_BUILDER_DATA_HYDRO_LEVELS_H__
Interface for scenario builder data (time series, hydro levels, ...)
Definition: scBuilderDataInterface.h:37
Rules for hydro levels, for all years and areas.
Definition: hydroLevelsData.h:34
bool apply(Study &study) override
Apply the changes to the study corresponding data (time series, hydro levels, ...)
Definition: hydroLevelsData.cpp:86
void setTSnumber(uint index, uint year, double value)
Assign a single value.
Definition: hydroLevelsData.h:91
bool reset(const Study &study) override
Reset data from the study.
Definition: hydroLevelsData.cpp:39
Definition: study.h:57
A n-by-n matrix.
Definition: matrix.h:44
uint height
Height of the matrix.
Definition: matrix.h:443
ColumnType * entry
All entries of the matrix (bidimensional array)
Definition: matrix.h:445
uint width
Width of the matrix.
Definition: matrix.h:441