Antares Simulator
Power System Simulator
avail-dispatchable-generation.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_AvailableDispatchGen_H__
22 #define __SOLVER_VARIABLE_ECONOMY_AvailableDispatchGen_H__
23 
24 #include "antares/solver/variable/variable.h"
25 
26 namespace Antares::Solver::Variable::Economy
27 {
29 {
31  static std::string Caption()
32  {
33  return "AVL DTG";
34  }
35 
37  static std::string Unit()
38  {
39  return "MWh";
40  }
41 
43  static std::string Description()
44  {
45  return "Available dispatchable generation";
46  }
47 
49  typedef Results<R::AllYears::Average< // The average values thoughout all years
50  R::AllYears::StdDeviation< // The standard deviation values throughout all years
51  R::AllYears::Min< // The minimum values thoughout all years
52  R::AllYears::Max< // The maximum values thoughout all years
53  >>>>>
55 
58 
60  static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
62  static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
63  & (Category::FileLevel::id
64  | Category::FileLevel::va);
66  static constexpr uint8_t precision = Category::all;
68  static constexpr uint8_t nodeDepthForGUI = +0;
70  static constexpr uint8_t decimal = 0;
72  static constexpr int columnCount = 1;
74  static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
75  static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
76  static constexpr uint8_t spatialAggregatePostProcessing = 0;
78  static constexpr uint8_t hasIntermediateValues = 1;
80  static constexpr uint8_t isPossiblyNonApplicable = 0;
81 
83  typedef std::vector<IntermediateValues> IntermediateValuesType;
84 
85  using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;
86 
87 }; // class VCard
88 
92 template<class NextT = Container::EndOfList>
94  : public Variable::IVariable<AvailableDispatchGen<NextT>, NextT, VCardAvailableDispatchGen>
95 {
96 public:
98  typedef NextT NextType;
103 
106 
108 
109  enum
110  {
112  count = 1 + NextT::count,
113  };
114 
115  template<int CDataLevel, int CFile>
116  struct Statistics
117  {
118  enum
119  {
120  count = ((VCardType::categoryDataLevel & CDataLevel
121  && VCardType::categoryFileLevel & CFile)
122  ? (NextType::template Statistics<CDataLevel, CFile>::count
124  : NextType::template Statistics<CDataLevel, CFile>::count),
125  };
126  };
127 
128 public:
129  void initializeFromStudy(Data::Study& study)
130  {
131  pNbYearsParallel = study.maxNbYearsInParallel;
132 
133  // Average thoughout all years
134  InitializeResultsFromStudy(AncestorType::pResults, study);
135 
136  // Intermediate values
137  pValuesForTheCurrentYear.resize(pNbYearsParallel);
138  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
139  {
140  pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
141  }
142 
143  // Next
144  NextType::initializeFromStudy(study);
145  }
146 
147  template<class R>
148  static void InitializeResultsFromStudy(R& results, Data::Study& study)
149  {
150  VariableAccessorType::InitializeAndReset(results, study);
151  }
152 
153  void initializeFromArea(Data::Study* study, Data::Area* area)
154  {
155  pArea = area;
156  // Next
157  NextType::initializeFromArea(study, area);
158  }
159 
160  void initializeFromLink(Data::Study* study, Data::AreaLink* link)
161  {
162  // Next
163  NextType::initializeFromAreaLink(study, link);
164  }
165 
166  void simulationBegin()
167  {
168  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
169  {
170  pValuesForTheCurrentYear[numSpace].reset();
171  }
172 
173  // Next
174  NextType::simulationBegin();
175  }
176 
177  void simulationEnd()
178  {
179  NextType::simulationEnd();
180  }
181 
182  void yearBegin(unsigned int year, unsigned int numSpace)
183  {
184  // Somme de toutes les productions disponibles pour l'ensemble des
185  // paliers thermiques (+must-run)
186  pValuesForTheCurrentYear[numSpace].reset();
187  for (const auto& cluster: pArea->thermal.list.each_enabled())
188  {
189  const auto& availableProduction = cluster->series.getColumn(year);
190  for (unsigned int hour = 0; hour != cluster->series.timeSeries.height; ++hour)
191  {
192  pValuesForTheCurrentYear[numSpace].hour[hour] += availableProduction[hour];
193  }
194  }
195 
196  // Next variable
197  NextType::yearBegin(year, numSpace);
198  }
199 
200  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
201  {
202  // Next variable
203  NextType::yearEndBuild(state, year, numSpace);
204  }
205 
206  void yearEnd(unsigned int year, unsigned int numSpace)
207  {
208  // Compute all statistics for the current year (daily,weekly,monthly)
209  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
210 
211  // Next variable
212  NextType::yearEnd(year, numSpace);
213  }
214 
215  void computeSummary(unsigned int year, unsigned int numSpace)
216  {
217  // Merge all those values with the global results
218  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
219 
220  // Next variable
221  NextType::computeSummary(year, numSpace);
222  }
223 
224  void hourBegin(unsigned int hourInTheYear)
225  {
226  // Next variable
227  NextType::hourBegin(hourInTheYear);
228  }
229 
230  void hourForEachArea(State& state, unsigned int numSpace)
231  {
232  // Next variable
233  NextType::hourForEachArea(state, numSpace);
234  }
235 
236  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
237  unsigned int,
238  unsigned int numSpace) const
239  {
240  return pValuesForTheCurrentYear[numSpace].hour;
241  }
242 
243  void localBuildAnnualSurveyReport(SurveyResults& results,
244  int fileLevel,
245  int precision,
246  unsigned int numSpace) const
247  {
248  // Initializing external pointer on current variable non applicable status
249  results.isCurrentVarNA = AncestorType::isNonApplicable;
250 
251  if (AncestorType::isPrinted[0])
252  {
253  // Write the data for the current year
254  results.variableCaption = VCardType::Caption();
255  results.variableUnit = VCardType::Unit();
256  pValuesForTheCurrentYear[numSpace]
257  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
258  }
259  }
260 
261 private:
263  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
264  //
265  Data::Area* pArea;
266  unsigned int pNbYearsParallel;
267 
268 }; // class AvailableDispatchGen
269 
270 } // namespace Antares::Solver::Variable::Economy
271 
272 #endif // __SOLVER_VARIABLE_ECONOMY_AvailableDispatchGen_H__
Definition for a single area.
Definition: area.h:51
ThermalClusterList list
List of all thermal clusters (enabled and disabled) except must-run clusters.
Definition: container.h:88
Definition: study.h:57
Marginal AvailableDispatchGen.
Definition: avail-dispatchable-generation.h:95
VCardType::ResultsType ResultsType
List of expected results.
Definition: avail-dispatchable-generation.h:105
NextT NextType
Type of the next static variable.
Definition: avail-dispatchable-generation.h:98
Variable::IVariable< AvailableDispatchGen< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: avail-dispatchable-generation.h:102
VCardAvailableDispatchGen VCardType
VCard.
Definition: avail-dispatchable-generation.h:100
@ count
How many items have we got.
Definition: avail-dispatchable-generation.h:112
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
Definition: avail-dispatchable-generation.h:117
Definition: avail-dispatchable-generation.h:29
VCardAvailableDispatchGen VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition: avail-dispatchable-generation.h:57
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition: avail-dispatchable-generation.h:54
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: avail-dispatchable-generation.h:60
static std::string Caption()
Caption.
Definition: avail-dispatchable-generation.h:31
static constexpr uint8_t precision
Precision (views)
Definition: avail-dispatchable-generation.h:66
static constexpr uint8_t decimal
Decimal precision.
Definition: avail-dispatchable-generation.h:70
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: avail-dispatchable-generation.h:72
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: avail-dispatchable-generation.h:78
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: avail-dispatchable-generation.h:74
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: avail-dispatchable-generation.h:62
static std::string Description()
The short description of the variable.
Definition: avail-dispatchable-generation.h:43
static std::string Unit()
Unit.
Definition: avail-dispatchable-generation.h:37
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: avail-dispatchable-generation.h:80
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: avail-dispatchable-generation.h:68