Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
variable.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_VARIABLE_H__
22#define __SOLVER_VARIABLE_VARIABLE_H__
23
24// Remove the visual studio warning: decorated name length exceeded, name was truncated
25#ifdef YUNI_OS_MSVC
26#pragma warning(disable : 4503)
27#endif
28
29#include <yuni/yuni.h>
30#include <yuni/core/static/if.h>
31
32#include "categories.h"
33#include "container.h"
34#include "endoflist.h"
35#include "info.h"
36#include "storage/intermediate.h"
37#include "storage/results.h"
38#include "surveyresults.h"
39
40namespace Antares
41{
42namespace Solver
43{
44namespace Variable
45{
49template<class ChildT, class NextT, class VCardT>
50class IVariable: protected NextT
51{
52public:
54 typedef ChildT ChildType;
56 typedef NextT NextType;
60 typedef VCardT VCardType;
62 typedef typename VCardType::ResultsType ResultsType;
67
68 static constexpr uint8_t categoryDataLevel = VCardType::categoryDataLevel;
69 static constexpr uint8_t categoryFileLevel = VCardType::categoryFileLevel;
70
71 template<int CDataLevel, int CFile>
73 {
74 enum
75 {
76 count = ((categoryDataLevel & CDataLevel && categoryFileLevel & CFile)
77 ? (NextType::template Statistics<CDataLevel, CFile>::count
78 + ResultsType::count)
79 : NextType::template Statistics<CDataLevel, CFile>::count),
80 };
81 };
82
83public:
90 template<class R>
91 static void InitializeResultsFromStudy(R& results, Data::Study& study);
92
98 template<class PredicateT>
99 static void RetrieveVariableList(PredicateT& predicate);
100
101 void getPrintStatusFromStudy(Data::Study& study);
102 void supplyMaxNumberOfColumns(Data::Study& study);
103
104public:
106
107
110 IVariable();
112
113 ~IVariable();
114
116
117
122 void initializeFromStudy(Data::Study& study);
123
124 size_t getMaxNumberColumns() const;
125
132 void initializeFromArea(Data::Study* study, Data::Area* area);
133
141
150 Data::Area* area,
151 Data::ThermalCluster* cluster);
153
154 void broadcastNonApplicability(bool applyNonApplicable);
155
157
158
161 void simulationBegin();
162
166 void simulationEnd();
168
170
171
176 void yearBegin(uint year);
177
186 void yearEndBuild(State& state, uint year);
187
197 void yearEndBuildPrepareDataForEachThermalCluster(State& state, uint year, uint numSpace);
198
207 void yearEndBuildForEachThermalCluster(State& state, uint year, uint numSpace);
208
216 void yearEnd(uint year);
217
218 template<class V>
219 void yearEndSpatialAggregates(V& allVars, uint year, unsigned int numSpace);
220
221 template<class V, class SetT>
222 void yearEndSpatialAggregates(V& allVars, uint year, const SetT& set);
223
224 template<class V>
225 void simulationEndSpatialAggregates(V& allVars);
226
227 template<class V, class SetT>
228 void simulationEndSpatialAggregates(V& allVars, const SetT& set);
230
232
233
234 void hourBegin(uint hourInTheYear);
236 void hourForEachArea(State& state);
237
238 void hourForEachArea(State& state, unsigned int numSpace);
239
241 // for a given area
242 void hourForEachLink(State& state, uint numSpace);
244 void hourEnd(State& state, uint hourInTheYear);
246
248
249 void weekBegin(State& state);
250 void weekForEachArea(State& state, uint numSpace);
251
252 void weekEnd(State& state);
254
256
257 void buildSurveyReport(SurveyResults& results,
258 int dataLevel,
259 int fileLevel,
260 int precision) const;
261
262 void buildAnnualSurveyReport(SurveyResults& results,
263 int dataLevel,
264 int fileLevel,
265 int precision,
266 uint numSpace) const;
267
268 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const;
269
273 void beforeYearByYearExport(uint year, uint numSpace);
275
279 template<class I>
280 static void provideInformations(I& infos);
281
289 template<class VCardSearchT, class O>
290 void computeSpatialAggregateWith(O& out, uint numSpace);
291
299 template<class VCardSearchT, class O>
300 void computeSpatialAggregateWith(O& out, const Data::Area* area);
301
302 template<class VCardToFindT>
303 const double* retrieveHourlyResultsForCurrentYear(uint numSpace) const;
304
305 template<class VCardToFindT>
306 void retrieveResultsForArea(typename Storage<VCardToFindT>::ResultsType** result,
307 const Data::Area* area);
308
309 template<class VCardToFindT>
310 void retrieveResultsForThermalCluster(typename Storage<VCardToFindT>::ResultsType** result,
311 const Data::ThermalCluster* cluster);
312
313 template<class VCardToFindT>
314 void retrieveResultsForLink(typename Storage<VCardToFindT>::ResultsType** result,
315 const Data::AreaLink* link);
316
317 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
318 uint column,
319 uint) const;
321
323 const StoredResultType& results() const;
324
325protected:
328 // Does current output variable appears non applicable in all output files.
329 // Following is an array of size :
330 // + 1 if variable is a single variable
331 // + > 1 if variable is a multi-variable
332 bool* isNonApplicable;
333 // Do we print results regarding the current variable in output files ? Or do we skip them ?
334 bool* isPrinted;
335 // Positive column count (original column count can be < 0 for some variable [see variables "by
336 // plant"])
337 uint pColumnCount;
338
339}; // class Variable
340
341} // namespace Variable
342} // namespace Solver
343} // namespace Antares
344
345#include "variable.hxx"
346
347#endif // __SOLVER_VARIABLE_VARIABLE_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
A single thermal cluster.
Definition cluster.h:78
Interface for any variable.
Definition variable.h:51
static void RetrieveVariableList(PredicateT &predicate)
Retrieve the list of all individual variables.
Definition variable.hxx:630
VariableAccessor< ResultsType, VCardType::columnCount > VariableAccessorType
Proxy for accessing to the intermediate results.
Definition variable.h:64
const StoredResultType & results() const
The results.
Definition variable.hxx:544
Storage< VCardT >::ResultsType StoredResultType
Results.
Definition variable.h:66
VCardT VCardType
VCard.
Definition variable.h:60
void simulationEnd()
Notify to all variables that the simulation has finished.
Definition variable.hxx:132
void hourEnd(State &state, uint hourInTheYear)
Event: A new hour in the year has just ended.
Definition variable.hxx:257
void yearEnd(uint year)
Notify to all variables that the year is now over.
Definition variable.hxx:151
void yearEndBuildPrepareDataForEachThermalCluster(State &state, uint year, uint numSpace)
Notify to all variables to prepare data for the close to year end calculations for each thermal clust...
Definition variable.hxx:178
void hourForEachArea(State &state)
Event: For a given hour in the year, walking through all areas.
Definition variable.hxx:226
StoredResultType pResults
All the results about this variable.
Definition variable.h:327
NextT NextType
Type of the next static variable.
Definition variable.h:56
IVariable< ChildT, NextT, VCardT > VariableType
Variable.
Definition variable.h:58
static void provideInformations(I &infos)
"Print" informations about the variable tree
Definition variable.hxx:361
static void InitializeResultsFromStudy(R &results, Data::Study &study)
Initialize the results of the variable.
Definition variable.hxx:71
void simulationBegin()
Notify to all variables that the simulation is about to begin.
Definition variable.hxx:125
void yearEndBuild(State &state, uint year)
Notify to all variables that the year is close to end.
void yearEndBuildForEachThermalCluster(State &state, uint year, uint numSpace)
Notify to all variables that the year is close to end.
Definition variable.hxx:240
void initializeFromArea(Data::Study *study, Data::Area *area)
Initialize the variable with a specific area.
Definition variable.hxx:78
IVariable()
Default constructor.
Definition variable.hxx:32
void initializeFromStudy(Data::Study &study)
Initialize the variable.
Definition variable.hxx:63
ChildT ChildType
Child.
Definition variable.h:54
void beforeYearByYearExport(uint year, uint numSpace)
Event triggered before exporting a year-by-year survey report.
Definition variable.hxx:354
void hourBegin(uint hourInTheYear)
Event: A new hour in the year has just began.
Definition variable.hxx:219
void initializeFromLink(Data::Study *study, Data::AreaLink *link)
Initialize the variable with a specific link between two areas.
Definition variable.hxx:86
void hourForEachLink(State &state, uint numSpace)
Event: For a given hour in the year, walking through all links.
Definition variable.hxx:250
void computeSpatialAggregateWith(O &out, uint numSpace)
Compute the spatial cluster with the results of a single variable.
Definition variable.hxx:383
void initializeFromThermalCluster(Data::Study *study, Data::Area *area, Data::ThermalCluster *cluster)
Initialize the variable with a specific thermal cluster.
Definition variable.hxx:94
VCardType::ResultsType ResultsType
List of expected results.
Definition variable.h:62
void yearBegin(uint year)
Notify to all variables that a new year is about to start.
Definition variable.hxx:144
Class utility for building CSV results files.
Definition surveyresults.h:41
Definition variable.h:25
VariableAccessor< typenameVCardT::ResultsType, VCardT::columnCount >::Type ResultsType
The true type used for the results.
Definition info.h:764