Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
nbOfDispatchedUnitsByPlant.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_NbOfDispatchedUnitsByPlant_H__
22#define __SOLVER_VARIABLE_ECONOMY_NbOfDispatchedUnitsByPlant_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 "NODU by plant";
40 }
41
43 static std::string Unit()
44 {
45 return "NODU";
46 }
47
49 static std::string Description()
50 {
51 return "Number of Dispatchable Units by plant";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 >>
58
61
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
65 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
66 & (Category::FileLevel::de);
68 static constexpr uint8_t precision = Category::all;
70 static constexpr uint8_t nodeDepthForGUI = +0;
72 static constexpr uint8_t decimal = 0;
74 static constexpr int columnCount = Category::dynamicColumns;
76 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
77 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
78 static constexpr uint8_t spatialAggregatePostProcessing = 0;
80 static constexpr uint8_t hasIntermediateValues = 1;
82 static constexpr uint8_t isPossiblyNonApplicable = 0;
83
85 typedef std::vector<IntermediateValues> IntermediateValuesBaseType;
86 typedef std::vector<IntermediateValuesBaseType> IntermediateValuesType;
87
88}; // class VCard
89
94template<class NextT = Container::EndOfList>
95class NbOfDispatchedUnitsByPlant: public Variable::IVariable<NbOfDispatchedUnitsByPlant<NextT>,
96 NextT,
97 VCardNbOfDispatchedUnitsByPlant>
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 pSize(0)
134 {
135 }
136
137 void initializeFromStudy(Data::Study& study)
138 {
139 // Next
140 NextType::initializeFromStudy(study);
141 }
142
143 void initializeFromArea(Data::Study* study, Data::Area* area)
144 {
145 pNbYearsParallel = study->maxNbYearsInParallel;
146 pValuesForTheCurrentYear.resize(pNbYearsParallel);
147
148 // Get the area
149 pSize = area->thermal.list.enabledCount();
150 if (pSize)
151 {
152 AncestorType::pResults.resize(pSize);
153 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
154 {
155 pValuesForTheCurrentYear[numSpace].resize(pSize);
156 }
157
158 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
159 {
160 for (unsigned int i = 0; i != pSize; ++i)
161 {
162 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
163 }
164 }
165
166 for (unsigned int i = 0; i != pSize; ++i)
167 {
168 AncestorType::pResults[i].initializeFromStudy(*study);
169 AncestorType::pResults[i].reset();
170 }
171 }
172 else
173 {
175 }
176
177 // Next
178 NextType::initializeFromArea(study, area);
179 }
180
181 size_t getMaxNumberColumns() const
182 {
183 return pSize * ResultsType::count;
184 }
185
186 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
187 {
188 // Next
189 NextType::initializeFromAreaLink(study, link);
190 }
191
192 void simulationBegin()
193 {
194 // Next
195 NextType::simulationBegin();
196 }
197
198 void simulationEnd()
199 {
200 NextType::simulationEnd();
201 }
202
203 void yearBegin(unsigned int year, unsigned int numSpace)
204 {
205 // Reset the values for the current year
206 for (unsigned int i = 0; i != pSize; ++i)
207 {
208 pValuesForTheCurrentYear[numSpace][i].reset();
209 }
210
211 // Next variable
212 NextType::yearBegin(year, numSpace);
213 }
214
215 void yearEndBuildPrepareDataForEachThermalCluster(State& state,
216 uint year,
217 unsigned int numSpace)
218 {
219 for (unsigned int i = 0; i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd]; ++i)
220 {
221 state.thermalClusterDispatchedUnitsCountForYear[i] += static_cast<uint>(
222 pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]);
223 }
224
225 // Next variable
226 NextType::yearEndBuildPrepareDataForEachThermalCluster(state, year, numSpace);
227 }
228
229 void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
230 {
231 // Get end year calculations
232 for (unsigned int i = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
233 i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
234 ++i)
235 {
236 pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]
237 = state.thermalClusterDispatchedUnitsCountForYear[i];
238 }
239
240 // Next variable
241 NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
242 }
243
244 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
245 {
246 // Next variable
247 NextType::yearEndBuild(state, year, numSpace);
248 }
249
250 void yearEnd(unsigned int year, unsigned int numSpace)
251 {
252 // Merge all results for all thermal clusters
253 {
254 for (unsigned int i = 0; i < pSize; ++i)
255 {
256 // Compute all statistics for the current year (daily,weekly,monthly)
257 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
258 }
259 }
260 // Next variable
261 NextType::yearEnd(year, numSpace);
262 }
263
264 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
265 unsigned int nbYearsForCurrentSummary)
266 {
267 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
268 {
269 for (unsigned int i = 0; i < pSize; ++i)
270 {
271 // Merge all those values with the global results
272 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
273 pValuesForTheCurrentYear[numSpace][i]);
274 }
275 }
276
277 // Next variable
278 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
279 }
280
281 void hourBegin(unsigned int hourInTheYear)
282 {
283 // Next variable
284 NextType::hourBegin(hourInTheYear);
285 }
286
287 void hourForEachArea(State& state, unsigned int numSpace)
288 {
289 auto area = state.area;
290 auto& thermal = state.thermal;
291 for (auto& cluster: area->thermal.list.each_enabled())
292 {
293 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[state.hourInTheYear]
294 = thermal[area->index].numberOfUnitsONbyCluster[cluster->enabledIndex];
295 }
296
297 // Next variable
298 NextType::hourForEachArea(state, numSpace);
299 }
300
301 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
302 unsigned int,
303 unsigned int numSpace) const
304 {
305 return pValuesForTheCurrentYear[numSpace][0].hour;
306 }
307
308 void localBuildAnnualSurveyReport(SurveyResults& results,
309 int fileLevel,
310 int precision,
311 unsigned int numSpace) const
312 {
313 // Initializing external pointer on current variable non applicable status
314 results.isCurrentVarNA = AncestorType::isNonApplicable;
315
316 if (AncestorType::isPrinted[0])
317 {
318 assert(NULL != results.data.area);
319 const auto& thermal = results.data.area->thermal;
320
321 // Write the data for the current year
322 for (auto& cluster: thermal.list.each_enabled())
323 {
324 // Write the data for the current year
325 results.variableCaption = cluster->name(); // VCardType::Caption();
326 results.variableUnit = VCardType::Unit();
327 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
328 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
329 }
330 }
331 }
332
333private:
335 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
336 size_t pSize;
337 unsigned int pNbYearsParallel;
338
339}; // class NbOfDispatchedUnitsByPlant
340
341} // namespace Economy
342} // namespace Variable
343} // namespace Solver
344} // namespace Antares
345
346#endif // __SOLVER_VARIABLE_ECONOMY_NbOfDispatchedUnitsByPlant_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
C02 Average value of the overrall OperatingCost emissions expected from all the thermal dispatchable ...
Definition nbOfDispatchedUnitsByPlant.h:98
NextT NextType
Type of the next static variable.
Definition nbOfDispatchedUnitsByPlant.h:101
VCardType::ResultsType ResultsType
List of expected results.
Definition nbOfDispatchedUnitsByPlant.h:108
Variable::IVariable< NbOfDispatchedUnitsByPlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition nbOfDispatchedUnitsByPlant.h:105
@ count
How many items have we got.
Definition nbOfDispatchedUnitsByPlant.h:115
VCardNbOfDispatchedUnitsByPlant VCardType
VCard.
Definition nbOfDispatchedUnitsByPlant.h:103
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 std::string Caption()
Caption.
Definition nbOfDispatchedUnitsByPlant.h:37
static constexpr int columnCount
Number of columns used by the variable.
Definition nbOfDispatchedUnitsByPlant.h:74
static std::string Unit()
Unit.
Definition nbOfDispatchedUnitsByPlant.h:43
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition nbOfDispatchedUnitsByPlant.h:76
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition nbOfDispatchedUnitsByPlant.h:80
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition nbOfDispatchedUnitsByPlant.h:65
static std::string Description()
The short description of the variable.
Definition nbOfDispatchedUnitsByPlant.h:49
static constexpr uint8_t precision
Precision (views)
Definition nbOfDispatchedUnitsByPlant.h:68
VCardNbOfDispatchedUnitsByPlant VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition nbOfDispatchedUnitsByPlant.h:60
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition nbOfDispatchedUnitsByPlant.h:70
Results< R::AllYears::Average< > > ResultsType
The expected results.
Definition nbOfDispatchedUnitsByPlant.h:57
static constexpr uint8_t categoryDataLevel
Data Level.
Definition nbOfDispatchedUnitsByPlant.h:63
static constexpr uint8_t decimal
Decimal precision.
Definition nbOfDispatchedUnitsByPlant.h:72
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition nbOfDispatchedUnitsByPlant.h:82