hybrid.core.State.from_sample

classmethod State.from_sample(sample, bqm, **kwargs)[source]

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

Energy is calculated from the binary quadratic model (BQM), and State.problem is also set to that BQM.

Example

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