2121
2222#include < chrono>
2323#include < memory>
24+ #include < variant>
25+ #include < type_traits>
2426
2527
2628void run_subcommand::setup_options (
@@ -72,6 +74,12 @@ void run_subcommand::setup_options(
7274namespace
7375{
7476
77+ template <class ... Ts>
78+ struct overloaded : Ts... { using Ts::operator ()...; };
79+
80+ template <class ... Ts>
81+ overloaded (Ts...) -> overloaded<Ts...>;
82+
7583cosim::execution load_system_structure (
7684 const cosim::filesystem::path& path,
7785 cosim::model_uri_resolver& uriResolver,
@@ -82,9 +90,19 @@ cosim::execution load_system_structure(
8290 (cosim::filesystem::is_directory (path) &&
8391 cosim::filesystem::exists (path / " OspSystemStructure.xml" ))) {
8492 const auto config = cosim::load_osp_config (path, uriResolver);
85- auto execution = cosim::execution (
86- startTime,
87- std::make_shared<cosim::fixed_step_algorithm>(config.step_size , workerThreadCount));
93+ std::shared_ptr<cosim::algorithm> algorithm;
94+
95+ std::visit (
96+ overloaded{
97+ [&algorithm, &workerThreadCount](const cosim::fixed_step_algorithm_params& params) {
98+ algorithm = std::make_shared<cosim::fixed_step_algorithm>(params, workerThreadCount);
99+ },
100+ [&algorithm, &workerThreadCount](const cosim::ecco_algorithm_params& params) {
101+ algorithm = std::make_shared<cosim::ecco_algorithm>(params, workerThreadCount);
102+ }},
103+ config.algorithm_configuration );
104+
105+ auto execution = cosim::execution (startTime, algorithm);
88106 cosim::inject_system_structure (
89107 execution,
90108 config.system_structure ,
@@ -154,6 +172,7 @@ class progress_monitor : public cosim::observer
154172 : logger_(startTime, duration, percentIncrement, mrProgressResolution)
155173 {}
156174
175+
157176private:
158177 void simulator_added (cosim::simulator_index, cosim::observable*, cosim::time_point) override {}
159178 void simulator_removed (cosim::simulator_index, cosim::time_point) override {}
@@ -184,6 +203,8 @@ class progress_monitor : public cosim::observer
184203 override
185204 {}
186205
206+ void state_restored (cosim::step_number, cosim::time_point) override {}
207+
187208 progress_logger logger_;
188209};
189210} // namespace
0 commit comments