Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
congestionFeeAbs.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_CongestionFeeAbs_H__
22#define __SOLVER_VARIABLE_ECONOMY_CongestionFeeAbs_H__
23
24#include <cmath>
25
26#include "../../variable.h"
27
28namespace Antares
29{
30namespace Solver
31{
32namespace Variable
33{
34namespace Economy
35{
37{
39 static std::string Caption()
40 {
41 return "CONG. FEE (ABS.)";
42 }
43
45 static std::string Unit()
46 {
47 return "Euro";
48 }
49
51 static std::string Description()
52 {
53 return "Congestion fee collected throughout all MC years (Absolute value)";
54 }
55
57 typedef Results<R::AllYears::Average< // The average values throughout all years
58 R::AllYears::StdDeviation< // The standard deviation values throughout all years
59 R::AllYears::Min< // The minimum values throughout all years
60 R::AllYears::Max< // The maximum values throughout all years
61 >>>>>
63
65 static constexpr uint8_t categoryDataLevel = Category::DataLevel::link;
67 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
68 & (Category::FileLevel::id
69 | Category::FileLevel::va);
71 static constexpr uint8_t precision = Category::all;
73 static constexpr uint8_t nodeDepthForGUI = +0;
75 static constexpr uint8_t decimal = 0;
77 static constexpr int columnCount = 1;
79 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
80 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
81 static constexpr uint8_t spatialAggregatePostProcessing = 0;
83 static constexpr uint8_t hasIntermediateValues = 1;
85 static constexpr uint8_t isPossiblyNonApplicable = 0;
86
88 typedef std::vector<IntermediateValues> IntermediateValuesType;
89
90}; // class VCard
91
95template<class NextT = Container::EndOfList>
97 : public Variable::IVariable<CongestionFeeAbs<NextT>, NextT, VCardCongestionFeeAbs>
98{
99public:
101 typedef NextT NextType;
106
109
111
112 enum
113 {
115 count = 1 + NextT::count,
116 };
117
118 template<int CDataLevel, int CFile>
120 {
121 enum
122 {
123 count = ((VCardType::categoryDataLevel & CDataLevel
125 ? (NextType::template Statistics<CDataLevel, CFile>::count
127 : NextType::template Statistics<CDataLevel, CFile>::count),
128 };
129 };
130
131public:
132 void initializeFromStudy(Data::Study& study)
133 {
134 pNbYearsParallel = study.maxNbYearsInParallel;
135
136 // Average on all years
137 AncestorType::pResults.initializeFromStudy(study);
139
140 // Intermediate values
141 pValuesForTheCurrentYear.resize(pNbYearsParallel);
142 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
143 {
144 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
145 }
146
147 // Next
148 NextType::initializeFromStudy(study);
149 }
150
151 void initializeFromArea(Data::Study* study, Data::Area* area)
152 {
153 // Next
154 NextType::initializeFromArea(study, area);
155 }
156
157 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
158 {
159 // Next
160 NextType::initializeFromAreaLink(study, link);
161 }
162
163 void simulationBegin()
164 {
165 // Next
166 NextType::simulationBegin();
167 }
168
169 void simulationEnd()
170 {
171 NextType::simulationEnd();
172 }
173
174 void yearBegin(uint year, unsigned int numSpace)
175 {
176 // Reset
177 pValuesForTheCurrentYear[numSpace].reset();
178 // Next variable
179 NextType::yearBegin(year, numSpace);
180 }
181
182 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
183 {
184 // Next variable
185 NextType::yearEndBuild(state, year, numSpace);
186 }
187
188 void yearEnd(unsigned int year, unsigned int numSpace)
189 {
190 // Compute all statistics for the current year (daily,weekly,monthly)
191 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
192
193 // Next variable
194 NextType::yearEnd(year, numSpace);
195 }
196
197 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
198 unsigned int nbYearsForCurrentSummary)
199 {
200 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
201 {
202 // Merge all those values with the global results
203 AncestorType::pResults.merge(numSpaceToYear[numSpace],
204 pValuesForTheCurrentYear[numSpace]);
205 }
206
207 // Next variable
208 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
209 }
210
211 void hourBegin(uint hourInTheYear)
212 {
213 // Next variable
214 NextType::hourBegin(hourInTheYear);
215 }
216
217 void hourForEachArea(State& state, unsigned int numSpace)
218 {
219 // Next variable
220 NextType::hourForEachArea(state, numSpace);
221 }
222
223 void hourForEachLink(State& state, unsigned int numSpace)
224 {
225#define UPSTREAM_PRICE \
226 state.problemeHebdo->ResultatsHoraires[state.link->from->index] \
227 .CoutsMarginauxHoraires[state.hourInTheWeek]
228#define DOWNSTREAM_PRICE \
229 state.problemeHebdo->ResultatsHoraires[state.link->with->index] \
230 .CoutsMarginauxHoraires[state.hourInTheWeek]
231
232 // Congestion Fee
233 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] = std::abs(
234 state.ntc.ValeurDuFlux[state.link->index] * (UPSTREAM_PRICE - DOWNSTREAM_PRICE));
235 // Next item in the list
236 NextType::hourForEachLink(state, numSpace);
237
238#undef UPSTREAM_PRICE
239#undef DOWNSTREAM_PRICE
240 }
241
242 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
243 {
244 // Next
245 NextType::buildDigest(results, digestLevel, dataLevel);
246 }
247
248 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
249 uint,
250 uint numSpace) const
251 {
252 return pValuesForTheCurrentYear[numSpace].hour;
253 }
254
255 void localBuildAnnualSurveyReport(SurveyResults& results,
256 int fileLevel,
257 int precision,
258 uint numSpace) const
259 {
260 // Initializing external pointer on current variable non applicable status
261 results.isCurrentVarNA = AncestorType::isNonApplicable;
262
263 if (AncestorType::isPrinted[0])
264 {
265 // Write the data for the current year
266 results.variableCaption = VCardType::Caption();
267 results.variableUnit = VCardType::Unit();
268 pValuesForTheCurrentYear[numSpace]
269 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
270 }
271 }
272
273private:
275 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
276 unsigned int pNbYearsParallel;
277
278}; // class CongestionFeeAbs
279
280} // namespace Economy
281} // namespace Variable
282} // namespace Solver
283} // namespace Antares
284
285#endif // __SOLVER_VARIABLE_ECONOMY_CongestionFeeAbs_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal CongestionFeeAbs.
Definition congestionFeeAbs.h:98
NextT NextType
Type of the next static variable.
Definition congestionFeeAbs.h:101
VCardType::ResultsType ResultsType
List of expected results.
Definition congestionFeeAbs.h:108
VCardCongestionFeeAbs VCardType
VCard.
Definition congestionFeeAbs.h:103
Variable::IVariable< CongestionFeeAbs< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition congestionFeeAbs.h:105
@ count
How many items have we got.
Definition congestionFeeAbs.h:115
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 nodeDepthForGUI
Indentation (GUI)
Definition congestionFeeAbs.h:73
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition congestionFeeAbs.h:85
static constexpr uint8_t decimal
Decimal precision.
Definition congestionFeeAbs.h:75
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition congestionFeeAbs.h:77
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition congestionFeeAbs.h:79
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition congestionFeeAbs.h:83
static constexpr uint8_t precision
Precision (views)
Definition congestionFeeAbs.h:71
static std::string Description()
The short description of the variable.
Definition congestionFeeAbs.h:51
static std::string Unit()
Unit.
Definition congestionFeeAbs.h:45
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition congestionFeeAbs.h:62
static constexpr uint8_t categoryDataLevel
Data Level.
Definition congestionFeeAbs.h:65
static std::string Caption()
Caption.
Definition congestionFeeAbs.h:39
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition congestionFeeAbs.h:67