hybrid.core.State.from_samples

classmethod State.from_samples(samples, bqm, **kwargs)[source]

Convenience method for constructing a state from raw (dict) samples.

Per-sample energy is calculated from the binary quadratic model (BQM), and State.problem is set to the BQM.

Example

>>> import dimod
>>> bqm = dimod.BQM.from_ising({}, {'ab': 0.5, 'bc': 0.5, 'ca': 0.5})
>>> state = State.from_samples([{'a': -1, 'b': -1, 'c': -1},
...                             {'a': -1, 'b': -1, 'c': 1}], bqm)