LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sampled_metric.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_INFERENCE_SAMPLED_METRIC_H
6#define LINE_INFERENCE_SAMPLED_METRIC_H
7
8/**
9 * @file
10 * @ingroup line_inference
11 * Observed metric data supplied to parameter estimators.
12 *
13 * Port of MATLAB `SampledMetric`, with the JAR's explicit format and condition
14 * types. Nodes and classes use the C++ model builder's 1-based indices; class
15 * zero is the aggregate sentinel corresponding to an empty MATLAB class.
16 */
17
18#include <cstddef>
19#include <optional>
20#include <vector>
21
23
24namespace line {
25namespace infer {
26
28
30 std::size_t node = 0;
31 std::size_t jobclass = 0;
33
34 ConditionEvent() = default;
35 ConditionEvent(std::size_t node_index, std::size_t class_index, lang::EventType event_type)
36 : node(node_index), jobclass(class_index), event(event_type) {}
37
38 bool operator==(const ConditionEvent& other) const {
39 return node == other.node && jobclass == other.jobclass && event == other.event;
40 }
41 bool operator!=(const ConditionEvent& other) const { return !(*this == other); }
42};
43
45 public:
47 std::vector<double> t;
48 std::vector<double> data;
49 std::size_t node;
50 std::size_t jobclass;
51 std::optional<ConditionEvent> cond;
53
54 SampledMetric(lang::MetricType metric_type, const std::vector<double>& times,
55 const std::vector<double>& observations, std::size_t node_index,
56 std::size_t class_index = 0)
57 : type(metric_type),
58 t(times),
59 data(observations),
60 node(node_index),
61 jobclass(class_index),
63
64 void set_conditional(const ConditionEvent& event) { cond = event; }
66
67 bool is_aggregate() const { return jobclass == 0; }
68 bool is_conditional() const { return cond.has_value(); }
69 bool is_trace() const { return format == SampledFormat::TRACE; }
70
71 SampledMetric copy() const { return *this; }
72};
73
74} // namespace infer
75} // namespace line
76
77#endif // LINE_INFERENCE_SAMPLED_METRIC_H
std::vector< double > data
SampledMetric copy() const
SampledMetric(lang::MetricType metric_type, const std::vector< double > &times, const std::vector< double > &observations, std::size_t node_index, std::size_t class_index=0)
std::vector< double > t
std::optional< ConditionEvent > cond
void set_conditional(const ConditionEvent &event)
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
EventType
The events a state can undergo, with the values of MATLAB EventType.
Definition lang_types.h:111
@ INIT
the model is initialized, t = 0
Definition lang_types.h:112
MetricType
Solver output metrics, with the numeric values of MATLAB MetricType.
Definition lang_types.h:46
ConditionEvent(std::size_t node_index, std::size_t class_index, lang::EventType event_type)
bool operator==(const ConditionEvent &other) const
bool operator!=(const ConditionEvent &other) const