Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
application.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
23#include <yuni/core/string.h>
24
25#include <antares/benchmarking/DurationCollector.h>
26#include <antares/benchmarking/timer.h>
27#include <antares/study/load-options.h>
28#include <antares/study/study.h>
29#include <antares/writer/i_writer.h>
30#include "antares/infoCollection/StudyInfoCollector.h"
31#include "antares/solver/misc/options.h"
32#include "antares/solver/simulation/ISimulationObserver.h"
33
34namespace Antares::Solver
35{
36class Application final: public Yuni::IEventObserver<Application, Yuni::Policy::SingleThreaded>
37{
38public:
40
41
48 ~Application() override;
50
51 Application(const Application&) = delete;
52
53 Application& operator=(const Application&) = delete;
54
60 void prepare(int argc, const char* argv[]);
61
67 void execute();
68
72 void resetProcessPriority() const;
73
74 void writeExectutionInfo();
75
80 std::unique_ptr<Data::Study> acquireStudy()
81 {
82 return std::move(pStudy);
83 }
84
85private:
89 void resetLogFilename() const;
90
94 void readDataForTheStudy(Antares::Data::StudyLoadOptions& options);
95
96 void onLogMessage(int level, const std::string& message);
97
99 Settings pSettings;
101 std::unique_ptr<Antares::Data::Study> pStudy;
103 Antares::Data::Parameters* pParameters = nullptr;
105 uint pErrorCount = 0;
107 uint pWarningCount = 0;
108
109 int pArgc = 0;
110 const char** pArgv = nullptr;
111
112 // Benchmarking
113 Benchmarking::Timer pTotalTimer;
114 Benchmarking::DurationCollector pDurationCollector;
115 Benchmarking::OptimizationInfo pOptimizationInfo;
116
117 std::shared_ptr<Yuni::Job::QueueService> ioQueueService;
118 IResultWriter::Ptr resultWriter = nullptr;
119
120 void prepareWriter(const Antares::Data::Study& study,
121 Benchmarking::DurationCollector& duration_collector);
122
123 void writeComment(Data::Study& study);
124 void startSimulation(Data::StudyLoadOptions& options);
125 // Return false if the user requested the version ,available solvers, etc, true otherwise
126 bool handleOptions(const Data::StudyLoadOptions& options);
127 // Return false if the user requested help, true otherwise
128 bool parseCommandLine(Data::StudyLoadOptions& options);
129 void handleParserReturn(Yuni::GetOpt::Parser* parser);
130 void postParametersChecks() const;
131
132}; // class Application
133
134} // namespace Antares::Solver
General data for a study.
Definition parameters.h:51
Definition load-options.h:36
Definition study.h:61
Definition application.h:37
Application()
Default Constructor.
Definition application.cpp:57
void resetProcessPriority() const
Reset the process priority (Windows only)
Definition process-priority.cpp:40
void prepare(int argc, const char *argv[])
Initialize data before launching the simulation.
Definition application.cpp:307
~Application() override
Destructor.
Definition application.cpp:494
void execute()
Execute the simulation.
Definition application.cpp:369
std::unique_ptr< Data::Study > acquireStudy()
/!\ Acquire the study. Leave Application object in an invalid state.
Definition application.h:80
Definition DurationCollector.h:36
Definition timer.h:29
Command line settings for launching the simulation.
Definition options.h:37
Definition StudyInfoCollector.h:61