Variables¶
Decision variable types.
Every variable is stored as a flat block of codes in [0, 1] (random keys). A variable knows how many codes it needs, how to turn codes into values (decode), and how to turn values back into codes (encode). Decoding is batch first: codes have shape (n, code_size), and values have shape (n, *shape). Partition variables return lists, because their groups have different sizes.
Indices in decoded permutations, selections and partitions are zero-based.
Real ¶
Real(name, shape=None, lb=0.0, ub=1.0)
Continuous values in [lb, ub]. Bounds may be arrays. The shape follows them if not given.
Permutation ¶
Permutation(name, n, count=None)
A permutation of 0..n-1. With count, a (count, n) array with one permutation per row.
Selection ¶
Selection(name, n, k, count=None)
An ordered selection of k distinct items out of n (zero-based indices).
BinarySelection ¶
BinarySelection(name, n, k, count=None)
A 0/1 mask of length n with exactly k ones.
Partition ¶
Partition(name, n, k, count=None)
Split items 0..n-1 into k groups (some may be empty). Decodes to a list of k index arrays.
The code has n + k - 1 keys: n items and k - 1 separators, sorted together.
BinaryPartition ¶
BinaryPartition(name, n, k, count=None)
Like Partition, but decodes to a (k, n) 0/1 assignment matrix.
FixedSum ¶
FixedSum(name, shape, target=1.0, axis=None)
Nonnegative reals with a fixed sum.
axis=None fixes the sum of all elements, axis=1 the sum of each row, and
axis=0 the sum of each column. target is a scalar, or one value per row or column.