Loading [MathJax]/extensions/tex2jax.js
Antares Simulator
Power System Simulator
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
minmax.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_STORAGE_MINMAX_H__
22#define __SOLVER_VARIABLE_STORAGE_MINMAX_H__
23
24#include "minmax-data.h"
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace R
33{
34namespace AllYears
35{
36template<class NextT = Empty>
37class Min;
38template<class NextT = Empty>
39class Max;
40
41template<bool OpInferior, class NextT>
42struct MinMaxBase: public NextT
43{
44public:
46 typedef NextT NextType;
47
48 enum
49 {
51 count = 1 + NextT::count,
52
53 categoryFile = NextT::categoryFile | Variable::Category::FileLevel::allFile,
54 };
55
57 static const char* Name()
58 {
59 return "minmaxbase";
60 }
61
62public:
64 {
65 }
66
67 ~MinMaxBase()
68 {
69 }
70
71protected:
72 void initializeFromStudy(Data::Study& study);
73
74 template<class S, class VCardT>
75 void buildSurveyReport(SurveyResults& report,
76 const S& results,
77 int dataLevel,
78 int fileLevel,
79 int precision) const
80 {
81 if (fileLevel & Category::FileLevel::id)
82 {
83 switch (precision)
84 {
85 case Category::hourly:
86 InternalExportIndices<HOURS_PER_YEAR, VCardT>(report,
87 Memory::RawPointer(
88 minmax.hourly.data()),
89 fileLevel);
90 break;
91 case Category::daily:
92 InternalExportIndices<DAYS_PER_YEAR, VCardT>(report,
93 minmax.daily.data(),
94 fileLevel);
95 break;
96 case Category::weekly:
97 InternalExportIndices<WEEKS_PER_YEAR, VCardT>(report,
98 minmax.weekly.data(),
99 fileLevel);
100 break;
101 case Category::monthly:
102 InternalExportIndices<MONTHS_PER_YEAR, VCardT>(report,
103 minmax.monthly.data(),
104 fileLevel);
105 break;
106 case Category::annual:
107 InternalExportIndices<1, VCardT>(report, minmax.annual.data(), fileLevel);
108 break;
109 }
110 }
111 else
112 {
113 switch (precision)
114 {
115 case Category::hourly:
116 InternalExportValues<HOURS_PER_YEAR, VCardT>(report,
117 Memory::RawPointer(
118 minmax.hourly.data()));
119 break;
120 case Category::daily:
121 InternalExportValues<DAYS_PER_YEAR, VCardT>(report, minmax.daily.data());
122 break;
123 case Category::weekly:
124 InternalExportValues<WEEKS_PER_YEAR, VCardT>(report, minmax.weekly.data());
125 break;
126 case Category::monthly:
127 InternalExportValues<MONTHS_PER_YEAR, VCardT>(report, minmax.monthly.data());
128 break;
129 case Category::annual:
130 InternalExportValues<1, VCardT>(report, minmax.annual.data());
131 break;
132 }
133 }
134 // Next
135 NextType::template buildSurveyReport<S, VCardT>(report,
136 results,
137 dataLevel,
138 fileLevel,
139 precision);
140 }
141
142 void reset();
143
144 void merge(uint year, const IntermediateValues& rhs);
145
146 template<template<class> class DecoratorT>
147 Antares::Memory::Stored<double>::ConstReturnType hourlyValuesForSpatialAggregate() const
148 {
149 return NextType::template hourlyValuesForSpatialAggregate<DecoratorT>();
150 }
151
152protected:
153 MinMaxData minmax;
154
155private:
156 template<uint Size, class VCardT>
157 static void InternalExportIndices(SurveyResults& report,
158 const MinMaxData::Data* array,
159 int fileLevel);
160
161 template<uint Size, class VCardT>
162 static void InternalExportValues(SurveyResults& report, const MinMaxData::Data* array);
163
164}; // class MinMaxBase
165
166template<class NextT>
167class Min: public MinMaxBase<true, NextT>
168{
169public:
173 typedef NextT NextType;
174
175public:
177 static const char* Name()
178 {
179 return "min";
180 }
181
182 enum
183 {
186 };
187};
188
189template<class NextT>
190class Max: public MinMaxBase<false, NextT>
191{
192public:
196 typedef NextT NextType;
197
198public:
200 static const char* Name()
201 {
202 return "max";
203 }
204
205 enum
206 {
209 };
210};
211
212} // namespace AllYears
213} // namespace R
214} // namespace Variable
215} // namespace Solver
216} // namespace Antares
217
218#include "minmax.hxx"
219
220#endif // __SOLVER_VARIABLE_STORAGE_MINMAX_H__
Definition study.h:61
MinMaxBase< false, NextT > MinMaxImplementationType
Implementation.
Definition minmax.h:194
static const char * Name()
Name of the filter.
Definition minmax.h:200
@ count
The count if item in the list.
Definition minmax.h:208
NextT NextType
Type of the net item in the list.
Definition minmax.h:196
MinMaxBase< true, NextT > MinMaxImplementationType
Implementation.
Definition minmax.h:171
static const char * Name()
Name of the filter.
Definition minmax.h:177
@ count
The count if item in the list.
Definition minmax.h:185
NextT NextType
Type of the net item in the list.
Definition minmax.h:173
Class utility for building CSV results files.
Definition surveyresults.h:41
Definition variable.h:25
static const char * Name()
Name of the filter.
Definition minmax.h:57
NextT NextType
Type of the net item in the list.
Definition minmax.h:46
@ count
The count if item in the list.
Definition minmax.h:51