Struct PWLModel

Struct Documentation

struct PWLModel

由测量点构成的分段线性(PWL)延迟模型。

构造时按 ratio 排序并合并重复横坐标。区间内线性插值,区间外沿首段或 末段斜率外推,因此调用方应结合 LibMeta 的边界约束使用。

Public Functions

inline double eval(double r) const

插值或外推 r 对应的延迟。

Throws:

std::runtime_error – 模型无效时抛出。

inline double slopeAt(double r) const

返回 r 所在区间的边际延迟 d(delay)/d(ratio)

Throws:

std::runtime_error – 模型无效时抛出。

Public Members

std::vector<double> xs

升序复用比采样点。

std::vector<double> ys

xs 对应的延迟(ns)。

std::vector<double> slopes

相邻采样点斜率,数量为 xs.size()-1

bool valid = false

模型是否至少含两个不同的横坐标。

Public Static Functions

static inline PWLModel fromPoints(std::vector<double> x, std::vector<double> y)

从无序采样点构造 PWL 模型。

Returns:

点数不足或横纵坐标数量不同时返回无效模型。