1function sn = sn_nonmarkov_toph(sn, options)
2% SN = SN_NONMARKOV_TOPH(SN, OPTIONS)
3% Convert non-Markovian distributions to PH
using specified approximation method
5% This function scans all service and arrival processes in the network
6% structure and converts non-Markovian distributions to Markovian Arrival
7% Processes (MAPs)
using the specified approximation method.
10% sn: Network structure from getStruct()
11% options: Solver options structure with fields:
12% - config.nonmkv: Method
for conversion (
'none',
'bernstein')
13% - config.nonmkvorder: Number of phases
for approximation (
default 20)
16% sn: Updated network structure with converted processes
18% Copyright (c) 2012-2026, Imperial College London
21% Get non-Markovian conversion method from options (
default 'bernstein')
22if isfield(options,
'config') && isfield(options.config,
'nonmkv')
23 nonmkvMethod = options.config.nonmkv;
25 nonmkvMethod = 'bernstein';
28% If method
is 'none', return without any conversion
29if strcmpi(nonmkvMethod, 'none')
33% Get number of phases from options (default 20)
34if isfield(options, 'config') && isfield(options.config, 'nonmkvorder')
35 nPhases = options.config.nonmkvorder;
40% Check if we should preserve deterministic distributions for exact MAP/D/c analysis
41if isfield(options, 'config') && isfield(options.config, 'preserveDet')
42 preserveDet = options.config.preserveDet;
47% Markovian ProcessType IDs (no conversion needed)
48markovianTypes = [ProcessType.EXP, ProcessType.ERLANG, ProcessType.HYPEREXP, ...
49 ProcessType.PH, ProcessType.APH, ProcessType.MAP, ...
50 ProcessType.DMAP, ProcessType.
MMAP, ...
51 ProcessType.ME, ProcessType.RAP, ...
52 ProcessType.COXIAN, ProcessType.COX2, ProcessType.MMPP2, ...
53 ProcessType.IMMEDIATE, ProcessType.DISABLED];
60 procType = sn.procid(ist, r);
62 % Skip if procType
is NaN (e.g., for Transition
nodes in SPNs)
67 % Skip if already Markovian, disabled, or immediate
68 if any(procType == markovianTypes)
72 % see _kb/04-networkstruct.md (api/sn