def to_json(self): """ Transform an Ising representation of a problem into a dimod.BinaryQuadraticModel (BQM) and return the serialized BQM. Returns ------- bqm.to_serializable(): dict The serialized BQM """ bqm = BinaryQuadraticModel(self.linear_dict, self.quadratic_dict, 0.0, dimod.SPIN) return bqm.to_serializable()
def to_json(self): """Transform a QUBO dictionary into a dimod.BinaryQuadraticModel (BQM) and return the serialized BQM. Returns ------- bqm.to_serializable(): dict The serialized BQM """ linear = {} quadratic = {} for (a, b) in self.problem_dict.keys(): if a == b: linear[a] = self.problem_dict[(a, b)] else: quadratic[(a, b)] = self.problem_dict[(a, b)] bqm = BinaryQuadraticModel(linear, quadratic, 0.0, dimod.BINARY) return bqm.to_serializable()