Antares Simulator
Power System Simulator
nonProportionalCost.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_NonProportionalCost_H__
22 #define __SOLVER_VARIABLE_ECONOMY_NonProportionalCost_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 "NP COST";
34  }
35 
37  static std::string Unit()
38  {
39  return "Euro";
40  }
41 
43  static std::string Description()
44  {
45  return "Non Proportional Cost throughout all MC years, of all the thermal dispatchable "
46  "clusters";
47  }
48 
50  typedef Results<R::AllYears::Average< // The average values throughout all years
51  R::AllYears::StdDeviation< // The standard deviation values throughout all
52  // years
53  R::AllYears::Min< // The minimum values throughout all years
54  R::AllYears::Max< // The maximum values throughout all years
55  >>>>,
57  >
59 
62 
64  static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
66  static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
67  & (Category::FileLevel::id
68  | Category::FileLevel::va);
70  static constexpr uint8_t precision = Category::all;
72  static constexpr uint8_t nodeDepthForGUI = +0;
74  static constexpr uint8_t decimal = 0;
76  static constexpr int columnCount = 1;
78  static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
79  static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
80  static constexpr uint8_t spatialAggregatePostProcessing = 0;
82  static constexpr uint8_t hasIntermediateValues = 1;
84  static constexpr uint8_t isPossiblyNonApplicable = 0;
85 
87  typedef std::vector<IntermediateValues> IntermediateValuesType;
88 
89  using IntermediateValuesTypeForSpatialAg = std::unique_ptr<IntermediateValuesBaseType[]>;
90 
91 }; // class VCard
92 
97 template<class NextT = Container::EndOfList>
99  : public Variable::IVariable<NonProportionalCost<NextT>, NextT, VCardNonProportionalCost>
100 {
101 public:
103  typedef NextT NextType;
108 
111 
113 
114  enum
115  {
117  count = 1 + NextT::count,
118  };
119 
120  template<int CDataLevel, int CFile>
121  struct Statistics
122  {
123  enum
124  {
125  count = ((VCardType::categoryDataLevel & CDataLevel
126  && VCardType::categoryFileLevel & CFile)
127  ? (NextType::template Statistics<CDataLevel, CFile>::count
129  : NextType::template Statistics<CDataLevel, CFile>::count),
130  };
131  };
132 
133 public:
134  void initializeFromStudy(Data::Study& study)
135  {
136  pNbYearsParallel = study.maxNbYearsInParallel;
137 
138  InitializeResultsFromStudy(AncestorType::pResults, study);
139 
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  template<class R>
151  static void InitializeResultsFromStudy(R& results, Data::Study& study)
152  {
153  VariableAccessorType::InitializeAndReset(results, study);
154  }
155 
156  void initializeFromArea(Data::Study* study, Data::Area* area)
157  {
158  // Next
159  NextType::initializeFromArea(study, area);
160  }
161 
162  void initializeFromLink(Data::Study* study, Data::AreaLink* link)
163  {
164  // Next
165  NextType::initializeFromAreaLink(study, link);
166  }
167 
168  void simulationBegin()
169  {
170  // Next
171  NextType::simulationBegin();
172  }
173 
174  void simulationEnd()
175  {
176  NextType::simulationEnd();
177  }
178 
179  void yearBegin(unsigned int year, unsigned int numSpace)
180  {
181  // Reset the values for the current year
182  pValuesForTheCurrentYear[numSpace].reset();
183  // Next variable
184  NextType::yearBegin(year, numSpace);
185  }
186 
187  void yearEndBuildForEachThermalCluster(State& state, uint year, unsigned int numSpace)
188  {
189  // Get end year calculations
190  for (unsigned int i = state.study.runtime.rangeLimits.hour[Data::rangeBegin];
191  i <= state.study.runtime.rangeLimits.hour[Data::rangeEnd];
192  ++i)
193  {
194  pValuesForTheCurrentYear[numSpace][i] += state
195  .thermalClusterNonProportionalCostForYear[i];
196  }
197 
198  // Next variable
199  NextType::yearEndBuildForEachThermalCluster(state, year, numSpace);
200  }
201 
202  void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
203  {
204  // Next variable
205  NextType::yearEndBuild(state, year, numSpace);
206  }
207 
208  void yearEnd(unsigned int year, unsigned int numSpace)
209  {
210  // Compute all statistics for the current year (daily,weekly,monthly)
211  pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
212 
213  // Next variable
214  NextType::yearEnd(year, numSpace);
215  }
216 
217  void computeSummary(unsigned int year, unsigned int numSpace)
218  {
219  // Merge all those values with the global results
220  AncestorType::pResults.merge(year, pValuesForTheCurrentYear[numSpace]);
221 
222  // Next variable
223  NextType::computeSummary(year, numSpace);
224  }
225 
226  void hourBegin(unsigned int hourInTheYear)
227  {
228  // Next variable
229  NextType::hourBegin(hourInTheYear);
230  }
231 
232  void hourForEachArea(State& state, unsigned int numSpace)
233  {
234  // Next variable
235  NextType::hourForEachArea(state, numSpace);
236  }
237 
238  Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
239  unsigned int,
240  unsigned int numSpace) const
241  {
242  return pValuesForTheCurrentYear[numSpace].hour;
243  }
244 
245  void localBuildAnnualSurveyReport(SurveyResults& results,
246  int fileLevel,
247  int precision,
248  unsigned int numSpace) const
249  {
250  // Initializing external pointer on current variable non applicable status
251  results.isCurrentVarNA = AncestorType::isNonApplicable;
252 
253  if (AncestorType::isPrinted[0])
254  {
255  // Write the data for the current year
256  results.variableCaption = VCardType::Caption();
257  results.variableUnit = VCardType::Unit();
258  pValuesForTheCurrentYear[numSpace]
259  .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
260  }
261  }
262 
263 private:
265  typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
266  unsigned int pNbYearsParallel;
267 
268 }; // class NonProportionalCost
269 
270 } // namespace Antares::Solver::Variable::Economy
271 
272 #endif // __SOLVER_VARIABLE_ECONOMY_NonProportionalCost_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: nonProportionalCost.h:100
VCardType::ResultsType ResultsType
List of expected results.
Definition: nonProportionalCost.h:110
@ count
How many items have we got.
Definition: nonProportionalCost.h:117
Variable::IVariable< NonProportionalCost< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition: nonProportionalCost.h:107
NextT NextType
Type of the next static variable.
Definition: nonProportionalCost.h:103
VCardNonProportionalCost VCardType
VCard.
Definition: nonProportionalCost.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 constexpr uint8_t precision
Precision (views)
Definition: nonProportionalCost.h:70
VCardNonProportionalCost VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition: nonProportionalCost.h:61
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition: nonProportionalCost.h:78
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition: nonProportionalCost.h:84
static std::string Description()
The short description of the variable.
Definition: nonProportionalCost.h:43
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition: nonProportionalCost.h:82
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition: nonProportionalCost.h:72
static std::string Unit()
Unit.
Definition: nonProportionalCost.h:37
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition: nonProportionalCost.h:76
static constexpr uint8_t categoryDataLevel
Data Level.
Definition: nonProportionalCost.h:64
static constexpr uint8_t decimal
Decimal precision.
Definition: nonProportionalCost.h:74
Results< R::AllYears::Average< R::AllYears::StdDeviation< R::AllYears::Min< R::AllYears::Max< > > > >, R::AllYears::Average > ResultsType
The expecte results.
Definition: nonProportionalCost.h:58
static std::string Caption()
Caption.
Definition: nonProportionalCost.h:31
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition: nonProportionalCost.h:66