Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
lold.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_LOLD_H__
22#define __SOLVER_VARIABLE_ECONOMY_LOLD_H__
23
24#include "antares/solver/variable/economy/unsupliedEnergy.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 "LOLD";
41 }
42
44 static std::string Unit()
45 {
46 return "Hours";
47 }
48
50 static std::string Description()
51 {
52 return "LOLD";
53 }
54
56 typedef Results<R::AllYears::Average< // The average values throughout all years
57 R::AllYears::StdDeviation< // The standard deviation values throughout all years
58 R::AllYears::Min< // The minimum values throughout all years
59 R::AllYears::Max< // The maximum values throughout 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 = 4;
79 static constexpr int columnCount = 1;
81 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSumThen1IfPositive;
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>
100class LOLD: public Variable::IVariable<LOLD<NextT>, NextT, VCardLOLD>
101{
102public:
104 typedef NextT NextType;
109
112
114
115 enum
116 {
118 count = 1 + NextT::count,
119 };
120
121 template<int CDataLevel, int CFile>
123 {
124 enum
125 {
126 count = ((VCardType::categoryDataLevel & CDataLevel
128 ? (NextType::template Statistics<CDataLevel, CFile>::count
130 : NextType::template Statistics<CDataLevel, CFile>::count),
131 };
132 };
133
134public:
135 void initializeFromStudy(Data::Study& study)
136 {
137 pNbYearsParallel = study.maxNbYearsInParallel;
138
139 // Intermediate values
140 InitializeResultsFromStudy(AncestorType::pResults, study);
141
142 pValuesForTheCurrentYear.resize(pNbYearsParallel);
143 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
144 {
145 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
146 }
147 // Next
148 NextType::initializeFromStudy(study);
149 }
150
151 template<class R>
152 static void InitializeResultsFromStudy(R& results, Data::Study& study)
153 {
154 VariableAccessorType::InitializeAndReset(results, study);
155 }
156
157 void initializeFromArea(Data::Study* study, Data::Area* area)
158 {
159 // Next
160 NextType::initializeFromArea(study, area);
161 }
162
163 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
164 {
165 // Next
166 NextType::initializeFromAreaLink(study, link);
167 }
168
169 void simulationBegin()
170 {
171 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
172 {
173 pValuesForTheCurrentYear[numSpace].reset();
174 }
175 // Next
176 NextType::simulationBegin();
177 }
178
179 void simulationEnd()
180 {
181 NextType::simulationEnd();
182 }
183
184 void yearBegin(unsigned int year, unsigned int numSpace)
185 {
186 // Reset the values for the current year
187 pValuesForTheCurrentYear[numSpace].reset();
188
189 // Next variable
190 NextType::yearBegin(year, numSpace);
191 }
192
193 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
194 {
195 // Next variable
196 NextType::yearEndBuild(state, year, numSpace);
197 }
198
199 void yearEnd(unsigned int year, unsigned int numSpace)
200 {
201 // Compute all statistics for the current year (daily,weekly,monthly)
202 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
203
204 // Next variable
205 NextType::yearEnd(year, numSpace);
206 }
207
208 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
209 unsigned int nbYearsForCurrentSummary)
210 {
211 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
212 {
213 // Merge all those values with the global results
214 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
215 pValuesForTheCurrentYear[numSpace]);
216 }
217
218 // Next variable
219 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
220 }
221
222 void hourBegin(unsigned int hourInTheYear)
223 {
224 // Next variable
225 NextType::hourBegin(hourInTheYear);
226 }
227
228 void hourForEachArea(State& state, unsigned int numSpace)
229 {
230 // LOLD
231 if (state.hourlyResults->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek] > 0.5)
232 {
233 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = 1.;
234 }
235
236 // Next variable
237 NextType::hourForEachArea(state, numSpace);
238 }
239
240 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
241 unsigned int,
242 unsigned int numSpace) const
243 {
244 return pValuesForTheCurrentYear[numSpace].hour;
245 }
246
247 void localBuildAnnualSurveyReport(SurveyResults& results,
248 int fileLevel,
249 int precision,
250 unsigned int numSpace) const
251 {
252 // Initializing external pointer on current variable non applicable status
253 results.isCurrentVarNA = AncestorType::isNonApplicable;
254
255 if (AncestorType::isPrinted[0])
256 {
257 // Write the data for the current year
258 results.variableCaption = VCardType::Caption();
259 results.variableUnit = VCardType::Unit();
260 pValuesForTheCurrentYear[numSpace]
261 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
262 }
263 }
264
265private:
267 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
268 unsigned int pNbYearsParallel;
269
270}; // class LOLD
271
272} // namespace Economy
273} // namespace Variable
274} // namespace Solver
275} // namespace Antares
276
277#endif // __SOLVER_VARIABLE_ECONOMY_LOLD_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
VCardLOLD VCardType
VCard.
Definition lold.h:106
Variable::IVariable< LOLD< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition lold.h:108
VCardType::ResultsType ResultsType
List of expected results.
Definition lold.h:111
@ count
How many items have we got.
Definition lold.h:118
NextT NextType
Type of the next static variable.
Definition lold.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 uint8_t precision
Precision (views)
Definition lold.h:73
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition lold.h:69
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition lold.h:75
static std::string Caption()
Caption.
Definition lold.h:38
VCardUnsupliedEnergy VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition lold.h:64
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition lold.h:87
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition lold.h:61
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition lold.h:79
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition lold.h:81
static constexpr uint8_t decimal
Decimal precision.
Definition lold.h:77
static std::string Description()
The short description of the variable.
Definition lold.h:50
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition lold.h:85
static constexpr uint8_t categoryDataLevel
Data Level.
Definition lold.h:67
static std::string Unit()
Unit.
Definition lold.h:44