Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
rowBalance.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_RowBalance_H__
22#define __SOLVER_VARIABLE_ECONOMY_RowBalance_H__
23
24#include <antares/study/area/constants.h>
25#include "antares/solver/variable/variable.h"
26
27namespace Antares
28{
29namespace Solver
30{
31namespace Variable
32{
33namespace Economy
34{
36{
38 static std::string Caption()
39 {
40 return "ROW BAL.";
41 }
42
44 static std::string Unit()
45 {
46 return "MWh";
47 }
48
50 static std::string Description()
51 {
52 return "Row Balance";
53 }
54
56 typedef Results<R::AllYears::Raw< // The raw values
57 >>
59
62
64 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
66 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
67 & (Category::FileLevel::id
68 | Category::FileLevel::va);
70 static constexpr uint8_t precision = Category::all;
72 static constexpr uint8_t nodeDepthForGUI = +0;
74 static constexpr uint8_t decimal = 0;
76 static constexpr int columnCount = 1;
78 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
79 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateOnce;
80 static constexpr uint8_t spatialAggregatePostProcessing = 0;
82 static constexpr uint8_t hasIntermediateValues = 1;
84 static constexpr uint8_t isPossiblyNonApplicable = 0;
85
88
90
91}; // class VCard
92
96template<class NextT = Container::EndOfList>
97class RowBalance: public Variable::IVariable<RowBalance<NextT>, NextT, VCardRowBalance>
98{
99public:
101 typedef NextT NextType;
106
109
111
112 enum
113 {
115 count = 1 + NextT::count,
116 };
117
118 template<int CDataLevel, int CFile>
120 {
121 enum
122 {
123 count = ((VCardType::categoryDataLevel & CDataLevel
125 ? (NextType::template Statistics<CDataLevel, CFile>::count
127 : NextType::template Statistics<CDataLevel, CFile>::count),
128 };
129 };
130
131public:
133 {
134 }
135
136 void initializeFromStudy(Data::Study& study)
137 {
138 // Average on all years
139 InitializeResultsFromStudy(AncestorType::pResults, study);
140
141 // Intermediate values
142 pValuesForTheCurrentYear.initializeFromStudy(study);
143
144 // Next
145 NextType::initializeFromStudy(study);
146 }
147
148 template<class R>
149 static void InitializeResultsFromStudy(R& results, Data::Study& study)
150 {
151 VariableAccessorType::InitializeAndReset(results, study);
152 }
153
154 void initializeFromArea(Data::Study* study, Data::Area* area)
155 {
156 // Copy raw values
157 unsigned int height = area->miscGen.height;
158 (void)::memcpy(pValuesForTheCurrentYear.hour,
159 area->miscGen.entry[Data::fhhRowBalance],
160 sizeof(double) * height);
161
162 if (study->parameters.mode == Data::SimulationMode::Adequacy)
163 {
164 for (unsigned int h = 0; h != height; ++h)
165 {
166 pValuesForTheCurrentYear.hour[h] -= area->reserves
167 .entry[Data::fhrPrimaryReserve][h];
168 }
169 }
170 // Compute all statistics for the current year (daily,weekly,monthly)
171 pValuesForTheCurrentYear.computeStatisticsForTheCurrentYear();
172
173 // Merge all those values with the global results
174 AncestorType::pResults.merge(0, pValuesForTheCurrentYear);
175
176 // Next
177 NextType::initializeFromArea(study, area);
178 }
179
180 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
181 {
182 // Next
183 NextType::initializeFromAreaLink(study, link);
184 }
185
186 void simulationBegin()
187 {
188 // Next
189 NextType::simulationBegin();
190 }
191
192 void simulationEnd()
193 {
194 NextType::simulationEnd();
195 }
196
197 void yearBegin(unsigned int year, unsigned int numSpace)
198 {
199 // Next variable
200 NextType::yearBegin(year, numSpace);
201 }
202
203 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
204 {
205 // Next variable
206 NextType::yearEndBuild(state, year, numSpace);
207 }
208
209 void yearEnd(unsigned int year, unsigned int numSpace)
210 {
211 // Next variable
212 NextType::yearEnd(year, numSpace);
213 }
214
215 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
216 unsigned int nbYearsForCurrentSummary)
217 {
218 // Next variable
219 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
220 }
221
222 void hourBegin(unsigned int hourInTheYear)
223 {
224 // Next variable
225 NextType::hourBegin(hourInTheYear);
226 }
227
228 void hourForEachArea(State& state, unsigned int numSpace)
229 {
230 // Next variable
231 NextType::hourForEachArea(state, numSpace);
232 }
233
234 void localBuildAnnualSurveyReport(SurveyResults& results,
235 int fileLevel,
236 int precision,
237 unsigned int) const
238 {
239 // Initializing external pointer on current variable non applicable status
240 results.isCurrentVarNA = AncestorType::isNonApplicable;
241
242 if (AncestorType::isPrinted[0])
243 {
244 // Write the data for the current year
245 results.variableCaption = VCardType::Caption();
246 results.variableUnit = VCardType::Unit();
247 pValuesForTheCurrentYear.template buildAnnualSurveyReport<VCardType>(results,
248 fileLevel,
249 precision);
250 }
251 }
252
253private:
255 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
256
257}; // class RowBalance
258
259} // namespace Economy
260} // namespace Variable
261} // namespace Solver
262} // namespace Antares
263
264#endif // __SOLVER_VARIABLE_ECONOMY_RowBalance_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal RowBalance.
Definition rowBalance.h:98
VCardRowBalance VCardType
VCard.
Definition rowBalance.h:103
Variable::IVariable< RowBalance< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition rowBalance.h:105
NextT NextType
Type of the next static variable.
Definition rowBalance.h:101
@ count
How many items have we got.
Definition rowBalance.h:115
VCardType::ResultsType ResultsType
List of expected results.
Definition rowBalance.h:108
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
Antares::Memory::Stored< Type >::Type hour
Values for each hour in the year.
Definition intermediate.h:136
void computeStatisticsForTheCurrentYear()
Compute statistics for the current year.
Definition intermediate.cpp:70
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 categoryFileLevel
File level (provided by the type of the results)
Definition rowBalance.h:66
static std::string Description()
The short description of the variable.
Definition rowBalance.h:50
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition rowBalance.h:72
static std::string Caption()
Caption.
Definition rowBalance.h:38
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition rowBalance.h:76
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition rowBalance.h:82
static std::string Unit()
Unit.
Definition rowBalance.h:44
Results< R::AllYears::Raw< > > ResultsType
The expecte results.
Definition rowBalance.h:58
static constexpr uint8_t precision
Precision (views)
Definition rowBalance.h:70
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition rowBalance.h:78
static constexpr uint8_t decimal
Decimal precision.
Definition rowBalance.h:74
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition rowBalance.h:84
static constexpr uint8_t categoryDataLevel
Data Level.
Definition rowBalance.h:64
VCardRowBalance VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition rowBalance.h:61