Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
marginalCost.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_MarginalCost_H__
22#define __SOLVER_VARIABLE_ECONOMY_MarginalCost_H__
23
24#include <cmath>
25
26#include "../../variable.h"
27
28namespace Antares
29{
30namespace Solver
31{
32namespace Variable
33{
34namespace Economy
35{
37{
39 static std::string Caption()
40 {
41 return "MARG. COST";
42 }
43
45 static std::string Unit()
46 {
47 return "Euro/MW";
48 }
49
51 static std::string Description()
52 {
53 return "Decrease of the overall operating cost expected by a 1MW capacity reinforcement";
54 }
55
57 typedef Results<R::AllYears::Average< // The average values throughout all years
58 R::AllYears::StdDeviation< // The standard deviation values throughout all years
59 R::AllYears::Min< // The minimum values throughout all years
60 R::AllYears::Max< // The maximum values throughout all years
61 >>>>>
63
65 static constexpr uint8_t categoryDataLevel = Category::DataLevel::link;
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 = 2;
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
90}; // class VCard
91
95template<class NextT = Container::EndOfList>
96class MarginalCost: public Variable::IVariable<MarginalCost<NextT>, NextT, VCardMarginalCost>
97{
98public:
100 typedef NextT NextType;
105
108
110
111 enum
112 {
114 count = 1 + NextT::count,
115 };
116
117 template<int CDataLevel, int CFile>
119 {
120 enum
121 {
122 count = ((VCardType::categoryDataLevel & CDataLevel
124 ? (NextType::template Statistics<CDataLevel, CFile>::count
126 : NextType::template Statistics<CDataLevel, CFile>::count),
127 };
128 };
129
130public:
131 void initializeFromStudy(Data::Study& study)
132 {
133 pNbYearsParallel = study.maxNbYearsInParallel;
134
135 // Average on all years
136 AncestorType::pResults.initializeFromStudy(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 // Next
147 NextType::initializeFromStudy(study);
148 }
149
150 void initializeFromArea(Data::Study* study, Data::Area* area)
151 {
152 // Next
153 NextType::initializeFromArea(study, area);
154 }
155
156 void initializeFromAreaLink(Data::Study* study, Data::AreaLink* link)
157 {
158 // Next
159 NextType::initializeFromAreaLink(study, link);
160 }
161
162 void simulationBegin()
163 {
164 // Next
165 NextType::simulationBegin();
166 }
167
168 void simulationEnd()
169 {
170 NextType::simulationEnd();
171 }
172
173 void yearBegin(uint year, unsigned int numSpace)
174 {
175 // Reset
176 pValuesForTheCurrentYear[numSpace].reset();
177 // Next variable
178 NextType::yearBegin(year, numSpace);
179 }
180
181 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
182 {
183 // Next variable
184 NextType::yearEndBuild(state, year, numSpace);
185 }
186
187 void yearEnd(unsigned int year, unsigned int numSpace)
188 {
189 // Compute all statistics for the current year (daily,weekly,monthly)
190 pValuesForTheCurrentYear[numSpace].computeAveragesForCurrentYearFromHourlyResults();
191
192 // Next variable
193 NextType::yearEnd(year, numSpace);
194 }
195
196 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
197 unsigned int nbYearsForCurrentSummary)
198 {
199 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
200 {
201 // Merge all those values with the global results
202 AncestorType::pResults.merge(numSpaceToYear[numSpace],
203 pValuesForTheCurrentYear[numSpace]);
204 }
205
206 // Next variable
207 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
208 }
209
210 void hourBegin(uint hourInTheYear)
211 {
212 // Next variable
213 NextType::hourBegin(hourInTheYear);
214 }
215
216 void hourForEachArea(State& state, unsigned int numSpace)
217 {
218 // Next variable
219 NextType::hourForEachArea(state, numSpace);
220 }
221
222 void hourForEachLink(State& state, unsigned int numSpace)
223 {
224 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = std::abs(
225 state.problemeHebdo->VariablesDualesDesContraintesDeNTC[state.hourInTheWeek]
226 .VariableDualeParInterconnexion[state.link->index]);
227
228 // This value should be reset to zero if (flow_lowerbound) < flow < (flow_upperbound) (with
229 // signed values)
230 double flow = state.problemeHebdo->ValeursDeNTC[state.hourInTheWeek]
231 .ValeurDuFlux[state.link->index];
232 double flow_lowerbound = -state.problemeHebdo->ValeursDeNTC[state.hourInTheWeek]
233 .ValeurDeNTCExtremiteVersOrigine[state.link->index];
234 double flow_upperbound = state.problemeHebdo->ValeursDeNTC[state.hourInTheWeek]
235 .ValeurDeNTCOrigineVersExtremite[state.link->index];
236
237 if (flow - 0.001 > flow_lowerbound && flow + 0.001 < flow_upperbound)
238 {
239 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = 0.;
240 }
241
242 // Next item in the list
243 NextType::hourForEachLink(state, numSpace);
244 }
245
246 void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
247 {
248 // Next
249 NextType::buildDigest(results, digestLevel, dataLevel);
250 }
251
252 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
253 uint,
254 uint numSpace) const
255 {
256 return pValuesForTheCurrentYear[numSpace].hour;
257 }
258
259 void localBuildAnnualSurveyReport(SurveyResults& results,
260 int fileLevel,
261 int precision,
262 uint numSpace) const
263 {
264 // Initializing external pointer on current variable non applicable status
265 results.isCurrentVarNA = AncestorType::isNonApplicable;
266
267 if (AncestorType::isPrinted[0])
268 {
269 // Write the data for the current year
270 results.variableCaption = VCardType::Caption();
271 results.variableUnit = VCardType::Unit();
272 pValuesForTheCurrentYear[numSpace]
273 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
274 }
275 }
276
277private:
279 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
280 unsigned int pNbYearsParallel;
281
282}; // class MarginalCost
283
284} // namespace Economy
285} // namespace Variable
286} // namespace Solver
287} // namespace Antares
288
289#endif // __SOLVER_VARIABLE_ECONOMY_MarginalCost_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
Marginal MarginalCost.
Definition marginalCost.h:97
VCardType::ResultsType ResultsType
List of expected results.
Definition marginalCost.h:107
@ count
How many items have we got.
Definition marginalCost.h:114
NextT NextType
Type of the next static variable.
Definition marginalCost.h:100
VCardMarginalCost VCardType
VCard.
Definition marginalCost.h:102
Variable::IVariable< MarginalCost< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition marginalCost.h:104
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 decimal
Decimal precision.
Definition marginalCost.h:75
static std::string Caption()
Caption.
Definition marginalCost.h:39
static constexpr uint8_t precision
Precision (views)
Definition marginalCost.h:71
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition marginalCost.h:77
static std::string Unit()
Unit.
Definition marginalCost.h:45
static std::string Description()
The short description of the variable.
Definition marginalCost.h:51
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition marginalCost.h:79
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition marginalCost.h:67
static constexpr uint8_t categoryDataLevel
Data Level.
Definition marginalCost.h:65
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > > > ResultsType
The expecte results.
Definition marginalCost.h:62
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition marginalCost.h:85
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition marginalCost.h:83
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition marginalCost.h:73