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