Antares Simulator
Power System Simulator
random.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 
22 #pragma once
23 
24 #include <map>
25 #include <vector>
26 
27 #include <antares/mersenne-twister/mersenne-twister.h>
28 #include <antares/study/study.h>
29 
30 namespace Antares::Solver::Simulation
31 {
33 {
34 public:
36  ~yearRandomNumbers() = default;
37 
38  void setNbAreas(uint nbAreas);
39  void setPowerFluctuations(Data::PowerFluctuations powerFluctuations);
40  void reset();
41 
42  // General data
43  uint pNbAreas;
44  Data::PowerFluctuations pPowerFluctuations;
45 
46  // Data for thermal noises
47  std::vector<std::vector<double>> pThermalNoisesByArea;
48  std::vector<size_t> pNbClustersByArea;
49 
50  // Data for reservoir levels
51  std::vector<double> pReservoirLevels;
52 
53  // Data for unsupplied and spilled energy costs
54  std::vector<double> pUnsuppliedEnergy;
55  std::vector<double> pSpilledEnergy;
56 
57  // Hydro costs noises
58  std::vector<std::vector<double>> pHydroCostsByArea_freeMod;
59  std::vector<double> pHydroCosts_rampingOrExcursion;
60 };
61 
63 {
64 public:
65  randomNumbers(uint maxNbPerformedYearsInAset, Data::PowerFluctuations powerFluctuations);
66  ~randomNumbers() = default;
67 
68  void allocate(const Antares::Data::Study& study);
69  void compute(Antares::Data::Study& study,
70  unsigned years,
71  std::map<unsigned int, bool>& isYearPerformed,
72  MersenneTwister& randomHydro);
73  void reset();
74 
75  std::vector<yearRandomNumbers> pYears;
76 
77  // Associates :
78  // year number (0, ..., total nb of years to compute - 1) --> index of the year's space
79  //(0,
80  //..., max nb of parallel years - 1)
81  std::map<uint, uint> yearNumberToIndex;
82 
83 private:
84  uint pMaxNbPerformedYears;
85 };
86 } // namespace Antares::Solver::Simulation
Definition: study.h:57
MersenneTwister Pseudo random number generator.
Definition: mersenne-twister.h:41