Skip to contents

Declares one permutation of a program(): size items in size slots, one item per slot (see perm_var()). perm_var() builds these for you.

Usage

permutation_decl(size, start = integer(), fixed = FALSE, precede = list())

Arguments

size

How many items, at least 2.

start

The arrangement the search starts from: start[i] is the slot of item i, so start contains each of the numbers 1 to size once. integer() starts with item i in slot i.

fixed

Whether the permutation is fixed at start, which must then be given. This is how evaluate() and resample() keep the arrangement of a solution.

precede

A list of pairs c(before, after), each requiring item before to be in an earlier slot than item after.

Value

A plain list without a class, with the fields kind = "permutation", size, start, fixed and precede. It is an element of the named list a program() takes as structures, and the element's name is the name ir_struct_ref() refers to.

Examples

# five stops, stop 4 before stop 1
structures <- list(route = permutation_decl(5, precede = list(c(4, 1))))