Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
congestionFee.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_CongestionFee_H__
22#define __SOLVER_VARIABLE_ECONOMY_CongestionFee_H__
23
24#include "../../variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
33{
35{
37 static std::string Caption()
38 {
39 return "CONG. FEE (ALG.)";
40 }
41
43 static std::string Unit()
44 {
45 return "Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Congestion fee collected throughout all MC years (Alg.)";
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
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::link;
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 = 0;
75 static constexpr int columnCount = 1;
77 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
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
88}; // class VCard
89
93template<class NextT = Container::EndOfList>
94class CongestionFee: public Variable::IVariable<CongestionFee<NextT>, NextT, VCardCongestionFee>
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 // Average on all years
134 AncestorType::pResults.initializeFromStudy(study);
136
137 // Intermediate values
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 void initializeFromArea(Data::Study* study, Data::Area* area)
149 {
150 // Next
151 NextType::initializeFromArea(study, area);
152 }
153
154 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
155 {
156 // Next
157 NextType::initializeFromAreaLink(study, link);
158 }
159
160 void simulationBegin()
161 {
162 // Next
163 NextType::simulationBegin();
164 }
165
166 void simulationEnd()
167 {
168 NextType::simulationEnd();
169 }
170
171 void yearBegin(uint year, unsigned int numSpace)
172 {
173 pValuesForTheCurrentYear[numSpace].reset();
174 // Next variable
175 NextType::yearBegin(year, numSpace);
176 }
177
178 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
179 {
180 // Next variable
181 NextType::yearEndBuild(state, year, numSpace);
182 }
183
184 void yearEnd(uint year, unsigned int numSpace)
185 {
186 // Compute all statistics for the current year (daily,weekly,monthly)
187 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
188
189 // Next variable
190 NextType::yearEnd(year, numSpace);
191 }
192
193 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
194 unsigned int nbYearsForCurrentSummary)
195 {
196 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
197 {
198 // Merge all those values with the global results
199 AncestorType::pResults.merge(numSpaceToYear[numSpace],
200 pValuesForTheCurrentYear[numSpace]);
201 }
202
203 // Next variable
204 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
205 }
206
207 void hourBegin(uint hourInTheYear)
208 {
209 // Next variable
210 NextType::hourBegin(hourInTheYear);
211 }
212
213 void hourForEachArea(State& state, unsigned int numSpace)
214 {
215 // Next variable
216 NextType::hourForEachArea(state, numSpace);
217 }
218
219 void hourForEachLink(State& state, unsigned int numSpace)
220 {
221#define UPSTREAM_PRICE \
222 state.problemeHebdo->ResultatsHoraires[state.link->from->index] \
223 .CoutsMarginauxHoraires[state.hourInTheWeek]
224#define DOWNSTREAM_PRICE \
225 state.problemeHebdo->ResultatsHoraires[state.link->with->index] \
226 .CoutsMarginauxHoraires[state.hourInTheWeek]
227
228 // Congestion Fee
229 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] = state.ntc.ValeurDuFlux
230 [state.link->index]
231 * (UPSTREAM_PRICE
232 - DOWNSTREAM_PRICE);
233 // Next item in the list
234 NextType::hourForEachLink(state, numSpace);
235
236#undef UPSTREAM_PRICE
237#undef DOWNSTREAM_PRICE
238 }
239
240 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
241 {
242 // Next
243 NextType::buildDigest(results, digestLevel, dataLevel);
244 }
245
246 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
247 uint,
248 uint numSpace) const
249 {
250 return pValuesForTheCurrentYear[numSpace].hour;
251 }
252
253 void localBuildAnnualSurveyReport(SurveyResults& results,
254 int fileLevel,
255 int precision,
256 uint numSpace) const
257 {
258 // Initializing external pointer on current variable non applicable status
259 results.isCurrentVarNA = AncestorType::isNonApplicable;
260
261 if (AncestorType::isPrinted[0])
262 {
263 // Write the data for the current year
264 results.variableCaption = VCardType::Caption();
265 results.variableUnit = VCardType::Unit();
266 pValuesForTheCurrentYear[numSpace]
267 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
268 }
269 }
270
271private:
273 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
274 unsigned int pNbYearsParallel;
275
276}; // class CongestionFee
277
278} // namespace Economy
279} // namespace Variable
280} // namespace Solver
281} // namespace Antares
282
283#endif // __SOLVER_VARIABLE_ECONOMY_CongestionFee_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal CongestionFee.
Definition congestionFee.h:95
VCardType::ResultsType ResultsType
List of expected results.
Definition congestionFee.h:105
Variable::IVariable< CongestionFee< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition congestionFee.h:102
@ count
How many items have we got.
Definition congestionFee.h:112
VCardCongestionFee VCardType
VCard.
Definition congestionFee.h:100
NextT NextType
Type of the next static variable.
Definition congestionFee.h:98
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 std::string Unit()
Unit.
Definition congestionFee.h:43
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition congestionFee.h:71
static constexpr uint8_t precision
Precision (views)
Definition congestionFee.h:69
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition congestionFee.h:81
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition congestionFee.h:75
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition congestionFee.h:83
static constexpr uint8_t categoryDataLevel
Data Level.
Definition congestionFee.h:63
static std::string Description()
The short description of the variable.
Definition congestionFee.h:49
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition congestionFee.h:77
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition congestionFee.h:60
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition congestionFee.h:65
static constexpr uint8_t decimal
Decimal precision.
Definition congestionFee.h:73
static std::string Caption()
Caption.
Definition congestionFee.h:37