dimod.binary.BinaryQuadraticModel.from_serializable#
- classmethod BinaryQuadraticModel.from_serializable(obj: Mapping) BinaryQuadraticModel [source]#
Deserialize a binary quadratic model.
- Parameters:
obj – A binary quadratic model serialized by
to_serializable()
.- Returns:
A binary quadratic model.
Examples
Encode and decode using JSON
>>> 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))