Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
overallCostCsr.h
1/*
2** Copyright 2007-2023 RTE
3** Authors: Antares_Simulator Team
4**
5** This file is part of Antares_Simulator.
6**
7** Antares_Simulator is free software: you can redistribute it and/or modify
8** it under the terms of the GNU General Public License as published by
9** the Free Software Foundation, either version 3 of the License, or
10** (at your option) any later version.
11**
12** There are special exceptions to the terms and conditions of the
13** license as they are applied to this software. View the full text of
14** the exceptions in file COPYING.txt in the directory of this software
15** distribution
16**
17** Antares_Simulator is distributed in the hope that it will be useful,
18** but WITHOUT ANY WARRANTY; without even the implied warranty of
19** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20** GNU General Public License for more details.
21**
22** You should have received a copy of the GNU General Public License
23** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>.
24**
25** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
26*/
27#pragma once
28
29#include "../variable.h"
30
31namespace Antares::Solver::Variable::Economy
32{
34{
36 static std::string Caption()
37 {
38 return "OV. COST CSR";
39 }
40
42 static std::string Unit()
43 {
44 return "Euro";
45 }
46
48 static std::string Description()
49 {
50 return "Overall Cost throughout all MC years";
51 }
52
54 typedef Results<R::AllYears::Average< // The average values throughout all years
55 >,
56 R::AllYears::Average // Use these values for spatial cluster
57 >
59
62
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
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
89
90}; // class VCard
91
96template<class NextT = Container::EndOfList>
97class OverallCostCsr: public Variable::IVariable<OverallCostCsr<NextT>, NextT, VCardOverallCostCsr>
98{
99public:
101 typedef NextT NextType;
106
109
111
112 enum
113 {
115 count = 1 + NextT::count,
116 };
117
118 template<int CDataLevel, int CFile>
120 {
121 enum
122 {
123 count = ((VCardType::categoryDataLevel & CDataLevel
125 ? (NextType::template Statistics<CDataLevel, CFile>::count
127 : NextType::template Statistics<CDataLevel, CFile>::count),
128 };
129 };
130
131public:
132 void initializeFromStudy(Data::Study& study)
133 {
134 pNbYearsParallel = study.maxNbYearsInParallel;
135
136 // Intermediate values
137 InitializeResultsFromStudy(AncestorType::pResults, 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 NextType::initializeFromStudy(study);
147 }
148
149 template<class R>
150 static void InitializeResultsFromStudy(R& results, Data::Study& study)
151 {
152 VariableAccessorType::InitializeAndReset(results, study);
153 }
154
155 void yearBegin(unsigned int year, unsigned int numSpace)
156 {
157 // Reset the values for the current year
158 pValuesForTheCurrentYear[numSpace].reset();
159
160 NextType::yearBegin(year, numSpace);
161 }
162
163 void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
164 {
165 for (unsigned int i = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
166 i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
167 ++i)
168 {
169 pValuesForTheCurrentYear[numSpace][i] += state.thermalClusterOperatingCostForYear[i];
170 }
171
172 NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
173 }
174
175 void yearEnd(unsigned int year, unsigned int numSpace)
176 {
177 // Compute all statistics for the current year (daily, weekly, monthly)
178 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
179
180 NextType::yearEnd(year, numSpace);
181 }
182
183 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
184 unsigned int nbYearsForCurrentSummary)
185 {
186 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
187 {
188 // Merge all those values with the global results
189 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
190 pValuesForTheCurrentYear[numSpace]);
191 }
192
193 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
194 }
195
196 void hourForEachArea(State& state, unsigned int numSpace)
197 {
198 const double costForSpilledOrUnsuppliedEnergyCSR =
199 // Total UnsupliedEnergy emissions
200 (state.hourlyResults->ValeursHorairesDeDefaillancePositiveCSR[state.hourInTheWeek]
201 * state.area->thermal.unsuppliedEnergyCost)
202 + (state.hourlyResults->ValeursHorairesDeDefaillanceNegative[state.hourInTheWeek]
203 * state.area->thermal.spilledEnergyCost)
204 // Current hydro storage and pumping generation costs
205 + (state.hourlyResults->valeurH2oHoraire[state.hourInTheWeek]
206 * (state.hourlyResults->TurbinageHoraire[state.hourInTheWeek]
207 - state.area->hydro.pumpingEfficiency
208 * state.hourlyResults->PompageHoraire[state.hourInTheWeek]));
209
210 pValuesForTheCurrentYear[numSpace][state.hourInTheYear]
211 += costForSpilledOrUnsuppliedEnergyCSR;
212
213 NextType::hourForEachArea(state, numSpace);
214 }
215
216 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
217 unsigned int,
218 unsigned int numSpace) const
219 {
220 return pValuesForTheCurrentYear[numSpace].hour;
221 }
222
223 void localBuildAnnualSurveyReport(SurveyResults& results,
224 int fileLevel,
225 int precision,
226 unsigned int numSpace) const
227 {
228 // Initializing external pointer on current variable non applicable status
229 results.isCurrentVarNA = AncestorType::isNonApplicable;
230
231 if (AncestorType::isPrinted[0])
232 {
233 // Write the data for the current year
234 results.variableCaption = VCardType::Caption();
235 results.variableUnit = VCardType::Unit();
236 pValuesForTheCurrentYear[numSpace]
237 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
238 }
239 }
240
241private:
243 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
244 unsigned int pNbYearsParallel;
245
246}; // class OverallCostCsr
247
248} // namespace Antares::Solver::Variable::Economy
Definition study.h:61
C02 Average value of the overall OverallCostCsr emissions expected from all the thermal dispatchable ...
Definition overallCostCsr.h:98
VCardType::ResultsType ResultsType
List of expected results.
Definition overallCostCsr.h:108
@ count
How many items have we got.
Definition overallCostCsr.h:115
Variable::IVariable< OverallCostCsr< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition overallCostCsr.h:105
VCardOverallCostCsr VCardType
VCard.
Definition overallCostCsr.h:103
NextT NextType
Type of the next static variable.
Definition overallCostCsr.h:101
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
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition overallCostCsr.h:77
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition overallCostCsr.h:83
static std::string Caption()
Caption.
Definition overallCostCsr.h:36
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition overallCostCsr.h:65
static constexpr uint8_t precision
Precision (views)
Definition overallCostCsr.h:69
VCardOverallCostCsr VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition overallCostCsr.h:61
static std::string Description()
The short description of the variable.
Definition overallCostCsr.h:48
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition overallCostCsr.h:81
static std::string Unit()
Unit.
Definition overallCostCsr.h:42
Results< R::AllYears::Average< >, R::AllYears::Average > ResultsType
The expecte results.
Definition overallCostCsr.h:58
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition overallCostCsr.h:71
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition overallCostCsr.h:75
static constexpr uint8_t decimal
Decimal precision.
Definition overallCostCsr.h:73