Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
hurdleCosts.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_HURDLE_COSTS_H__
22#define __SOLVER_VARIABLE_ECONOMY_HURDLE_COSTS_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 "HURDLE COST";
40 }
41
43 static std::string Unit()
44 {
45 return "Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Hurdle costs, over all MC years";
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 HurdleCosts: public Variable::IVariable<HurdleCosts<NextT>, NextT, VCardHurdleCosts>
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 hourForEachArea(State& state, unsigned int numSpace)
213 {
214 // Next variable
215 NextType::hourForEachArea(state, numSpace);
216 }
217
218 void hourForEachLink(State& state, unsigned int numSpace)
219 {
220 // Flow assessed over all MC years (linear)
221 if (state.link->useHurdlesCost)
222 {
223 const double flowLinear = state.ntc.ValeurDuFlux[state.link->index];
224
225 if (state.link->useLoopFlow)
226 {
227 const double loopFlow = state.problemeHebdo->ValeursDeNTC[state.hourInTheWeek]
228 .ValeurDeLoopFlowOrigineVersExtremite[state.link->index];
229 if (flowLinear - loopFlow > 0.)
230 {
231 const double hurdleCostDirect = (flowLinear - loopFlow)
232 * state.link->parameters
233 .entry[Data::fhlHurdlesCostDirect]
234 [state.hourInTheYear];
235 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear]
236 += hurdleCostDirect;
237 // Incrementing annual system cost (to be printed in output in a separate file)
238 state.annualSystemCost += hurdleCostDirect;
239 }
240 else
241 {
242 const double hurdleCostIndirect = -(flowLinear - loopFlow)
243 * state.link->parameters
244 .entry[Data::fhlHurdlesCostIndirect]
245 [state.hourInTheYear];
246 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear]
247 += hurdleCostIndirect;
248 // Incrementing annual system cost (to be printed in output into a separate
249 // file)
250 state.annualSystemCost += hurdleCostIndirect;
251 }
252 }
253 else
254 {
255 if (flowLinear > 0.)
256 {
257 const double hurdleCostDirect = flowLinear
258 * state.link->parameters
259 .entry[Data::fhlHurdlesCostDirect]
260 [state.hourInTheYear];
261 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear]
262 += hurdleCostDirect;
263 // Incrementing annual system cost (to be printed in output in a separate file)
264 state.annualSystemCost += hurdleCostDirect;
265 }
266 else
267 {
268 const double hurdleCostIndirect = -flowLinear
269 * state.link->parameters
270 .entry[Data::fhlHurdlesCostIndirect]
271 [state.hourInTheYear];
272 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear]
273 += hurdleCostIndirect;
274 // Incrementing annual system cost (to be printed in output into a separate
275 // file)
276 state.annualSystemCost += hurdleCostIndirect;
277 }
278 }
279 }
280 // Next item in the list
281 NextType::hourForEachLink(state, numSpace);
282 }
283
284 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
285 {
286 // Next
287 NextType::buildDigest(results, digestLevel, dataLevel);
288 }
289
290 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
291 unsigned int,
292 unsigned int numSpace) const
293 {
294 return pValuesForTheCurrentYear[numSpace].hour;
295 }
296
297 void localBuildAnnualSurveyReport(SurveyResults& results,
298 int fileLevel,
299 int precision,
300 unsigned int numSpace) const
301 {
302 // Initializing external pointer on current variable non applicable status
303 results.isCurrentVarNA = AncestorType::isNonApplicable;
304
305 if (AncestorType::isPrinted[0])
306 {
307 // Write the data for the current year
308 results.variableCaption = VCardType::Caption();
309 results.variableUnit = VCardType::Unit();
310 pValuesForTheCurrentYear[numSpace]
311 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
312 }
313 }
314
315private:
317 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
318 unsigned int pNbYearsParallel;
319}; // class HurdleCosts
320
321} // namespace Economy
322} // namespace Variable
323} // namespace Solver
324} // namespace Antares
325
326#endif // __SOLVER_VARIABLE_ECONOMY_HURDLE_COSTS_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal HurdleCosts.
Definition hurdleCosts.h:95
Variable::IVariable< HurdleCosts< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition hurdleCosts.h:102
VCardHurdleCosts VCardType
VCard.
Definition hurdleCosts.h:100
NextT NextType
Type of the next static variable.
Definition hurdleCosts.h:98
VCardType::ResultsType ResultsType
List of expected results.
Definition hurdleCosts.h:105
@ count
How many items have we got.
Definition hurdleCosts.h:112
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 hurdleCosts.h:63
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition hurdleCosts.h:81
static std::string Description()
The short description of the variable.
Definition hurdleCosts.h:49
static std::string Unit()
Unit.
Definition hurdleCosts.h:43
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition hurdleCosts.h:65
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition hurdleCosts.h:71
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition hurdleCosts.h:75
static std::string Caption()
Caption.
Definition hurdleCosts.h:37
static constexpr uint8_t precision
Precision (views)
Definition hurdleCosts.h:69
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition hurdleCosts.h:83
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition hurdleCosts.h:60
static constexpr uint8_t decimal
Decimal precision.
Definition hurdleCosts.h:73
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition hurdleCosts.h:77