Loading [MathJax]/extensions/MathZoom.js
Antares Simulator
Power System Simulator
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
lolpCsr.h
1/*
2** Copyright 2007-2023 RTE
3** Authors: Antares_Simulator Team
4**
5** This file is part of Antares_Simulator.
6**
7** Antares_Simulator is free software: you can redistribute it and/or modify
8** it under the terms of the GNU General Public License as published by
9** the Free Software Foundation, either version 3 of the License, or
10** (at your option) any later version.
11**
12** There are special exceptions to the terms and conditions of the
13** license as they are applied to this software. View the full text of
14** the exceptions in file COPYING.txt in the directory of this software
15** distribution
16**
17** Antares_Simulator is distributed in the hope that it will be useful,
18** but WITHOUT ANY WARRANTY; without even the implied warranty of
19** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20** GNU General Public License for more details.
21**
22** You should have received a copy of the GNU General Public License
23** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>.
24**
25** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
26*/
27#pragma once
28
29#include "../variable.h"
30
31namespace Antares::Solver::Variable::Economy
32{
34{
36 static std::string Caption()
37 {
38 return "LOLP CSR";
39 }
40
42 static std::string Unit()
43 {
44 return "%";
45 }
46
48 static std::string Description()
49 {
50 return "LOLP for CSR";
51 }
52
54 typedef Results<R::AllYears::Average< // The average values throughout all years
55 >>
57
60
61 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
63 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
64 & (Category::FileLevel::id
65 | Category::FileLevel::va);
67 static constexpr uint8_t precision = Category::all;
69 static constexpr uint8_t nodeDepthForGUI = +0;
71 static constexpr uint8_t decimal = 2;
73 static constexpr int columnCount = 1;
75 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
76 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
77 static constexpr uint8_t spatialAggregatePostProcessing = 0;
79 static constexpr uint8_t hasIntermediateValues = 1;
81 static constexpr uint8_t isPossiblyNonApplicable = 0;
82
84 typedef std::vector<IntermediateValues> IntermediateValuesType;
85
87
88}; // class VCard
89
93template<class NextT = Container::EndOfList>
94class LOLP_CSR: public Variable::IVariable<LOLP_CSR<NextT>, NextT, VCardLOLP_CSR>
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 simulationBegin()
153 {
154 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
155 {
156 pValuesForTheCurrentYear[numSpace].reset();
157 }
158 // Next
159 NextType::simulationBegin();
160 }
161
162 void yearBegin(unsigned int year, unsigned int numSpace)
163 {
164 // Reset the values for the current year
165 pValuesForTheCurrentYear[numSpace].reset();
166
167 // Next variable
168 NextType::yearBegin(year, numSpace);
169 }
170
171 void yearEnd(unsigned int year, unsigned int numSpace)
172 {
173 // Compute all statistics for the current year (daily,weekly,monthly)
174 pValuesForTheCurrentYear[numSpace].computeStatisticsOrForTheCurrentYear();
175
176 // Next variable
177 NextType::yearEnd(year, numSpace);
178 }
179
180 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
181 unsigned int nbYearsForCurrentSummary)
182 {
183 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
184 {
185 // Merge all those values with the global results
186 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
187 pValuesForTheCurrentYear[numSpace]);
188 }
189
190 // Next variable
191 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
192 }
193
194 void hourForEachArea(State& state, unsigned int numSpace)
195 {
196 if (state.hourlyResults->ValeursHorairesDeDefaillancePositiveCSR[state.hourInTheWeek] > 0.5)
197 {
198 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = 100;
199 }
200
201 // Next variable
202 NextType::hourForEachArea(state, numSpace);
203 }
204
205 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
206 unsigned int,
207 unsigned int numSpace) const
208 {
209 return pValuesForTheCurrentYear[numSpace].hour;
210 }
211
212 void localBuildAnnualSurveyReport(SurveyResults& results,
213 int fileLevel,
214 int precision,
215 unsigned int numSpace) const
216 {
217 // Initializing external pointer on current variable non applicable status
218 results.isCurrentVarNA = AncestorType::isNonApplicable;
219
220 if (AncestorType::isPrinted[0])
221 {
222 // Write the data for the current year
223 results.variableCaption = VCardType::Caption();
224 results.variableUnit = VCardType::Unit();
225 pValuesForTheCurrentYear[numSpace]
226 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
227 }
228 }
229
230private:
232 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
233 unsigned int pNbYearsParallel;
234
235}; // class LOLP_CSR
236
237} // namespace Antares::Solver::Variable::Economy
Definition study.h:61
VCardLOLP_CSR VCardType
VCard.
Definition lolpCsr.h:100
Variable::IVariable< LOLP_CSR< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition lolpCsr.h:102
NextT NextType
Type of the next static variable.
Definition lolpCsr.h:98
@ count
How many items have we got.
Definition lolpCsr.h:112
VCardType::ResultsType ResultsType
List of expected results.
Definition lolpCsr.h:105
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 spatialAggregate
The Spatial aggregation.
Definition lolpCsr.h:75
static std::string Unit()
Unit.
Definition lolpCsr.h:42
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition lolpCsr.h:69
static std::string Caption()
Caption.
Definition lolpCsr.h:36
VCardLOLP_CSR VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition lolpCsr.h:59
static constexpr uint8_t decimal
Decimal precision.
Definition lolpCsr.h:71
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition lolpCsr.h:63
static constexpr uint8_t precision
Precision (views)
Definition lolpCsr.h:67
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition lolpCsr.h:79
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition lolpCsr.h:73
static std::string Description()
The short description of the variable.
Definition lolpCsr.h:48
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition lolpCsr.h:81
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition lolpCsr.h:56