Health-GPS 3.0.0.0
Global Health Policy Simulation model (Health-GPS)
Loading...
Searching...
No Matches
runner.h
Go to the documentation of this file.
1#pragma once
2#include "event_aggregator.h"
3#include "simulation.h"
4
5#include <atomic>
6#include <exception>
7#include <functional>
8#include <memory>
9#include <stop_token>
10
11namespace hgps {
12
25class Runner {
26 public:
27 Runner() = delete;
28
32 Runner(std::shared_ptr<EventAggregator> bus,
33 std::unique_ptr<RandomBitGenerator> seed_generator) noexcept;
34
41 double run(Simulation &baseline, const unsigned int trial_runs);
42
50 double run(Simulation &baseline, Simulation &intervention, const unsigned int trial_runs);
51
54 bool is_running() const noexcept;
55
57 void cancel() noexcept;
58
59 private:
60 std::atomic<bool> running_;
61 std::shared_ptr<EventAggregator> event_bus_;
62 std::unique_ptr<RandomBitGenerator> seed_generator_;
63 std::stop_source source_;
64 std::string runner_id_{};
65
66 void run_model_thread(const std::stop_token &token, Simulation &model, unsigned int run,
67 unsigned int seed, std::exception_ptr &error);
68
69 void notify(std::unique_ptr<hgps::EventMessage> message);
70};
71
72} // namespace hgps
Defines the event aggregator interface type.
Definition event_aggregator.h:59
Pseudo-random number generator algorithm interface.
Definition randombit_generator.h:9
void cancel() noexcept
Cancel a running experiment.
Definition runner.cpp:149
bool is_running() const noexcept
Gets a value indicating whether an experiment is current running.
Definition runner.cpp:147
double run(Simulation &baseline, const unsigned int trial_runs)
Run an experiment for baseline scenario only.
Definition runner.cpp:47
Runner()=delete
Defines the simulation engine data type class.
Definition simulation.h:24
Top-level namespace for Health-GPS Console host application.
Definition command_options.cpp:9
@ error
General error reporting message.
Definition event_message.h:25
@ baseline
Baseline scenario.
Definition scenario.h:19
@ intervention
Intervention scenario.
Definition scenario.h:22
Global namespace.
Definition column_iterator.h:123