Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
minmax.hxx
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_MIN_HXX__
22#define __SOLVER_VARIABLE_STORAGE_MIN_HXX__
23
24#include <limits>
25
26namespace Antares
27{
28namespace Solver
29{
30namespace Variable
31{
32namespace R
33{
34namespace AllYears
35{
36template<bool OpInferior, class NextT>
37inline void MinMaxBase<OpInferior, NextT>::initializeFromStudy(Data::Study& study)
38{
39 // Next
40 NextType::initializeFromStudy(study);
41}
42
43template<bool OpInferior, class NextT>
44inline void MinMaxBase<OpInferior, NextT>::reset()
45{
46 // Reset at the begining of the simulation
47 if (OpInferior)
48 {
49 minmax.resetInf();
50 }
51 else
52 {
53 minmax.resetSup();
54 }
55 // Next
56 NextType::reset();
57}
58
59template<bool OpInferior, class NextT>
60inline void MinMaxBase<OpInferior, NextT>::merge(uint year, const IntermediateValues& rhs)
61{
62 if (OpInferior)
63 {
64 minmax.mergeInf(year, rhs);
65 }
66 else
67 {
68 minmax.mergeSup(year, rhs);
69 }
70 // Next
71 NextType::merge(year, rhs);
72}
73
74template<bool OpInferior, class NextT>
75template<uint Size, class VCardT>
76void MinMaxBase<OpInferior, NextT>::InternalExportIndices(SurveyResults& report,
77 const MinMaxData::Data* array,
78 int fileLevel)
79{
80 assert(array);
81 assert(report.data.columnIndex < report.maxVariables && "Column index out of bounds");
82
83 // Caption
84 report.captions[0][report.data.columnIndex] = report.variableCaption;
85 report.captions[1][report.data.columnIndex] = report.variableUnit;
86 report.captions[2][report.data.columnIndex] = (OpInferior ? "min" : "max");
87
88 // Precision
89 int recommendedPrecision = (int)Category::MaxDecimalPrecision(fileLevel);
90 uint decimalPrec = (recommendedPrecision < (int)VCardT::decimal) ? (uint)recommendedPrecision
91 : (uint)VCardT::decimal;
92
93 // Non applicability
94 report.nonApplicableStatus[report.data.columnIndex] = *report.isCurrentVarNA;
95
96 Solver::Variable::AssignPrecisionToPrintfFormat(report.precision[report.data.columnIndex],
97 decimalPrec);
98
99 // Values
100 double* v = report.values[report.data.columnIndex];
101 for (uint i = 0; i != Size; ++i)
102 {
103 v[i] = (double)array[i].indice;
104 }
105
106 // Next column index
107 ++report.data.columnIndex;
108}
109
110template<bool OpInferior, class NextT>
111template<uint Size, class VCardT>
112inline void MinMaxBase<OpInferior, NextT>::InternalExportValues(SurveyResults& report,
113 const MinMaxData::Data* array)
114{
115 assert(array);
116 assert(report.data.columnIndex < report.maxVariables && "Column index out of bounds");
117
118 // Caption
119 report.captions[0][report.data.columnIndex] = report.variableCaption;
120 report.captions[1][report.data.columnIndex] = report.variableUnit;
121 report.captions[2][report.data.columnIndex] = (OpInferior ? "min" : "max");
122 // Precision
123 Solver::Variable::AssignPrecisionToPrintfFormat(report.precision[report.data.columnIndex],
124 VCardT::decimal);
125
126 // Non applicability
127 report.nonApplicableStatus[report.data.columnIndex] = *report.isCurrentVarNA;
128
129 // Values
130 double* v = report.values[report.data.columnIndex];
131 for (uint i = 0; i != Size; ++i)
132 {
133 v[i] = array[i].value;
134 }
135
136 // Next column index
137 ++report.data.columnIndex;
138}
139
140} // namespace AllYears
141} // namespace R
142} // namespace Variable
143} // namespace Solver
144} // namespace Antares
145
146#endif // __SOLVER_VARIABLE_STORAGE_MIN_HXX__
Definition variable.h:25