Antares Simulator
Power System Simulator
LpsFromAntares.h
1 
2 /*
3  * Copyright 2007-2025, RTE (https://www.rte-france.com)
4  * See AUTHORS.txt
5  * SPDX-License-Identifier: MPL-2.0
6  * This file is part of Antares-Simulator,
7  * Adequacy and Performance assessment for interconnected energy networks.
8  *
9  * Antares_Simulator is free software: you can redistribute it and/or modify
10  * it under the terms of the Mozilla Public Licence 2.0 as published by
11  * the Mozilla Foundation, either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Antares_Simulator is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * Mozilla Public Licence 2.0 for more details.
18  *
19  * You should have received a copy of the Mozilla Public Licence 2.0
20  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
21  */
22 
23 #pragma once
24 #include <array>
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 namespace Antares::Solver
30 {
31 
37 {
38  unsigned int year = 0;
39  unsigned int week = 0;
40  // Order of comparison is order of member declaration
41  auto operator<=>(const WeeklyProblemId& other) const = default;
42 };
43 
44 // Type de données inutile car les matrices de tous les pbs Weekly sont
45 // identiques. Cela pourra changer à l'avenir si des coefficients de contraintes
46 // couplantes peuvent varier au cours du temps (ex: rendement d'une pompe à
47 // chaleur qui varie selon la température, FlowBased ?, etc)
54 {
55  unsigned VariablesCount = 0; // Mathématiquement : Nb colonnes de la matrice,
56  // Informatiquement = TypeDeVariable.size()
57  unsigned ConstraintesCount = 0; // Mathématiqument : Nb lignes de la matrice,
58  // Informatiquement = Mdeb.size()
59  unsigned CoeffCount = 0; // Mathématiquement : Nb coeffs non nuls de la
60  // matrice, Informatiquement = Nbterm.size() =
61  // IndicesColonnes.size()=
62  // CoefficientsDeLaMatriceDesContraintes.size()
63 
64  std::vector<unsigned> Mdeb; // Indique dans les indices dans le vecteur IndicesColonnes qui
65  // correspondent au début de chaque ligne. Ex : Mdeb[3] = 8 et
66  // Mdeb[4] = 13 -> Les termes IndicesColonnes[8] à
67  // IndicesColonnes[12] correspondent à des Id de colonnes de la
68  // ligne 3 de la matrice (en supposant que les lignes sont indexées
69  // à partir de 0)
70  std::vector<unsigned> ColumnIndexes; // Id des colonnes des termes de
71  // CoefficientsDeLaMatriceDesContraintes : Ex
72  // IndicesColonnes[3] = 8 ->
73  // CoefficientsDeLaMatriceDesContraintes[8] donne la
74  // valeur du terme de la colonne 8, et de la ligne i où
75  // i est tel que Mdeb[i] <= 3 < Mdeb[i+1]
76  std::vector<double> ConstraintsMatrixCoeff; // Coefficients de la matrice
77 
78  std::vector<std::string> VariablesMeaning;
79  std::vector<std::string> ConstraintsMeaning;
80 
81  auto operator<=>(const ConstantDataFromAntares& other) const = default;
82 };
83 
89 {
90  std::vector<char> Direction; // Sens de la contrainte : < ou > ou =, taille =
91  // NombreDeContraintes
92  std::vector<double> Xmax; // Borne max des variables de la semaine
93  // considérée, taille = NombreDeVariables
94  std::vector<double> Xmin; // Borne min des variables de la semaine
95  // considérée, taille = NombreDeVariables
96  std::vector<double> LinearCost; // Coefficients du vecteur de coût de la fonction objectif,
97  // taille = NombreDeVariables
98  std::vector<double> RHS; // Vecteur des second membre des contraintes, taille =
99  // NombreDeContraintes
100  std::string name;
101 
102  auto operator<=>(const WeeklyDataFromAntares& other) const = default;
103 };
104 
105 using WeeklyDataByYearWeek = std::map<WeeklyProblemId, WeeklyDataFromAntares>;
106 
112 class LpsFromAntares final
113 {
114 public:
115  /*
116  * @brief Checks if the LpsFromAntares object is empty.
117  * Emptiness is defined by either the constant data or the weekly data being empty.
118  */
119  [[nodiscard]] bool empty() const;
120  /*
121  * @brief Replaces the constant data in the LpsFromAntares object.
122  * Copy happens
123  */
124  void setConstantData(const ConstantDataFromAntares& data);
125  /*
126  * @brief Adds weekly data to the LpsFromAntares object.
127  */
128  void addWeeklyData(WeeklyProblemId id, WeeklyDataFromAntares&& data);
129  /*
130  * @brief Retrieves weekly data from the LpsFromAntares object.
131  */
132  [[nodiscard]] const WeeklyDataFromAntares& weeklyData(WeeklyProblemId id) const;
133  /*
134  * @brief Retrieves the number of weeks in the LpsFromAntares object.
135  */
136  [[nodiscard]] size_t weekCount() const noexcept;
137 
138  ConstantDataFromAntares constantProblemData;
139  WeeklyDataByYearWeek weeklyProblems;
140 };
141 
142 } // namespace Antares::Solver
The LpsFromAntares class is used to manage the constant and weekly data for Antares problems.
Definition: LpsFromAntares.h:113
The ConstantDataFromAntares class is used to store constant data across all weeks of Antares problems...
Definition: LpsFromAntares.h:54
The WeeklyDataFromAntares class is used to store weekly data for an Antares Problem.
Definition: LpsFromAntares.h:89
The WeeklyProblemId struct is used to identify a weekly problem by year and week.
Definition: LpsFromAntares.h:37