hybrid.utils.random_sample#

random_sample(bqm)[source]#

Return a random sample for a binary quadratic model.

Parameters:

bqm (BinaryQuadraticModel) – Binary quadratic model (BQM).

Returns:

A sample with random values for the BQM.

Return type:

dict

Examples

>>> import dimod
>>> bqm = dimod.BQM({}, {'ab': -1, 'bc': -1, 'ca': -1}, 0, 'BINARY')
>>> random_sample(bqm)     
{'a': 0, 'b': 1, 'c': 1}