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