dimod.BinaryQuadraticModel.binary

BinaryQuadraticModel.binary

An instance of the QUBO model subclass of the BinaryQuadraticModel superclass (a BQM with binary variables).

Enables access to biases for the binary-valued binary quadratic model regardless of the vartype set when the model was created. If the model was created with the spin vartype, the QUBO model subclass is instantiated upon the first use of the binary property and used in any subsequent reads.

Examples

This example creates an Ising model and uses the binary property to instantiate the corresponding QUBO model.

>>> import dimod
...
>>> bqm_spin = dimod.BinaryQuadraticModel({0: 0.0, 1: 0.0}, {(0, 1): 0.5}, -0.5, dimod.SPIN)
>>> bqm_qubo = bqm_spin.binary
>>> bqm_qubo  # doctest: +SKIP
BinaryQuadraticModel({0: -1.0, 1: -1.0}, {(0, 1): 2.0}, 0.0, Vartype.BINARY)
>>> bqm_qubo.binary is bqm_qubo
True

Note

Methods like add_variable(), add_variables_from(), add_interaction(), etc. should only be used on the base model.

Type:BinaryQuadraticModel