Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
localMatchingRuleViolations.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_LMR_VIOLATIONS_H__
22#define __SOLVER_VARIABLE_ECONOMY_LMR_VIOLATIONS_H__
23
24#include "antares/solver/variable/variable.h"
25
26namespace Antares::Solver::Variable::Economy
27{
29{
31 static std::string Caption()
32 {
33 return "LMR VIOL.";
34 }
35
37 static std::string Unit()
38 {
39 return " ";
40 }
41
43 static std::string Description()
44 {
45 return "Local Matching Rule is violated more than the provided threshold";
46 }
47
49 typedef Results<R::AllYears::Average< // The average values throughout all years
50 >>
52
55
57 static constexpr uint8_t categoryDataLevel = Category::DataLevel::area;
59 static constexpr uint8_t categoryFileLevel = ResultsType::categoryFile
60 & (Category::FileLevel::id
61 | Category::FileLevel::va);
63 static constexpr uint8_t precision = Category::all;
65 static constexpr uint8_t nodeDepthForGUI = +0;
67 static constexpr uint8_t decimal = 0;
69 static constexpr int columnCount = 1;
71 static constexpr uint8_t spatialAggregate = Category::spatialAggregateSum;
72 static constexpr uint8_t spatialAggregateMode = Category::spatialAggregateEachYear;
73 static constexpr uint8_t spatialAggregatePostProcessing = 0;
75 static constexpr uint8_t hasIntermediateValues = 1;
77 static constexpr uint8_t isPossiblyNonApplicable = 0;
78
80 typedef std::vector<IntermediateValues> IntermediateValuesType;
81
83
84}; // class VCard
85
90template<class NextT = Container::EndOfList>
91class LMRViolations: public Variable::IVariable<LMRViolations<NextT>, NextT, VCardLMRViolations>
92{
93public:
95 typedef NextT NextType;
100
103
105
106 enum
107 {
109 count = 1 + NextT::count,
110 };
111
112 template<int CDataLevel, int CFile>
114 {
115 enum
116 {
117 count = ((VCardType::categoryDataLevel & CDataLevel
119 ? (NextType::template Statistics<CDataLevel, CFile>::count
121 : NextType::template Statistics<CDataLevel, CFile>::count),
122 };
123 };
124
125 void initializeFromStudy(Data::Study& study)
126 {
127 pNbYearsParallel = study.maxNbYearsInParallel;
128
129 // Intermediate values
130 InitializeResultsFromStudy(AncestorType::pResults, study);
131
132 pValuesForTheCurrentYear.resize(pNbYearsParallel);
133 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
134 {
135 pValuesForTheCurrentYear[numSpace].initializeFromStudy(study);
136 }
137
138 // Next
139 NextType::initializeFromStudy(study);
140 }
141
142 template<class R>
143 static void InitializeResultsFromStudy(R& results, Data::Study& study)
144 {
145 VariableAccessorType::InitializeAndReset(results, study);
146 }
147
148 void initializeFromArea(Data::Study* study, Data::Area* area)
149 {
150 // Next
151 NextType::initializeFromArea(study, area);
152 }
153
154 void initializeFromLink(Data::Study* study, Data::AreaLink* link)
155 {
156 // Next
157 NextType::initializeFromAreaLink(study, link);
158 }
159
160 void simulationBegin()
161 {
162 for (unsigned int numSpace = 0; numSpace < pNbYearsParallel; numSpace++)
163 {
164 pValuesForTheCurrentYear[numSpace].reset();
165 }
166 // Next
167 NextType::simulationBegin();
168 }
169
170 void simulationEnd()
171 {
172 NextType::simulationEnd();
173 }
174
175 void yearBegin(unsigned int year, unsigned int numSpace)
176 {
177 // Reset the values for the current year
178 pValuesForTheCurrentYear[numSpace].reset();
179 // Next variable
180 NextType::yearBegin(year, numSpace);
181 }
182
183 void yearEndBuild(State& state, unsigned int year, unsigned int numSpace)
184 {
185 // Next variable
186 NextType::yearEndBuild(state, year, numSpace);
187 }
188
189 void yearEnd(unsigned int year, unsigned int numSpace)
190 {
191 // Compute all statistics for the current year (daily,weekly,monthly)
192 pValuesForTheCurrentYear[numSpace].computeStatisticsForTheCurrentYear();
193
194 // Next variable
195 NextType::yearEnd(year, numSpace);
196 }
197
198 void computeSummary(std::map<unsigned int, unsigned int>& numSpaceToYear,
199 unsigned int nbYearsForCurrentSummary)
200 {
201 for (unsigned int numSpace = 0; numSpace < nbYearsForCurrentSummary; ++numSpace)
202 {
203 // Merge all those values with the global results
204 AncestorType::pResults.merge(numSpaceToYear[numSpace] /*year*/,
205 pValuesForTheCurrentYear[numSpace]);
206 }
207
208 // Next variable
209 NextType::computeSummary(numSpaceToYear, nbYearsForCurrentSummary);
210 }
211
212 void hourBegin(unsigned int hourInTheYear)
213 {
214 // Next variable
215 NextType::hourBegin(hourInTheYear);
216 }
217
218 void hourForEachArea(State& state, unsigned int numSpace)
219 {
220 // Total LocalMatchingRule Violations
221 pValuesForTheCurrentYear[numSpace][state.hourInTheYear] = state.hourlyResults
222 ->ValeursHorairesLmrViolations
223 [state.hourInTheWeek];
224
225 // Next variable
226 NextType::hourForEachArea(state, numSpace);
227 }
228
229 Antares::Memory::Stored<double>::ConstReturnType retrieveRawHourlyValuesForCurrentYear(
230 unsigned int,
231 unsigned int numSpace) const
232 {
233 return pValuesForTheCurrentYear[numSpace].hour;
234 }
235
236 void localBuildAnnualSurveyReport(SurveyResults& results,
237 int fileLevel,
238 int precision,
239 unsigned int numSpace) const
240 {
241 // Initializing external pointer on current variable non applicable status
242 results.isCurrentVarNA = AncestorType::isNonApplicable;
243
244 if (AncestorType::isPrinted[0])
245 {
246 // Write the data for the current year
247 results.variableCaption = VCardType::Caption();
248 results.variableUnit = VCardType::Unit();
249 pValuesForTheCurrentYear[numSpace]
250 .template buildAnnualSurveyReport<VCardType>(results, fileLevel, precision);
251 }
252 }
253
254private:
256 typename VCardType::IntermediateValuesType pValuesForTheCurrentYear;
257 unsigned int pNbYearsParallel;
258
259}; // class LMRViolations
260
261} // namespace Antares::Solver::Variable::Economy
262
263#endif // __SOLVER_VARIABLE_ECONOMY_LMR_VIOLATIONS_H__
Definition for a single area.
Definition area.h:52
Definition study.h:61
C02 Average value of the overrall CO2 emissions expected from all the thermal dispatchable clusters.
Definition localMatchingRuleViolations.h:92
Variable::IVariable< LMRViolations< NextT >, NextT, VCardType > AncestorType
Ancestor.
Definition localMatchingRuleViolations.h:99
VCardLMRViolations VCardType
VCard.
Definition localMatchingRuleViolations.h:97
NextT NextType
Type of the next static variable.
Definition localMatchingRuleViolations.h:95
VCardType::ResultsType ResultsType
List of expected results.
Definition localMatchingRuleViolations.h:102
@ count
How many items have we got.
Definition localMatchingRuleViolations.h:109
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 localMatchingRuleViolations.h:114
Definition localMatchingRuleViolations.h:29
static constexpr int columnCount
Number of columns used by the variable (One ResultsType per column)
Definition localMatchingRuleViolations.h:69
static constexpr uint8_t decimal
Decimal precision.
Definition localMatchingRuleViolations.h:67
static constexpr uint8_t categoryFileLevel
File level (provided by the type of the results)
Definition localMatchingRuleViolations.h:59
Results< R::AllYears::Average< > > ResultsType
The expecte results.
Definition localMatchingRuleViolations.h:51
static std::string Description()
The short description of the variable.
Definition localMatchingRuleViolations.h:43
static std::string Caption()
Caption.
Definition localMatchingRuleViolations.h:31
static constexpr uint8_t hasIntermediateValues
Intermediate values.
Definition localMatchingRuleViolations.h:75
static constexpr uint8_t isPossiblyNonApplicable
Can this variable be non applicable (0 : no, 1 : yes)
Definition localMatchingRuleViolations.h:77
static constexpr uint8_t categoryDataLevel
Data Level.
Definition localMatchingRuleViolations.h:57
static std::string Unit()
Unit.
Definition localMatchingRuleViolations.h:37
VCardLMRViolations VCardForSpatialAggregate
The VCard to look for for calculating spatial aggregates.
Definition localMatchingRuleViolations.h:54
static constexpr uint8_t spatialAggregate
The Spatial aggregation.
Definition localMatchingRuleViolations.h:71
static constexpr uint8_t precision
Precision (views)
Definition localMatchingRuleViolations.h:63
static constexpr uint8_t nodeDepthForGUI
Indentation (GUI)
Definition localMatchingRuleViolations.h:65