Limited-path-models tuple partition practicable shuffle content alignment valency-density fud inducer

Haskell commentary on the implementation of Tractable and Practicable Inducers/Haskell Implementation/Limited-path-models inducer

See section ‘Optimisation’ P674. The limited-path-models tuple partition list maximiser, $Z_{P,A,A_R,\mathrm{csd},\mathrm{p} }$, is constructed \[ \begin{eqnarray} &&Z_{P,A,A_R,\mathrm{csd},\mathrm{p} } = \\ &&\hspace{2em}\mathrm{maximiseLister}(X_{P,A,A_R,\mathrm{csd},\mathrm{p} }, P_{P,A,A_R,\mathrm{csd},\mathrm{p} }, \mathrm{top}(\mathrm{omax}), R_{P,A,A_R,\mathrm{csd},\mathrm{p} }) \end{eqnarray} \] The optimise function $X_{P,A,A_R,\mathrm{csd},\mathrm{p} } \in \mathcal{F}_{\infty,U_A,V_A} \cap \mathcal{F}_{\mathrm{q} } :\to \mathbf{Q}$, is the rational approximation to the shuffle content alignment valency-density valued total function of the limited-models infinite-layer substrate fuds, defined \[ X_{P,A,A_R,\mathrm{csd},\mathrm{p} } = \{(F,I_{\mathrm{csd} }^{ * }((A,A_R,F))) : F \in \mathcal{F}_{\infty,U_A,V_A} \cap \mathcal{F}_{\mathrm{q} }\} \] where the shuffle content alignment valency-density computer $I_{\mathrm{csd}} \in \mathrm{computers}$ is defined as (Text) \[ \begin{eqnarray} I_{\mathrm{csd} }^{ * }((A,A_R,F)) = (I_{\mathrm{a} }^{ * }(A * F^{\mathrm{T} })-I_{\mathrm{a} }^{ * }(A_R * F^{\mathrm{T} }))/I_{\mathrm{cvl} }^{ * }(F) \end{eqnarray} \] The $I_{\mathrm{csd} }^{ * }$ function is defined in module AlignmentPracticable,

systemsHistogramsHistogramsFudsAlignmentCsd_u :: System -> Histogram -> Histogram -> Fud -> Double

as

systemsHistogramsHistogramsFudsAlignmentCsd_u uu aa aarr ff = 
    (algn (aa `fmul` ff) - algn (aarr `fmul` ff)) / (w ** (1/m))
...

Note that the _u suffix indicates that there are no bounds checking guards on the arguments.

The neighbourhood function $P_{P,A,A_R,\mathrm{csd},\mathrm{p} } \in \mathrm{P}(X_{P,A,A_R,\mathrm{csd},\mathrm{p} }) \to \mathrm{P}(X_{P,A,A_R,\mathrm{csd},\mathrm{p} })$, derived from the limited-layer limited-derived-volume limited-underlying-volume limited-breadth partition infinite-layer fud tree, $\mathrm{tfiubhd}(U)(V)$, is defined (Text) \[ \begin{eqnarray} &&P_{P,A,A_R,\mathrm{csd},\mathrm{p} }(Q) =\\ &&\hspace{2em}\{(F \cup G,I_{\mathrm{csd} }^{ * }((A,A_R,F \cup G))) : \\ &&\hspace{3em}(F,\cdot) \in Q,~\mathrm{layer}(F,\mathrm{der}(F)) < \mathrm{lmax},\\ &&\hspace{3em}G \subseteq \{P^{\mathrm{T} } : K \in \mathrm{tuples}(V_A,F),~|K^{\mathrm{C} }| \leq \mathrm{xmax},~P \in \mathrm{B}(K^{\mathrm{CS} }),~|P| \geq 2\},\\ &&\hspace{3em}1 \leq |G| \leq \mathrm{bmax},\\ &&\hspace{3em}W = \mathrm{der}(F \cup G), ~|W^{\mathrm{C} }| \leq \mathrm{wmax}\} \end{eqnarray} \] The neighbourhood function is defined in module AlignmentPracticable,

parametersSystemsSamplesShufflesFunctionsFunctionNeighbourhoodPartitionLimitedPathModels :: 
  Integer -> Integer -> Integer -> Integer -> 
  System -> Histogram -> Histogram -> Map.Map Fud Double -> Maybe (Map.Map Fud Double)

as

