Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
variable-print-info.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
22#ifndef __SOLVER_VARIABLE_PRINT_POLICY_H__
23#define __SOLVER_VARIABLE_PRINT_POLICY_H__
24
25#include <map>
26#include <string>
27#include <vector>
28
29#include <yuni/yuni.h>
30#include <yuni/core/fwd.h>
31#include <yuni/core/string.h>
32
33namespace Antares
34{
35namespace Data
36{
37// Represents an output variable (wears the same name) and mainly answers the question :
38// Is the real variable printed in all output reports ? Or is it not printed in any report ?
40{
41public:
42 VariablePrintInfo(uint dataLvl, uint fileLvl);
43 ~VariablePrintInfo() = default;
44
45 // Do we enable or disable variable's print in output reports ?
46 void enablePrint(bool b);
47 bool isPrinted() const;
48 void reverse();
49
50 uint getMaxColumnsCount();
51 void setMaxColumns(uint maxColumnsNumber);
52
53 bool isPrintedOnDataLevel(uint dataLevel) const
54 {
55 return dataLevel_ & dataLevel;
56 }
57
58 bool isPrintedOnFileLevel(uint fileLevel) const
59 {
60 return fileLevel_ & fileLevel;
61 }
62
63private:
64 // Is the variable printed ?
65 bool to_be_printed_ = true;
66
67 // The number of columns the output variable takes in a SYNTHESIS report.
68 // Recall that synthesis reports always contain more columns than
69 // any other reports (for instance year-by-year reports)
70 uint maxNumberColumns_ = 0;
71
72 // Which reports the output variable has columns in ?
73 // Example : areas/values-<time-interval>.txt
74 // dataLevel can be : areas, links, bindingConstraint
75 // fileLevel can be : values-<time-interval>.txt, details-<time-interval>.txt,
76 // id-<time-interval>.txt, ...
77 uint dataLevel_ = 0;
78 uint fileLevel_ = 0;
79};
80
82
84{
85public:
87 void add(const AnyString& name, uint dataLevel, uint fileLevel);
88
89private:
90 AllVariablesPrintInfo* allvarsinfo;
91};
92
93// Variables print info collection. Mainly a vector of pointers to print info.
94// This collection is filled with as many print info as we can find output variables in the output
95// variables Antares's static list.
97{
98public:
99 // Public methods
100 AllVariablesPrintInfo() = default;
101 ~AllVariablesPrintInfo() = default;
102
103 void add(std::string name, VariablePrintInfo v);
104 void clear();
105 VariablePrintInfo& operator[](uint i);
106 size_t size() const;
107 bool exists(std::string name);
108
109 void setPrintStatus(std::string varname, bool printStatus);
110 void setPrintStatus(unsigned int index, bool printStatus);
111
112 void setMaxColumns(std::string varname, uint maxColumnsNumber);
113 std::string name_of(unsigned int index) const;
114
115 void prepareForSimulation(bool isThematicTrimmingEnabled,
116 const std::vector<std::string>& excluded_vars = {});
117
118 // Classic search, then get the print status
119 bool isPrinted(std::string var_name) const;
120
121 uint getTotalMaxColumnsCount() const
122 {
123 return totalMaxColumnsCount_;
124 }
125
126 uint getNbSelectedZonalVars() const
127 {
128 return numberSelectedAreaVariables;
129 }
130
131 uint getNbSelectedLinkVars() const
132 {
133 return numberSelectedLinkVariables;
134 }
135
136 void computeMaxColumnsCountInReports();
137 void setAllPrintStatusesTo(bool b);
138 void reverseAll();
139
140 unsigned int numberOfEnabledVariables();
141 std::vector<std::string> namesOfEnabledVariables();
142 std::vector<std::string> namesOfDisabledVariables();
143
144private:
145 std::vector<std::string> namesOfVariablesWithPrintStatus(bool printStatus);
146 void countSelectedAreaVars();
147 void countSelectedLinkVars();
148
149private:
150 // Contains print info for all variables
151 std::map<std::string, VariablePrintInfo> allVarsPrintInfo;
152 std::map<unsigned int, std::string> index_to_name;
153
154 // Max columns count a report of any kind can contain, depending on the number of selected
155 // variables. The less variables are selected, the smallest this count is.
156 uint totalMaxColumnsCount_ = 0;
157
158 // Number of selected zonal variables
159 uint numberSelectedAreaVariables = 0;
160 // Number of selected link variables
161 uint numberSelectedLinkVariables = 0;
162};
163
164} // namespace Data
165} // namespace Antares
166
167#endif // __SOLVER_VARIABLE_PRINT_POLICY_H__
Definition variable-print-info.h:97
Definition variable-print-info.h:40
Definition variable-print-info.h:84