R/shuffle_samples.R
mk_swapping_function.Rd
If length(n_swaps)==1
, the returned function may be called an arbitrary number of times.
If length(n_swaps)>1
and called without argument, the returned function may be called length(n_swaps) timed before returning NULL, which would be the stopping criterion if all requested swaps have been exhausted. Alternatively, the function may be called with an iteration number as the only argument, giving the user some freedom how to iterate over the sample swapping protocol.
mk_swapping_function(n_swaps = 1)
Vector with number of swaps to be proposed in successive calls to the returned function (each value should be in valid range from 1..floor(n_samples/2)
)
Function to return a list with length n vectors src
and dst
, denoting source and destination index for the swap operation, or NULL if the user provided a defined protocol for the number of swaps and the last iteration has been reached.
data("invivo_study_samples")
bc <- BatchContainer$new(
dimensions = c("plate" = 2, "column" = 5, "row" = 6)
)
scoring_f <- osat_score_generator("plate", "Sex")
optimize_design(
bc, scoring = scoring_f, invivo_study_samples,
max_iter = 100,
shuffle_proposal_func = mk_swapping_function(1)
)
#> Warning: NAs in features / batch columns; they will be excluded from scoring
#> Checking variances of 1-dim. score vector.
#> ... (418.374) - OK
#> Initial score: 182.5
#> Achieved score: 132.5 at iteration 1
#> Achieved score: 90.5 at iteration 5
#> Achieved score: 56.5 at iteration 11
#> Achieved score: 30.5 at iteration 23
#> Achieved score: 12.5 at iteration 24
#> Achieved score: 2.5 at iteration 26
#> Achieved score: 0.5 at iteration 36
#> Batch container with 60 locations and 59 samples (assigned).
#> Dimensions: plate, column, row