LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
Region.m
1classdef Region < handle
2 % A finite capacity region
3 %
4 % Copyright (c) 2012-2026, Imperial College London
5 % All rights reserved.
6
7 properties (Constant)
8 UNBOUNDED = -1;
9 end
10
11 properties
12 name;
13 classes;
14 nodes;
15 globalMaxJobs;
16 globalMaxMemory;
17 classMaxJobs;
18 classMaxMemory;
19 dropRule;
20 classWeight;
21 classSize;
22 constraintA; % Linear constraint matrix A (C x K), An <= b
23 constraintB; % Linear constraint vector b (C x 1)
24 end
25
26 methods
27 function self = Region(nodes,classes)
28 self.name = '';
29 self.nodes = {nodes{:}}';
30 self.classes = classes;
31 self.globalMaxJobs = Region.UNBOUNDED;
32 self.globalMaxMemory = Region.UNBOUNDED;
33 self.classWeight = ones(1,length(self.classes));
34 self.dropRule = DropStrategy.WAITQ * ones(1,length(self.classes));
35 self.classSize = ones(1,length(self.classes));
36 self.classMaxJobs = Region.UNBOUNDED * ones(1,length(self.classes));
37 self.classMaxMemory = Region.UNBOUNDED * ones(1,length(self.classes));
38 self.constraintA = [];
39 self.constraintB = [];
40 end
41
42 function self = setGlobalMaxJobs(self, njobs)
43 self.globalMaxJobs = njobs;
44 end
45
46 function self = setGlobalMaxMemory(self, memlim)
47 self.globalMaxMemory = memlim;
48 end
49
50 function self = setClassMaxJobs(self, class, njobs)
51 self.classMaxJobs(class.index) = njobs;
52 end
53
54 function self = setClassWeight(self, class, weight)
55 self.classWeight(class.index) = weight;
56 end
57
58 function self = setDropRule(self, class, dropStrategy)
59 % SELF = SETDROPRULE(CLASS, DROPSTRATEGY)
60 % Set the drop rule for a class.
61 % dropStrategy can be:
62 % - A boolean: true = DROP, false = WAITQ (for backwards compatibility)
63 % - A DropStrategy enum value: DROP, WAITQ, BAS, BBS, RSRD
64 if islogical(dropStrategy)
65 if dropStrategy
66 self.dropRule(class.index) = DropStrategy.DROP;
67 else
68 self.dropRule(class.index) = DropStrategy.WAITQ;
69 end
70 else
71 self.dropRule(class.index) = dropStrategy;
72 end
73 end
74
75 function strategy = getDropRule(self, class)
76 % STRATEGY = GETDROPRULE(CLASS)
77 % Get the drop strategy for a class.
78 strategy = self.dropRule(class.index);
79 end
80
81 function self = setClassSize(self, class, size)
82 self.classSize(class.index) = size;
83 end
84
85 function self = setClassMaxMemory(self, class, memlim)
86 self.classMaxMemory(class.index) = memlim;
87 end
88
89 function self = setName(self, name)
90 self.name = name;
91 end
92
93 function name = getName(self)
94 name = self.name;
95 end
96
97 function self = setLinearConstraints(self, A, b)
98 % SELF = SETLINEARCONSTRAINTS(A, B)
99 % Set general linear admission constraints An <= b.
100 % A: Constraint matrix (C x K) where C is the number of
101 % constraints and K is the number of classes.
102 % b: Capacity vector (C x 1) or (1 x C).
103 self.constraintA = A;
104 self.constraintB = b(:); % Ensure column vector
105 end
106
107 function tf = hasLinearConstraints(self)
108 % TF = HASLINEARCONSTRAINTS()
109 % Returns true if linear constraints have been set.
110 tf = ~isempty(self.constraintA) && ~isempty(self.constraintB);
111 end
112 end
113
114end
Definition mmt.m:124