View source: R/optimize_SeqCA.R
| simulated_annealing_sca | R Documentation |
for k columns and strength t for the third stage of an algorithm by Torres-Jimenez et al. (2022)
optimize_SeqCA(A, t, sa_params = list(), target=factorial(t),
skipsa=FALSE, skipreduce=FALSE, verbose = FALSE, ...)
simulated_annealing_sca(A, t, maxAccepted = 100, maxAttempts = 500,
initialTemperature = 100, finalTemperature = 0.1,
temperatureReduction = 0.95, probreshuffle=0, verbose = FALSE, ...)
A |
an SeqCA of strength |
t |
the strength for which the coverage of all permutations of length t must be guaranteed for all |
maxAccepted |
positive integer, maximum accepted perturbations for each temperature; default 100 |
maxAttempts |
positive integer, maximum attempts for each temperature; default 500 |
initialTemperature |
positive number, default 100 |
finalTemperature |
positive number, less than initialTemperature, default 0.1 |
temperatureReduction |
positive number, less than 1; the closer to 1, the slower the temperature reduction, and the more temperatures are run; default 0.95, corresponding to 135 temperatures with the other defaults |
probreshuffle |
probability of a proper reshuffle in case that is possible; value between 0 and 1; positive values do not work yet. |
verbose |
logical; if TRUE, printing progress information |
... |
currently not used |
skipsa |
logical, default FALSE; if TRUE, simulated annealing is suppressed |
skipreduce |
logical, default FALSE; if TRUE, the initial iterative reduction step is suppressed (useful if the SeqCA is the result of such a reduction) |
target |
number of rows at which no further improvement is attempted; defaults to the number of permutations needed to cover all orders for a single t-tuple, which is likely unachievable for most relevant problem sizes |
sa_params |
list of parameters whose default values are to be changed; all parameters not in the list keep their default states; the possible paramters are |
in case of success, a strength t SeqCA with k columns is returned; all rows contain the integers 1 to k.
The function simulated_annealing_sca implements the simulated annealing
approach of Torres-Jimenez et al. (2022).
It can be applied directly to a partial SeqCA, but its main purpose is being called by function
optimize_SeqCA for reducing the number of rows of an existing strength t SeqCA (see below).#'
The perturbation function was not described in detail by Torres-Jimenez et al. 2022; they only
stated that the correct order for a currently non-covered randomly selected sequence is forced
for the row for which this action creates the fewest missings.
This is implemented in the internal perturbation function within function
simulated_annealing_sca by simply reordering the sequence elements
(which might of course break existing coverages of the row, but might also bring useful new coverages).
optimize_SeqCA implements a workflow for applying
reduce_rows_iterative_complete and subsequently applying simulated
annealing repeatedly.
Torres-Jimenez et al. (2022) describe a 3-stage approach, the third stage of which is
simulated annealing. Simulated annealing is invoked if postprocessing of an initial greedy SeqCA
is unable to find further rows that can be removed without deteriorating coverage.
The post-processing and simulated annealing are combined in function optimze_SeqCA.
While the simulated annealing is needed for
achieving the very good performance that the paper reports on,
it can be very slow.
Therefore, it can be suppressed by setting skipsa=TRUE, in which case the function
optimize_SeqCA is basically a wrapper for reduce_rows_iterative_complete.
The paper claims that the method is most useful for larger problems;
but for these, the run time will often be prohibitive.
If optimize_SeqCA is stuck in simulated annealing iterations,
having achieved some progress but neither improving nor finishing, the process can
be interrupted by pressing the <ESC>-key, in which case it will return
the last successful outcome.
Claude 4 was heavily involved in the development of these functions, by initially implementing the simulated annealing pseudo code from the paper; it worked reasonably well for everything except implementing the perturbation.
The implementation of simulated annealing is very preliminary,
and the probreshuffle argument does not work yet for positive probabilities.
Ulrike Groemping
Torres-Jimenez et al. (2022)
greedySeqCA_TJ() for the greedy method by
Torres-Jimenez et al. (2022) and
reduce_rows_iterative_complete() for the
postoptimization stage method of that paper that is used as the first stage of function
optimize_SeqCA
## a small SeqCA with originally 13 rows
A_TJ <- greedySeqCA_TJ(6,3, postopt = FALSE, seed=2323)
dim(A_TJ)
## on Windows, the above A_TJ is quickly postoptimized to 9 runs
A_TJ_reduced <- optimize_SeqCA(A_TJ, 3, target=9, verbose=TRUE)
coverageSeqCA(A_TJ_reduced, 3)
## one less row is possible, but requires a somewhat slow simulated
## annealing optimization
A_TJ_reduced8 <- optimize_SeqCA(A_TJ, 3, target=8, verbose=TRUE)
# NOTE: example() skips the following code,
# unless the user specifies
# options(run_heavy_examples = TRUE)
## without setting the optimization target, one would have to wait until
## the simulated annealing for reducing to 7 runs failed
optimize_SeqCA(A_TJ_reduced, 3, verbose=TRUE, skipreduce=TRUE)
## Here: Kuhn much slower than TJ
nrow(A <- greedySeqCA_Kuhn(6, 4, seed=75)) ## 52 before, 41 after reduce
## Not run:
## this should only be run interactively, with a user prepared
## to interrupt it if it seems stuck
aus <- optimize_SeqCA(A, 4, skipreduce=TRUE, verbose=TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.