Antares Simulator
Power System Simulator
flowLinearAbs.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_FlowLinearAbs_H__
22 #define __SOLVER_VARIABLE_ECONOMY_FlowLinearAbs_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 "UCAP LIN.";
36  }
37 
39  static std::string Unit()
40  {
41  return "MWh";
42  }
43 
45  static std::string Description()
46  {
47  return "Used capacity assessed, over all MC years, through linear optimization";
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>
90 class FlowLinearAbs: public Variable::IVariable<FlowLinearAbs<NextT>, NextT, VCardFlowLinearAbs>
91 {
92 public:
94  typedef NextT NextType;
99 
102 
104 
105  enum
106  {
108  count = 1 + NextT::count,
109  };
110 
111  template<int CDataLevel, int CFile>
112  struct Statistics
113  {
114  enum
115  {
116  count = ((VCardType::categoryDataLevel & CDataLevel
117  && VCardType::categoryFileLevel & CFile)
118  ? (NextType::template Statistics<CDataLevel, CFile>::count
120  : NextType::template Statistics<CDataLevel, CFile>::count),
121  };
122  };
123 
124 public:
125  void initializeFromStudy(Data::Study& study)
126  {
127  pNbYearsParallel = study.maxNbYearsInParallel;
128 
129  // Average on all years
130  AncestorType::pResults.initializeFromStudy(study);
131  AncestorType::pResults.reset();
132 
133  // Intermediate values
134  pValuesForTheCurrentYear.resize(pNbYearsParallel);
135  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
136  {
137  pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
138  }
139 
140  // Next
141  NextType::initializeFromStudy(study);
142  }
143 
144  void initializeFromArea(Data::Study* study, Data::Area* area)
145  {
146  // Next
147  NextType::initializeFromArea(study, area);
148  }
149 
150  void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
151  {
152  // Next
153  NextType::initializeFromAreaLink(study, link);
154  }
155 
156  void simulationBegin()
157  {
158  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
159  {
160  pValuesForTheCurrentYear[numSpace].reset();
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  // Reset
174  pValuesForTheCurrentYear[numSpace].reset();
175  // Next variable
176  NextType::yearBegin(year, numSpace);
177  }
178 
179  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
180  {
181  // Next variable
182  NextType::yearEndBuild(state, year, numSpace);
183  }
184 
185  void yearEnd(unsigned int year, unsigned int numSpace)
186  {
187  // Compute all statistics for the current year (daily,weekly,monthly)
188  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
189 
190  // Next variable
191  NextType::yearEnd(year, numSpace);
192  }
193 
194  void computeSummary(unsigned int year, unsigned int numSpace)
195  {
196  // Merge all those values with the global results
197  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
198 
199  // Next variable
200  NextType::computeSummary(year, numSpace);
201  }
202 
203  void hourBegin(uint hourInTheYear)
204  {
205  // Next variable
206  NextType::hourBegin(hourInTheYear);
207  }
208 
209  void hourForEachArea(State& state, unsigned int numSpace)
210  {
211  // Next variable
212  NextType::hourForEachArea(state, numSpace);
213  }
214 
215  void hourForEachLink(State& state, unsigned int numSpace)
216  {
217  // Flow assessed over all MC years (linear)
218  pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] += std::abs(
219  state.ntc.ValeurDuFlux[state.link->index]);
220  // Next item in the list
221  NextType::hourForEachLink(state, numSpace);
222  }
223 
224  void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
225  {
226  // Next
227  NextType::buildDigest(results, digestLevel, dataLevel);
228  }
229 
230  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
231  uint,
232  uint numSpace) const
233  {
234  return pValuesForTheCurrentYear[numSpace].hour;
235  }
236 
237  void localBuildAnnualSurveyReport(SurveyResults& results,
238  int fileLevel,
239  int precision,
240  uint numSpace) const
241  {
242  // Initializing external pointer on current variable non applicable status
243  results.isCurrentVarNA = AncestorType::isNonApplicable;
244 
245  if (AncestorType::isPrinted[0])
246  {
247  // Write the data for the current year
248  results.variableCaption = VCardType::Caption();
249  results.variableUnit = VCardType::Unit();
250  pValuesForTheCurrentYear[numSpace]
251  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
252  }
253  }
254 
255 private:
257  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
258  unsigned int pNbYearsParallel;
259 
260 }; // class FlowLinearAbs
261 
262 } // namespace Antares::Solver::Variable::Economy
263 
264 #endif // __SOLVER_VARIABLE_ECONOMY_FlowLinearAbs_H__
Definition for a single area.
Definition: area.h:51
Definition: study.h:57
Marginal FlowLinearAbs.
Definition: flowLinearAbs.h:91
NextT NextType
Type of the next static variable.
Definition: flowLinearAbs.h:94
@ count
How many items have we got.
Definition: flowLinearAbs.h:108
VCardFlowLinearAbs VCardType
VCard.
Definition: flowLinearAbs.h:96
Variable::IVariable< FlowLinearAbs< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: flowLinearAbs.h:98
VCardType::ResultsType ResultsType
List of expected results.
Definition: flowLinearAbs.h:101
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 categoryDataLevel
Data Level.
Definition: flowLinearAbs.h:59
static std::string Description()
The short description of the variable.
Definition: flowLinearAbs.h:45
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: flowLinearAbs.h:71
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: flowLinearAbs.h:61
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: flowLinearAbs.h:79
static std::string Unit()
Unit.
Definition: flowLinearAbs.h:39
static constexpr uint8_t precision
Precision (views)
Definition: flowLinearAbs.h:65
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition: flowLinearAbs.h:56
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: flowLinearAbs.h:67
static std::string Caption()
Caption.
Definition: flowLinearAbs.h:33
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: flowLinearAbs.h:73
static constexpr uint8_t decimal
Decimal precision.
Definition: flowLinearAbs.h:69
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: flowLinearAbs.h:77