Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
flowLinear.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_FlowLinear_H__
22#define __SOLVER_VARIABLE_ECONOMY_FlowLinear_H__
23
24#include "../../variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
33{
35{
37 static std::string Caption()
38 {
39 return "FLOW LIN.";
40 }
41
43 static std::string Unit()
44 {
45 return "MWh";
46 }
47
49 static std::string Description()
50 {
51 return "Flow assessed, over all MC years, through linear optimization";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values throughout all years
58 R::AllYears::Max< // The maximum values throughout all years
59 >>>>>
61
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::link;
65 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
66 & (Category::FileLevel::id
67 | Category::FileLevel::va);
69 static constexpr uint8_t precision = Category::all;
71 static constexpr uint8_t nodeDepthForGUI = +0;
73 static constexpr uint8_t decimal = 0;
75 static constexpr int columnCount = 1;
77 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
78 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
79 static constexpr uint8_t spatialAggregatePostProcessing = 0;
81 static constexpr uint8_t hasIntermediateValues = 1;
83 static constexpr uint8_t isPossiblyNonApplicable = 0;
84
86 typedef std::vector<IntermediateValues> IntermediateValuesType;
87
88}; // class VCard
89
93template<class NextT = Container::EndOfList>
94class FlowLinear: public Variable::IVariable<FlowLinear<NextT>, NextT, VCardFlowLinear>
95{
96public:
98 typedef NextT NextType;
103
106
108
109 enum
110 {
112 count = 1 + NextT::count,
113 };
114
115 template<int CDataLevel, int CFile>
117 {
118 enum
119 {
120 count = ((VCardType::categoryDataLevel & CDataLevel
122 ? (NextType::template Statistics<CDataLevel, CFile>::count
124 : NextType::template Statistics<CDataLevel, CFile>::count),
125 };
126 };
127
128public:
129 void initializeFromStudy(Data::Study& study)
130 {
131 pNbYearsParallel = study.maxNbYearsInParallel;
132
133 // Average on all years
134 AncestorType::pResults.initializeFromStudy(study);
136
137 // Intermediate values
138 pValuesForTheCurrentYear.resize(pNbYearsParallel);
139 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
140 {
141 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
142 }
143
144 // Next
145 NextType::initializeFromStudy(study);
146 }
147
148 void initializeFromArea(Data::Study* study, Data::Area* area)
149 {
150 // Next
151 NextType::initializeFromArea(study, area);
152 }
153
154 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
155 {
156 // Next
157 NextType::initializeFromAreaLink(study, link);
158 }
159
160 void simulationBegin()
161 {
162 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
163 {
164 pValuesForTheCurrentYear[numSpace].reset();
165 }
166 // Next
167 NextType::simulationBegin();
168 }
169
170 void simulationEnd()
171 {
172 NextType::simulationEnd();
173 }
174
175 void yearBegin(uint year, unsigned int numSpace)
176 {
177 // Reset
178 pValuesForTheCurrentYear[numSpace].reset();
179 // Next variable
180 NextType::yearBegin(year, numSpace);
181 }
182
183 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
184 {
185 // Next variable
186 NextType::yearEndBuild(state, year, numSpace);
187 }
188
189 void yearEnd(unsigned int year, unsigned int numSpace)
190 {
191 // Compute all statistics for the current year (daily,weekly,monthly)
192 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
193
194 // Next variable
195 NextType::yearEnd(year, numSpace);
196 }
197
198 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
199 unsigned int nbYearsForCurrentSummary)
200 {
201 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
202 {
203 // Merge all those values with the global results
204 AncestorType::pResults.merge(numSpaceToYear[numSpace],
205 pValuesForTheCurrentYear[numSpace]);
206 }
207
208 // Next variable
209 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
210 }
211
212 void hourBegin(uint hourInTheYear)
213 {
214 // Next variable
215 NextType::hourBegin(hourInTheYear);
216 }
217
218 void hourForEachArea(State& state, unsigned int numSpace)
219 {
220 // Next variable
221 NextType::hourForEachArea(state, numSpace);
222 }
223
224 void hourForEachLink(State& state, unsigned int numSpace)
225 {
226 // Flow assessed over all MC years (linear)
227 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear] += state.ntc.ValeurDuFlux
228 [state.link->index];
229 // Next item in the list
230 NextType::hourForEachLink(state, numSpace);
231 }
232
233 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
234 {
235 if (dataLevel & Category::DataLevel::link)
236 {
237 if (digestLevel & Category::digestFlowLinear)
238 {
239 results.data.matrix
240 .entry[results.data.link->from->index][results.data.link->with->index]
241 = AncestorType::pResults.avgdata.allYears;
242 results.data.matrix
243 .entry[results.data.link->with->index][results.data.link->from->index]
244 = -AncestorType::pResults.avgdata.allYears;
245 }
246 }
247
248 // Next
249 NextType::buildDigest(results, digestLevel, dataLevel);
250 }
251
252 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
253 uint,
254 uint numSpace) const
255 {
256 return pValuesForTheCurrentYear[numSpace].hour;
257 }
258
259 void localBuildAnnualSurveyReport(SurveyResults& results,
260 int fileLevel,
261 int precision,
262 uint numSpace) const
263 {
264 // Initializing external pointer on current variable non applicable status
265 results.isCurrentVarNA = AncestorType::isNonApplicable;
266
267 if (AncestorType::isPrinted[0])
268 {
269 // Write the data for the current year
270 results.variableCaption = VCardType::Caption();
271 results.variableUnit = VCardType::Unit();
272 pValuesForTheCurrentYear[numSpace]
273 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
274 }
275 }
276
277private:
279 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
280 unsigned int pNbYearsParallel;
281
282}; // class FlowLinear
283
284} // namespace Economy
285} // namespace Variable
286} // namespace Solver
287} // namespace Antares
288
289#endif // __SOLVER_VARIABLE_ECONOMY_FlowLinear_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal FlowLinear.
Definition flowLinear.h:95
Variable::IVariable< FlowLinear< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition flowLinear.h:102
VCardType::ResultsType ResultsType
List of expected results.
Definition flowLinear.h:105
NextT NextType
Type of the next static variable.
Definition flowLinear.h:98
@ count
How many items have we got.
Definition flowLinear.h:112
VCardFlowLinear VCardType
VCard.
Definition flowLinear.h:100
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 categoryFileLevel
File level (provided by the type of the results)
Definition flowLinear.h:65
static std::string Unit()
Unit.
Definition flowLinear.h:43
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition flowLinear.h:71
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition flowLinear.h:83
static constexpr uint8_t precision
Precision (views)
Definition flowLinear.h:69
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition flowLinear.h:81
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition flowLinear.h:75
static std::string Caption()
Caption.
Definition flowLinear.h:37
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition flowLinear.h:60
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition flowLinear.h:77
static constexpr uint8_t categoryDataLevel
Data Level.
Definition flowLinear.h:63
static std::string Description()
The short description of the variable.
Definition flowLinear.h:49
static constexpr uint8_t decimal
Decimal precision.
Definition flowLinear.h:73