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
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 = getConstraintA(self)
62 function b = getConstraintB(self)
66 function tf = hasLinearConstraints(self)
67 tf = ~isempty(self.constraintA) && ~isempty(self.constraintB);
70 function self = setGlobalMaxJobs(self, njobs)
71 self.globalMaxJobs = njobs;
74 function self = setGlobalMaxMemory(self, memlim)
75 self.globalMaxMemory = memlim;
78 function self = setClassMaxJobs(self, class, njobs)
79 self.classMaxJobs(class.index) = njobs;
82 function self = setClassWeight(self, class, weight)
83 self.classWeight(class.index) = weight;
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)
94 self.dropRule(class.index) = DropStrategy.DROP;
96 self.dropRule(class.index) = DropStrategy.WAITQ;
99 self.dropRule(class.index) = dropStrategy;
103 function strategy = getDropRule(self, class)
104 % STRATEGY = GETDROPRULE(CLASS)
105 % Get the drop strategy for a class.
106 strategy = self.dropRule(class.index);
109 function self = setClassSize(self, class, size)
110 self.classSize(class.index) = size;
113 function self = setClassMaxMemory(self, class, memlim)
114 self.classMaxMemory(class.index) = memlim;
117 function self = setName(self, name)
121 function name = getName(self)