SetPacking#

class SetPacking(subsets)[source]#

Bases: OptimizationApplication

Optimization application for the “set packing” [1] problem.

References

[1]: “Set packing”, https://en.wikipedia.org/wiki/Set_packing

Parameters:

subsets (List[List[int]]) – A list of subsets

Methods

interpret(result)[source]#

Interpret a result as a list of subsets

Parameters:

result (OptimizationResult | ndarray) – The calculated result of the problem

Returns:

A list of subsets whose corresponding variable is 1

Return type:

List[List[int]]

static sample_most_likely(state_vector)#

Compute the most likely binary string from state vector.

Parameters:

state_vector (QuasiDistribution | Statevector | ndarray | Dict) – state vector or counts or quasi-probabilities.

Returns:

binary string as numpy.ndarray of ints.

Raises:

ValueError – if state_vector is not QuasiDistribution, Statevector, np.ndarray, or dict.

Return type:

ndarray

to_quadratic_program()[source]#

Convert a set packing instance into a QuadraticProgram

Returns:

The QuadraticProgram created from the set packing instance.

Return type:

QuadraticProgram