Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
profitByPlant.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
22#pragma once
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 "Profit by plant";
40 }
41
43 static std::string Unit()
44 {
45 return "Profit - Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Profit for thermal units";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values throughout all years
56 >>
58
61
63 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
65 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
66 & (Category::FileLevel::de);
68 static constexpr uint8_t precision = Category::all;
70 static constexpr uint8_t nodeDepthForGUI = +0;
72 static constexpr uint8_t decimal = 0;
74 static constexpr int columnCount = Category::dynamicColumns;
76 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
77 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
78 static constexpr uint8_t spatialAggregatePostProcessing = 0;
80 static constexpr uint8_t hasIntermediateValues = 1;
82 static constexpr uint8_t isPossiblyNonApplicable = 0;
83
85 typedef std::vector<IntermediateValues> IntermediateValuesBaseType;
86 typedef std::vector<IntermediateValuesBaseType> IntermediateValuesType;
87}; // class VCard
88
93template<class NextT = Container::EndOfList>
94class ProfitByPlant: public Variable::IVariable<ProfitByPlant<NextT>, NextT, VCardProfitByPlant>
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:
130 pNbClustersOfArea(0)
131 {
132 }
133
134 void initializeFromStudy(Data::Study& study)
135 {
136 // Next
137 NextType::initializeFromStudy(study);
138 }
139
140 void initializeFromArea(Data::Study* study, Data::Area* area)
141 {
142 // Get the number of years in parallel
143 pNbYearsParallel = study->maxNbYearsInParallel;
144 pValuesForTheCurrentYear.resize(pNbYearsParallel);
145
146 // Get the area
147 pNbClustersOfArea = area->thermal.list.enabledCount();
148 if (pNbClustersOfArea)
149 {
150 AncestorType::pResults.resize(pNbClustersOfArea);
151 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
152 {
153 pValuesForTheCurrentYear[numSpace].resize(pNbClustersOfArea);
154 }
155
156 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
157 {
158 for (unsigned int i = 0; i != pNbClustersOfArea; ++i)
159 {
160 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
161 }
162 }
163
164 for (unsigned int i = 0; i != pNbClustersOfArea; ++i)
165 {
166 AncestorType::pResults[i].initializeFromStudy(*study);
167 AncestorType::pResults[i].reset();
168 }
169 }
170 else
171 {
173 }
174
175 // Next
176 NextType::initializeFromArea(study, area);
177 }
178
179 size_t getMaxNumberColumns() const
180 {
181 return pNbClustersOfArea * ResultsType::count;
182 }
183
184 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
185 {
186 // Next
187 NextType::initializeFromAreaLink(study, link);
188 }
189
190 void simulationBegin()
191 {
192 // Next
193 NextType::simulationBegin();
194 }
195
196 void simulationEnd()
197 {
198 NextType::simulationEnd();
199 }
200
201 void yearBegin(unsigned int year, unsigned int numSpace)
202 {
203 // Reset the values for the current year
204 for (unsigned int i = 0; i != pNbClustersOfArea; ++i)
205 {
206 pValuesForTheCurrentYear[numSpace][i].reset();
207 }
208
209 // Next variable
210 NextType::yearBegin(year, numSpace);
211 }
212
213 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
214 {
215 // Next variable
216 NextType::yearEndBuild(state, year, numSpace);
217 }
218
219 void yearEnd(unsigned int year, unsigned int numSpace)
220 {
221 // Merge all results for all thermal clusters
222 {
223 for (unsigned int i = 0; i < pNbClustersOfArea; ++i)
224 {
225 // Compute all statistics for the current year (daily,weekly,monthly)
226 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
227 }
228 }
229 // Next variable
230 NextType::yearEnd(year, numSpace);
231 }
232
233 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
234 unsigned int nbYearsForCurrentSummary)
235 {
236 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
237 {
238 for (unsigned int i = 0; i < pNbClustersOfArea; ++i)
239 {
240 // Merge all those values with the global results
241 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
242 pValuesForTheCurrentYear[numSpace][i]);
243 }
244 }
245
246 // Next variable
247 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
248 }
249
250 void hourBegin(unsigned int hourInTheYear)
251 {
252 // Next variable
253 NextType::hourBegin(hourInTheYear);
254 }
255
256 void hourForEachArea(State& state, unsigned int numSpace)
257 {
258 // Useful local variables
259 auto area = state.area;
260 auto& thermal = state.thermal;
261 const std::vector<double>& areaMarginalCosts = state.hourlyResults->CoutsMarginauxHoraires;
262 uint hourInTheWeek = state.hourInTheWeek;
263 uint hourInTheYear = state.hourInTheYear;
264
265 for (auto& cluster: area->thermal.list.each_enabled())
266 {
267 double hourlyClusterProduction = thermal[area->index]
268 .thermalClustersProductions[cluster->enabledIndex];
269 uint tsIndex = cluster->series.timeseriesNumbers[state.year];
270
271 // Thermal cluster profit
272 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[hourInTheYear]
273 = std::max((hourlyClusterProduction - cluster->PthetaInf[hourInTheYear]), 0.)
274 * (-areaMarginalCosts[hourInTheWeek]
275 - cluster->getCostProvider().getMarginalCost(tsIndex, hourInTheYear));
276 }
277
278 // Next variable
279 NextType::hourForEachArea(state, numSpace);
280 }
281
282 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
283 unsigned int,
284 unsigned int numSpace) const
285 {
286 return pValuesForTheCurrentYear[numSpace][0].hour;
287 }
288
289 void localBuildAnnualSurveyReport(SurveyResults& results,
290 int fileLevel,
291 int precision,
292 unsigned int numSpace) const
293 {
294 // Initializing external pointer on current variable non applicable status
295 results.isCurrentVarNA = AncestorType::isNonApplicable;
296
297 if (AncestorType::isPrinted[0])
298 {
299 assert(NULL != results.data.area);
300 const auto& thermal = results.data.area->thermal;
301
302 // Write the data for the current year
303 for (auto& cluster: thermal.list.each_enabled())
304 {
305 // Write the data for the current year
306 results.variableCaption = cluster->name(); // VCardType::Caption();
307 results.variableUnit = VCardType::Unit();
308 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
309 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
310 }
311 }
312 }
313
314private:
316 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
317 size_t pNbClustersOfArea;
318 unsigned int pNbYearsParallel;
319
320}; // class
321
322} // namespace Economy
323} // namespace Variable
324} // namespace Solver
325} // namespace Antares
Definition for a single area.
Definition area.h:52
Definition study.h:61
C02 Average value of the overrall OperatingCost emissions expected from all the thermal dispatchable ...
Definition profitByPlant.h:95
VCardType::ResultsType ResultsType
List of expected results.
Definition profitByPlant.h:105
NextT NextType
Type of the next static variable.
Definition profitByPlant.h:98
@ count
How many items have we got.
Definition profitByPlant.h:112
VCardProfitByPlant VCardType
VCard.
Definition profitByPlant.h:100
Variable::IVariable< ProfitByPlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition profitByPlant.h:102
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
VCardProfitByPlant VCardForSpatialAggregate
The VCard to look for calculating spatial aggregates.
Definition profitByPlant.h:60
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition profitByPlant.h:76
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition profitByPlant.h:70
static constexpr uint8_t decimal
Decimal precision.
Definition profitByPlant.h:72
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition profitByPlant.h:80
static std::string Unit()
Unit.
Definition profitByPlant.h:43
static constexpr uint8_t precision
Precision (views)
Definition profitByPlant.h:68
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition profitByPlant.h:65
static constexpr int columnCount
Number of columns used by the variable.
Definition profitByPlant.h:74
Results< R::AllYears::Average< > > ResultsType
The expected results.
Definition profitByPlant.h:57
static std::string Description()
The short description of the variable.
Definition profitByPlant.h:49
static constexpr uint8_t categoryDataLevel
Data Level.
Definition profitByPlant.h:63
static std::string Caption()
Caption.
Definition profitByPlant.h:37
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition profitByPlant.h:82