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