Antares Simulator
Power System Simulator
operatingCost.h
1 /*
2  * Copyright 2007-2025, 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_OperatingCost_H__
22 #define __SOLVER_VARIABLE_ECONOMY_OperatingCost_H__
23 
24 #include "antares/solver/variable/variable.h"
25 
26 namespace Antares::Solver::Variable::Economy
27 {
29 {
31  static std::string Caption()
32  {
33  return "OP. COST";
34  }
35 
37  static std::string Unit()
38  {
39  return "Euro";
40  }
41 
43  static std::string Description()
44  {
45  return "Operating Cost throughout all MC years, of all the thermal dispatchable clusters";
46  }
47 
49  typedef Results<R::AllYears::Average< // The average values throughout all years
50  R::AllYears::StdDeviation< // The standard deviation values throughout all
51  // years
52  R::AllYears::Min< // The minimum values throughout all years
53  R::AllYears::Max< // The maximum values throughout all years
54  >>>>,
56  >
58 
61 
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 
88  using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;
89 
90 }; // class VCard
91 
96 template<class NextT = Container::EndOfList>
97 class OperatingCost: public Variable::IVariable<OperatingCost<NextT>, NextT, VCardOperatingCost>
98 {
99 public:
101  typedef NextT NextType;
106 
109 
111 
112  enum
113  {
115  count = 1 + NextT::count,
116  };
117 
118  template<int CDataLevel, int CFile>
119  struct Statistics
120  {
121  enum
122  {
123  count = ((VCardType::categoryDataLevel & CDataLevel
124  && VCardType::categoryFileLevel & CFile)
125  ? (NextType::template Statistics<CDataLevel, CFile>::count
127  : NextType::template Statistics<CDataLevel, CFile>::count),
128  };
129  };
130 
131 public:
132  void initializeFromStudy(Data::Study& study)
133  {
134  pNbYearsParallel = study.maxNbYearsInParallel;
135 
136  InitializeResultsFromStudy(AncestorType::pResults, study);
137 
138  pValuesForTheCurrentYear.resize(pNbYearsParallel);
139  for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
140  {
141  pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
142  }
143 
144  // Next
145  NextType::initializeFromStudy(study);
146  }
147 
148  template<class R>
149  static void InitializeResultsFromStudy(R& results, Data::Study& study)
150  {
151  VariableAccessorType::InitializeAndReset(results, study);
152  }
153 
154  void initializeFromArea(Data::Study* study, Data::Area* area)
155  {
156  // Next
157  NextType::initializeFromArea(study, area);
158  }
159 
160  void initializeFromLink(Data::Study* study, Data::AreaLink* link)
161  {
162  // Next
163  NextType::initializeFromAreaLink(study, link);
164  }
165 
166  void simulationBegin()
167  {
168  // Next
169  NextType::simulationBegin();
170  }
171 
172  void simulationEnd()
173  {
174  NextType::simulationEnd();
175  }
176 
177  void yearBegin(unsigned int year, unsigned int numSpace)
178  {
179  // Reset the values for the current year
180  pValuesForTheCurrentYear[numSpace].reset();
181  // Next variable
182  NextType::yearBegin(year, numSpace);
183  }
184 
185  void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
186  {
187  // Get end year calculations
188  for (unsigned int i = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
189  i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
190  ++i)
191  {
192  pValuesForTheCurrentYear[numSpace][i] += state.thermalClusterOperatingCostForYear[i];
193  }
194 
195  // Next variable
196  NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
197  }
198 
199  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
200  {
201  // Next variable
202  NextType::yearEndBuild(state, year, numSpace);
203  }
204 
205  void yearEnd(unsigned int year, unsigned int numSpace)
206  {
207  // Compute all statistics for the current year (daily,weekly,monthly)
208  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
209 
210  // Next variable
211  NextType::yearEnd(year, numSpace);
212  }
213 
214  void computeSummary(unsigned int year, unsigned int numSpace)
215  {
216  // Merge all those values with the global results
217  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
218 
219  // Next variable
220  NextType::computeSummary(year, numSpace);
221  }
222 
223  void hourBegin(unsigned int hourInTheYear)
224  {
225  // Next variable
226  NextType::hourBegin(hourInTheYear);
227  }
228 
229  void hourForEachArea(State& state, unsigned int numSpace)
230  {
231  // Next variable
232  NextType::hourForEachArea(state, numSpace);
233  }
234 
235  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
236  unsigned int,
237  unsigned int numSpace) const
238  {
239  return pValuesForTheCurrentYear[numSpace].hour;
240  }
241 
242  void localBuildAnnualSurveyReport(SurveyResults& results,
243  int fileLevel,
244  int precision,
245  unsigned int numSpace) const
246  {
247  // Initializing external pointer on current variable non applicable status
248  results.isCurrentVarNA = AncestorType::isNonApplicable;
249 
250  if (AncestorType::isPrinted[0])
251  {
252  // Write the data for the current year
253  results.variableCaption = VCardType::Caption();
254  results.variableUnit = VCardType::Unit();
255  pValuesForTheCurrentYear[numSpace]
256  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
257  }
258  }
259 
260 private:
262  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
263  unsigned int pNbYearsParallel;
264 
265 }; // class OperatingCost
266 
267 } // namespace Antares::Solver::Variable::Economy
268 
269 #endif // __SOLVER_VARIABLE_ECONOMY_OperatingCost_H__
Definition for a single area.
Definition: area.h:51
Definition: study.h:57
C02 Average value of the overrall OperatingCost emissions expected from all the thermal dispatchable ...
Definition: operatingCost.h:98
VCardType::ResultsType ResultsType
List of expected results.
Definition: operatingCost.h:108
NextT NextType
Type of the next static variable.
Definition: operatingCost.h:101
VCardOperatingCost VCardType
VCard.
Definition: operatingCost.h:103
@ count
How many items have we got.
Definition: operatingCost.h:115
Variable::IVariable< OperatingCost< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: operatingCost.h:105
Interface for any variable.
Definition: variable.h:47
StoredResultType pResults
All the results about this variable.
Definition: variable.h:323
Temporary buffer for allocating results for a single year.
Definition: intermediate.h:42
Definition: results.h:44
@ count
The count if item in the list.
Definition: results.h:52
Definition: cbuilder.h:120
static std::string Unit()
Unit.
Definition: operatingCost.h:37
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: operatingCost.h:71
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: operatingCost.h:81
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: operatingCost.h:63
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > >, R::AllYears::Average > ResultsType
The expecte results.
Definition: operatingCost.h:57
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: operatingCost.h:75
static std::string Caption()
Caption.
Definition: operatingCost.h:31
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: operatingCost.h:65
static std::string Description()
The short description of the variable.
Definition: operatingCost.h:43
VCardOperatingCost VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition: operatingCost.h:60
static constexpr uint8_t precision
Precision (views)
Definition: operatingCost.h:69
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: operatingCost.h:83
static constexpr uint8_t decimal
Decimal precision.
Definition: operatingCost.h:73
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: operatingCost.h:77