Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
price.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_Price_H__
22#define __SOLVER_VARIABLE_ECONOMY_Price_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 "MRG. PRICE";
40 }
41
43 static std::string Unit()
44 {
45 return "Euro";
46 }
47
49 static std::string Description()
50 {
51 return "Marginal Price, throughout all MC years";
52 }
53
55 typedef Results<R::AllYears::Average< // The average values thoughout all years
56 R::AllYears::StdDeviation< // The standard deviation values throughout all years
57 R::AllYears::Min< // The minimum values thoughout all years
58 R::AllYears::Max< // The maximum values thoughout all years
59 >>>>>
61
64
66 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
68 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
69 & (Category::FileLevel::id
70 | Category::FileLevel::va);
72 static constexpr uint8_t precision = Category::all;
74 static constexpr uint8_t nodeDepthForGUI = +0;
76 static constexpr uint8_t decimal = 4;
78 static constexpr int columnCount = 1;
80 static constexpr uint8_t spatialAggregate = Category::spatialAggregateAverage;
81 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
82 static constexpr uint8_t spatialAggregatePostProcessing = Category::
83 spatialAggregatePostProcessingPrice;
85 static constexpr uint8_t hasIntermediateValues = 1;
87 static constexpr uint8_t isPossiblyNonApplicable = 0;
88
90 typedef std::vector<IntermediateValues> IntermediateValuesType;
91
93
94}; // class VCard
95
99template<class NextT = Container::EndOfList>
100class Price: public Variable::IVariable<Price<NextT>, NextT, VCardPrice>
101{
102public:
104 typedef NextT NextType;
109
112
114
115 enum
116 {
118 count = 1 + NextT::count,
119 };
120
121 template<int CDataLevel, int CFile>
123 {
124 enum
125 {
126 count = ((VCardType::categoryDataLevel & CDataLevel
128 ? (NextType::template Statistics<CDataLevel, CFile>::count
130 : NextType::template Statistics<CDataLevel, CFile>::count),
131 };
132 };
133
134public:
135 void initializeFromStudy(Data::Study& study)
136 {
137 pNbYearsParallel = study.maxNbYearsInParallel;
138
139 // Average thoughout all years
140 InitializeResultsFromStudy(AncestorType::pResults, study);
141
142 // Intermediate values
143 pValuesForTheCurrentYear.resize(pNbYearsParallel);
144 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
145 {
146 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
147 }
148
149 // Next
150 NextType::initializeFromStudy(study);
151 }
152
153 template<class R>
154 static void InitializeResultsFromStudy(R& results, Data::Study& study)
155 {
156 VariableAccessorType::InitializeAndReset(results, study);
157 }
158
159 void initializeFromArea(Data::Study* study, Data::Area* area)
160 {
161 // Next
162 NextType::initializeFromArea(study, area);
163 }
164
165 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
166 {
167 // Next
168 NextType::initializeFromAreaLink(study, link);
169 }
170
171 void simulationBegin()
172 {
173 // Next
174 NextType::simulationBegin();
175 }
176
177 void simulationEnd()
178 {
179 NextType::simulationEnd();
180 }
181
182 void yearBegin(uint year, unsigned int numSpace)
183 {
184 // Reset the values for the current year
185 pValuesForTheCurrentYear[numSpace].reset();
186 // Next variable
187 NextType::yearBegin(year, numSpace);
188 }
189
190 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
191 {
192 // Next variable
193 NextType::yearEndBuild(state, year, numSpace);
194 }
195
196 void yearEnd(uint year, unsigned int numSpace)
197 {
198 // Compute all statistics for the current year (daily,weekly,monthly)
199 pValuesForTheCurrentYear[numSpace].computeAveragesForCurrentYearFromHourlyResults();
200
201 // Next variable
202 NextType::yearEnd(year, numSpace);
203 }
204
205 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
206 unsigned int nbYearsForCurrentSummary)
207 {
208 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
209 {
210 // Merge all those values with the global results
211 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
212 pValuesForTheCurrentYear[numSpace]);
213 }
214
215 // Next variable
216 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
217 }
218
219 void hourBegin(uint hourInTheYear)
220 {
221 // Next variable
222 NextType::hourBegin(hourInTheYear);
223 }
224
225 void hourForEachArea(State& state, unsigned int numSpace)
226 {
227 // Marginal Price
228 // Note: The marginal price provided by the solver is negative
229 // (naming convention).
230 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] -= state.hourlyResults
231 ->CoutsMarginauxHoraires
232 [state.hourInTheWeek];
233 // Next variable
234 NextType::hourForEachArea(state, numSpace);
235 }
236
237 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
238 uint,
239 unsigned int numSpace) const
240 {
241 return pValuesForTheCurrentYear[numSpace].hour;
242 }
243
244 void localBuildAnnualSurveyReport(SurveyResults& results,
245 int fileLevel,
246 int precision,
247 unsigned int numSpace) const
248 {
249 // Initializing external pointer on current variable non applicable status
250 results.isCurrentVarNA = AncestorType::isNonApplicable;
251
252 if (AncestorType::isPrinted[0])
253 {
254 // Write the data for the current year
255 results.variableCaption = VCardType::Caption();
256 results.variableUnit = VCardType::Unit();
257 pValuesForTheCurrentYear[numSpace]
258 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
259 }
260 }
261
262private:
264 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
265 unsigned int pNbYearsParallel;
266
267}; // class Price
268
269} // namespace Economy
270} // namespace Variable
271} // namespace Solver
272} // namespace Antares
273
274#endif // __SOLVER_VARIABLE_ECONOMY_Price_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal Price.
Definition price.h:101
@ count
How many items have we got.
Definition price.h:118
Variable::IVariable< Price< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition price.h:108
VCardType::ResultsType ResultsType
List of expected results.
Definition price.h:111
NextT NextType
Type of the next static variable.
Definition price.h:104
VCardPrice VCardType
VCard.
Definition price.h:106
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
VCardPrice VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition price.h:63
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition price.h:87
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition price.h:68
static constexpr uint8_t precision
Precision (views)
Definition price.h:72
static constexpr uint8_t categoryDataLevel
Data Level.
Definition price.h:66
static constexpr uint8_t decimal
Decimal precision.
Definition price.h:76
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition price.h:74
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition price.h:78
static std::string Description()
The short description of the variable.
Definition price.h:49
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition price.h:60
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition price.h:80
static std::string Unit()
Unit.
Definition price.h:43
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition price.h:85
static std::string Caption()
Caption.
Definition price.h:37