Antares Simulator
Power System Simulator
solver_utils.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_SIMULATION_SOLVER_UTILS_H__
22 #define __SOLVER_SIMULATION_SOLVER_UTILS_H__
23 
24 #include <limits> // For std numeric_limits
25 #include <map>
26 #include <vector>
27 
28 #include <antares/study/fwd.h>
29 #include <antares/writer/i_writer.h>
30 
31 namespace Antares::Solver::Simulation
32 {
34 {
35  // Un lot d'année à exécuter en parallèle.
36  // En fonction d'une éventuelle play-list, certaines seront jouées et d'autres non.
37 
38 public:
39  // Numeros des annees en parallele pour ce lot (certaines ne seront pas jouées en cas de
40  // play-list "trouée")
41  std::vector<unsigned int> yearsIndices;
42 
43  // Une annee doit-elle être rejouée ?
44  std::map<uint, bool> yearFailed;
45 
46  // Associe le numero d'une année jouée à l'indice de l'espace
47  std::map<unsigned int, unsigned int> performedYearToSpace;
48 
49  // L'inverse : pour une année jouée, associe l'indice de l'espace au numero de l'année
50  std::map<unsigned int, unsigned int> spaceToPerformedYear;
51 
52  // Pour chaque année, est-elle la première à devoir être jouée dans son lot d'années ?
53  std::map<unsigned int, bool> isFirstPerformedYearOfASet;
54 
55  // Pour chaque année du lot, est-elle jouée ou non ?
56  std::map<unsigned int, bool> isYearPerformed;
57 
58  // Nbre d'années en parallele vraiment jouées pour ce lot
59  unsigned int nbPerformedYears;
60 
61  // Nbre d'années en parallele jouées ou non pour ce lot
62  unsigned int nbYears;
63 };
64 
66 {
67 public:
68  void setNbPerformedYears(uint n);
69  void addCost(const double cost);
70  void endStandardDeviation();
71 
72  // System costs statistics
73  double costAverage = 0.;
74  double costStdDeviation = 0.;
75  double costMin = std::numeric_limits<double>::max();
76  double costMax = 0.;
77 
78 private:
79  // Total number of performed years in the study
80  uint nbPerformedYears = 0.;
81 };
82 
84 {
85 public:
86  // Costs
87  costStatistics systemCost;
88  costStatistics criterionCost1;
89  costStatistics criterionCost2;
90  costStatistics optimizationTime1;
91  costStatistics optimizationTime2;
92  costStatistics updateTime;
93 
95  void setNbPerformedYears(uint n);
96  void endStandardDeviations();
97  void writeToOutput(IResultWriter& writer);
98 
99 private:
100  void writeSystemCostToOutput(IResultWriter& writer);
101  void writeCriterionCostsToOutput(IResultWriter& writer) const;
102  void writeUpdateTimes(IResultWriter& writer) const;
103  void writeOptimizationTimeToOutput(IResultWriter& writer) const;
104 };
105 } // namespace Antares::Solver::Simulation
106 
107 #endif // __SOLVER_SIMULATION_SOLVER_H__
Definition: i_writer.h:32
Definition: solver_utils.h:66