Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
max-mrg.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_ECONOMY_MARGE_H__
22#define __SOLVER_VARIABLE_ECONOMY_MARGE_H__
23
24#include "antares/solver/variable/variable.h"
25
26#include "max-mrg-utils.h"
27
28namespace Antares
29{
30namespace Solver
31{
32namespace Variable
33{
34namespace Economy
35{
37{
39 static std::string Caption()
40 {
41 return "MAX MRG";
42 }
43
45 static std::string Unit()
46 {
47 return "MWh";
48 }
49
51 static std::string Description()
52 {
53 return "Maximum margin throughout all MC years";
54 }
55
57 typedef Results<R::AllYears::Average< // The average values throughout all years
58 R::AllYears::StdDeviation< // The standard deviation values throughout all years
59 R::AllYears::Min< // The minimum values throughout all years
60 R::AllYears::Max< // The maximum values throughout all years
61 >>>>>
63
66
68 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
70 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
71 & (Category::FileLevel::id
72 | Category::FileLevel::va);
74 static constexpr uint8_t precision = Category::all;
76 static constexpr uint8_t nodeDepthForGUI = +0;
78 static constexpr uint8_t decimal = 0;
80 static constexpr int columnCount = 1;
82 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
83 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
84 static constexpr uint8_t spatialAggregatePostProcessing = 0;
86 static constexpr uint8_t hasIntermediateValues = 1;
88 static constexpr uint8_t isPossiblyNonApplicable = 0;
89
91 typedef std::vector<IntermediateValues> IntermediateValuesType;
92
94
95}; // class VCard
96
100template<class NextT = Container::EndOfList>
101class Marge: public Variable::IVariable<Marge<NextT>, NextT, VCardMARGE>
102{
103public:
105 typedef NextT NextType;
110
113
115
116 enum
117 {
119 count = 1 + NextT::count,
120 };
121
122 template<int CDataLevel, int CFile>
124 {
125 enum
126 {
127 count = ((VCardType::categoryDataLevel & CDataLevel
129 ? (NextType::template Statistics<CDataLevel, CFile>::count
131 : NextType::template Statistics<CDataLevel, CFile>::count),
132 };
133 };
134
135public:
136 void initializeFromStudy(Data::Study& study)
137 {
138 pNbYearsParallel = study.maxNbYearsInParallel;
139
140 // Intermediate values
141 InitializeResultsFromStudy(AncestorType::pResults, study);
142
143 pValuesForTheCurrentYear.resize(pNbYearsParallel);
144 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
145 {
146 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
147 }
148
149 // Next
150 NextType::initializeFromStudy(study);
151 }
152
153 template<class R>
154 static void InitializeResultsFromStudy(R& results, Data::Study& study)
155 {
156 VariableAccessorType::InitializeAndReset(results, study);
157 }
158
159 void initializeFromArea(Data::Study* study, Data::Area* area)
160 {
161 // Next
162 NextType::initializeFromArea(study, area);
163 }
164
165 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
166 {
167 // Next
168 NextType::initializeFromAreaLink(study, link);
169 }
170
171 void simulationBegin()
172 {
173 // Next
174 NextType::simulationBegin();
175 }
176
177 void simulationEnd()
178 {
179 // Next
180 NextType::simulationEnd();
181 }
182
183 void yearBegin(unsigned int year, unsigned int numSpace)
184 {
185 // Reset the values for the current year
186 pValuesForTheCurrentYear[numSpace].reset();
187 // Next variable
188 NextType::yearBegin(year, numSpace);
189 }
190
191 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
192 {
193 // Next variable
194 NextType::yearEndBuild(state, year, numSpace);
195 }
196
197 void yearEnd(unsigned int year, unsigned int numSpace)
198 {
199 // Compute all statistics for the current year (daily,weekly,monthly)
200 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
201
202 // Next variable
203 NextType::yearEnd(year, numSpace);
204 }
205
206 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
207 unsigned int nbYearsForCurrentSummary)
208 {
209 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
210 {
211 // Merge all those values with the global results
212 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
213 pValuesForTheCurrentYear[numSpace]);
214 }
215
216 // Next variable
217 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
218 }
219
220 void hourBegin(unsigned int hourInTheYear)
221 {
222 // Next variable
223 NextType::hourBegin(hourInTheYear);
224 }
225
226 void hourForEachArea(State& state, unsigned int numSpace)
227 {
228 // Next variable
229 NextType::hourForEachArea(state, numSpace);
230 }
231
232 void weekForEachArea(State& state, unsigned int numSpace)
233 {
234 double* rawhourly = Memory::RawPointer(pValuesForTheCurrentYear[numSpace].hour);
235
236 // Getting data required to compute max margin
237 MaxMrgUsualDataFactory maxMRGdataFactory(state, numSpace);
238 MaxMRGinput maxMRGinput = maxMRGdataFactory.data();
239 computeMaxMRG(rawhourly + state.hourInTheYear, maxMRGinput);
240
241 // next
242 NextType::weekForEachArea(state, numSpace);
243 }
244
245 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
246 unsigned int,
247 unsigned int numSpace) const
248 {
249 return pValuesForTheCurrentYear[numSpace].hour;
250 }
251
252 void localBuildAnnualSurveyReport(SurveyResults& results,
253 int fileLevel,
254 int precision,
255 unsigned int numSpace) const
256 {
257 // Initializing external pointer on current variable non applicable status
258 results.isCurrentVarNA = AncestorType::isNonApplicable;
259
260 if (AncestorType::isPrinted[0])
261 {
262 // Write the data for the current year
263 results.variableCaption = VCardType::Caption();
264 results.variableUnit = VCardType::Unit();
265 pValuesForTheCurrentYear[numSpace]
266 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
267 }
268 }
269
270private:
272 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
273 unsigned int pNbYearsParallel;
274
275}; // class Marge
276
277} // namespace Economy
278} // namespace Variable
279} // namespace Solver
280} // namespace Antares
281
282#endif // __SOLVER_VARIABLE_ECONOMY_MARGE_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Max MRG.
Definition max-mrg.h:102
@ count
How many items have we got.
Definition max-mrg.h:119
VCardMARGE VCardType
VCard.
Definition max-mrg.h:107
NextT NextType
Type of the next static variable.
Definition max-mrg.h:105
VCardType::ResultsType ResultsType
List of expected results.
Definition max-mrg.h:112
Variable::IVariable< Marge< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition max-mrg.h:109
Interface for any variable.
Definition variable.h:51
StoredResultType pResults
All the results about this variable.
Definition variable.h:327
Temporary buffer for allocating results for a single year.
Definition intermediate.h:46
Definition results.h:48
@ count
The count if item in the list.
Definition results.h:56
Definition cbuilder.h:120
Definition variable.h:25
static constexpr uint8_t precision
Precision (views)
Definition max-mrg.h:74
static constexpr uint8_t decimal
Decimal precision.
Definition max-mrg.h:78
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition max-mrg.h:62
static std::string Description()
The short description of the variable.
Definition max-mrg.h:51
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition max-mrg.h:76
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition max-mrg.h:86
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition max-mrg.h:70
static constexpr uint8_t categoryDataLevel
Data Level.
Definition max-mrg.h:68
static std::string Unit()
Unit.
Definition max-mrg.h:45
VCardMARGE VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition max-mrg.h:65
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition max-mrg.h:88
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition max-mrg.h:82
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition max-mrg.h:80
static std::string Caption()
Caption.
Definition max-mrg.h:39