dimod.as_bqm¶

as_bqm
(*args, cls=None, copy=False)[source]¶ Convert the input to a binary quadratic model.
Converts the following input formats to a binary quadratic model (BQM):
 as_bqm(vartype)
 Creates an empty binary quadratic model.
 as_bqm(bqm)
 Creates a BQM from another BQM. See copy and cls kwargs below.
 as_bqm(bqm, vartype)
 Creates a BQM from another BQM, changing to the appropriate vartype if necessary. See copy and cls kwargs below.
 as_bqm(n, vartype)
 Creates a BQM with n variables, indexed linearly from zero, setting all biases to zero.
 as_bqm(quadratic, vartype)
 Creates a BQM from quadratic biases given as a square array_like or a dictionary of the form {(u, v): b, …}. Note that when formed with SPINvariables, biases on the diagonal are added to the offset.
 as_bqm(linear, quadratic, vartype)
 Creates a BQM from linear and quadratic biases, where linear is a onedimensional array_like or a dictionary of the form {v: b, …}, and quadratic is a square array_like or a dictionary of the form {(u, v): b, …}. Note that when formed with SPINvariables, biases on the diagonal are added to the offset.
 as_bqm(linear, quadratic, offset, vartype)
 Creates a BQM from linear and quadratic biases, where linear is a onedimensional array_like or a dictionary of the form {v: b, …}, and quadratic is a square array_like or a dictionary of the form {(u, v): b, …}, and offset is a numerical offset. Note that when formed with SPINvariables, biases on the diagonal are added to the offset.
Parameters:  *args – See above.
 cls (type/list, optional, default=:class:.AdjVectorBQM) – Class of the returned BQM. If given as a list, the returned BQM is of one of the types in the list.
 copy (bool, optional, default=False) – If False, a new BQM is only constructed when necessary.
Returns: A binary quadratic model.