Loading [MathJax]/extensions/tex2jax.js
Antares Simulator
Power System Simulator
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages Concepts
in-memory-study.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#pragma once
22#define WIN32_LEAN_AND_MEAN
23#include "antares/solver/simulation/economy.h"
24#include "antares/solver/simulation/simulation.h"
25#include "antares/study/scenario-builder/rules.h"
26#include "antares/study/scenario-builder/sets.h"
27#include "antares/study/study.h"
28
29using namespace Antares::Solver;
30using namespace Antares::Solver::Simulation;
31using namespace Antares::Data::ScenarioBuilder;
32
33void initializeStudy(Study* study);
34void configureLinkCapacities(AreaLink* link);
35
37{
38public:
39 TimeSeriesConfigurer() = default;
40
42 ts_(&matrix)
43 {
44 }
45
46 TimeSeriesConfigurer& setColumnCount(unsigned int columnCount,
47 unsigned rowCount = HOURS_PER_YEAR);
48 TimeSeriesConfigurer& fillColumnWith(unsigned int column, double value);
49
50private:
51 Matrix<>* ts_ = nullptr;
52};
53
55{
56public:
57 ThermalClusterConfig() = default;
59 ThermalClusterConfig& setNominalCapacity(double nominalCapacity);
60 ThermalClusterConfig& setUnitCount(unsigned int unitCount);
61 ThermalClusterConfig& setCosts(double cost);
62 ThermalClusterConfig& setAvailablePowerNumberOfTS(unsigned int columnCount);
63 ThermalClusterConfig& setAvailablePower(unsigned int column, double value);
64
65private:
66 ThermalCluster* cluster_ = nullptr;
67 TimeSeriesConfigurer tsAvailablePowerConfig_;
68};
69
70std::shared_ptr<ThermalCluster> addClusterToArea(Area* area, const std::string& clusterName);
71void addScratchpadToEachArea(Study& study);
72
73// -------------------------------
74// Simulation results retrieval
75// -------------------------------
77{
78public:
80 averageResults_(averageResults)
81 {
82 }
83
84 double hour(unsigned int hour)
85 {
86 return averageResults_.hourly[hour];
87 }
88
89 double day(unsigned int day)
90 {
91 return averageResults_.daily[day];
92 }
93
94 double week(unsigned int week)
95 {
96 return averageResults_.weekly[week];
97 }
98
99private:
100 Variable::R::AllYears::AverageData& averageResults_;
101};
102
104{
105public:
107 simulation_(simulation)
108 {
109 }
110
111 averageResults overallCost(Area* area);
112 averageResults levelForSTSgroup(Area* area, unsigned int groupNb);
113 averageResults load(Area* area);
114 averageResults hydroStorage(Area* area);
115 averageResults flow(AreaLink* link);
116 averageResults thermalGeneration(ThermalCluster* cluster);
117 averageResults thermalNbUnitsON(ThermalCluster* cluster);
118
119private:
120 template<class VCard>
121 typename Variable::Storage<VCard>::ResultsType* retrieveAreaResults(Area* area);
122
123 template<class VCard>
124 typename Variable::Storage<VCard>::ResultsType* retrieveLinkResults(AreaLink* link);
125
126 template<class VCard>
127 typename Variable::Storage<VCard>::ResultsType* retrieveResultsForThermalCluster(
128 ThermalCluster* cluster);
129
130 ISimulation<Economy>& simulation_;
131};
132
133template<class VCard>
134typename Variable::Storage<VCard>::ResultsType* OutputRetriever::retrieveAreaResults(Area* area)
135{
136 typename Variable::Storage<VCard>::ResultsType* result = nullptr;
137 simulation_.variables.retrieveResultsForArea<VCard>(&result, area);
138 return result;
139}
140
141template<class VCard>
142typename Variable::Storage<VCard>::ResultsType* OutputRetriever::retrieveLinkResults(AreaLink* link)
143{
144 typename Variable::Storage<VCard>::ResultsType* result = nullptr;
145 simulation_.variables.retrieveResultsForLink<VCard>(&result, link);
146 return result;
147}
148
149template<class VCard>
150typename Variable::Storage<VCard>::ResultsType* OutputRetriever::retrieveResultsForThermalCluster(
151 ThermalCluster* cluster)
152{
153 typename Variable::Storage<VCard>::ResultsType* result = nullptr;
154 simulation_.variables.retrieveResultsForThermalCluster<VCard>(&result, cluster);
155 return result;
156}
157
159{
160public:
162
163 loadTSNumberData& load()
164 {
165 return rules_->load;
166 }
167
169 {
170 return rules_->binding_constraints;
171 }
172
173 hydroTSNumberData& hydro()
174 {
175 return rules_->hydro;
176 }
177
178private:
179 Rules::Ptr rules_;
180};
181
182// =====================
183// Simulation handler
184// =====================
185
187{
188public:
189 SimulationHandler(Study& study):
190 study_(study)
191 {
192 }
193
194 ~SimulationHandler() = default;
195 void create();
196
197 void run()
198 {
199 simulation_->run();
200 }
201
202 ISimulation<Economy>& rawSimu()
203 {
204 return *simulation_;
205 }
206
207private:
208 std::shared_ptr<ISimulation<Economy>> simulation_;
209 Benchmarking::DurationCollector durationCollector_;
210 Settings settings_;
211 Study& study_;
212 NullResultWriter resultWriter_;
213 NullSimulationObserver observer_;
214};
215
216// =========================
217// Basic study builder
218// =========================
219
221{
222 StudyBuilder();
223
224 void simulationBetweenDays(const unsigned int firstDay, const unsigned int lastDay);
225 Area* addAreaToStudy(const std::string& areaName);
226 void setNumberMCyears(unsigned int nbYears);
227 void playOnlyYear(unsigned int year);
228 void giveWeightToYear(float weight, unsigned int year);
229
230 // Data members
231 std::unique_ptr<Study> study;
232 std::shared_ptr<SimulationHandler> simulation;
233};
234
235std::shared_ptr<Antares::Data::BindingConstraint> addBindingConstraints(Antares::Data::Study& study,
236 std::string name,
237 std::string group);
Definition for a single area.
Definition area.h:52
Definition BindingConstraintsTSNumbersData.h:32
std::shared_ptr< Rules > Ptr
Smart pointer.
Definition rules.h:55
Definition HydroTSNumberData.h:29
Definition LoadTSNumberData.h:29
Definition study.h:61
A single thermal cluster.
Definition cluster.h:78
A n-by-n matrix.
Definition jit.h:30
Definition i_writer.h:55
The NullSimulationObserver class is a null object for the ISimulationObserver interface.
Definition ISimulationObserver.h:57
Definition DurationCollector.h:36
Definition in-memory-study.h:104
Definition in-memory-study.h:159
Command line settings for launching the simulation.
Definition options.h:37
Definition in-memory-study.h:187
Definition in-memory-study.h:55
Definition in-memory-study.h:37
Definition in-memory-study.h:77
VariableAccessor< typenameVCardT::ResultsType, VCardT::columnCount >::Type ResultsType
The true type used for the results.
Definition info.h:764
Definition in-memory-study.h:221