dwave.optimization.model.Model.disjoint_lists#

Model.disjoint_lists(primary_set_size, num_disjoint_lists)#

Create a disjoint-lists symbol as a decision variable.

Divides a set of the elements of range(primary_set_size) into num_disjoint_lists ordered partitions.

Also creates num_disjoint_lists extra successors from the symbol that output the disjoint lists as arrays.

Parameters:
  • primary_set_size – Number of elements in the primary set to be partitioned into disjoint lists.

  • num_disjoint_lists – Number of disjoint lists.

Returns:

A tuple where the first element is the disjoint-lists symbol and the second is a list of its newly added successor nodes.

Examples

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

>>> from dwave.optimization.model import Model
>>> model = Model()
>>> destinations, routes = model.disjoint_lists(10, 4)