1classdef FiniteCapacityRegion < handle
2 % A finite capacity region
4 % Copyright (c) 2012-2026, Imperial College London
22 constraintA; % Linear constraint matrix (C_f x K) or empty
23 constraintB; % Linear constraint capacity (C_f x 1) or empty
27 function self = FiniteCapacityRegion(
nodes,classes)
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 = [];
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.
48 if size(A, 1) ~= length(b)
49 line_error(mfilename, 'A and b must have matching number of rows.
');
51 if size(A, 2) ~= length(self.classes)
52 line_error(mfilename, 'A
column count must equal number of classes (%d).
', length(self.classes));
58 function [A, b] = getLinearConstraints(self)
59 % [A, B] = GETLINEARCONSTRAINTS() — Linear admission constraint
60 % pair (A,b), or empties if not set.
65 function tf = hasLinearConstraints(self)
66 tf = ~isempty(self.constraintA) && ~isempty(self.constraintB);
69 function self = setGlobalMaxJobs(self, njobs)
70 self.globalMaxJobs = njobs;
73 function self = setGlobalMaxMemory(self, memlim)
74 self.globalMaxMemory = memlim;
77 function self = setClassMaxJobs(self, class, njobs)
78 self.classMaxJobs(class.index) = njobs;
81 function self = setClassWeight(self, class, weight)
82 self.classWeight(class.index) = weight;
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)
93 self.dropRule(class.index) = DropStrategy.DROP;
95 self.dropRule(class.index) = DropStrategy.WAITQ;
98 self.dropRule(class.index) = dropStrategy;
102 function strategy = getDropRule(self, class)
103 % STRATEGY = GETDROPRULE(CLASS)
104 % Get the drop strategy for a class.
105 strategy = self.dropRule(class.index);
108 function self = setClassSize(self, class, size)
109 self.classSize(class.index) = size;
112 function self = setClassMaxMemory(self, class, memlim)
113 self.classMaxMemory(class.index) = memlim;
116 function self = setName(self, name)
120 function name = getName(self)