1function model = QN2LINE(sn, modelName)
2% MODEL = QN2LINE(QN, MODELNAME)
4% Copyright (c) 2012-2026, Imperial College London
6if nargin<2%~exist(
'modelName',
'var')
10M = sn.nstations; %number of stations
11K = sn.nclasses; %number of
classes
13NK = sn.njobs; % initial population per class
14Ktrue = nnz(NK); %
classes that are not artificial
17model = Network(modelName);
22 case SchedStrategy.INF
23 node{ist} = Delay(model, sn.nodenames{ist});
24 case SchedStrategy.FORK
25 node{ist} = ForkStation(model, sn.nodenames{ist});
26 case SchedStrategy.EXT
27 node{ist} = Source(model,
'Source'); idSource = ist;
28 node{M+1} = Sink(model,
'Sink'); hasSink = 1;
30 node{ist} = Queue(model, sn.nodenames{ist}, SchedStrategy.toFeature(sn.sched(ist)));
31 node{ist}.setNumServers(sn.nservers(ist));
39 jobclass{k} = OpenClass(model, sn.classnames{k}, 0);
41 jobclass{k} = ClosedClass(model, sn.classnames{k}, NK(k), node{sn.refstat(k)}, 0);
44 %
if the reference node
is unspecified, as in artificial
classes,
45 % set it to the first node where the rate
for this class is
48 if sum(nnz(sn.proc{ist}{k}{1}))>0
53 jobclass{k} = OpenClass(model, sn.classnames{k});
55 jobclass{k} = ClosedClass(model, sn.classnames{k}, NK(k), node{ist}, 0);
60 SCVik = map_scv(PH{ist}{k});
63 case SchedStrategy.EXT
64 if isnan(sn.rates(ist,k))
65 node{ist}.setArrival(
jobclass{k}, Disabled.getInstance());
66 elseif sn.rates(ist,k)==0
67 node{ist}.setArrival(
jobclass{k}, Immediate.getInstance());
69 node{ist}.setArrival(
jobclass{k}, APH.fitMeanAndSCV(map_mean(PH{ist}{k}),SCVik));
71 case SchedStrategy.FORK
74 if isnan(sn.rates(ist,k))
75 node{ist}.setService(
jobclass{k}, Disabled.getInstance());
76 elseif sn.rates(ist,k)==0
77 node{ist}.setService(
jobclass{k}, Immediate.getInstance());
79 node{ist}.setService(
jobclass{k}, APH.fitMeanAndSCV(map_mean(PH{ist}{k}),SCVik));
83 %
this could be made more precised by fitting into a 2-state
84 % APH, especially
if SCV in [0.5,0.1]
85 % nPhases = max(1,round(1/SCVik));
87 %
case SchedStrategy.EXT
88 % node{i}.setArrival(
jobclass{k}, Erlang(nPhases/map_mean(PH{i}{k}),nPhases));
89 %
case SchedStrategy.FORK
92 % node{i}.setService(
jobclass{k}, Erlang(nPhases/map_mean(PH{i}{k}),nPhases));
101 myP{k,c} = zeros(M+hasSink);
104 % routing matrix
for each class
105 if hasSink && m == idSource % direct to sink
106 myP{k,c}(ist,M+1) = rt((ist-1)*K+k,(m-1)*K+c);
108 myP{k,c}(ist,m) = rt((ist-1)*K+k,(m-1)*K+c);