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