Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
overallCost.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_ADEQUACY_OverallCost_H__
22#define __SOLVER_VARIABLE_ADEQUACY_OverallCost_H__
23
24#include "antares/solver/variable/variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Adequacy
33{
35{
37 static std::string Caption()
38 {
39 return "OV. COST";
40 }
41
43 static std::string Unit()
44 {
45 return "Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Overall Cost throughout all MC years";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 >,
57 R::AllYears::Average // Use these values for spatial cluster
58 >
60
63
65 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
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
91
92}; // class VCard
93
98template<class NextT = Container::EndOfList>
99class OverallCost: public Variable::IVariable<OverallCost<NextT>, NextT, VCardOverallCost>
100{
101public:
103 typedef NextT NextType;
108
111
113
114 enum
115 {
117 count = 1 + NextT::count,
118 };
119
120 template<int CDataLevel, int CFile>
122 {
123 enum
124 {
125 count = ((VCardType::categoryDataLevel & CDataLevel
127 ? (NextType::template Statistics<CDataLevel, CFile>::count
129 : NextType::template Statistics<CDataLevel, CFile>::count),
130 };
131 };
132
133public:
134 void initializeFromStudy(Data::Study& study)
135 {
136 pNbYearsParallel = study.maxNbYearsInParallel;
137
138 // Intermediate values
139 InitializeResultsFromStudy(AncestorType::pResults, study);
140
141 // Intermediate values
142 pValuesForTheCurrentYear.resize(pNbYearsParallel);
143 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
144 {
145 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
146 }
147
148 // Next
149 NextType::initializeFromStudy(study);
150 }
151
152 template<class R>
153 static void InitializeResultsFromStudy(R& results, Data::Study& study)
154 {
155 VariableAccessorType::InitializeAndReset(results, study);
156 }
157
158 void initializeFromArea(Data::Study* study, Data::Area* area)
159 {
160 // Next
161 NextType::initializeFromArea(study, area);
162 }
163
164 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
165 {
166 // Next
167 NextType::initializeFromAreaLink(study, link);
168 }
169
170 void simulationBegin()
171 {
172 // Next
173 NextType::simulationBegin();
174 }
175
176 void simulationEnd()
177 {
178 NextType::simulationEnd();
179 }
180
181 void yearBegin(unsigned int year, unsigned int numSpace)
182 {
183 // Reset the values for the current year
184 pValuesForTheCurrentYear[numSpace].reset();
185 // Next variable
186 NextType::yearBegin(year, numSpace);
187 }
188
189 void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
190 {
191 // Get end year calculations
192 for (unsigned int i = 0; i < state.study.runtime.rangeLimits.hour[Data::rangeCount]; ++i)
193 {
194 pValuesForTheCurrentYear[numSpace][i] += state.thermalClusterOperatingCostForYear[i];
195 }
196
197 // Next variable
198 NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
199 }
200
201 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
202 {
203 // Next variable
204 NextType::yearEndBuild(state, year, numSpace);
205 }
206
207 void yearEnd(unsigned int year, unsigned int numSpace)
208 {
209 // Compute all statistics for the current year (daily,weekly,monthly)
210 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
211
212 // Next variable
213 NextType::yearEnd(year, numSpace);
214 }
215
216 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
217 unsigned int nbYearsForCurrentSummary)
218 {
219 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
220 {
221 // Merge all those values with the global results
222 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
223 pValuesForTheCurrentYear[numSpace]);
224 }
225
226 // Next variable
227 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
228 }
229
230 void hourBegin(unsigned int hourInTheYear)
231 {
232 // Next variable
233 NextType::hourBegin(hourInTheYear);
234 }
235
236 void hourForEachArea(State& state, unsigned int numSpace)
237 {
238 auto area = state.area;
239 auto& thermal = state.thermal;
240 // Total UnsupliedEnergy emissions
241 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] +=
242 // Current Hydro Storage generation
243 (state.hourlyResults->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek]
244 * area->thermal.unsuppliedEnergyCost)
245 + ((state.hourlyResults->ValeursHorairesDeDefaillanceNegative[state.hourInTheWeek]
246 + state.resSpilled.entry[area->index][state.hourInTheWeek])
247 * area->thermal.spilledEnergyCost);
248
249 // Hydro costs : water value and pumping
250 pValuesForTheCurrentYear[numSpace].hour[state.hourInTheYear]
251 += state.problemeHebdo->CaracteristiquesHydrauliques[state.area->index]
252 .WeeklyWaterValueStateRegular
253 * (state.hourlyResults->TurbinageHoraire[state.hourInTheWeek]
254 - area->hydro.pumpingEfficiency
255 * state.hourlyResults->PompageHoraire[state.hourInTheWeek]);
256
257 // Thermal costs
258 for (auto& cluster: area->thermal.list.each_enabled())
259 {
260 pValuesForTheCurrentYear[numSpace][state.hourInTheYear]
261 += thermal[area->index].thermalClustersOperatingCost[cluster->enabledIndex];
262 }
263
264 // Next variable
265 NextType::hourForEachArea(state, numSpace);
266 }
267
268 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
269 unsigned int,
270 unsigned int numSpace) const
271 {
272 return pValuesForTheCurrentYear[numSpace].hour;
273 }
274
275 void localBuildAnnualSurveyReport(SurveyResults& results,
276 int fileLevel,
277 int precision,
278 unsigned int numSpace) const
279 {
280 // Initializing external pointer on current variable non applicable status
281 results.isCurrentVarNA = AncestorType::isNonApplicable;
282
283 if (AncestorType::isPrinted[0])
284 {
285 // Write the data for the current year
286 results.variableCaption = VCardType::Caption();
287 results.variableUnit = VCardType::Unit();
288
289 pValuesForTheCurrentYear[numSpace]
290 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
291 }
292 }
293
294private:
296 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
297 unsigned int pNbYearsParallel;
298}; // class OverallCost
299
300} // namespace Adequacy
301} // namespace Variable
302} // namespace Solver
303} // namespace Antares
304
305#endif // __SOLVER_VARIABLE_ADEQUACY_OverallCost_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
C02 Average value of the overrall OverallCost emissions expected from all the thermal dispatchable cl...
Definition overallCost.h:100
@ count
How many items have we got.
Definition overallCost.h:117
VCardOverallCost VCardType
VCard.
Definition overallCost.h:105
Variable::IVariable< OverallCost< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition overallCost.h:107
VCardType::ResultsType ResultsType
List of expected results.
Definition overallCost.h:110
NextT NextType
Type of the next static variable.
Definition overallCost.h:103
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
VCardOverallCost VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition overallCost.h:62
static std::string Caption()
Caption.
Definition overallCost.h:37
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition overallCost.h:85
static std::string Unit()
Unit.
Definition overallCost.h:43
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition overallCost.h:79
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition overallCost.h:73
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition overallCost.h:83
Results< R::AllYears::Average< >, R::AllYears::Average > ResultsType
The expecte results.
Definition overallCost.h:59
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition overallCost.h:77
static constexpr uint8_t precision
Precision (views)
Definition overallCost.h:71
static std::string Description()
The short description of the variable.
Definition overallCost.h:49
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition overallCost.h:67
static constexpr uint8_t categoryDataLevel
Data Level.
Definition overallCost.h:65
static constexpr uint8_t decimal
Decimal precision.
Definition overallCost.h:75