LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
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
22
#include "
line/lang/lang_types.h
"
23
24
namespace
line
{
25
namespace
infer
{
26
27
enum class
SampledFormat
{
TIMESERIES
,
TRACE
};
28
29
struct
ConditionEvent
{
30
std::size_t
node
= 0;
31
std::size_t
jobclass
= 0;
32
lang::EventType
event
=
lang::EventType::INIT
;
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
44
class
SampledMetric
{
45
public
:
46
lang::MetricType
type
;
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
;
52
SampledFormat
format
;
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),
62
format
(
SampledFormat
::
TIMESERIES
) {}
63
64
void
set_conditional
(
const
ConditionEvent
& event) {
cond
= event; }
65
void
set_trace
() {
format
=
SampledFormat::TRACE
; }
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
line::infer::SampledMetric::is_trace
bool is_trace() const
Definition
sampled_metric.h:69
line::infer::SampledMetric::format
SampledFormat format
Definition
sampled_metric.h:52
line::infer::SampledMetric::jobclass
std::size_t jobclass
Definition
sampled_metric.h:50
line::infer::SampledMetric::data
std::vector< double > data
Definition
sampled_metric.h:48
line::infer::SampledMetric::type
lang::MetricType type
Definition
sampled_metric.h:46
line::infer::SampledMetric::set_trace
void set_trace()
Definition
sampled_metric.h:65
line::infer::SampledMetric::copy
SampledMetric copy() const
Definition
sampled_metric.h:71
line::infer::SampledMetric::is_aggregate
bool is_aggregate() const
Definition
sampled_metric.h:67
line::infer::SampledMetric::SampledMetric
SampledMetric(lang::MetricType metric_type, const std::vector< double > ×, const std::vector< double > &observations, std::size_t node_index, std::size_t class_index=0)
Definition
sampled_metric.h:54
line::infer::SampledMetric::is_conditional
bool is_conditional() const
Definition
sampled_metric.h:68
line::infer::SampledMetric::t
std::vector< double > t
Definition
sampled_metric.h:47
line::infer::SampledMetric::node
std::size_t node
Definition
sampled_metric.h:49
line::infer::SampledMetric::cond
std::optional< ConditionEvent > cond
Definition
sampled_metric.h:51
line::infer::SampledMetric::set_conditional
void set_conditional(const ConditionEvent &event)
Definition
sampled_metric.h:64
lang_types.h
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
line::infer
Definition
infer_compute_ql_at_arrival.h:39
line::infer::SampledFormat
SampledFormat
Definition
sampled_metric.h:27
line::infer::SampledFormat::TRACE
@ TRACE
Definition
sampled_metric.h:27
line::infer::SampledFormat::TIMESERIES
@ TIMESERIES
Definition
sampled_metric.h:27
line::lang::EventType
EventType
The events a state can undergo, with the values of MATLAB EventType.
Definition
lang_types.h:111
line::lang::EventType::INIT
@ INIT
the model is initialized, t = 0
Definition
lang_types.h:112
line::lang::MetricType
MetricType
Solver output metrics, with the numeric values of MATLAB MetricType.
Definition
lang_types.h:46
line
Definition
aoi_dist2ph.h:52
line::infer::ConditionEvent
Definition
sampled_metric.h:29
line::infer::ConditionEvent::ConditionEvent
ConditionEvent(std::size_t node_index, std::size_t class_index, lang::EventType event_type)
Definition
sampled_metric.h:35
line::infer::ConditionEvent::node
std::size_t node
Definition
sampled_metric.h:30
line::infer::ConditionEvent::operator==
bool operator==(const ConditionEvent &other) const
Definition
sampled_metric.h:38
line::infer::ConditionEvent::ConditionEvent
ConditionEvent()=default
line::infer::ConditionEvent::event
lang::EventType event
Definition
sampled_metric.h:32
line::infer::ConditionEvent::jobclass
std::size_t jobclass
Definition
sampled_metric.h:31
line::infer::ConditionEvent::operator!=
bool operator!=(const ConditionEvent &other) const
Definition
sampled_metric.h:41
include
line
inference
sampled_metric.h
Generated by
1.18.0