Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
IModel.h
Go to the documentation of this file.
1#ifndef IMODEL_H
2#define IMODEL_H
3
4#include <cstddef>
5#include <vector>
6#include <map>
7#include <memory>
8
9#include "Include.h"
10#include "ObservableValue.h"
11
12using Vec = std::vector<double>;
13
38public:
39 virtual ~IModelThreadGuard() = default;
40};
41
42class IModel {
43public:
45 virtual ~IModel() = default;
46
52 virtual std::shared_ptr<IModel> clone_for_worker() const { return nullptr; }
53
57 virtual bool can_clone_for_worker() const { return false; }
58
65 virtual std::unique_ptr<IModelThreadGuard> force_decay_threads(size_t) { return nullptr; }
66
76 virtual void prepare_for_prediction() {}
77
86 virtual std::map<ObservableId, std::vector<ObservableValue>> predict_optimized(const std::map<ParamId, double>& p, const std::map<ParamId, double>& eta) = 0;
87
93 virtual std::size_t n_observables() const = 0;
94
102 virtual std::unordered_set<ParamId> get_obs_deps(ObservableId id) = 0;
103
109 virtual std::vector<BinnedObservableId> get_obs_ids() = 0;
110
117 virtual void compute_observables() const = 0;
118};
119
120#endif
virtual ~IModelThreadGuard()=default
Interface for a model capable of producing observable predictions.
Definition IModel.h:42
virtual void prepare_for_prediction()
Materialize model-side runtime state before repeated predictions.
Definition IModel.h:76
virtual std::unordered_set< ParamId > get_obs_deps(ObservableId id)=0
Returns the model parameters required by an observable.
virtual std::unique_ptr< IModelThreadGuard > force_decay_threads(size_t)
Temporarily force internal model/decay thread counts.
Definition IModel.h:65
virtual std::size_t n_observables() const =0
Returns the number of currently active binned observables.
virtual std::shared_ptr< IModel > clone_for_worker() const
Returns an isolated model instance suitable for one worker thread.
Definition IModel.h:52
virtual std::map< ObservableId, std::vector< ObservableValue > > predict_optimized(const std::map< ParamId, double > &p, const std::map< ParamId, double > &eta)=0
Computes model predictions for a given parameter point.
virtual ~IModel()=default
Default virtual destructor.
virtual bool can_clone_for_worker() const
Whether clone_for_worker is implemented.
Definition IModel.h:57
virtual void compute_observables() const =0
Forces computation of the currently configured observables.
virtual std::vector< BinnedObservableId > get_obs_ids()=0
Returns the identifiers of the currently active observable bins.
std::vector< double > Vec