parametersSystemsSamplesShufflesFunctionsFunctionNeighbourhoodPartitionLimitedPathModels 
  xmax bmax wmax lmax uu aa aarr qq
  | ... = Just $ llmm 
    [(hh, (algn (aa `fmul` hh) - algn (aarr `fmul` hh)) / (w' ** (1/m))) | 
        ff <- keys qq, layer ff < lmax, let uu2 = (uu `uunion` fsys ff),
        gg <- llfudsll bmax [qqtt pp | kk <- tuplesll (vars aa) ff, vol uu2 kk <= xmax, 
                                       pp <- partsll (cart uu2 kk), dim pp >= 2], 
        gg /= fudEmpty, let hh = ff `funion` gg, 
        let ww = fder hh, let w = vol (uu `uunion` fsys hh) ww, w <= wmax, 
        let w' = fromIntegral w, let m = fromIntegral (Set.size ww)]
  | otherwise = Nothing
  where
    algn = histogramsAlignment
    tuplesll vv ff = Set.toList $ setVariablesFudsSetTuple vv ff
    llfudsll bmax ll = Set.toList $ Set.map qqff $ setsPowersetLimited (Set.fromList ll) bmax
    ...
    partsll = Set.toList . setsPartitionSet
    ...

Note that the neighbourhood function could also be implemented with the $I_{\mathrm{csd} }^{ * }$ function mentioned above.

For the first layer, $F = \emptyset$, the set of next layer fuds corresponds to the non-empty pluri-valent partition-sets of the intersection of (i) the lower-limited-valency substrate partition-sets set $\mathcal{N}_{U,V,\mathrm{umin} }$, where $\mathrm{umin}=2$, (ii) the limited-underlying-volume substrate partition-sets set, $\mathcal{N}_{U,V,\mathrm{xmax} }$, (iii) the limited-breadth substrate partition-sets set, $\mathcal{N}_{U,V,\mathrm{bmax} }$, (iv) and the limited-derived-volume substrate partition-sets set, $\mathcal{N}_{U,V,\mathrm{wmax} }$, \[ \begin{eqnarray} &&|P_{P,A,A_R,\mathrm{csd},\mathrm{p} }(\{(\emptyset,\cdot)\})| = \\ &&\hspace{5em}|\mathcal{N}_{U,V,\overline{2} } \cap \mathcal{N}_{U_A,V_A,\mathrm{xmax} } \cap \mathcal{N}_{U_A,V_A,\mathrm{bmax} } \cap \mathcal{N}_{U_A,V_A,\mathrm{wmax} }| - 1 \end{eqnarray} \] In the case of pluri-valent regular variables $V$, having valency $d>1$ and dimension $n$, if the implied underlying-dimension limit, $\mathrm{kmax} = \ln \mathrm{xmax}~/ \ln d$, is integral, $\ln \mathrm{xmax}~/ \ln d \in \mathbf{N}$, then the cardinality of the intersection is \[ \begin{eqnarray} &&|\mathcal{N}_{U,V,\overline{2} } \cap \mathcal{N}_{U,V,\mathrm{xmax} } \cap \mathcal{N}_{U,V,\mathrm{bmax} }| = \\ &&\hspace{5em}\bigg(\sum_{b \in {0 \ldots \mathrm{bmax}} } \binom{c}{b}\bigg)~:~c = \sum_{k \in {0 \ldots \mathrm{kmax}} } \binom{n}{k} (\mathrm{bell}(d^k)-1) \end{eqnarray} \] The intersection is defined in module AlignmentSubstrate,

valenciesDimensionsLimitsSetSetPartitionSubstrateLimitedUnderlyingDimensionBreadthPluriValentCardinalityRegular :: 
  Integer -> Integer -> Integer -> Integer -> Maybe Integer

as

valenciesDimensionsLimitsSetSetPartitionSubstrateLimitedUnderlyingDimensionBreadthPluriValentCardinalityRegular d n kmax bmax
  | n >= 0 && d > 0 && bmax >= 0 = Just $ 
      let c = sum [binom n k * (bell (d^k) - 1) | k <- [0..(min n kmax)]] in sum [binom c b | b <- [0..(min c bmax)]]
  | otherwise = Nothing
...

For example,

let nnvvkbmaxpvcdr d n kmax bmax = fromJust $ valenciesDimensionsLimitsSetSetPartitionSubstrateLimitedUnderlyingDimensionBreadthPluriValentCardinalityRegular d n kmax bmax

[(d,n,d^kmax,bmax,nnvvkbmaxpvcdr d n kmax bmax) | d <- [2..5], n <- [2..5], kmax <- [1..3], bmax <- [2..4], nnvvkbmaxpvcdr d n kmax bmax <= 200]
[(2,2,2,2,4),(2,2,2,3,4),(2,2,2,4,4),(2,2,4,2,137),(2,2,8,2,137),(2,3,2,2,7),(2,3,2,3,8),(2,3,2,4,8),(2,4,2,2,11),(2,4,2,3,15),(2,4,2,4,16),(2,5,2,2,16),(2,5,2,3,26),(2,5,2,4,31),(3,2,3,2,37),(3,2,3,3,93),(3,2,3,4,163),(3,3,3,2,79),(3,4,3,2,137)]

let ppcsdwp xmax bmax wmax aa  = fromJust $ parametersSystemsSamplesShufflesFunctionsFunctionNeighbourhoodPartitionLimitedPathModels xmax bmax wmax 1 (sys aa) aa (ind aa) (Map.singleton fudEmpty 0)

let ppcsdwpinvll xmax bmax wmax aa = Map.toList $ functionsInverse $ ppcsdwp xmax bmax wmax aa

let ppcsdwpmax xmax bmax wmax aa = Set.findMax $ relationsMaximum $ functionsRelation $ ppcsdwp xmax bmax wmax aa

let aa = resize 100 (regpivot 3 2)

Map.size (ppcsdwp (3^1) 2 (3^1) aa)
8

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 2 (3^1) aa]
"(0.0,8)"

Map.size (ppcsdwp (3^1) 2 4 aa)
23

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 2 4 aa]
"(0.0,14)"
"(0.6832378262846674,4)"
"(5.076597698514661,2)"
"(5.076597698514675,2)"
"(23.159383609286493,1)"

(algn aa)/3
14.464725491153994

rp $ ppcsdwpmax (3^1) 2 4 aa
"({({({(1,1),({ { {(1,1)} },{ {(1,2)},{(1,3)} } },{ {(1,1)} })},1 % 1),({(1,2),({ { {(1,1)} },{ {(1,2)},{(1,3)} } },{ {(1,2)},{(1,3)} })},1 % 1),({(1,3),({ { {(1,1)} },{ {(1,2)},{(1,3)} } },{ {(1,2)},{(1,3)} })},1 % 1)},{ { { {(1,1)} },{ {(1,2)},{(1,3)} } } }),({({(2,1),({ { {(2,1)} },{ {(2,2)},{(2,3)} } },{ {(2,1)} })},1 % 1),({(2,2),({ { {(2,1)} },{ {(2,2)},{(2,3)} } },{ {(2,2)},{(2,3)} })},1 % 1),({(2,3),({ { {(2,1)} },{ {(2,2)},{(2,3)} } },{ {(2,2)},{(2,3)} })},1 % 1)},{ { { {(2,1)} },{ {(2,2)},{(2,3)} } } })},23.159383609286493)"

let (ff,_) = ppcsdwpmax (3^1) 2 4 aa

algn $ aa
43.39417647346198

algn $ aa `fmul` ff
117.62895517637247

Map.size (ppcsdwp (3^1) 2 (3^2) aa)
36

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 2 (3^2) aa]
"(0.0,20)"
"(0.6832378262846674,4)"
"(4.153144930067293,4)"
"(5.076597698514661,2)"
"(5.076597698514675,2)"
"(14.464725491153994,1)"
"(18.290281632910705,1)"
"(18.290281632910716,1)"
"(23.159383609286493,1)"

