Finds a path between two permutation states using iterative cycle expansion. Generates random operation sequences, analyzes their cycles, and looks for intersections between forward (from start) and backward (from final) state sets. Uses bridge states to progressively narrow the search space.
find_path_iterative(
start_state,
final_state,
k,
moves = c("1", "2", "3"),
combo_length = 20,
n_samples = 200,
n_top = 10,
max_iterations = 10,
potc = 1,
ptr = 10,
opd = FALSE,
reuse_combos = FALSE,
distance_method = "manhattan",
verbose = TRUE
)List containing:
Character vector of operations, or NULL if not found
Logical, whether a path was found
Number of iterations used
Details about the selected intersection
List of forward bridge states
List of backward bridge states
Integer vector, the starting permutation state
Integer vector, the target permutation state
Integer, parameter for reverse operations
Character vector, allowed operations (default c("1", "2", "3"))
Integer, length of random operation sequences (default 20)
Integer, number of random sequences to test per iteration (default 200)
Integer, number of top sequences to analyze fully (default 10)
Integer, maximum number of search iterations (default 10)
Numeric in (0,1], fraction of cycle states to keep (default 1)
Integer, max intersections to process per iteration (default 10)
Logical, if TRUE filters states to only combos containing bridge state (default FALSE)
Logical, if TRUE generates random combos only once per side (cycle 1) and reuses them in subsequent cycles. Saves time but reduces diversity (default FALSE)
Character, method for comparing states during bridge selection. One of "manhattan" (sum of absolute differences) or "breakpoints" (number of adjacency violations). Default "manhattan".
Logical, if TRUE prints progress messages (default TRUE)
# Small example
set.seed(42)
start <- 1:6
final <- c(3L, 1L, 2L, 6L, 4L, 5L)
# result <- find_path_iterative(start, final, k = 3, max_iterations = 5)
Run the code above in your browser using DataLab