Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
solver.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#ifndef __SOLVER_SIMULATION_SOLVER_H__
22#define __SOLVER_SIMULATION_SOLVER_H__
23
24#include <yuni/job/queue/service.h>
25
26#include <antares/benchmarking/DurationCollector.h>
27#include <antares/logs/logs.h>
28#include <antares/solver/simulation/ISimulationObserver.h>
29#include <antares/study/study.h>
30#include <antares/writer/writer_factory.h>
31#include "antares/solver/hydro/management/management.h"
32#include "antares/solver/misc/options.h"
33#include "antares/solver/simulation/solver.data.h"
34#include "antares/solver/simulation/solver_utils.h"
35#include "antares/solver/variable/state.h"
36
37namespace Antares::Solver::Simulation
38{
39
40template<class Impl>
41class yearJob;
42
43template<class Impl>
44class ISimulation: public Impl
45{
46 friend class yearJob<Impl>;
47
48public:
50
51
55 const ::Settings& settings,
56 Benchmarking::DurationCollector& duration_collector,
57 IResultWriter& resultWriter,
58 Simulation::ISimulationObserver& simulationObserver);
62
63 // Check that the writer is valid
64 void checkWriter() const;
65
69 void run();
70
78 void writeResults(bool synthesis, uint year = 0, uint numSpace = 9999);
79
83 const ::Settings& settings;
84
85private:
89 void regenerateTimeSeries(uint year);
90
96 uint buildSetsOfParallelYears(uint firstYear,
97 uint endYear,
98 std::vector<setOfParallelYears>& setsOfParallelYears);
99
105 void allocateMemoryForRandomNumbers(randomNumbers& randomForParallelYears);
106
113 void computeRandomNumbers(randomNumbers& randomForYears,
114 std::vector<uint>& years,
115 std::map<unsigned int, bool>& isYearPerformed,
116 MersenneTwister& randomHydro);
117
128 void computeAnnualCostsStatistics(std::vector<Variable::State>& state,
129 setOfParallelYears& batch);
130
137 void loopThroughYears(uint firstYear, uint endYear, std::vector<Variable::State>& state);
138
142 uint pNbYearsReallyPerformed;
144 uint pNbMaxPerformedYearsInParallel;
146 bool pYearByYear;
148 bool pFirstSetParallelWithAPerformedYearWasRun;
149
151 annualCostsStatistics pAnnualStatistics;
152
153 // Collecting durations inside the simulation
154 Benchmarking::DurationCollector& pDurationCollector;
155
156public:
158 std::shared_ptr<Yuni::Job::QueueService> pQueueService = nullptr;
161
162 std::reference_wrapper<ISimulationObserver> simulationObserver_;
163}; // class ISimulation
164} // namespace Antares::Solver::Simulation
165
166#include "solver.hxx"
167
168#endif // __SOLVER_SIMULATION_SOLVER_H__
Definition study.h:61
MersenneTwister Pseudo random number generator.
Definition mersenne-twister.h:41
Definition i_writer.h:34
The ISimulationObserver class is an interface for observing the simulation.
Definition ISimulationObserver.h:36
const ::Settings & settings
The global settings.
Definition solver.h:83
void writeResults(bool synthesis, uint year=0, uint numSpace=9999)
Export the results to disk.
Definition solver.hxx:357
Antares::Solver::IResultWriter & pResultWriter
Result writer.
Definition solver.h:160
ISimulation(Data::Study &study, const ::Settings &settings, Benchmarking::DurationCollector &duration_collector, IResultWriter &resultWriter, Simulation::ISimulationObserver &simulationObserver)
Constructor (with a given study)
Definition solver.hxx:222
void run()
Run the simulation.
Definition solver.hxx:270
Data::Study & study
Reference to the current study.
Definition solver.h:81
std::shared_ptr< Yuni::Job::QueueService > pQueueService
The queue service that runs every set of parallel years.
Definition solver.h:158
~ISimulation()
Destructor.
Definition solver.hxx:265
Definition solver_utils.h:193
Definition solver.hxx:43
Definition DurationCollector.h:36