| markflex | R Documentation |
Functions for manipulating flexible values: determination of flexible positions (flexpos), determination of a flexible set (markflex), and calculation of the profile (flexprofile); furthermore, postopNCK for the Nayeri, Konjevod and Colbourn (2013) postprocessing based on flexible values
flexpos(D, t, nocafast=FALSE, ...)
uniquecount(D, t, ...)
markflex(D, t, fixrows=0, verbose=0, nocafast=FALSE, ...)
flexprofile(D, ...)
postopNCK(D, t, fixrows=0, verbose=0, outerRetry = NULL, outerMaxnochange = 10,
innerRetry=NULL, innerMaxnochange=25, seed=NULL, nocafast=FALSE, ...)
D |
an N x k CA of strength t with v levels, coded from 0 to v-1 or from 1 to v; flexible values, if any, must be denoted as |
t |
integer-valued (>=2), the strength of |
fixrows |
integer from 0 to |
verbose |
integer-valued degree of verbosity; 1 requests that the latest stages of unsuccessful attempts are added as an attribute to the returned unchanged matrix in case of a failure |
nocafast |
logical; if |
... |
can be used to hand additional arguments to |
outerRetry |
|
outerMaxnochange |
integer-valued number of iterations to try and find optimum positions within a candidate row or its automatically-determined replacements |
innerRetry |
|
innerMaxnochange |
integer-valued number of iterations to try and find optimum positions within a candidate row or its automatically-determined replacements |
seed |
|
Function flexpos returns a logical matrix with TRUE values indicating
flexible positions of D. Any position that is already NA in D is set to TRUE.
Function markflex returns the ingoing CA, with values denoted as before,
with rows potentially reordered (for facilitating all-flexible rows),
and with flexible positions changed to NA. this may change
Function postopNCK returns an object of class CA with prior attributes preserved
and attributes Call and seed augmented by the postopNCK call details.
Functions flexpos, markflex and postopNCK call
their faster C-pendant from package cafast, whenever that package is
available and its use is not suppressed by nocafast=TRUE.
Function flexpos marks flexible positions, i.e. positions all of whose t-way interactions are also covered
in at least one tuple without them. It will not work to treat all these positions as flexible at the same time,
because this would eliminate all instances of the affected interactions.
Function markflex uses the greedy algorithm of @nayeriRandomizedPostoptimizationCovering2013 for marking elements
as flexible. It makes use of function flexpos for swapping rows so that it becomes more likely that entire rows
consist of wildcards (flexible set points).
It works reasonably fast for strength 2 or small k, but becomes slow for larger strength and/or many columns.
Nayeri et al. (2013) ascertain that the determination of the maximum set of flexible points is an NP-hard problem, and
this algorithm is not guaranteed to find the maximum flexible set.
The returned flexible positions tend to be at the bottom of the array.
Function flexprofile obtains the profile of column-wise flexible values for D.
Function postopNCK likely needs some tuning for speed and efficiency,
but is nevertheless often successful; if the suggested package cafast
is available, its C-implementation of the function is used, including the larger default
values from that implementation, because it is substantially faster.
The function attempts to remove rows by trying to make entire rows
contain flexible values; in fact, it removes rows that have fewer than t non-flexible values,
as those cannot contribute to t-coverage. It implements a variant of the proposed algorithm by Nayeri et al. (2013).
If successful, it returns D after removal of as many as possible flexible
rows, as created by markflex. If that immediate and cheap approach does not
work, the function tries to iteratively improve the number of flexible values in the
last row, until the row has flexible entries only. If that is not successful in a given
number of iterations (innerMaxnochange),
an inner retry step switches to a different last row to make flexible
(at most innerRetry attempts).
An outer loop makes outerRetry such
attempts and keeps the user informed via messages about the current status.
If the user interrupts via the keyboard (<Esc> or <Ctrl>-<c>),
the result of the latest successful outer retry is returned (make sure to
not abort iterations before the next outer retry was started).
Without such an interrupt, if no attempt is successful,
the function returns the unchanged input matrix,
adding as an attribute a list with the last states of each retry,
if requested by the verbose argument.
Nayeri, Colbourn and Konjevod (2013)
cafast::postopNCK_c(), cafast::markflex_c() and cafast::flexpos_c()
that implement the same functionality as the R-based functions of this package
in C and are thus much faster
# identify flexible values
A <- cyc(19,2)
coverage(A, 3)
(AwithFlex <- markflex(A, 3))
coverage(AwithFlex, 3)
caverify::ca_verify(AwithFlex, 3)
## also works for mixed levels
(L18withFlex <- markflex(DoE.base::L18, 2))
flexprofile(L18withFlex)
## last two rows removable
## row 16 only needed for pair 23 in first two columns
## change element [8,1] to 2 --> row 16 becomes removable
L18withFlex[8,1] <- 2
flexprofile(L18withFlex) ## frequency reduced by 1 for column 1
(L18withFlexmod <- markflex(L18withFlex, 2))
## now, three rows can be removed
coverage(L18withFlexmod[1:15,], 2, start0=FALSE)
## do the replacement on the raw design
L18mod <- DoE.base::L18; L18mod[8,1] <- 2
(L18modwithFlex <- markflex(L18mod, 2, flexible="NA"))
## example of Colbourn and Torres-Jimenez (2013)
## Figure 2 of the paper
hilf <- strsplit(c("2222001", "0022222", "1121201", "0120110",
"2210202", "2102122", "1200020", "0211121",
"1012100", "2001210", "0000001", "1111012",
"2222222", "2222011"), "")
plan <- do.call(rbind, lapply(hilf, as.numeric))
dim(plan)
## flexpos marks all positions that are not involved in any unique pairs
flexpos(plan, 2)
## these cannot be simultaneously made flexible
## markflex creates actual flexible values (=don't care values)
## and moves flexible rows to the end
(planMod <- markflex(plan, 2))
## there are two rows with all values flexible (can be omitted)
coverage(planMod[1:12,], 2) ## now optimal
eCAN(2,7,3)
## fixing the first two rows from being moved
## allows only one row to be removed
## fixing rows comes at a price
(planMod2 <- markflex(plan, 2, fixrows=2))
## if removal of rows is the goal,
## postopNCK does the entire job automatically
## and very fast for this trivial case
plan_postopNCK <- postopNCK(plan, 2, outerRetry=1)
dim(plan_postopNCK)
coverage(plan_postopNCK, 2)
## postopNCK is fast on trivial problems like the above,
## but may take its time otherwise
## such examples can be found in the help for MCA2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.