dimod.BinaryQuadraticModel.spin

BinaryQuadraticModel.spin

BinaryQuadraticModel – An instance of the Ising model subclass of the BinaryQuadraticModel superclass, corresponding to a binary quadratic model with spins as its variables.

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

Examples

This example creates a QUBO model and uses the spin property to instantiate the corresponding Ising model.

>>> import dimod
>>> bqm_qubo = dimod.BinaryQuadraticModel({0: -1, 1: -1}, {(0, 1): 2}, 0.0, dimod.BINARY)
>>> bqm_spin = bqm_qubo.spin
>>> bqm_spin   
BinaryQuadraticModel({0: 0.0, 1: 0.0}, {(0, 1): 0.5}, -0.5, Vartype.SPIN)
>>> bqm_spin.spin is bqm_spin
True

Note

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