LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
fromMarginalBounds.m
1function space = fromMarginalBounds(sn, ind, lb, ub, cap, options)
2% SPACE = FROMMARGINALBOUNDS(QN, IND, LB, UB, CAP, OPTIONS)
3
4% Copyright (c) 2012-2026, Imperial College London
5% All rights reserved.
6
7if nargin<6 %~exist('options','var')
8 options = Solver.defaultOptions;
9end
10
11% ind: node index
12ist = sn.nodeToStation(ind);
13%isf = sn.nodeToStateful(ind);
14
15% returns all states lb<= x<= ub, where ub/lb are either a scalar (total
16% number of jobs) or a vector (per-class number of jobs)
17space = [];
18if isempty(lb), lb=0*ub; end
19R = sn.nclasses;
20if length(lb) == 1, isVectorLB =0; else, isVectorLB = 1; end
21if length(ub) == 1, isVectorUB =0; else, isVectorUB = 1; end
22if isVectorLB~=isVectorUB, line_error(mfilename,'Bounds must either be both vectors or both scalars'); end
23
24if isVectorUB && isVectorLB
25 nmax = State.fromMarginal(sn, ind, ub, options);
26 if isempty(nmax)
27 nmax = State.fromMarginal(sn, ind, ub, options);
28 end
29 n = pprodcon(lb,ub);
30 while n ~= -1
31 state = State.fromMarginal(sn, ind, n, options);
32 space(end+1:end+size(state,1),(size(nmax,2)-size(state,2)+1):size(nmax,2)) = state;
33 n = pprodcon(n,lb,ub);
34 end
35else % both scalar
36 if ub >= lb
37 for bi=ub:-1:lb % reverse order so that largest vector determines size(space,2)
38 nset = multichoose(R,bi);
39 for j=1:size(nset,1)
40 state = State.fromMarginal(sn, ind, nset(j,:));
41 if bi==ub && j==1
42 space(end+1:end+size(state,1),:) = state;
43 else
44 space(end+1:end+size(state,1),(end-size(state,2)+1):end) = state;
45 end
46 end
47 end
48 end
49end
50space = unique(space,'rows');
51% now we remove states that are not reachable
52if sn.isstateful(ind)
53 keep = [];
54 for s=1:size(space,1)
55 [ni,nir] = State.toMarginal(sn,ind,space(s,:));
56 if sn.isstation(ind)
57 if all(nir <= sn.classcap(ist,:)) && ni <= cap
58 keep = [keep; s];
59 end
60 else
61 if ni <= cap
62 keep = [keep; s];
63 end
64 end
65 end
66 space = space(keep,:);
67end
68space = space(end:-1:1,:); % so that states with jobs in phase 1 comes earlier
69end