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