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