Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
dispatchable-generation-margin.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_DispatchableGenMargin_H__
22#define __SOLVER_VARIABLE_ECONOMY_DispatchableGenMargin_H__
23
24#include <antares/study/area/scratchpad.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 "DTG MRG";
41 }
42
44 static std::string Unit()
45 {
46 return "MWh";
47 }
48
50 static std::string Description()
51 {
52 return "Dispatchable Generation Margin";
53 }
54
56 typedef Results<R::AllYears::Average< // The average values thoughout all years
57 R::AllYears::StdDeviation< // The standard deviation values throughout all years
58 R::AllYears::Min< // The minimum values thoughout all years
59 R::AllYears::Max< // The maximum values thoughout all years
60 >>>>>
62
65
67 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
69 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
70 & (Category::FileLevel::id
71 | Category::FileLevel::va);
73 static constexpr uint8_t precision = Category::all;
75 static constexpr uint8_t nodeDepthForGUI = +0;
77 static constexpr uint8_t decimal = 0;
79 static constexpr int columnCount = 1;
81 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
82 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
83 static constexpr uint8_t spatialAggregatePostProcessing = 0;
85 static constexpr uint8_t hasIntermediateValues = 1;
87 static constexpr uint8_t isPossiblyNonApplicable = 0;
88
90 typedef std::vector<IntermediateValues> IntermediateValuesType;
91
93
94}; // class VCard
95
99template<class NextT = Container::EndOfList>
101 : public Variable::IVariable<DispatchableGenMargin<NextT>, NextT, VCardDispatchableGenMargin>
102{
103public:
105 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:
136 void initializeFromStudy(Data::Study& study)
137 {
138 pNbYearsParallel = study.maxNbYearsInParallel;
139
140 // Average thoughout all years
141 InitializeResultsFromStudy(AncestorType::pResults, study);
142
143 // Intermediate values
144 pValuesForTheCurrentYear.resize(pNbYearsParallel);
145 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
146 {
147 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
148 }
149
150 // Next
151 NextType::initializeFromStudy(study);
152 }
153
154 template<class R>
155 static void InitializeResultsFromStudy(R& results, Data::Study& study)
156 {
157 VariableAccessorType::InitializeAndReset(results, study);
158 }
159
160 void initializeFromArea(Data::Study* study, Data::Area* area)
161 {
162 pArea = area;
163 // Next
164 NextType::initializeFromArea(study, area);
165 }
166
167 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
168 {
169 // Next
170 NextType::initializeFromAreaLink(study, link);
171 }
172
173 void simulationBegin()
174 {
175 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
176 {
177 pValuesForTheCurrentYear[numSpace].reset();
178 }
179
180 // Next
181 NextType::simulationBegin();
182 }
183
184 void simulationEnd()
185 {
186 NextType::simulationEnd();
187 }
188
189 void yearBegin(unsigned int year, unsigned int numSpace)
190 {
191 pValuesForTheCurrentYear[numSpace].reset();
192
193 // Next variable
194 NextType::yearBegin(year, numSpace);
195 }
196
197 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
198 {
199 // Next variable
200 NextType::yearEndBuild(state, year, numSpace);
201 }
202
203 void yearEnd(unsigned int year, unsigned int numSpace)
204 {
205 // Compute all statistics for the current year (daily,weekly,monthly)
206 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
207
208 // Next variable
209 NextType::yearEnd(year, numSpace);
210 }
211
212 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
213 unsigned int nbYearsForCurrentSummary)
214 {
215 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
216 {
217 // Merge all those values with the global results
218 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
219 pValuesForTheCurrentYear[numSpace]);
220 }
221
222 // Next variable
223 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
224 }
225
226 void hourBegin(unsigned int hourInTheYear)
227 {
228 // Next variable
229 NextType::hourBegin(hourInTheYear);
230 }
231
232 void hourForEachArea(State& state, unsigned int numSpace)
233 {
234 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] += state.scratchpad
235 ->dispatchableGenerationMargin
236 [state.hourInTheWeek];
237 // Next variable
238 NextType::hourForEachArea(state, numSpace);
239 }
240
241 template<class VCardToFindT>
242 inline const double* retrieveHourlyResultsForCurrentYear(unsigned int numSpace) const
243 {
244 typedef RetrieveResultsAssignment<
245 Yuni::Static::Type::StrictlyEqual<VCardType, VCardToFindT>::Yes>
246 AssignT;
247 return (AssignT::Yes)
248 ? Memory::RawPointer(pValuesForTheCurrentYear[numSpace].hour)
249 : NextType::template retrieveHourlyResultsForCurrentYear<VCardToFindT>(numSpace);
250 }
251
252 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
253 unsigned int,
254 unsigned int numSpace) const
255 {
256 return pValuesForTheCurrentYear[numSpace].hour;
257 }
258
259 void localBuildAnnualSurveyReport(SurveyResults& results,
260 int fileLevel,
261 int precision,
262 unsigned int numSpace) const
263 {
264 // Initializing external pointer on current variable non applicable status
265 results.isCurrentVarNA = AncestorType::isNonApplicable;
266
267 if (AncestorType::isPrinted[0])
268 {
269 // Write the data for the current year
270 results.variableCaption = VCardType::Caption();
271 results.variableUnit = VCardType::Unit();
272 pValuesForTheCurrentYear[numSpace]
273 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
274 }
275 }
276
277private:
279 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
280 Data::Area* pArea;
281 unsigned int pNbYearsParallel;
282
283}; // class DispatchableGenMargin
284
285} // namespace Economy
286} // namespace Variable
287} // namespace Solver
288} // namespace Antares
289
290#endif // __SOLVER_VARIABLE_ECONOMY_DispatchableGenMargin_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal DispatchableGenMargin.
Definition dispatchable-generation-margin.h:102
NextT NextType
Type of the next static variable.
Definition dispatchable-generation-margin.h:105
Variable::IVariable< DispatchableGenMargin< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition dispatchable-generation-margin.h:109
VCardDispatchableGenMargin VCardType
VCard.
Definition dispatchable-generation-margin.h:107
VCardType::ResultsType ResultsType
List of expected results.
Definition dispatchable-generation-margin.h:112
@ count
How many items have we got.
Definition dispatchable-generation-margin.h:119
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
Definition dispatchable-generation-margin.h:124
Definition dispatchable-generation-margin.h:36
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition dispatchable-generation-margin.h:79
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition dispatchable-generation-margin.h:81
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition dispatchable-generation-margin.h:69
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition dispatchable-generation-margin.h:85
static std::string Caption()
Caption.
Definition dispatchable-generation-margin.h:38
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition dispatchable-generation-margin.h:61
static constexpr uint8_t decimal
Decimal precision.
Definition dispatchable-generation-margin.h:77
static std::string Unit()
Unit.
Definition dispatchable-generation-margin.h:44
static std::string Description()
The short description of the variable.
Definition dispatchable-generation-margin.h:50
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition dispatchable-generation-margin.h:75
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition dispatchable-generation-margin.h:87
static constexpr uint8_t categoryDataLevel
Data Level.
Definition dispatchable-generation-margin.h:67
static constexpr uint8_t precision
Precision (views)
Definition dispatchable-generation-margin.h:73
VCardDispatchableGenMargin VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition dispatchable-generation-margin.h:64