LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
refreshRegions.m
1function sn = refreshRegions(self)
2% SN = REFRESHREGIONS() Populate finite capacity region information in sn struct
3%
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7% Extract finite capacity region information
8% region is a cell array of size F (number of regions)
9% region{f} is Matrix(M, K+1) where:
10% entry (i,r) = max jobs of class r at station i in region f
11% entry (i,K+1) = global max jobs at station i in region f
12% -1 = infinite capacity
13sn = self.sn;
14if ~isempty(self.regions)
15 F = length(self.regions);
16 sn.nregions = F;
17 sn.region = cell(F, 1);
18
19 M = sn.nstations;
20 K = sn.nclasses;
21
22 % regionrule(f, r) = DropStrategy for class r in region f
23 sn.regionrule = DropStrategy.DROP * ones(F, K); % Default to drop
24 % regionweight(f, r) = class weight for class r in region f
25 sn.regionweight = ones(F, K); % Default weight = 1.0
26 % regionsz(f, r) = class size/memory for class r in region f
27 sn.regionsz = ones(F, K); % Default size = 1
28 % regionLinConA{f}/regionLinConb{f} = linear constraint matrices for region f
29 sn.regionLinConA = cell(F, 1);
30 sn.regionLinConb = cell(F, 1);
31
32 for f = 1:F
33 fcr = self.regions{f};
34 % Matrix with M rows (stations) and K+1 columns (K classes + 1 global)
35 regionMatrix = -1 * ones(M, K + 1); % Initialize all to infinite (-1)
36
37 % Find which stations are in this region and set their capacities
38 for n = 1:length(fcr.nodes)
39 node = fcr.nodes{n};
40 for i = 1:M
41 if self.stations{i} == node
42 % Set per-class max jobs for this station in this region
43 % fcr.classMaxJobs is an array indexed by class index
44 for r = 1:K
45 regionMatrix(i, r) = fcr.classMaxJobs(r);
46 end
47 % Set global max jobs for this station in this region (column K+1)
48 regionMatrix(i, K + 1) = fcr.globalMaxJobs;
49 break;
50 end
51 end
52 end
53
54 % Extract drop rule for each class in this region
55 for r = 1:K
56 % fcr.dropRule is a DropStrategy array indexed by class index
57 sn.regionrule(f, r) = fcr.dropRule(r);
58 end
59
60 % Extract class weights and sizes for this region
61 for r = 1:K
62 sn.regionweight(f, r) = fcr.classWeight(r);
63 sn.regionsz(f, r) = fcr.classSize(r);
64 end
65
66 sn.region{f} = regionMatrix;
67
68 % Capture linear-constraint matrices if the region defines them
69 if ismethod(fcr, 'hasLinearConstraints') && fcr.hasLinearConstraints()
70 sn.regionLinConA{f} = fcr.getConstraintA();
71 sn.regionLinConb{f} = fcr.getConstraintB();
72 end
73 end
74else
75 sn.nregions = 0;
76 sn.region = {};
77 sn.regionrule = [];
78 sn.regionweight = [];
79 sn.regionsz = [];
80 sn.regionLinConA = {};
81 sn.regionLinConb = {};
82end
83self.sn = sn;
84end
Definition mmt.m:124