LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
FiniteCapacityRegion.m
1classdef FiniteCapacityRegion < 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 (C_f x K) or empty
23 constraintB; % Linear constraint capacity (C_f x 1) or empty
24 end
25
26 methods
27 function self = FiniteCapacityRegion(nodes,classes)
28 self.name = '';
29 self.nodes = {nodes{:}}';
30 self.classes = classes;
31 self.globalMaxJobs = FiniteCapacityRegion.UNBOUNDED;
32 self.globalMaxMemory = FiniteCapacityRegion.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 = FiniteCapacityRegion.UNBOUNDED * ones(1,length(self.classes));
37 self.classMaxMemory = FiniteCapacityRegion.UNBOUNDED * ones(1,length(self.classes));
38 self.constraintA = [];
39 self.constraintB = [];
40 end
41
42 function self = setConstraint(self, A, b)
43 % SETCONSTRAINT(A, B) — Set the linear constraint A * x <= B
44 % where x is the per-class job count vector. A must be (C x K),
45 % B must be (C x 1) for some number of constraints C.
46 A = double(A);
47 b = double(b(:));
48 if size(A, 1) ~= length(b)
49 line_error(mfilename, 'A and b must have matching number of rows.');
50 end
51 if size(A, 2) ~= length(self.classes)
52 line_error(mfilename, 'A column count must equal number of classes (%d).', length(self.classes));
53 end
54 self.constraintA = A;
55 self.constraintB = b;
56 end
57
58 function A = getConstraintA(self)
59 A = self.constraintA;
60 end
61
62 function b = getConstraintB(self)
63 b = self.constraintB;
64 end
65
66 function tf = hasLinearConstraints(self)
67 tf = ~isempty(self.constraintA) && ~isempty(self.constraintB);
68 end
69
70 function self = setGlobalMaxJobs(self, njobs)
71 self.globalMaxJobs = njobs;
72 end
73
74 function self = setGlobalMaxMemory(self, memlim)
75 self.globalMaxMemory = memlim;
76 end
77
78 function self = setClassMaxJobs(self, class, njobs)
79 self.classMaxJobs(class.index) = njobs;
80 end
81
82 function self = setClassWeight(self, class, weight)
83 self.classWeight(class.index) = weight;
84 end
85
86 function self = setDropRule(self, class, dropStrategy)
87 % SELF = SETDROPRULE(CLASS, DROPSTRATEGY)
88 % Set the drop rule for a class.
89 % dropStrategy can be:
90 % - A boolean: true = DROP, false = WAITQ (for backwards compatibility)
91 % - A DropStrategy enum value: DROP, WAITQ, BAS, BBS, RSRD
92 if islogical(dropStrategy)
93 if dropStrategy
94 self.dropRule(class.index) = DropStrategy.DROP;
95 else
96 self.dropRule(class.index) = DropStrategy.WAITQ;
97 end
98 else
99 self.dropRule(class.index) = dropStrategy;
100 end
101 end
102
103 function strategy = getDropRule(self, class)
104 % STRATEGY = GETDROPRULE(CLASS)
105 % Get the drop strategy for a class.
106 strategy = self.dropRule(class.index);
107 end
108
109 function self = setClassSize(self, class, size)
110 self.classSize(class.index) = size;
111 end
112
113 function self = setClassMaxMemory(self, class, memlim)
114 self.classMaxMemory(class.index) = memlim;
115 end
116
117 function self = setName(self, name)
118 self.name = name;
119 end
120
121 function name = getName(self)
122 name = self.name;
123 end
124 end
125
126end
Definition mmt.m:124