1function [
P, placeable] = pas_placement(H)
2% [
P, PLACEABLE] = PAS_PLACEMENT(H)
4% Placement-order logic of a pass-and-swap (
P&S) / order-independent network
5% with swap graph H. Isolates
the check that decides which
class orderings are
6% feasible (adhere to
the placement partial order)
for PFQN_PAS_IS / PFQN_PASNC.
8% An ordering c = (c_1, ..., c_ell)
is FEASIBLE iff it
is non-decreasing with
9% respect to H, i.e.
class a never appears before
class b whenever H(b,a) ~= 0
10% (Comte & Dorsman, 2021, arXiv:2009.12299). Equivalently H(b,a) ~= 0 means b
11% must be placed before a. Collecting these constraints and taking
the
12% transitive closure yields
the precedence matrix
13%
P(i,j) = 1 iff
class i must be placed before class j,
14% so an ordering
is feasible iff every
class is placed only after all of its
15%
P-predecessors. H may be given as a mere Hasse diagram;
the closure makes
the
19% H - (R x R) swap-graph adjacency (H(b,a) ~= 0 forces b before a). The empty
20% or all-zero graph yields
P = 0 (no constraints, pure OI: every ordering
24%
P - (R x R) precedence closure;
P(i,j)=1 iff i must precede j.
25% placeable - function handle placeable(x) returning
the row vector of
class
26% indices that may be placed next given
the remaining per-
class
27%
count vector x (1 x R): those present classes with no remaining
28% predecessor still to be placed. Used to enumerate/sample
the
29% feasible orderings and to check placement-order adherence.
31% See also PFQN_PAS_IS, PFQN_PASNC, PAS_SWAP2PREC.
33% Copyright (c) 2012-2026, Imperial College London
39 placeable = @(x) find(x > 0);
44% Transitive closure of
the "must precede" relation (
P(i,j)=1 iff i precedes j,
45% i.e. edge i->j in H). Iterate R times so paths of any length are captured.
47for it = 1:R %#ok<NASGU>
48 Pnext = (
P | (
P * H)) > 0;
56placeable = @(x) local_placeable(x,
P);
59function idx = local_placeable(x,
P)
60% Class j
is placeable iff it
is present (x(j)>0) and no still-present class i
61% must precede it: sum_i x(i)
P(i,j) == 0.
66 idx = find((x *
P) == 0 & x > 0);