api.infer
- sn_set_service_coc(sn, stationIdx, classIdx, rate, scv)
SN_SET_SERVICE_COC Update service rate preserving cell-of-cells format.
Works like sn_set_service with autoRefresh=true, but writes mu, phi, proc, pie using cell-of-cells indexing (sn.mu{i}{k}) instead of 2D cell indexing (sn.mu{i,k}). This avoids reshaping the cell arrays, which would break solvers that expect cell-of-cells format.
- Inputs:
sn - NetworkStruct stationIdx - station index (1-based) classIdx - class index (1-based) rate - new service rate (positive scalar) scv - squared coefficient of variation (default 1.0)
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.
- mexify_infer
@brief MATLAB Coder script to generate MEX functions for infer_ module.
This script generates MEX (MATLAB Executable) versions of demand- inference functions for improved performance.
- Skipped functions (Coder-incompatible):
- infer_get_qlen_arrival - Cell-array data argument with ragged
per-class samples.
- infer_gibbs - Cell-array data argument and use of
exist() for default-arg detection.
- infer_rps - Calls lsqnonneg() (Optimization
Toolbox), not supported by Coder.
infer_mlps, infer_minps, infer_minps_setup, infer_fmlps - Take a Network model OOP object and
call its method getNumberOfServers().
- infer_quick_model - Construct Network/Source/Queue/JobClass
OOP objects.
- infer_fluid_ps_rt_likelihood - Returns a function handle (ode_h) and
consumes the sn struct.
- sn_set_service_coc - Uses ProcessType enum, cell-of-cells
fields of the sn struct.
See also
CODER,CODER.CONFIG,CODER.TYPEOF,CODEGEN.
- infer_variational(spec, options)
OUT = INFER_VARIATIONAL(SPEC, OPTIONS)
Variational inference for Markovian queueing networks, following I. Perez, G. Casale, “Variational Inference for Markovian Queueing Networks”, Advances in Applied Probability 53(3), 2021.
The network trajectory is reparameterised by the transition counts Y^eta, eta=(i,j,c), so that the station marginals decouple:
- x_{i,c}(t) = x_{i,c}(0) + sum_{eta in In(i,c)} Y^eta(t)
sum_{eta in Out(i,c)} Y^eta(t)
The variational family is a product of inhomogeneous pure-birth processes, one per transition, with rate nu^eta(t,y), times a product of Gamma densities over the unknown service rates. The state space is expanded by adding DELTA to every feasible rate, so that queue lengths may go negative and the approximating measure stays mutually absolutely continuous with the target (Sec. 3 of the paper); the original model is recovered as DELTA -> 0.
Each iteration performs, per transition, a backward pass for the Lagrange multipliers r^eta (Eq. 14) with multiplicative jumps at the observation epochs, the rate update
nu^eta(t,y) = exp(E log Xi^eta(t,y)) r^eta(t,y+1)/r^eta(t,y),
and a forward pass of the master equation for the marginal. The conjugate Gamma posteriors are then refreshed from the expected number of firings and the expected exposure time of each station-class pair.
Expectations over the other transitions are taken on a deterministic Halton lattice mapped through the inverse marginal c.d.f., so the estimator carries no random-number stream and is reproducible across the MATLAB, Java, Python and C++ implementations.
SPEC fields (plain arrays; (m,r) pairs are flattened column-major, so that pair (m,r) sits at index (r-1)*M+m):
arcs (T x 3) [i j c] transitions; i=0 external source, j=0 sink x0 (M x R) initial queue lengths sched (M x 1) 0=INF, 1=shared server (PS/FCFS), 2=external nservers (M x 1) number of servers routeprob (T x 1) routing probability p^c_{i,j} of each transition arcparam (T x 1) index in 1..P of the rate governing the arc, 0 if known arcrate (T x 1) known rate for arcs with arcparam==0, NaN otherwise alpha0 (P x 1) Gamma prior shapes beta0 (P x 1) Gamma prior rates obsTimes (K x 1) observation epochs obsData (K x M*R) observed queue lengths, NaN where not observed obsRange (M x R) support size of the uniform contamination epsilon scalar probability that a reading is faulty capacity (M x R) optional upper bound on the queue length, Inf by
default. In a closed network this is the chain population, and clamping the load there keeps the expanded state space from crediting a station with more jobs than the network holds
OPTIONS fields: tmax, dt, ngrid, ymax, nsamples, iter_max, tol, delta, floor, rate_max, verbose.
OUT fields: alpha, beta, rates (posterior mean rates), meanServiceTime, bound (ELBO per iteration), Y (T x G x ymax+1 marginals), nu, tgrid, qlen (G x M*R expected queue lengths), iter, converged, tailmass.
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.
- infer_smp_nelson_aalen(from, to, dur, varargin)
NA = INFER_SMP_NELSON_AALEN(FROM, TO, DUR, …)
Nelson-Aalen estimate of the cumulative transition intensity A~_ij(t) = int_0^t a~_ij(s) ds of every observed transition, on the clock reset at each jump, from the sojourn data of INFER_SMP (TO = 0 for a censored sojourn). The risk set at t of transition i->j is the number of sojourns in i of duration at least t, so this is the nonparametric benchmark of the ‘intensity’ approach (Asanjarani et al., Sec. 4).
OPTION ‘nstates’ sets E (default max(FROM, TO)).
- NA is a struct array, one entry per observed transition, with fields
from, to the transition time the distinct event times of i->j, ascending A the estimate at those times (a right-continuous step function) var its Greenwood-type variance sum d/Y^2
See also
INFER_SMP,INFER_SMP_HAZARD.
- infer_smp_hazard(fit, t, varargin)
HZ = INFER_SMP_HAZARD(FIT, T, …)
Both hazard functions of every transition of an INFER_SMP fit, on the instants T > 0, whichever approach produced it (Asanjarani et al., Eqs. 11-15):
- intensity a~_ij(t), the transition intensity, i.e. the rate of
jumping to j at t given that the sojourn in i has lasted t
- sojourn alpha_ij(t) = f_ij(t) / S_ij(t), the hazard of the
conditional sojourn law F_ij of a sojourn that ends in j
cumulative A~_ij(t) = int_0^t a~_ij(s) ds cif CIF_ij(t) = P(sojourn <= t, next state j)
They are related by a~_ij(t) = p_ij f_ij(t) / S_i(t), with S_i the holding time survival of state i. An ‘intensity’ fit carries a~ (the hazard of the fitted clock) and A~ in closed form and obtains the CIF by the quadrature of SMP_STAGE_CIF; alpha_ij then follows as a~_ij S_i / (p_ij - CIF_ij). A ‘sojourn’ fit carries alpha (the hazard of the fitted F_ij) and the CIF in closed form; a~ follows from the relation above, and A~ is a midpoint sum on the grid [0, logspace(log10(T_max)-8, log10(T_max), 2001)] joined with linspace(0, T_max, 20001) and T, which resolves an integrable singularity at 0.
OPTION ‘z’ (p x 1, default 0) evaluates the proportional-hazards factors.
HZ is a struct array aligned with FIT.arcs, with fields from, to, intensity, sojourn, cumulative, cif (rows aligned with T).
See also
INFER_SMP,SMP_STAGE_CIF.
- infer_smp_family(family, mode, varargin)
VARARGOUT = INFER_SMP_FAMILY(FAMILY, MODE, …)
The parametric families INFER_SMP fits, in one place so that the estimator, the hazard conversions and the Environment builder read one parameterization. Every family is fitted in UNCONSTRAINED coordinates THETA:
‘exp’ THETA = log(rate) Exp(rate) ‘weibull’ THETA = [log(shape), log(scale)] Weibull(shape, scale) ‘gamma’ THETA = [log(shape), log(scale)] Gamma(shape, scale) ‘lognormal’ THETA = [mu, log(sigma)] Lognormal(mu, sigma)
- Modes:
N = INFER_SMP_FAMILY(F, ‘npar’) number of parameters [LOGF, LOGS] = INFER_SMP_FAMILY(F, ‘logfs’, THETA, T, ETA)
log density and log survival at T under the proportional-hazards factor exp(ETA) (ETA a scalar or one per instant, 0 for the baseline): H(t) = H0(t) exp(ETA), log h = log h0 + ETA, log f = log h - H. The survival of ‘gamma’ and ‘lognormal’ is floored at 1e-300 before the log, so a censored time far in the tail costs a large finite penalty.
P = INFER_SMP_FAMILY(F, ‘natural’, THETA) natural parameters THETA = INFER_SMP_FAMILY(F, ‘theta0’, TEV, TEXP)
starting point from the event times TEV and the total exposure TEXP
- D = INFER_SMP_FAMILY(F, ‘dist’, THETA, ETA)
the LINE distribution of the law with hazard h0(t) exp(ETA). Only ‘exp’ and ‘weibull’ are closed under a proportional-hazards factor; the other two are refused for ETA ~= 0.
See also
INFER_SMP.
- infer_smp_env(fit, models, varargin)
ENV = INFER_SMP_ENV(FIT, MODELS, …)
The Environment of a semi-Markov fit returned by INFER_SMP, with MODELS{e} the Network of stage e (E networks with the same stateful nodes). An ‘intensity’ fit becomes competing arcs (addTransition), each the fitted latent clock of its transition; a ‘sojourn’ fit becomes kernel arcs (addKernelTransition) with the fitted embedded probability and conditional sojourn law. Either is solved by SolverENV method ‘smp’.
- OPTIONS (name/value):
‘name’ environment name (default ‘SMPFit’) ‘names’ 1 x E cell of stage names (default ‘S1’..’SE’) ‘types’ 1 x E cell of stage types (default ‘stage’), e.g. ‘UP’/’DOWN’ for
Environment.getReliabilityTable
- ‘z’ a covariate vector (p x 1) at which to evaluate the
proportional-hazards factors (default 0, the baseline). Only ‘exp’ and ‘weibull’ arcs stay in their family under a factor, so a ‘gamma’ or ‘lognormal’ arc with a covariate effect is refused for z ~= 0.
See also
INFER_SMP,ENVIRONMENT,SOLVERENV.
- infer_smp(from, to, dur, varargin)
FIT = INFER_SMP(FROM, TO, DUR, …)
Maximum-likelihood fit of a fully parametric semi-Markov multi-state model to right-censored sojourn data, under either of the two parameterizations of Asanjarani, Liquet and Nazarathy.
DATA. One row per observed sojourn: the process entered state FROM(k), stayed DUR(k) > 0, and then moved to state TO(k), or was still in FROM(k) when observation stopped, coded TO(k) = 0 (right censoring). States are 1..E. Subjects enter only through their rows, so a history J0 -> J1 -> … -> JN with sojourns tau_1..tau_N and censoring time U contributes the rows (J0,J1,tau_1), …, (J_{N-1},J_N,tau_N) and, unless J_N is absorbing, (J_N, 0, U).
- OPTIONS (name/value):
- ‘approach’ ‘intensity’ (default) fits the transition intensity functions
a~_ij(t) (Approach II): each transition i->j is a latent clock with its own law and the likelihood splits into one two-state censored-data likelihood per transition (Eqs. 30-31), every sojourn out of i that did not end in j counting as censored for i->j. ‘sojourn’ fits Approach I: the embedded chain p_ij and the law F_ij of a sojourn that ends in j, with likelihood (27); a censored sojourn in i contributes S_i(U) = sum_j p_ij S_ij(U), which couples the parameters of a state, so a state with censored rows is fitted jointly (p by a softmax) and one without in closed form for p.
- ‘dist’ family of every transition, ‘weibull’ (default), ‘exp’,
‘gamma’ or ‘lognormal’; or an E x E cell of family names to choose per transition (empty entries take ‘weibull’).
- ‘covariates’ n x p matrix Z of subject covariates, entering as a
proportional-hazards factor exp(beta_ij’ z) on a~_ij (Eq. 33) or on the sojourn hazard alpha_ij (Eq. 32).
- ‘covmask’ E x E x p logical array selecting which covariates enter each
transition (default: all), the “+Select” models of Sec. 4.
‘nstates’ E (default max(FROM, TO)). ‘tolx’, ‘tolf’, ‘maxiter’ Nelder-Mead tolerances (1e-9, 1e-12, 2000 per
parameter).
- FIT is a struct with fields
approach, nstates, ncov arcs struct array, one per fitted transition, with fields from, to,
family, theta (unconstrained), params (natural: rate | shape, scale | mu, sigma), beta, se (of [theta; beta]), prob (Approach I: p_ij; Approach II: the embedded probability at z = 0), nevents
loglik, nparams, aic P E x E embedded jump chain at z = 0
INFER_SMP_ENV turns a fit into an Environment, INFER_SMP_HAZARD evaluates both hazard functions of either fit, and INFER_SMP_NELSON_AALEN is the nonparametric benchmark of Sec. 4.
The maximizer is a deterministic Nelder-Mead (the Lagarias et al. variant of fminsearch, restarted from its own optimum until it stops improving), the same in all four codebases; an exponential transition without covariates has its closed-form MLE. Standard errors are from the central-difference Hessian of the negative log-likelihood in the THETA coordinates, NaN when it is not positive definite.
Reference: A. Asanjarani, B. Liquet, Y. Nazarathy, Estimation of semi-Markov multi-state models: a comparison of the sojourn times and transition intensities approaches, arXiv:2005.14462 (2020).
See also
INFER_SMP_ENV,INFER_SMP_HAZARD,INFER_SMP_NELSON_AALEN.
- infer_rps(rt, class, ql, V)
INFER_RPS Regression for Processor Sharing (RPS) demand estimation
RT: response time samples (column vector with all samples) CLASS: class of each request sample (column vector) QL: queue length samples (matrix with R columns containing the
number of jobs of each class observed by each sample)
V: number of cores/servers
Based on mean-value analysis for PS stations. For a single server:
E[R_r] = E[D_r] * E[Q_bar_A]
where Q_bar_A is the total number of jobs seen upon admission, including the arriving job itself. For V > 1 processors, the queue length is split equally among the servers:
E[R_r] = E[D_r] * E[Q_bar_A] / V
The demand E[D_r] is estimated via non-negative least squares regression of response times against Q_bar_A / V.
Note: RPS assumes equal splitting among all V servers, which can lead to overestimation under low loads when fewer than V servers are actually busy. ERPS improves on this by using the mean number of busy servers instead of V.
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_quick_model(open, stations, classes, servers, jobs, routing)
QUICKMODEL Generate simple closed queueing network based on given parameters
- infer_qmle(Q, N, Z)
- infer_nhpp_ks(times, T, varargin)
INFER_NHPP_KS KS test for a non-homogeneous Poisson arrival process.
RESULT = INFER_NHPP_KS(TIMES, T) tests whether the arrival times TIMES in [0,T] came from an NHPP.
THE CONDITIONAL-UNIFORM TRANSFORMATION. Conditional on the number of arrivals in the interval, the arrival times of an NHPP are distributed as the order statistics of iid variables with cdf Lambda(t)/Lambda(T). Mapping the data through that cdf therefore turns ANY NHPP, whatever its rate, into iid uniforms, and one KS test then covers every rate function. Without a cumulative rate the rate is taken constant on the interval, which is the piecewise-constant approximation the reference uses on each subinterval.
WHY THE PLAIN TEST IS WEAK, AND WHAT FIXES IT. The CU KS test has “remarkably little power” against processes with non-exponential interarrival times, because it looks at the POSITIONS of the points and those stay nearly uniform for many non-Poisson processes. Lewis (1965) applies the Durbin (1961) transformation first: reorder the GAPS between the uniforms ascending, rescale each by how many gaps remain, and cumulate. That turns a difference in the gap DISTRIBUTION – exactly what a non-exponential renewal process has – into a difference in position, which KS can see. Measured on 400 replications of an Erlang-4 renewal process, the CU test rejects at its own size while the Lewis test rejects essentially always.
Options: ‘cumRate’ (the cumulative rate Lambda(t)), ‘method’ (‘lewis’ by default, ‘cu’ for the plain test), ‘T0’ (the left end, default 0).
Returns a struct with fields statistic, pvalue, n, uniforms and transformed.
Reference: S.-H. Kim, W. Whitt (2014). Are call center and hospital arrivals well modeled by nonhomogeneous Poisson processes? Manufacturing and Service Operations Management 16(3), 464-480; J. Durbin (1961), Biometrika 48, 41-55; P. A. W. Lewis (1965), JRSS B 27, 417-432.
See also
TRACE_IDI,MAP_FIT.
- infer_mlps(model, node, rt, class, ql)
INFER_MLPS MLPS demand estimation using sn struct-level operations.
Estimates service demands at a PS queue using the Maximum Likelihood for Processor Sharing method. Pre-builds augmented CTMC models for each unique (tagClass, aQueue) combination once, then uses sn_set_service + solver_ctmc directly inside the optimization loop.
- Inputs:
model - LINE Network model with delay rates set and queue rates to estimate node - PS queue node (Station object) rt - response time samples (column vector, n x 1) class - class of each sample (column vector, n x 1) ql - queue lengths at arrival (n x R matrix, per-class)
- Returns:
demandEst - 1 x R vector of estimated mean service demands
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.
- infer_minps_setup(data, initSample, sampleSize, V, model, node)
MAIN_MINPS setups the input data for the MINPS estimation method and calls it
Copyright (c) 2012-2014, Imperial College London All rights reserved.
- infer_minps(model, node, rt, class, ql)
INFER_MINPS MINPS demand estimation method.
Runs both MLPS and RPS estimators and selects the one with the smaller mean demand estimate.
- Inputs:
model - LINE Network model with delay rates set and queue rates to estimate node - PS queue node (Station object) rt - response time samples (column vector, n x 1) class - class of each sample (column vector, n x 1) ql - queue lengths at arrival (n x R matrix, per-class)
- Returns:
demandEst - 1 x R vector of estimated mean service demands
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_setparams(model, paramSpec, a)
INFER_LQN_SETPARAMS Apply a parameter vector to a LayeredNetwork.
MODEL = INFER_LQN_SETPARAMS(MODEL, PARAMSPEC, A) sets the LQN parameters named in PARAMSPEC to the values in the vector A, in place, and returns the (same handle) MODEL. This is the parameter-injection half of the LQN parameter identification method (see INFER_LQN).
- PARAMSPEC is a struct array; PARAMSPEC(i) has fields:
- .type‘hostdem’ (activity mean host demand) or
‘think’ (task mean think time)
.name : name of the activity (‘hostdem’) or task (‘think’)
Mean values are injected as exponential distributions (SCV = 1), which is the assumption of the CASCON 2005 tracking method. The cached layered struct (MODEL.lsn) is invalidated so the next getStruct/solve re-reads the mutated model objects.
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_optget(s, f, d)
INFER_LQN_OPTGET Return option field s.(f), or default d when absent/empty.
V = INFER_LQN_OPTGET(S, F, D) returns S.(F) if S is a struct with a non-empty field F, otherwise the default value D. Small helper shared by the LQN parameter identification routines (see INFER_LQN).
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_jacobian(hfun, a, fdStep, fdFloor)
INFER_LQN_JACOBIAN Forward finite-difference sensitivity matrix of h at a.
[H, H0] = INFER_LQN_JACOBIAN(HFUN, A, FDSTEP, FDFLOOR) returns the sensitivity matrix H = dh/da evaluated at the parameter vector A by forward finite differences, and H0 = HFUN(A). HFUN maps a parameter vector to a numeric observation vector z = h(a). This is the approximate sensitivity matrix H_k used in the EKF update (Zheng, Yang, Woodside, Litoiu, Iszlai, “Tracking Time-Varying Parameters in Software Systems with Extended Kalman Filters”, CASCON 2005).
Each column is H(:,i) = (HFUN(a + d_i) - H0)/d_i with the per-parameter step d_i = FDSTEP * max(|a_i|, FDFLOOR). HFUN is evaluated numel(A)+1 times.
FDSTEP : relative perturbation (default 1e-3) FDFLOOR : minimum absolute perturbation scale (default 1e-6)
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_getobs(names, metrics, obsSpec)
INFER_LQN_GETOBS Extract an observation vector from solved LQN metrics.
Z = INFER_LQN_GETOBS(NAMES, METRICS, OBSSPEC) returns the column vector Z of performance measures selected by OBSSPEC from the per-element numeric metric vectors in METRICS. This is the measurement-model half of the LQN parameter identification method (see INFER_LQN): it maps a solved model to the observation vector z = h(a).
NAMES : cell array of element names, as in LayeredNetworkStruct.names. METRICS : struct with fields QLen, Util, RespT, Tput (each a vector indexed
by element, aligned with NAMES, as returned by getEnsembleAvg).
- OBSSPECstruct array; OBSSPEC(i) has fields:
.metric : ‘RespT’ | ‘Util’ | ‘Tput’ | ‘QLen’ .name : element name (processor for utilization; entry or reference
task for response time; entry/task for throughput)
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_findbyname(container, name)
INFER_LQN_FINDBYNAME Locate an LQN element by name in a cell container.
EL = INFER_LQN_FINDBYNAME(CONTAINER, NAME) returns the first element of the cell array CONTAINER whose .name equals NAME, or [] if none matches. Used by the LQN parameter identification helpers to resolve activities and tasks referenced by name in a parameter specification (see INFER_LQN).
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_gibbs(data, nbCores, tol)
- infer_get_qlen_arrival(data)
INFER_GET_QLEN_ARRIVAL Compute queue lengths at arrival from cell data.
Wrapper around infer_compute_ql_at_arrival for the legacy cell-based data format. Assumes data is available in standard format where data{3,k} contains arrival times (in ms) and data{4,k} contains response times for class k.
- Inputs:
data - cell array in standard format (6 x K+1)
- Returns:
ql - 1 x K cell array, each cell is numSamples(k) x K matrix
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_fmlps(model, node, rt, class, ql, W)
INFER_FMLPS FMLPS demand estimation using sn struct-level operations.
Estimates service demands at a PS queue using the Fluid Maximum Likelihood for Processor Sharing method. Uses sn_set_service for fast parameter updates, avoiding model.reset()/getStruct() in the optimization loop.
- Inputs:
model - LINE Network model with delay rates set and queue rates to estimate node - PS queue node (Station object) rt - response time samples (column vector, n x 1) class - class of each sample (column vector, n x 1) ql - queue lengths at arrival (n x R matrix, per-class) W - total population (number of threads/jobs)
- Returns:
demandEst - 1 x R vector of estimated mean service demands
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.
- infer_fluid_ps_rt_likelihood(sn, taggedClass, y0_levels, Rsampled)
INFER_FLUID_PS_RT_LIKELIHOOD Fluid-based response time likelihood.
Builds an augmented model with tagged class K+1 by expanding the NetworkStruct arrays (following solver_fluid_passage_time’s pattern), then uses solver_fluid_odes to obtain the ODE handle.
- Usage modes:
- [ode_h, q_indices, augPhases] = infer_fluid_ps_rt_likelihood(sn, taggedClass)
Build augmented model and return ODE handle + indexing info.
- [~, ~, ~, LIKE] = infer_fluid_ps_rt_likelihood(sn, taggedClass, y0_levels, Rsampled)
Build augmented model, solve ODE, and return likelihood.
- Inputs:
sn - NetworkStruct (from model.getStruct()) taggedClass - class index of the tagged job y0_levels - M x K matrix of fluid levels per station per class (optional) Rsampled - observed response time (optional)
The augmented model adds class K+1 (tagged) with the same service rates as taggedClass. At the reference (queue) station, the tagged class absorbs by switching to taggedClass and routing to the delay station. The likelihood is extracted from the ODE derivative at the terminal state.
Reference: Casale, G. et al., “Fluid Analysis of Queueing in Processor Sharing Systems”
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.
- infer_lqn(model, paramSpec, obsSpec, Z, options)
INFER_LQN Identify hidden LQN parameters from measured performance data.
[MODEL, INFO] = INFER_LQN(MODEL, PARAMSPEC, OBSSPEC, Z, OPTIONS) estimates the LQN parameters named in PARAMSPEC (activity host demands and/or task think times) of the LayeredNetwork MODEL from the sequence of performance measurements Z, using an Extended Kalman Filter over the observation model defined by OBSSPEC. It implements Zheng, Yang, Woodside, Litoiu, Iszlai, “Tracking Time-Varying Parameters in Software Systems with Extended Kalman Filters”, CASCON 2005. A single measurement column with OPTIONS.QFac = 0 reduces to one-shot least-squares calibration.
- Inputs:
PARAMSPEC : struct array of parameters to estimate; see INFER_LQN_SETPARAMS. OBSSPEC : struct array of observed metrics; see INFER_LQN_GETOBS. Z : (no x nsteps) measurements, no == numel(OBSSPEC). OPTIONS : struct with optional fields (defaults in parentheses):
solver (@SolverLN) observation-model solver constructor solveropts ([]) options struct passed to the solver QFac (0.1) drift-noise factor, Q_ii=(QFac*a0_i*cvA)^2 RFac (0.2) meas.-noise factor, R_ii=((RFac*zbar_i)/1.96)^2/gammaT cvA (1) parameter drift coefficient of variation gammaT ([]) T/Tstar ratio for R (else from T and Tstar, else 1) T, Tstar ([]) measurement interval and system constant Q, R ([]) explicit covariances (override the above) P0 ([]) initial covariance (default diag((0.5*a0)^2)) a0 ([]) initial estimate (default: current model values) aTrue ([]) ground truth, enables the Ea RMS metric fdStep (1e-3), fdFloor (1e-6), clampPositive (true), verbose (false)
- Outputs:
MODEL : the LayeredNetwork with the final parameter estimate applied. INFO : EKF result struct (see INFER_LQN_EKF) augmented with ahat, a0,
Q, R, P0.
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_lqn_ekf(hfun, a0, P0, Z, Q, R, options)
INFER_LQN_EKF Extended Kalman Filter for LQN parameter identification.
[AHAT, INFO] = INFER_LQN_EKF(HFUN, A0, P0, Z, Q, R, OPTIONS) tracks a hidden parameter vector across the measurement sequence Z using an Extended Kalman Filter, following Zheng, Yang, Woodside, Litoiu, Iszlai, “Tracking Time-Varying Parameters in Software Systems with Extended Kalman Filters”, CASCON 2005 (equations 1-9). The parameter is modelled as a zero-mean random walk a_k = a_{k-1} + w and the measurement as z_k = h(a_k) + v, where h is the (nonlinear) LQN performance model supplied as HFUN.
- Inputs:
- HFUNhandle mapping a parameter vector to a predicted observation
vector z = h(a) (evaluates the LQN model).
A0 : (np x 1) initial parameter estimate. P0 : (np x np) initial estimation-error covariance. Z : (no x nsteps) measurement matrix, one column per step. Q : (np x np) parameter-drift (process-noise) covariance. R : (no x no) measurement-error covariance. OPTIONS : struct with optional fields:
fdStep (1e-3), fdFloor (1e-6) - finite-difference steps clampPositive (true) - clamp estimates to > fdFloor aTrue ([]) - ground truth for Ea metric verbose (false)
- Outputs:
AHAT : (np x nsteps) parameter estimate trajectory. INFO : struct with fields P (final covariance), Phist (per-step
covariances), e (no x nsteps prediction errors), zpred (predicted measurements), Er (prediction RMS), Ea (parameter tracking RMS vs aTrue when supplied, else []).
Copyright (c) 2012-2026, Imperial College London All rights reserved.
- infer_compute_ql_at_arrival(at, at_jobid, rt, rt_jobid, class, R)
INFER_COMPUTE_QL_AT_ARRIVAL Compute per-class queue lengths at arrival.
Reconstructs the queue state seen by each arriving job using arrival and departure times. Arrival times and response times are matched by job ID, so they need not be in the same order or come from the same data source.
At ties, departures are processed before arrivals.
- Inputs:
at - arrival times (column vector, n x 1) at_jobid - job IDs for arrival times (column vector, n x 1) rt - response times (column vector, m x 1, m >= n) rt_jobid - job IDs for response times (column vector, m x 1) class - class of each arrival sample (column vector, n x 1,
ordered consistently with at and at_jobid)
R - number of classes
- Returns:
- ql - n x R matrix of per-class queue lengths at each arrival,
rows ordered consistently with the input at/at_jobid
Copyright (c) 2012-2026, Imperial College London All rights reserved. This code is released under the 3-Clause BSD License.