dwave.optimization.model.Model.disjoint_bit_sets#

Model.disjoint_bit_sets(primary_set_size, num_disjoint_sets)#

Create a disjoint-sets symbol as a decision variable.

Divides a set of the elements of range(primary_set_size) into num_disjoint_sets ordered partitions, stored as bit sets (arrays of length primary_set_size, with ones at the indices of elements currently in the set, and zeros elsewhere). The ordering of a set is not semantically meaningful.

Also creates from the symbol num_disjoint_sets extra successors that output the disjoint sets as arrays.

Parameters:
  • primary_set_size – Number of elements in the primary set that are partitioned into disjoint sets. Must be non-negative.

  • num_disjoint_sets – Number of disjoint sets. Must be positive.

Returns:

A tuple where the first element is the disjoint-sets symbol and the second is a set of its newly added successors.

Examples

This example creates a symbol of 10 elements that is divided into 4 sets.

>>> from dwave.optimization.model import Model
>>> model = Model()
>>> parts_set, parts_subsets = model.disjoint_bit_sets(10, 4)