Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
minDispatchableGenByPlant.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#pragma once
22
23#include "antares/solver/variable/variable.h"
24
25namespace Antares::Solver::Variable::Economy
26{
28{
30 static std::string Caption()
31 {
32 return "MIN DTG by plant";
33 }
34
36 static std::string Unit()
37 {
38 return "MIN GEN - MWh";
39 }
40
42 static std::string Description()
43 {
44 return "Min power by cluster";
45 }
46
48 typedef Results<R::AllYears::Average< // The average values throughout all years
49 >>
51
54
56 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
58 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
59 & (Category::FileLevel::de);
61 static constexpr uint8_t precision = Category::all;
63 static constexpr uint8_t nodeDepthForGUI = +0;
65 static constexpr uint8_t decimal = 0;
67 static constexpr int columnCount = Category::dynamicColumns;
69 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
70 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
71 static constexpr uint8_t spatialAggregatePostProcessing = 0;
73 static constexpr uint8_t hasIntermediateValues = 1;
75 static constexpr uint8_t isPossiblyNonApplicable = 0;
76
78 typedef std::vector<IntermediateValues> IntermediateValuesBaseType;
79 typedef std::vector<IntermediateValuesBaseType> IntermediateValuesType;
80
81}; // class VCard
82
86template<class NextT = Container::EndOfList>
87class MinDispatchableGenByPlant: public Variable::IVariable<MinDispatchableGenByPlant<NextT>,
88 NextT,
89 VCardMinDispatchableGenByPlant>
90{
91public:
93 typedef NextT NextType;
98
101
103
104 enum
105 {
107 count = 1 + NextT::count,
108 };
109
110 template<int CDataLevel, int CFile>
112 {
113 enum
114 {
115 count = ((VCardType::categoryDataLevel & CDataLevel
117 ? (NextType::template Statistics<CDataLevel, CFile>::count
119 : NextType::template Statistics<CDataLevel, CFile>::count),
120 };
121 };
122
123public:
124 MinDispatchableGenByPlant() = default;
125 ~MinDispatchableGenByPlant() = default;
126
127 void initializeFromArea(Data::Study* study, Data::Area* area)
128 {
129 // Get the number of years in parallel
130 pNbYearsParallel = study->maxNbYearsInParallel;
131 pValuesForTheCurrentYear.resize(pNbYearsParallel);
132
133 // Get the area
134 nbClusters_ = area->thermal.list.enabledCount();
135 if (nbClusters_)
136 {
137 AncestorType::pResults.resize(nbClusters_);
138
139 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
140 {
141 pValuesForTheCurrentYear[numSpace].resize(nbClusters_);
142 }
143
144 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
145 {
146 for (unsigned int i = 0; i != nbClusters_; ++i)
147 {
148 pValuesForTheCurrentYear[numSpace][i].initializeFromStudy(*study);
149 }
150 }
151
152 for (unsigned int i = 0; i != nbClusters_; ++i)
153 {
154 AncestorType::pResults[i].initializeFromStudy(*study);
155 AncestorType::pResults[i].reset();
156 }
157 }
158 else
159 {
161 }
162 // Next
163 NextType::initializeFromArea(study, area);
164 }
165
166 size_t getMaxNumberColumns() const
167 {
168 return nbClusters_ * ResultsType::count;
169 }
170
171 void yearBegin(unsigned int year, unsigned int numSpace)
172 {
173 // Reset the values for the current year
174 for (unsigned int i = 0; i != nbClusters_; ++i)
175 {
176 pValuesForTheCurrentYear[numSpace][i].reset();
177 }
178 // Next variable
179 NextType::yearBegin(year, numSpace);
180 }
181
182 void yearEnd(unsigned int year, unsigned int numSpace)
183 {
184 // Merge all results for all thermal clusters
185 {
186 for (unsigned int i = 0; i < nbClusters_; ++i)
187 {
188 // Compute all statistics for the current year (daily,weekly,monthly)
189 pValuesForTheCurrentYear[numSpace][i].computeStatisticsForTheCurrentYear();
190 }
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 for (unsigned int i = 0; i < nbClusters_; ++i)
202 {
203 // Merge all those values with the global results
204 AncestorType::pResults[i].merge(numSpaceToYear[numSpace],
205 pValuesForTheCurrentYear[numSpace][i]);
206 }
207 }
208
209 // Next variable
210 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
211 }
212
213 void hourForEachArea(State& state, unsigned int numSpace)
214 {
215 auto& area = state.area;
216 auto& thermal = state.thermal;
217 for (auto& cluster: area->thermal.list.each_enabled())
218 {
219 double minGen = cluster->PthetaInf[state.hourInTheYear];
220 double production = thermal[area->index]
221 .thermalClustersProductions[cluster->enabledIndex];
222
223 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex].hour[state.hourInTheYear]
224 += std::min(production, minGen);
225 }
226
227 // Next variable
228 NextType::hourForEachArea(state, numSpace);
229 }
230
231 inline void buildDigest(SurveyResults& results, int digestLevel, int dataLevel) const
232 {
233 // Ask to build the digest to the next variable
234 NextType::buildDigest(results, digestLevel, dataLevel);
235 }
236
237 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
238 unsigned int column,
239 unsigned int numSpace) const
240 {
241 return pValuesForTheCurrentYear[numSpace][column].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 assert(NULL != results.data.area);
255 const auto& thermal = results.data.area->thermal;
256
257 // Write the data for the current year
258 for (auto& cluster: thermal.list.each_enabled())
259 {
260 // Write the data for the current year
261 results.variableCaption = cluster->name(); // VCardType::Caption();
262 results.variableUnit = VCardType::Unit();
263 pValuesForTheCurrentYear[numSpace][cluster->enabledIndex]
264 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
265 }
266 }
267 }
268
269private:
271 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
272 size_t nbClusters_ = 0;
273 unsigned int pNbYearsParallel;
274
275}; // class MinDispatchableGenByPlant
276
277} // namespace Antares::Solver::Variable::Economy
Definition for a single area.
Definition area.h:52
Definition study.h:61
Energy generated by all thermal dispatchable clusters.
Definition minDispatchableGenByPlant.h:90
VCardMinDispatchableGenByPlant VCardType
VCard.
Definition minDispatchableGenByPlant.h:95
Variable::IVariable< MinDispatchableGenByPlant< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition minDispatchableGenByPlant.h:97
@ count
How many items have we got.
Definition minDispatchableGenByPlant.h:107
NextT NextType
Type of the next static variable.
Definition minDispatchableGenByPlant.h:93
VCardType::ResultsType ResultsType
List of expected results.
Definition minDispatchableGenByPlant.h:100
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
static constexpr uint8_t categoryDataLevel
Data Level.
Definition minDispatchableGenByPlant.h:56
Results< R::AllYears::Average< > > ResultsType
For synthesis.
Definition minDispatchableGenByPlant.h:50
static std::string Description()
The short description of the variable.
Definition minDispatchableGenByPlant.h:42
static constexpr uint8_t precision
Precision (views)
Definition minDispatchableGenByPlant.h:61
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition minDispatchableGenByPlant.h:58
static constexpr uint8_t decimal
Decimal precision.
Definition minDispatchableGenByPlant.h:65
static std::string Caption()
Caption.
Definition minDispatchableGenByPlant.h:30
static constexpr int columnCount
Number of columns used by the variable.
Definition minDispatchableGenByPlant.h:67
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition minDispatchableGenByPlant.h:75
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition minDispatchableGenByPlant.h:63
static std::string Unit()
Unit.
Definition minDispatchableGenByPlant.h:36
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition minDispatchableGenByPlant.h:73
VCardMinDispatchableGenByPlant VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition minDispatchableGenByPlant.h:53
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition minDispatchableGenByPlant.h:69