Derived set maximisers

Code commentary on the implementation of Tractable and Practicable Inducers/Python Implementation/Derived set maximisers

Sections

No-sum-layer highest-layer limited-derived derived variables set builder

No-sum-layer highest-layer limited-derived derived variables set builder

Similarly to the tuple builder, some implementations of the highest-layer limited-derived derived variables set builder (Text) may drop the computation of $\mathrm{sumlayer}(F,J)$, especially if the layerer is subject to the excluded-self restriction. The no-sum-layer highest-layer limited-derived derived variables set builder $I_{P,U,\mathrm{D,d,ns}} \in \mathrm{computers}$ is defined in module AlignmentPracticable,

parametersSystemsBuilderDerivedVarsHighestNoSumlayer :: 
  Integer -> Integer -> System -> Set.Set Variable -> Fud -> Histogram -> Histogram ->  
  Maybe (Map.Map (Set.Set Variable, Histogram, Histogram) Double)

as

def parametersSystemsBuilderDerivedVarsHighestNoSumlayer(wmax,omax,uu,vv,ff,xx,xxrr):
    ...
    def init(vv):
        return sdict([((sgl(w), histogramEmpty(), histogramEmpty()),(0,0,0)) for w in vv])
    def final(nn):
        return sdict([((kk,aa,bb),a) for ((kk,aa,bb),a) in nn.items() if len(kk) > 1])
    def buildd(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 <= wmax and fder(depends(ff,jj)) == jj:
                bb = red(xx,jj)
                bbrr = red(xxrr,jj)
                m = len(jj)
                a = algn(bb)
                b = algn(bbrr)
                c = u ** (1.0/m)
                mm[(jj, bb, bbrr)] = ((a-b)/c,-b/c,-u)
        mm = top(omax,mm)
        if len(mm) > 0:
            rr = nn.copy()
            rr.update(mm)
            return buildd(ww,mm,rr) 
        return final(nn) 
    if wmax < 0 or omax < 0:
        return None
    if not (vars(xx).issubset(uvars(uu)) and vars(xx) == vars(xxrr) and vv.issubset(vars(xx))):
        return None
    if not fvars(ff).issubset(uvars(uu)):
        return None
    return maxfst(buildd(fvars(ff)-vv,init(fder(ff)),sdict()))

For example,

def buildffdervarns(aa,rr,ff,wmax,omax):
    vv = vars(aa)
    ww = vv | fvars(ff)
    xx = apply(vv,ww,fhis(ff),aa)
    xxrr = apply(vv,ww,fhis(ff),rr)
    return sset([(kk,a) for ((kk,_,_),a) in  parametersSystemsBuilderDerivedVarsHighestNoSumlayer(wmax,omax,uunion(sys(aa),fsys(ff)),vv,ff,xx,xxrr).items()])

aa = mul(scalar(81),regpivot(3,3))

ff = fudEmpty()
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {({15, 16}, 81.59074711243147)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,2]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {({15, 16}, 100.84641034011004)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,3]]),cdtt([3,17],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {({15, 16, 17}, 158.04397361570332)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,2]]),cdtt([3,17],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {({15, 16, 17}, 184.23221525401473)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,3]]),cdtt([3,17],[[1,1],[2,2],[3,3]]),cdtt([3,18],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,100)
# {({15, 16, 18}, 158.04397361570332)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,3]]),cdtt([3,17],[[1,1],[2,2],[3,3]]),cdtt([3,18],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,1)
# {({15, 16, 18}, 158.04397361570332)}

ff = llff([cdtt([1,15],[[1,1],[2,2],[3,3]]),cdtt([2,16],[[1,1],[2,2],[3,3]]),cdtt([15,17],[[1,1],[2,2],[3,3]]),cdtt([16,18],[[1,1],[2,2],[3,3]])])
buildffdervarns(aa,ind(aa),ff,3**3,1)
# {({17, 18}, 81.59074711243147)}

top