Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
setofareas.hxx
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_SET_OF_AREAS_HXX__
22#define __SOLVER_VARIABLE_SET_OF_AREAS_HXX__
23
24namespace Antares
25{
26namespace Solver
27{
28namespace Variable
29{
30template<class NextT>
31void SetsOfAreas<NextT>::initializeFromStudy(Data::Study& study)
32{
33 using namespace Antares;
34
35 // The study
36 pStudy = &study;
37 // alias to the set of sets of areas
38 auto& sets = study.setsOfAreas;
39 // Reserving the memory
40 pSetsOfAreas.reserve(sets.size());
41 pOriginalSets.reserve(sets.size());
42
43 // For each set...
44 for (uint setIndex = 0; setIndex != sets.size(); ++setIndex)
45 {
46 if (!sets.hasOutput(setIndex))
47 {
48 continue;
49 }
50 // Name of the set
51 const auto& setname = sets.caption(setIndex);
52
53 // Useless if the result set is empty
54 if (!sets.resultSize(setIndex))
55 {
56 logs.warning() << "The set of areas named '" << setname
57 << "' is empty. No output will be produced for this set.";
58 continue;
59 }
60
61 auto n = std::make_unique<NextT>();
62
63 // Initialize the variables
64 // From the study
65 n->initializeFromStudy(study);
66
67 // Making specific variables non applicable in following output reports :
68 // - annual district reports
69 // - over all years district statistics reports
70 n->broadcastNonApplicability(true);
71
72 // For each current set's variable, getting the print status, that is :
73 // is variable's column(s) printed in output (set of areas) reports ?
74 n->getPrintStatusFromStudy(study);
75
76 pSetsOfAreas.push_back(std::move(n));
77
78 auto* originalSet = &sets[setIndex];
79 assert(originalSet != NULL);
80 assert(!originalSet->empty());
81 pOriginalSets.push_back(originalSet);
82
83 pNames.push_back(setname);
84 }
85}
86
87template<class NextT>
88inline void SetsOfAreas<NextT>::initializeFromArea(Data::Study*, Data::Area*)
89{
90 // Nothing to do here
91}
92
93template<class NextT>
94inline void SetsOfAreas<NextT>::initializeFromAreaLink(Data::Study*, Data::AreaLink*)
95{
96 // Nothing to do here
97}
98
99template<class NextT>
100inline void SetsOfAreas<NextT>::initializeFromThermalCluster(Data::Study*,
101 Data::Area*,
103{
104 // This method should not be called at this stage
105}
106
107template<class NextT>
108inline void SetsOfAreas<NextT>::simulationBegin()
109{
110 // Nothing to do here
111}
112
113template<class NextT>
114inline void SetsOfAreas<NextT>::simulationEnd()
115{
116 // Nothing to do here
117}
118
119template<class NextT>
120inline void SetsOfAreas<NextT>::yearBegin(uint /*year*/, uint /* numSpace */)
121{
122 // Nothing to do here
123}
124
125template<class NextT>
126inline void SetsOfAreas<NextT>::yearEndBuild(State& /*state*/, uint /*year*/, uint /*numSpace*/)
127{
128 // Nothing to do here
129}
130
131template<class NextT>
132inline void SetsOfAreas<NextT>::yearEnd(uint /*year*/, uint /*numSpace*/)
133{
134 // Nothing to do here
135}
136
137template<class NextT>
138inline void SetsOfAreas<NextT>::computeSummary(
139 std::map<unsigned int, unsigned int>& /*numSpaceToYear*/,
140 unsigned int /* nbYearsForCurrentSummary */)
141{
142 // Nothing to do here
143}
144
145template<class NextT>
146inline void SetsOfAreas<NextT>::hourBegin(uint /*hourInTheYear*/)
147{
148 // Nothing to do here
149}
150
151template<class NextT>
152inline void SetsOfAreas<NextT>::weekBegin(State&)
153{
154 // Nothing to do here
155}
156
157template<class NextT>
158inline void SetsOfAreas<NextT>::weekForEachArea(State&, unsigned int /*numSpace*/)
159{
160 // Nothing to do here
161}
162
163template<class NextT>
164inline void SetsOfAreas<NextT>::weekEnd(State&)
165{
166 // Nothing to do here
167}
168
169template<class NextT>
170void SetsOfAreas<NextT>::hourForEachArea(State& state, unsigned int)
171{
172 (void)state;
173}
174
175template<class NextT>
176inline void SetsOfAreas<NextT>::hourForEachLink(State& state)
177{
178 (void)state;
179}
180
181template<class NextT>
182inline void SetsOfAreas<NextT>::hourEnd(State& state, uint hourInTheYear)
183{
184 (void)state;
185 (void)hourInTheYear;
186}
187
188template<class NextT>
189inline void SetsOfAreas<NextT>::buildSurveyReport(SurveyResults& results,
190 int dataLevel,
191 int fileLevel,
192 int precision) const
193{
194 int count_int = count;
195 bool setOfAreasDataLevel = dataLevel & Category::DataLevel::setOfAreas;
196 if (count_int && setOfAreasDataLevel)
197 {
198 pSetsOfAreas[results.data.setOfAreasIndex]->buildSurveyReport(results,
199 dataLevel,
200 fileLevel,
201 precision);
202 }
203}
204
205template<class NextT>
206inline void SetsOfAreas<NextT>::buildAnnualSurveyReport(SurveyResults& results,
207 int dataLevel,
208 int fileLevel,
209 int precision,
210 uint numSpace) const
211{
212 int count_int = count;
213 bool setOfAreasDataLevel = dataLevel & Category::DataLevel::setOfAreas;
214 if (count_int && setOfAreasDataLevel)
215 {
216 pSetsOfAreas[results.data.setOfAreasIndex]->buildAnnualSurveyReport(results,
217 dataLevel,
218 fileLevel,
219 precision,
220 numSpace);
221 }
222}
223
224template<class NextT>
225void SetsOfAreas<NextT>::buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
226{
227 int count_int = count;
228 bool setOfAreasDataLevel = dataLevel & Category::DataLevel::setOfAreas;
229 if (count_int && setOfAreasDataLevel)
230 {
231 // Reset
232 results.data.rowCaptions.clear();
233 results.data.rowCaptions.resize(pSetsOfAreas.size());
234 results.data.area = nullptr;
235 results.data.rowIndex = 0;
236
237 for (auto& set: pSetsOfAreas)
238 {
239 results.data.columnIndex = 0;
240 results.data.rowCaptions[results.data.rowIndex].clear()
241 << "@ " << pNames[results.data.rowIndex];
242 set->buildDigest(results, digestLevel, dataLevel);
243 ++results.data.rowIndex;
244 }
245 }
246}
247
248template<class NextT>
249template<class I>
250inline void SetsOfAreas<NextT>::provideInformations(I& infos)
251{
252 // Begining of the node
253 if (VCardType::nodeDepthForGUI)
254 {
255 infos.template beginNode<VCardType>();
256 // Next variable in the list
257 NextType::template provideInformations<I>(infos);
258 // End of the node
259 infos.endNode();
260 }
261 else
262 {
263 // Giving our VCard
264 infos.template addVCard<VCardType>();
265 // Next variable in the list
266 NextType::template provideInformations<I>(infos);
267 }
268}
269
270template<class NextT>
271template<class V>
272void SetsOfAreas<NextT>::yearEndSpatialAggregates(V& allVars, uint year, uint numSpace)
273{
274 for (uint setindex = 0; setindex != pSetsOfAreas.size(); ++setindex)
275 {
276 assert(setindex < pOriginalSets.size());
277 pSetsOfAreas[setindex]->yearEndSpatialAggregates(allVars,
278 year,
279 *(pOriginalSets[setindex]),
280 numSpace);
281 }
282}
283
284template<class NextT>
285template<class V>
286void SetsOfAreas<NextT>::computeSpatialAggregatesSummary(
287 V& allVars,
288 std::map<unsigned int, unsigned int>& numSpaceToYear,
289 unsigned int nbYearsForCurrentSummary)
290{
291 for (uint setindex = 0; setindex != pSetsOfAreas.size(); ++setindex)
292 {
293 assert(setindex < pOriginalSets.size());
294 pSetsOfAreas[setindex]->computeSpatialAggregatesSummary(allVars,
295 numSpaceToYear,
296 nbYearsForCurrentSummary);
297 }
298}
299
300template<class NextT>
301template<class V>
302void SetsOfAreas<NextT>::simulationEndSpatialAggregates(V& allVars)
303{
304 for (uint i = 0; i != pSetsOfAreas.size(); ++i)
305 {
306 pSetsOfAreas[i]->simulationEndSpatialAggregates(allVars, *(pOriginalSets[i]));
307 }
308}
309
310template<class NextT>
311void SetsOfAreas<NextT>::beforeYearByYearExport(uint year, uint numSpace)
312{
313 for (uint i = 0; i != pSetsOfAreas.size(); ++i)
314 {
315 pSetsOfAreas[i]->beforeYearByYearExport(year, numSpace);
316 }
317}
318
319template<class NextT>
320template<class SearchVCardT, class O>
321inline void SetsOfAreas<NextT>::computeSpatialAggregateWith(O&)
322{
323 // Do nothing
324}
325
326template<class NextT>
327template<class SearchVCardT, class O>
328inline void SetsOfAreas<NextT>::computeSpatialAggregateWith(O& out,
329 const Data::Area* area,
330 uint numSpace)
331{
332 (void)out;
333 (void)area;
334 (void)numSpace;
335 // pSetsOfAreas[area->index]->computeSpatialAggregateWith<SearchVCardT,O>(out);
336}
337
338template<class NextT>
339template<class VCardToFindT>
340inline const double* SetsOfAreas<NextT>::retrieveHourlyResultsForCurrentYear() const
341{
342 return nullptr;
343}
344
345template<class NextT>
346template<class VCardToFindT>
347inline void SetsOfAreas<NextT>::retrieveResultsForArea(
348 typename Storage<VCardToFindT>::ResultsType** result,
349 const Data::Area* area)
350{
351 (void)result;
352 (void)area;
353}
354
355template<class NextT>
356template<class VCardToFindT>
357inline void SetsOfAreas<NextT>::retrieveResultsForThermalCluster(
358 typename Storage<VCardToFindT>::ResultsType** result,
359 const Data::ThermalCluster* cluster)
360{
361 (void)result;
362 (void)cluster;
363}
364
365template<class NextT>
366template<class VCardToFindT>
367inline void SetsOfAreas<NextT>::retrieveResultsForLink(
368 typename Storage<VCardToFindT>::ResultsType** result,
369 const Data::AreaLink* link)
370{
371 (void)result;
372 (void)link;
373}
374
375template<class NextT>
376template<class PredicateT>
377inline void SetsOfAreas<NextT>::RetrieveVariableList(PredicateT& /*predicate*/)
378{
379}
380
381} // namespace Variable
382} // namespace Solver
383} // namespace Antares
384
385#endif // __SOLVER_VARIABLE_SET_OF_AREAS_HXX__
Definition for a single area.
Definition area.h:52
Definition study.h:61
A single thermal cluster.
Definition cluster.h:78
static void RetrieveVariableList(PredicateT &predicate)
Retrieve the list of all individual variables.
Definition setofareas.hxx:377
Definition cbuilder.h:120
Definition variable.h:25
VariableAccessor< typenameVCardT::ResultsType, VCardT::columnCount >::Type ResultsType
The true type used for the results.
Definition info.h:764