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_ECONOMY_OverallCost_H__
22#define __SOLVER_VARIABLE_ECONOMY_OverallCost_H__
23
24#include "antares/solver/variable/variable.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace Economy
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 = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
193 i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
194 ++i)
195 {
196 pValuesForTheCurrentYear[numSpace][i] += state.thermalClusterOperatingCostForYear[i];
197 // Incrementing annual system cost (to be printed in output into a separate file)
198 state.annualSystemCost += state.thermalClusterOperatingCostForYear[i];
199 }
200
201 // Next variable
202 NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
203 }
204
205 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
206 {
207 // Next variable
208 NextType::yearEndBuild(state, year, numSpace);
209 }
210
211 void yearEnd(unsigned int year, unsigned int numSpace)
212 {
213 // Compute all statistics for the current year (daily,weekly,monthly)
214 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
215
216 // Next variable
217 NextType::yearEnd(year, numSpace);
218 }
219
220 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
221 unsigned int nbYearsForCurrentSummary)
222 {
223 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
224 {
225 // Merge all those values with the global results
226 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
227 pValuesForTheCurrentYear[numSpace]);
228 }
229
230 // Next variable
231 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
232 }
233
234 void hourBegin(unsigned int hourInTheYear)
235 {
236 // Next variable
237 NextType::hourBegin(hourInTheYear);
238 }
239
240 void hourForEachArea(State& state, unsigned int numSpace)
241 {
242 const double costForSpilledOrUnsuppliedEnergy =
243 // Total UnsupliedEnergy emissions
244 (state.hourlyResults->ValeursHorairesDeDefaillancePositive[state.hourInTheWeek]
245 * state.area->thermal.unsuppliedEnergyCost)
246 + (state.hourlyResults->ValeursHorairesDeDefaillanceNegative[state.hourInTheWeek]
247 * state.area->thermal.spilledEnergyCost)
248 // Current hydro storage and pumping generation costs
249 + (state.hourlyResults->valeurH2oHoraire[state.hourInTheWeek]
250 * (state.hourlyResults->TurbinageHoraire[state.hourInTheWeek]
251 - state.area->hydro.pumpingEfficiency
252 * state.hourlyResults->PompageHoraire[state.hourInTheWeek]));
253
254 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] += costForSpilledOrUnsuppliedEnergy;
255
256 // Incrementing annual system cost (to be printed in output into a separate file)
257 state.annualSystemCost += costForSpilledOrUnsuppliedEnergy;
258
259 // Next variable
260 NextType::hourForEachArea(state, numSpace);
261 }
262
263 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
264 unsigned int,
265 unsigned int numSpace) const
266 {
267 return pValuesForTheCurrentYear[numSpace].hour;
268 }
269
270 void localBuildAnnualSurveyReport(SurveyResults& results,
271 int fileLevel,
272 int precision,
273 unsigned int numSpace) const
274 {
275 // Initializing external pointer on current variable non applicable status
276 results.isCurrentVarNA = AncestorType::isNonApplicable;
277
278 if (AncestorType::isPrinted[0])
279 {
280 // Write the data for the current year
281 results.variableCaption = VCardType::Caption();
282 results.variableUnit = VCardType::Unit();
283 pValuesForTheCurrentYear[numSpace]
284 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
285 }
286 }
287
288private:
290 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
291 unsigned int pNbYearsParallel;
292
293}; // class OverallCost
294
295} // namespace Economy
296} // namespace Variable
297} // namespace Solver
298} // namespace Antares
299
300#endif // __SOLVER_VARIABLE_ECONOMY_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
NextT NextType
Type of the next static variable.
Definition overallCost.h:103
Variable::IVariable< OverallCost< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition overallCost.h:107
VCardOverallCost VCardType
VCard.
Definition overallCost.h:105
VCardType::ResultsType ResultsType
List of expected results.
Definition overallCost.h:110
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 overallCost.h:71
static constexpr uint8_t decimal
Decimal precision.
Definition overallCost.h:75
Results< R::AllYears::Average< >, R::AllYears::Average > ResultsType
The expecte results.
Definition overallCost.h:59
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition overallCost.h:79
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition overallCost.h:83
static std::string Description()
The short description of the variable.
Definition overallCost.h:49
static constexpr uint8_t categoryDataLevel
Data Level.
Definition overallCost.h:65
static std::string Caption()
Caption.
Definition overallCost.h:37
VCardOverallCost VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition overallCost.h:62
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition overallCost.h:77
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition overallCost.h:73
static std::string Unit()
Unit.
Definition overallCost.h:43
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition overallCost.h:67
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition overallCost.h:85