dimod.BinaryQuadraticModel.from_serializable

classmethod BinaryQuadraticModel.from_serializable(obj)[source]

Deserialize a binary quadratic model.

Parameters:obj (dict) – A binary quadratic model serialized by to_serializable().
Returns:BinaryQuadraticModel

Examples

Encode and decode using JSON

>>> import dimod
>>> import json
...
>>> bqm = dimod.BinaryQuadraticModel({'a': -1.0, 'b': 1.0}, {('a', 'b'): -1.0}, 0.0, dimod.SPIN)
>>> s = json.dumps(bqm.to_serializable())
>>> new_bqm = dimod.BinaryQuadraticModel.from_serializable(json.loads(s))

See also

to_serializable()

json.loads(), json.load() JSON deserialization functions