optimize_SeqCA: Simulated Annealing for improving an SeqCA

View source: R/optimize_SeqCA.R

simulated_annealing_scaR Documentation

Simulated Annealing for improving an SeqCA

Description

for k columns and strength t for the third stage of an algorithm by Torres-Jimenez et al. (2022)

Usage

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, ...)

Arguments

A

an SeqCA of strength t, or for simulated_annealing_sca, a partial SeqCA for which coverage is to be completed

t

the strength for which the coverage of all permutations of length t must be guaranteed for all combn(k,t) t-element subsets of 1,...,k (k the number of columns of A)

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 maxAccepted, maxAttempts, initialTemperature, finalTemperature, temperatureReduction, probreshuffle

Value

in case of success, a strength t SeqCA with k columns is returned; all rows contain the integers 1 to k.

Details

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.

Use of AI

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.

Warning

The implementation of simulated annealing is very preliminary, and the probreshuffle argument does not work yet for positive probabilities.

Author(s)

Ulrike Groemping

References

Torres-Jimenez et al. (2022)

See Also

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

Examples

## 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)


CAs documentation built on Nov. 29, 2026, 1:06 a.m.