Map.size (ppcsdwp (3^1) 3 (3^3) aa)
92

nnvvkbmaxpvcdr 3 2 1 3
93

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 3 (3^3) aa]
"(0.0,28)"
"(0.6832378262846674,4)"
"(4.153144930067293,4)"
"(4.443504556997696,12)"
...
"(22.400928626215162,3)"
"(22.400928626215176,3)"
"(23.159383609286493,1)"

let aa = resize 100 (regpivot 3 3)

Map.size (ppcsdwp (3^1) 2 (3^3) aa)
78

nnvvkbmaxpvcdr 3 3 1 2
79

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 2 (3^3) aa]
"(0.0,30)"
"(0.2460860038704027,12)"
"(2.306159747968083,12)"
"(2.8214219702236107,12)"
"(9.739865187690867,3)"
"(12.451311893917975,6)"
"(15.918481590327701,3)"

Map.size (ppcsdwp (3^1) 3 (3^3) aa)
298

nnvvkbmaxpvcdr 3 3 1 3
299

rpln $ sort $ [(a, Set.size xx) | (a,xx) <- ppcsdwpinvll (3^1) 3 (3^3) aa]
"(0.0,42)"
"(0.2460860038704027,12)"
"(0.86007688761201,8)"
"(2.306159747968083,12)"
"(2.467390741669783,36)"
...
"(21.303162058872793,3)"
"(25.97257020581094,3)"
"(31.253377751394225,1)"

bell (3^1)
5

bell (3^2)
21147

nnvvkbmaxpvcdr 3 3 2 2
2012982976

nnvvkbmaxpvcdr 3 3 2 3
42573918990376

top