LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sn_has_classdep_routing.m
1function tf = sn_has_classdep_routing(sn)
2% SN_HAS_CLASSDEP_ROUTING True when classes are not routed alike.
3%
4% TF = SN_HAS_CLASSDEP_ROUTING(SN) returns true when the routing probabilities
5% differ between job classes, either because a class switches class on a hop or
6% because two classes leave the same station with different probabilities. It
7% is false for a single-class model and for a multiclass model in which every
8% class traverses the network identically.
9%
10% This is the condition under which per-class visit ratios diverge, so a method
11% that aggregates classes into a per-chain demand vector stops being exact.
12% Used to gate Marie's aggregation-decomposition in SolverMVA: with all classes
13% routed alike that method reproduces the exact solution, and it degrades as the
14% per-class demand vectors separate.
15%
16% sn.rt is indexed station-major, (i-1)*K+r, matching sn_refresh_visits.
17%
18% Copyright (c) 2012-2026, Imperial College London
19% All rights reserved.
20
21tf = false;
22K = sn.nclasses;
23M = sn.nstations;
24if K <= 1
25 return;
26end
27
28tol = GlobalConstants.FineTol;
29for i = 1:M
30 for j = 1:M
31 shared = [];
32 for r = 1:K
33 % Class switching: leaving station i as class r and arriving at j
34 % as some other class s makes the routing class-dependent outright.
35 for s = 1:K
36 if r ~= s && sn.rt((i-1)*K+r, (j-1)*K+s) > tol
37 tf = true;
38 return;
39 end
40 end
41 p = sn.rt((i-1)*K+r, (j-1)*K+r);
42 if isempty(shared)
43 shared = p;
44 elseif abs(p - shared) > tol
45 tf = true;
46 return;
47 end
48 end
49 end
50end
51end