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