Tuple set maximisers
Code commentary on the implementation of Tractable and Practicable Inducers/Python Implementation/Tuple set maximisers
Sections
Multi-effective no-sum-layer limited-underlying tuple set list builder
Multi-effective no-sum-layer limited-underlying tuple set list builder
A performance improvement to the no-sum-layer limited-underlying tuple set list builder (Text) is to restrict the builder to variables that are multi-effective, $\{u : u \in V,~|(X\%\{u\})^{\mathrm{F}}|>1\}$ (Text).
The tuple set builder, $I_{P,U,\mathrm{B,ns,me}}$, is defined in module AlignmentPracticable
,
parametersSystemsBuilderTupleNoSumlayerMultiEffective ::
Integer -> Integer -> Integer -> Integer -> System -> Set.Set Variable -> Fud -> Histogram -> Histogram ->
Maybe (Set.Set ((Set.Set Variable, Histogram, Histogram),Double))
as
def parametersSystemsBuilderTupleNoSumlayerMultiEffective(xmax,omax,bmax,mmax,uu,vv,ff,xx,xxrr):
...
def init(vv):
return sdict([(((sgl(w), histogramEmpty(), histogramEmpty()),0),(0,0,0)) for w in vv])
def final(nn):
return sdict([(((kk,aa,bb),y),a) for (((kk,aa,bb),y),a) in nn.items() if len(kk) > 1])
def buildb(ww,qq,nn):
pp = sset([kk|sgl(w) for (((kk,_,_),_),_) in qq.items() for w in (ww-kk)])
mm = sdict()
for jj in pp:
u = vol(uu,jj)
if u <= xmax:
bb = red(xx,jj)
bbrr = red(xxrr,jj)
a1 = sumfacln(bb)
a2 = sumfacln(ind(bb))
b1 = sumfacln(bbrr)
b2 = sumfacln(ind(bbrr))
mm[((jj, bb, bbrr), a1-b1)] = (a1-a2-b1+b2, -b1+b2, -u)
mm = top(omax,mm)
if len(mm) > 0:
rr = nn.copy()
rr.update(mm)
return buildb(ww,mm,rr)
return final(nn)
if xmax < 0 or omax < 0 or mmax < 1 or bmax < mmax:
return None
if not (vars(xx).issubset(uvars(uu)) and vars(xx) == vars(xxrr) and vv.issubset(vars(xx))):
return None
meff = sset([v for v in vv if acard(eff(red(xx,sgl(v)))) > 1])
if len(meff) == 0:
return sset()
if len(ff) == 0:
return topd(bmax//mmax,buildb(meff,init(meff),sdict()))
if fvars(ff).issubset(vars(xx)):
return topd(bmax//mmax,buildb(fvars(ff)|meff,init(fder(ff)),sdict()))
return None
For example,
def buildtupnsme(uu,aa,rr,xmax,omax,bmax,mmax):
return [kk for ((kk,_,_),_) in parametersSystemsBuilderTupleNoSumlayerMultiEffective(xmax,omax,bmax,mmax,uu,vars(aa),fudEmpty(),aa,rr)]
buildtupnsme(uu,aa,ind(aa),3**3,100,1000,1)
# [{1, 2}, {1, 2, 3}, {1, 3}, {2, 3}]
buildtupnsme(uu,aa,ind(aa),3**3,100,2,1)
# [{1, 2, 3}, {2, 3}]
buildtupnsme(uu,aa,ind(aa),3**3,100,1,1)
# [{1, 2, 3}]
buildtupnsme(uu,aa,ind(aa),3**4,100,1000,1)
# [{1, 2}, {1, 2, 3}, {1, 3}, {2, 3}]
buildtupnsme(uu,aa,ind(aa),3**4,100,2,1)
# [{1, 2, 3}, {2, 3}]
buildtupnsme(uu,aa,ind(aa),3**4,100,1,1)
# [{1, 2, 3}]