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, b] = getLinearConstraints(self)
59 % [A, B] = GETLINEARCONSTRAINTS() — Linear admission constraint
60 % pair (A,b), or empties if not set.
61 A = self.constraintA;
62 b = self.constraintB;
63 end
64
65 function tf = hasLinearConstraints(self)
66 tf = ~isempty(self.constraintA) && ~isempty(self.constraintB);
67 end
68
69 function self = setGlobalMaxJobs(self, njobs)
70 self.globalMaxJobs = njobs;
71 end
72
73 function self = setGlobalMaxMemory(self, memlim)
74 self.globalMaxMemory = memlim;
75 end
76
77 function self = setClassMaxJobs(self, class, njobs)
78 self.classMaxJobs(class.index) = njobs;
79 end
80
81 function self = setClassWeight(self, class, weight)
82 self.classWeight(class.index) = weight;
83 end
84
85 function self = setDropRule(self, class, dropStrategy)
86 % SELF = SETDROPRULE(CLASS, DROPSTRATEGY)
87 % Set the drop rule for a class.
88 % dropStrategy can be:
89 % - A boolean: true = DROP, false = WAITQ (for backwards compatibility)
90 % - A DropStrategy enum value: DROP, WAITQ, BAS, BBS, RSRD
91 if islogical(dropStrategy)
92 if dropStrategy
93 self.dropRule(class.index) = DropStrategy.DROP;
94 else
95 self.dropRule(class.index) = DropStrategy.WAITQ;
96 end
97 else
98 self.dropRule(class.index) = dropStrategy;
99 end
100 end
101
102 function strategy = getDropRule(self, class)
103 % STRATEGY = GETDROPRULE(CLASS)
104 % Get the drop strategy for a class.
105 strategy = self.dropRule(class.index);
106 end
107
108 function self = setClassSize(self, class, size)
109 self.classSize(class.index) = size;
110 end
111
112 function self = setClassMaxMemory(self, class, memlim)
113 self.classMaxMemory(class.index) = memlim;
114 end
115
116 function self = setName(self, name)
117 self.name = name;
118 end
119
120 function name = getName(self)
121 name = self.name;
122 end
123 end
124
125end
Definition fjtag.m:157