| DHF2CA | R Documentation |
Function to construct a larger CA by replacing levels of a DHF with columns of a smaller CA
DHF2CA(P, D, v = max(D) + 1, unique=TRUE, ...)
P |
an M x k DHF of strength t with w levels and at least v classes (a PHF of strength t with w levels is a special case) |
D |
an N x w CA of strength t with |
v |
number of levels of |
unique |
logical; if |
... |
further arguments to function |
a CA(chi + (N-rho) * M, t, k, v) (matrix, not of class ca, as there are no
guarantees regarding the strength, because guarding this is left to the user or to calling functions).
A PHF is a perfect hash family, a DHF a distributed hash family (weaker condition).
Function DHF2CA yields a CA(chi + (N-rho)*M, t, k, v) from replacing the levels
of the DHF (or the PHF) with the columns of the CA, leaving out the constant rows of the CA
and adding a few (chi) back in, if needed, where chi=max(0, rho - (M - 1)(v - rho)),
according to Corollary 2.4 of Colbourn and Torres-Jimenez (2010).
The function uses function maxconstant to maximize the constant rows of the CA.
The function does not check for the strengths of the ingoing arrays. Hence, it is the users responsibility to ensure that these are as needed.
Colbourn, Dougherty and Horsley (2019) and references therein, as well as Colbourn and Torres-Jimenez 2010.
#########################################
## DHF2CA
#########################################
## example from Table 1 of Colbourn and Torres-Jimenez
P <- t(SCA_Bose(11)[,1:3])
dim(P) ## levels 0, ..., 10
D <- paleyCA(3,11) ## 2-level, one constant row
dim(D)
(chi <- max(0, 1 - 2*(2-1)))
aus <- DHF2CA(P, D)
dim(aus) ## 0 + 3*(12-1) rows, 121 columns
eCAN(3, 121, 2) ## optimal
# further examples are demos only, they are not for good use cases
# a DHF[4,10,4,4,2], i.e., 4 rows, 10 columns, 4 levels, strength 4, 2 partitions
# from Colbourn et al. 2021, Table 1
P <- cbind(rep(1,4), c(1, rep(2,3)), c(1, rep(3,3)),
rbind(2, rbind(1:3, c(2:3,1), c(3, 1:2))),
rbind(3, rbind(1:3, c(3, 1:2), c(2:3, 1))),
rep(4,4))
## CA with v=2 levels, 4 columns, strength 4 (--> full factorial)
D <- as.matrix(expand.grid(0:1,0:1,0:1,0:1)) ## two rows can be made constant
(chi <- max(0, 2 - 3*(2-2)))
aus <- DHF2CA(P, D, unique=FALSE)
dim(aus) ## 2 + 4*(16-2)= 58 rows, 10 columns
aus <- DHF2CA(P, D)
dim(aus) ## 52 x 10
## 6 duplicate rows removed
## (this happens for poorly chosen ingredients)
coverage(aus, 4) ## works
# a PHF(4,4,19,9) from the Dwyer catalogue
P <- rbind(c(4, 2, 3, 7, 4, 0, 1, 2, 5, 3, 4, 5, 7, 6, 1, 0, 1, 8, 8),
c(6, 2, 8, 4, 2, 1, 1, 0, 7, 5, 3, 8, 7, 4, 0, 4, 5, 6, 8),
c(7, 1, 4, 0, 2, 5, 8, 5, 1, 7, 5, 3, 6, 4, 0, 3, 2, 6, 8),
c(4, 8, 5, 0, 0, 1, 2, 5, 1, 1, 7, 7, 2, 4, 3, 8, 6, 3, 0))
# we need a strength 4 CA with nine columns
D <- paleyCA(4, 9) ## is current best, has two constant rows
aus <- DHF2CA(P, D, unique=FALSE)
(chi <- max(0, 2 - (4-1)*(2-2)))
dim(aus) ## not competitive, although D is optimal 2 + (24-2)*4
aus <- DHF2CA(P, D)
dim(aus) ## 38 duplicate rows removed, still relevantly worse than current best
Ns(4, 19, 2)
## best for 6-level is in DWYERcat, 2768 runs for 9 columns in 6 levels
pathGH <- "https://raw.githubusercontent.com/aadwyer/CA_Database/main/Repository/CA"
# the instruction line starts with a comment character and is ignored,
# therefore ninstruct=0
D <- readCA(paste0(pathGH, "/CA_2768_4_9_6.txt"), ignore.chars=c("]", "["),
ninstruct=0, sep=",")
## DHF2CA needs quite a while for this case
## activated one_is_enough argument for maxconstant for run time reasons
aus <- DHF2CA(P, D, one_is_enough=TRUE) ##
(chi <- max(0, 1 - (2-1)*(6-1)))
dim(aus) ## 4*2767 = 11068, much more than the 5422 in the Colbourn tables
coverage(aus, 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.