Antares Simulator
Power System Simulator
join.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_Join_H__
22 #define __SOLVER_VARIABLE_ECONOMY_Join_H__
23 
24 #include "antares/solver/variable/variable.h"
25 
26 namespace Antares::Solver::Variable
27 {
28 struct VCardJoin
29 {
31  static std::string Caption()
32  {
33  return "";
34  }
35 
37  static std::string Unit()
38  {
39  return "";
40  }
41 
43  static std::string Description()
44  {
45  return "";
46  }
47 
49  typedef Results<R::AllYears::Average< // The average values throughout all years
50  R::AllYears::StdDeviation< // The standard deviation values throughout all years
51  R::AllYears::Min< // The minimum values throughout all years
52  R::AllYears::Max< // The maximum values throughout all years
53  >>>>>
55 
57  static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
59  static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
60  & (Category::FileLevel::id
61  | Category::FileLevel::va);
63  static constexpr uint8_t precision = Category::all;
65  static constexpr uint8_t nodeDepthForGUI = +0;
67  static constexpr uint8_t decimal = 0;
69  static constexpr int columnCount = 0;
71  static constexpr uint8_t spatialAggregate = Category::noSpatialAggregate;
72  static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
73  static constexpr uint8_t spatialAggregatePostProcessing = 0;
75  static constexpr uint8_t hasIntermediateValues = 0;
76 
77 }; // class VCard
78 
82 template<class LeftT, class RightT>
83 class Join: public Variable::IVariable<Join<LeftT, RightT>, Yuni::Default, VCardJoin>,
84  public LeftT,
85  public RightT
86 {
87 public:
88  typedef LeftT LeftType;
89  typedef RightT RightType;
90 
95 
98 
100 
101  enum
102  {
104  count = 1 + RightT::count,
105  };
106 
107  template<int CDataLevel, int CFile>
108  struct Statistics
109  {
110  enum
111  {
112  count = (int)LeftType::template Statistics < CDataLevel,
113  CFile > ::count + (int)RightType::template Statistics < CDataLevel,
114  CFile > ::count,
115  };
116  };
117 
118 public:
124  template<class PredicateT>
125  static void RetrieveVariableList(PredicateT& predicate)
126  {
127  LeftType::RetrieveVariableList(predicate);
128  RightType::RetrieveVariableList(predicate);
129  }
130 
131 public:
132  void initializeFromStudy(Data::Study& study)
133  {
134  LeftType::initializeFromStudy(study);
135  RightType::initializeFromStudy(study);
136  }
137 
138  void initializeFromArea(Data::Study* study, Data::Area* area)
139  {
140  LeftType::initializeFromArea(study, area);
141  RightType::initializeFromArea(study, area);
142  }
143 
144  void initializeFromLink(Data::Study* study, Data::AreaLink* link)
145  {
146  LeftType::initializeFromAreaLink(study, link);
147  RightType::initializeFromAreaLink(study, link);
148  }
149 
150  void initializeFromThermalCluster(Data::Study* study,
151  Data::Area* area,
152  Data::ThermalCluster* cluster)
153  {
154  LeftType::initializeFromThermalCluster(study, area, cluster);
155  RightType::initializeFromThermalCluster(study, area, cluster);
156  }
157 
158  void simulationBegin()
159  {
160  LeftType::simulationBegin();
161  RightType::simulationBegin();
162  }
163 
164  void simulationEnd()
165  {
166  LeftType::simulationEnd();
167  RightType::simulationEnd();
168  }
169 
170  void yearBegin(unsigned int year, unsigned int numSpace)
171  {
172  LeftType::yearBegin(year, numSpace);
173  RightType::yearBegin(year, numSpace);
174  }
175 
176  void yearEndBuildPrepareDataForEachThermalCluster(State& state, uint year)
177  {
178  // Next variable
179  LeftType::yearEndBuildPrepareDataForEachThermalCluster(state, year);
180  RightType::yearEndBuildPrepareDataForEachThermalCluster(state, year);
181  }
182 
183  void yearEndBuildForEachThermalCluster(State& state, uint year)
184  {
185  // Next variable
186  LeftType::yearEndBuildForEachThermalCluster(state, year);
187  RightType::yearEndBuildForEachThermalCluster(state, year);
188  }
189 
190  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
191  {
192  LeftType::yearEndBuild(state, year, numSpace);
193  RightType::yearEndBuild(state, year, numSpace);
194  }
195 
196  void yearEnd(unsigned int year, unsigned int numSpace)
197  {
198  LeftType::yearEnd(year, numSpace);
199  RightType::yearEnd(year, numSpace);
200  }
201 
202  void computeSummary(unsigned int year, unsigned int numSpace)
203  {
204  // Next variable
205  LeftType::computeSummary(year, numSpace);
206  RightType::computeSummary(year, numSpace);
207  }
208 
209  void weekBegin(State& state)
210  {
211  LeftType::weekBegin(state);
212  RightType::weekBegin(state);
213  }
214 
215  void weekForEachArea(State& state, unsigned int numSpace)
216  {
217  LeftType::weekForEachArea(state, numSpace);
218  RightType::weekForEachArea(state, numSpace);
219  }
220 
221  void weekEnd(State& state)
222  {
223  LeftType::weekEnd(state);
224  RightType::weekEnd(state);
225  }
226 
227  void hourBegin(unsigned int hourInTheYear)
228  {
229  LeftType::hourBegin(hourInTheYear);
230  RightType::hourBegin(hourInTheYear);
231  }
232 
233  void hourForEachArea(State& state, unsigned int numSpace)
234  {
235  LeftType::hourForEachArea(state, numSpace);
236  RightType::hourForEachArea(state, numSpace);
237  }
238 
239  void hourForEachLink(State& state)
240  {
241  LeftType::hourForEachLink(state);
242  RightType::hourForEachLink(state);
243  }
244 
245  void hourEnd(State& state, unsigned int hourInTheYear)
246  {
247  LeftType::hourEnd(state, hourInTheYear);
248  RightType::hourEnd(state, hourInTheYear);
249  }
250 
251  void buildSurveyReport(SurveyResults& results,
252  int dataLevel,
253  int fileLevel,
254  int precision) const
255  {
256  LeftType::buildSurveyReport(results, dataLevel, fileLevel, precision);
257  RightType::buildSurveyReport(results, dataLevel, fileLevel, precision);
258  }
259 
260  void buildAnnualSurveyReport(SurveyResults& results,
261  int dataLevel,
262  int fileLevel,
263  int precision,
264  uint numSpace) const
265  {
266  LeftType::buildAnnualSurveyReport(results, dataLevel, fileLevel, precision, numSpace);
267  RightType::buildAnnualSurveyReport(results, dataLevel, fileLevel, precision, numSpace);
268  }
269 
270  void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
271  {
272  // Building the digest
273  LeftType ::buildDigest(results, digestLevel, dataLevel);
274  RightType::buildDigest(results, digestLevel, dataLevel);
275  }
276 
277  void beforeYearByYearExport(uint year, uint numSpace)
278  {
279  // Building the digest
280  LeftType ::beforeYearByYearExport(year, numSpace);
281  RightType::beforeYearByYearExport(year, numSpace);
282  }
283 
284  template<class SearchVCardT, class O>
285  void computeSpatialAggregateWith(O& out)
286  {
287  LeftType ::template computeSpatialAggregateWith<SearchVCardT, O>(out);
288  RightType::template computeSpatialAggregateWith<SearchVCardT, O>(out);
289  }
290 
291  template<class SearchVCardT, class O>
292  void computeSpatialAggregateWith(O& out, const Data::Area* area, uint numSpace)
293  {
294  LeftType ::template computeSpatialAggregateWith<SearchVCardT, O>(out, area, numSpace);
295  RightType::template computeSpatialAggregateWith<SearchVCardT, O>(out, area, numSpace);
296  }
297 
298  template<class V>
299  void yearEndSpatialAggregates(V& allVars, unsigned int year, unsigned int numSpace)
300  {
301  LeftType::yearEndSpatialAggregates(allVars, year, numSpace);
302  RightType::yearEndSpatialAggregates(allVars, year, numSpace);
303  }
304 
305  template<class V>
306  void computeSpatialAggregatesSummary(V& allVars, unsigned int year, unsigned int numSpace)
307  {
308  LeftType::computeSpatialAggregatesSummary(allVars, year, numSpace);
309  RightType::computeSpatialAggregatesSummary(allVars, year, numSpace);
310  }
311 
312  template<class V>
313  void simulationEndSpatialAggregates(V& allVars)
314  {
315  LeftType::simulationEndSpatialAggregates(allVars);
316  RightType::simulationEndSpatialAggregates(allVars);
317  }
318 
319  template<class I>
320  static void provideInformations(I& infos)
321  {
322  LeftType ::provideInformations(infos);
323  RightType::provideInformations(infos);
324  }
325 
326  template<class VCardToFindT>
327  const double* retrieveHourlyResultsForCurrentYear() const
328  {
329  // Is this function ever called ?
330  auto* result = LeftType::template retrieveHourlyResultsForCurrentYear<VCardToFindT>();
331  return (!result) ? RightType::template retrieveHourlyResultsForCurrentYear<VCardToFindT>()
332  : result;
333  }
334 
335  template<class VCardToFindT>
336  void retrieveResultsForArea(typename Variable::Storage<VCardToFindT>::ResultsType** result,
337  const Data::Area* area)
338  {
339  LeftType::template retrieveResultsForArea<VCardToFindT>(result, area);
340  RightType::template retrieveResultsForArea<VCardToFindT>(result, area);
341  }
342 
343  template<class VCardToFindT>
344  void retrieveResultsForThermalCluster(
346  const Data::ThermalCluster* cluster)
347  {
348  LeftType::template retrieveResultsForThermalCluster<VCardToFindT>(result, cluster);
349  RightType::template retrieveResultsForThermalCluster<VCardToFindT>(result, cluster);
350  }
351 
352  template<class VCardToFindT>
353  void retrieveResultsForLink(typename Variable::Storage<VCardToFindT>::ResultsType** result,
354  const Data::AreaLink* link)
355  {
356  LeftType::template retrieveResultsForLink<VCardToFindT>(result, link);
357  RightType::template retrieveResultsForLink<VCardToFindT>(result, link);
358  }
359 
360  void localBuildAnnualSurveyReport(SurveyResults& results, int fileLevel, int precision) const
361  {
362  LeftType::localBuildAnnualSurveyReport(results, fileLevel, precision);
363  RightType::localBuildAnnualSurveyReport(results, fileLevel, precision);
364  }
365 
366 }; // class Join
367 
368 } // namespace Antares::Solver::Variable
369 
370 #endif // __SOLVER_VARIABLE_ECONOMY_Join_H__
Definition for a single area.
Definition: area.h:51
Definition: study.h:57
A single thermal cluster.
Definition: cluster.h:76
Interface for any variable.
Definition: variable.h:47
const StoredResultType & results() const
The results.
Definition: variable.hxx:544
Join.
Definition: join.h:86
VCardJoin VCardType
VCard.
Definition: join.h:92
static void RetrieveVariableList(PredicateT &predicate)
Retrieve the list of all individual variables.
Definition: join.h:125
@ count
How many items have we got.
Definition: join.h:104
VCardType::ResultsType ResultsType
List of expected results.
Definition: join.h:97
Variable::IVariable< Join< LeftT, RightT >, Yuni::Default, VCardType > AncestorType
Ancestor.
Definition: join.h:94
Definition: results.h:44
Definition: cbuilder.h:120
VariableAccessor< typename VCardT::ResultsType, VCardT::columnCount >::Type ResultsType
The true type used for the results.
Definition: info.h:760
static std::string Description()
The short description of the variable.
Definition: join.h:43
static constexpr uint8_t precision
Precision (views)
Definition: join.h:63
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: join.h:57
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: join.h:59
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: join.h:75
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: join.h:65
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition: join.h:54
static std::string Unit()
Unit.
Definition: join.h:37
static std::string Caption()
Caption.
Definition: join.h:31
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: join.h:69
static constexpr uint8_t decimal
Decimal precision.
Definition: join.h:67
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: join.h:71