Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
loldCsr.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{
33
35{
37 static std::string Caption()
38 {
39 return "LOLD CSR";
40 }
41
43 static std::string Unit()
44 {
45 return "Hours";
46 }
47
49 static std::string Description()
50 {
51 return "LOLD for CSR";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values throughout all years
58 R::AllYears::Max< // The maximum values throughout all years
59 >>>>>
61
62 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
64 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
65 & (Category::FileLevel::id
66 | Category::FileLevel::va);
68 static constexpr uint8_t precision = Category::all;
70 static constexpr uint8_t nodeDepthForGUI = +0;
72 static constexpr uint8_t decimal = 4;
74 static constexpr int columnCount = 1;
76 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
77 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
78 static constexpr uint8_t spatialAggregatePostProcessing = 0;
80 static constexpr uint8_t hasIntermediateValues = 1;
82 static constexpr uint8_t isPossiblyNonApplicable = 0;
83
85 typedef std::vector<IntermediateValues> IntermediateValuesType;
86
88
89}; // class VCard
90
94template<class NextT = Container::EndOfList>
95class LOLD_CSR: public Variable::IVariable<LOLD_CSR<NextT>, NextT, VCardLOLD_CSR>
96{
97public:
99 typedef NextT NextType;
104
107
109
110 enum
111 {
113 count = 1 + NextT::count,
114 };
115
116 template<int CDataLevel, int CFile>
118 {
119 enum
120 {
121 count = ((VCardType::categoryDataLevel & CDataLevel
123 ? (NextType::template Statistics<CDataLevel, CFile>::count
125 : NextType::template Statistics<CDataLevel, CFile>::count),
126 };
127 };
128
129public:
130 void initializeFromStudy(Data::Study& study)
131 {
132 pNbYearsParallel = study.maxNbYearsInParallel;
133
134 // Intermediate values
135 InitializeResultsFromStudy(AncestorType::pResults, study);
136
137 pValuesForTheCurrentYear.resize(pNbYearsParallel);
138 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
139 {
140 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
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].computeStatisticsForTheCurrentYear();
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] = 1.;
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 LOLD_CSR
236
237} // namespace Antares::Solver::Variable::Economy
Definition study.h:61
VCardLOLD_CSR VCardType
VCard.
Definition loldCsr.h:101
Variable::IVariable< LOLD_CSR< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition loldCsr.h:103
NextT NextType
Type of the next static variable.
Definition loldCsr.h:99
@ count
How many items have we got.
Definition loldCsr.h:113
VCardType::ResultsType ResultsType
List of expected results.
Definition loldCsr.h:106
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 nodeDepthForGUI
Indentation (GUI)
Definition loldCsr.h:70
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition loldCsr.h:64
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition loldCsr.h:60
static constexpr uint8_t decimal
Decimal precision.
Definition loldCsr.h:72
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition loldCsr.h:74
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition loldCsr.h:80
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition loldCsr.h:76
static std::string Caption()
Caption.
Definition loldCsr.h:37
static std::string Description()
The short description of the variable.
Definition loldCsr.h:49
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition loldCsr.h:82
static constexpr uint8_t precision
Precision (views)
Definition loldCsr.h:68
static std::string Unit()
Unit.
Definition loldCsr.h:43