Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
overflow.h
1/*
2** Copyright 2007-2024, 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 __SOLVER_VARIABLE_ECONOMY_Overflow_H__
22#define __SOLVER_VARIABLE_ECONOMY_Overflow_H__
23
24#include "antares/solver/variable/variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
33{
35{
37 static std::string Caption()
38 {
39 return "H. OVFL";
40 }
41
43 static std::string Unit()
44 {
45 return "%";
46 }
47
49 static std::string Description()
50 {
51 return "Hydro overflow";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values throughout all years
58 R::AllYears::Max< // The maximum values throughout all years
59 >>>>>
61
64
66 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
68 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
69 & (Category::FileLevel::id
70 | Category::FileLevel::va);
72 static constexpr uint8_t precision = Category::all;
74 static constexpr uint8_t nodeDepthForGUI = +0;
76 static constexpr uint8_t decimal = 0;
78 static constexpr int columnCount = 1;
80 static constexpr uint8_t spatialAggregate = Category::noSpatialAggregate;
81 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
82 static constexpr uint8_t spatialAggregatePostProcessing = 0;
84 static constexpr uint8_t hasIntermediateValues = 1;
86 static constexpr uint8_t isPossiblyNonApplicable = 1;
87
89 typedef std::vector<IntermediateValues> IntermediateValuesType;
90
92
93}; // class VCard
94
98template<class NextT = Container::EndOfList>
99class Overflows: public Variable::IVariable<Overflows<NextT>, NextT, VCardOverflow>
100{
101public:
103 typedef NextT NextType;
108
111
113
114 enum
115 {
117 count = 1 + NextT::count,
118 };
119
120 template<int CDataLevel, int CFile>
122 {
123 enum
124 {
125 count = ((VCardType::categoryDataLevel & CDataLevel
127 ? (NextType::template Statistics<CDataLevel, CFile>::count
129 : NextType::template Statistics<CDataLevel, CFile>::count),
130 };
131 };
132
133public:
134 void initializeFromStudy(Data::Study& study)
135 {
136 pNbYearsParallel = study.maxNbYearsInParallel;
137
138 InitializeResultsFromStudy(AncestorType::pResults, study);
139
140 pValuesForTheCurrentYear.resize(pNbYearsParallel);
141 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
142 {
143 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
144 }
145
146 // Next
147 NextType::initializeFromStudy(study);
148 }
149
150 template<class R>
151 static void InitializeResultsFromStudy(R& results, Data::Study& study)
152 {
153 VariableAccessorType::InitializeAndReset(results, study);
154 }
155
156 void initializeFromArea(Data::Study* study, Data::Area* area)
157 {
158 // Next
159 NextType::initializeFromArea(study, area);
160 }
161
162 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
163 {
164 // Next
165 NextType::initializeFromAreaLink(study, link);
166 }
167
168 void simulationBegin()
169 {
170 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
171 {
172 pValuesForTheCurrentYear[numSpace].reset();
173 }
174 // Next
175 NextType::simulationBegin();
176 }
177
178 void simulationEnd()
179 {
180 NextType::simulationEnd();
181 }
182
183 void yearBegin(unsigned int year, unsigned int numSpace)
184 {
185 // Reset the values for the current year
186 pValuesForTheCurrentYear[numSpace].reset();
187
188 // Next variable
189 NextType::yearBegin(year, numSpace);
190 }
191
192 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
193 {
194 // Next variable
195 NextType::yearEndBuild(state, year, numSpace);
196 }
197
198 void yearEnd(unsigned int year, unsigned int numSpace)
199 {
200 // Compute all statistics for the current year (daily, weekly, monthly, annual).
201 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
202
203 // Next variable
204 NextType::yearEnd(year, numSpace);
205 }
206
207 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
208 unsigned int nbYearsForCurrentSummary)
209 {
210 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
211 {
212 // Merge all those values with the global results
213 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
214 pValuesForTheCurrentYear[numSpace]);
215 }
216
217 // Next variable
218 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
219 }
220
221 void hourBegin(unsigned int hourInTheYear)
222 {
223 // Next variable
224 NextType::hourBegin(hourInTheYear);
225 }
226
227 void hourForEachArea(State& state, unsigned int numSpace)
228 {
229 // Retrieving hourly reservoir levels of week simulation
230 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] = state.hourlyResults
231 ->debordementsHoraires
232 [state.hourInTheWeek];
233
234 // Next variable
235 NextType::hourForEachArea(state, numSpace);
236 }
237
238 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
239 unsigned int,
240 unsigned int numSpace) const
241 {
242 return pValuesForTheCurrentYear[numSpace].hour;
243 }
244
245 void localBuildAnnualSurveyReport(SurveyResults& results,
246 int fileLevel,
247 int precision,
248 unsigned int numSpace) const
249 {
250 // Initializing external pointer on current variable non applicable status
251 results.isCurrentVarNA = AncestorType::isNonApplicable;
252
253 if (AncestorType::isPrinted[0])
254 {
255 // Write the data for the current year
256 results.variableCaption = VCardType::Caption();
257 results.variableUnit = VCardType::Unit();
258 pValuesForTheCurrentYear[numSpace]
259 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
260 }
261 }
262
263private:
265 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
266 unsigned int pNbYearsParallel;
267
268}; // class HydroLevel
269
270} // namespace Economy
271} // namespace Variable
272} // namespace Solver
273} // namespace Antares
274
275#endif // __SOLVER_VARIABLE_ECONOMY_Overflow_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Reservoir level.
Definition overflow.h:100
@ count
How many items have we got.
Definition overflow.h:117
Variable::IVariable< Overflows< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition overflow.h:107
VCardType::ResultsType ResultsType
List of expected results.
Definition overflow.h:110
NextT NextType
Type of the next static variable.
Definition overflow.h:103
VCardOverflow VCardType
VCard.
Definition overflow.h:105
Interface for any variable.
Definition variable.h:51
StoredResultType pResults
All the results about this variable.
Definition variable.h:327
Temporary buffer for allocating results for a single year.
Definition intermediate.h:46
Definition results.h:48
@ count
The count if item in the list.
Definition results.h:56
Definition cbuilder.h:120
Definition variable.h:25
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition overflow.h:84
static constexpr uint8_t decimal
Decimal precision.
Definition overflow.h:76
static constexpr uint8_t precision
Precision (views)
Definition overflow.h:72
VCardOverflow VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition overflow.h:63
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition overflow.h:60
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition overflow.h:74
static std::string Description()
The short description of the variable.
Definition overflow.h:49
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition overflow.h:86
static std::string Unit()
Unit.
Definition overflow.h:43
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition overflow.h:78
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition overflow.h:68
static constexpr uint8_t categoryDataLevel
Data Level.
Definition overflow.h:66
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition overflow.h:80
static std::string Caption()
Caption.
Definition overflow.h:37