random_design_candidate: Create a random design_object candidate

View source: R/random.R

random_design_candidateR Documentation

Create a random design_object candidate

Description

Sample from the candidate set to create a random design_object. If level occurrences are specified, single rows are swapped with random rows from the candidate set until the design_object candidate satisfies them. A swap is kept if it does not move the design_object candidate further away from the level occurrences.

Usage

random_design_candidate(
  utility,
  candidate_set,
  rows,
  sample_with_replacement,
  print_counter = FALSE,
  max_attempts = 1e+05
)

Arguments

utility

A named list of utility functions. See the examples and the vignette for examples of how to define these correctly for different types of experimental designs.

candidate_set

A matrix or data frame in the "wide" format containing all permitted combinations of attributes. The default is NULL. If no candidate set is provided, then it is built from the utility functions subject to specified exclusions with build_candidate_set. This is passed in as an object and not a character string. The candidate set will be expanded to include zero columns to consider alternative specific attributes.

rows

An integer giving the number of rows in the final design

sample_with_replacement

A boolean equal to TRUE if we sample from the candidate set with replacement. The default is FALSE

print_counter

A boolean equal to TRUE if we print the number of attempts to find a design candidate every 1000th attempt. The default is FALSE

max_attempts

The maximum number of swaps to try before stopping with an error. The default is 100000.


spdesign documentation built on Oct. 6, 2026, 9:07 a.m.