Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
npCostByDispatchablePlant.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_NonProportionalCostByDispatchablePlant_H__
22#define __SOLVER_VARIABLE_ECONOMY_NonProportionalCostByDispatchablePlant_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 "NP Cost by plant";
40 }
41
43 static std::string Unit()
44 {
45 return "NP Cost - Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Non proportional costs by all the clusters";
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 // typedef std::vector<IntermediateValues> IntermediateValuesType;
89
90}; // class VCard
91
96template<class NextT = Container::EndOfList>
98 : public Variable::IVariable<NonProportionalCostByDispatchablePlant<NextT>,
99 NextT,
100 VCardNonProportionalCostByDispatchablePlant>
101{
102public:
104 typedef NextT NextType;
110
113
115
116 enum
117 {
119 count = 1 + NextT::count,
120 };
121
122 template<int CDataLevel, int CFile>
124 {
125 enum
126 {
127 count = ((VCardType::categoryDataLevel & CDataLevel
129 ? (NextType::template Statistics<CDataLevel, CFile>::count
131 : NextType::template Statistics<CDataLevel, CFile>::count),
132 };
133 };
134
135public:
137 pSize(0)
138 {
139 }
140
141 void initializeFromStudy(Data::Study& study)
142 {
143 // Next
144 NextType::initializeFromStudy(study);
145 }
146
147 void initializeFromArea(Data::Study* study, Data::Area* area)
148 {
149 // Get the number of years in parallel
150 pNbYearsParallel = study->maxNbYearsInParallel;
151 pValuesForTheCurrentYear.resize(pNbYearsParallel);
152
153 // Get the area
154 pSize = area->thermal.list.enabledCount();
155 if (pSize)
156 {
157 AncestorType::pResults.resize(pSize);
158 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
159 {
160 pValuesForTheCurrentYear[numSpace].resize(pSize);
161 }
162
163 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
164 {
165 for (unsigned int i = 0; i != pSize; ++i)
166 {
167 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
168 }
169 }
170
171 for (unsigned int i = 0; i != pSize; ++i)
172 {
173 AncestorType::pResults[i].initializeFromStudy(*study);
174 AncestorType::pResults[i].reset();
175 }
176 }
177 else
178 {
180 }
181
182 // Next
183 NextType::initializeFromArea(study, area);
184 }
185
186 size_t getMaxNumberColumns() const
187 {
188 return pSize * ResultsType::count;
189 }
190
191 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
192 {
193 // Next
194 NextType::initializeFromAreaLink(study, link);
195 }
196
197 void simulationBegin()
198 {
199 // Next
200 NextType::simulationBegin();
201 }
202
203 void simulationEnd()
204 {
205 NextType::simulationEnd();
206 }
207
208 void yearBegin(unsigned int year, unsigned int numSpace)
209 {
210 // Reset the values for the current year
211 for (unsigned int i = 0; i != pSize; ++i)
212 {
213 pValuesForTheCurrentYear[numSpace][i].reset();
214 }
215
216 // Next variable
217 NextType::yearBegin(year, numSpace);
218 }
219
220 void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
221 {
222 // Get end year calculations
223 for (unsigned int i = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
224 i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
225 ++i)
226 {
227 pValuesForTheCurrentYear[numSpace][state.thermalCluster->enabledIndex].hour[i]
228 = state.thermalClusterNonProportionalCostForYear[i];
229 }
230
231 // Next variable
232 NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
233 }
234
235 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
236 {
237 // Next variable
238 NextType::yearEndBuild(state, year, numSpace);
239 }
240
241 void yearEnd(unsigned int year, unsigned int numSpace)
242 {
243 // Merge all results for all thermal clusters
244 {
245 for (unsigned int i = 0; i < pSize; ++i)
246 {
247 // Compute all statistics for the current year (daily,weekly,monthly)
248 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
249 }
250 }
251 // Next variable
252 NextType::yearEnd(year, numSpace);
253 }
254
255 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
256 unsigned int nbYearsForCurrentSummary)
257 {
258 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
259 {
260 for (unsigned int i = 0; i < pSize; ++i)
261 {
262 // Merge all those values with the global results
263 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
264 pValuesForTheCurrentYear[numSpace][i]);
265 }
266 }
267
268 // Next variable
269 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
270 }
271
272 void hourBegin(unsigned int hourInTheYear)
273 {
274 // Next variable
275 NextType::hourBegin(hourInTheYear);
276 }
277
278 void hourForEachArea(State& state, unsigned int numSpace)
279 {
280 // Next variable
281 NextType::hourForEachArea(state, numSpace);
282 }
283
284 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
285 unsigned int,
286 unsigned int numSpace) const
287 {
288 return pValuesForTheCurrentYear[numSpace][0].hour;
289 }
290
291 void localBuildAnnualSurveyReport(SurveyResults& results,
292 int fileLevel,
293 int precision,
294 unsigned int numSpace) const
295 {
296 // Initializing external pointer on current variable non applicable status
297 results.isCurrentVarNA = AncestorType::isNonApplicable;
298
299 if (AncestorType::isPrinted[0])
300 {
301 assert(NULL != results.data.area);
302 const auto& thermal = results.data.area->thermal;
303
304 // Write the data for the current year
305 for (auto& cluster: thermal.list.each_enabled())
306 {
307 // Write the data for the current year
308 results.variableCaption = cluster->name(); // VCardType::Caption();
309 results.variableUnit = VCardType::Unit();
310 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
311 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
312 }
313 }
314 }
315
316private:
318 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
319 size_t pSize;
320 unsigned int pNbYearsParallel;
321
322}; // class NonProportionalCostByDispatchablePlant
323
324} // namespace Economy
325} // namespace Variable
326} // namespace Solver
327} // namespace Antares
328
329#endif // __SOLVER_VARIABLE_ECONOMY_NonProportionalCostByDispatchablePlant_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 npCostByDispatchablePlant.h:101
VCardType::ResultsType ResultsType
List of expected results.
Definition npCostByDispatchablePlant.h:112
VCardNonProportionalCostByDispatchablePlant VCardType
VCard.
Definition npCostByDispatchablePlant.h:106
@ count
How many items have we got.
Definition npCostByDispatchablePlant.h:119
Variable::IVariable< NonProportionalCostByDispatchablePlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition npCostByDispatchablePlant.h:109
NextT NextType
Type of the next static variable.
Definition npCostByDispatchablePlant.h:104
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 int columnCount
Number of columns used by the variable.
Definition npCostByDispatchablePlant.h:74
VCardNonProportionalCostByDispatchablePlant VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition npCostByDispatchablePlant.h:60
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition npCostByDispatchablePlant.h:65
static std::string Description()
The short description of the variable.
Definition npCostByDispatchablePlant.h:49
static constexpr uint8_t decimal
Decimal precision.
Definition npCostByDispatchablePlant.h:72
Results< R::AllYears::Average< > > ResultsType
The expected results.
Definition npCostByDispatchablePlant.h:57
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition npCostByDispatchablePlant.h:70
static constexpr uint8_t categoryDataLevel
Data Level.
Definition npCostByDispatchablePlant.h:63
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition npCostByDispatchablePlant.h:80
static std::string Caption()
Caption.
Definition npCostByDispatchablePlant.h:37
static constexpr uint8_t precision
Precision (views)
Definition npCostByDispatchablePlant.h:68
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition npCostByDispatchablePlant.h:76
static std::string Unit()
Unit.
Definition npCostByDispatchablePlant.h:43
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition npCostByDispatchablePlant.h:82