I am trying to code finance portfolio optimisation problem into a quantum annealer, using the Hamiltonian Ising model. I am using the dwave module


I was wondering how one gets to decide what the bias is? I don't really get how that works. On the documentation of Dwave it says the following:

enter image description here

There also was this example code:

import neal
>>> sampler = neal.SimulatedAnnealingSampler()
h = {'a': 0.0, 'b': 0.0, 'c': 0.0}
J = {('a', 'b'): 1.0, ('b', 'c'): 1.0, ('a', 'c'): 1.0}
sampleset = sampler.sample_ising(h, J, num_reads=10)

1 Answer 1


Problem solving in Ocean framework goes by modeling the problem into a BinaryQuadraticModel. The pure quantum samplers natively only understand this model. For the hybrid samplers (Leap) one can model the problem into DiscreteQuadraticModel.

The bias are the linear terms in those models objective functions. They are derived with respect to the problem after the transformation into a BQM or DQM was done. Finance is a topic in D-Waves problem solving handbook. There are some papers listed.

So, to get the bias terms the problem first needs a formulation as a constrained optimization problem. Examples are given in the Ocean docs, e.g. for a map coloring problem. There are some tools to derive a BQM from constraint optimization problems (pyqubo or dwavebinarycsp ). This needs to get transformed into an Ising problem to be used for neal.sampler.SimulatedAnnealingSampler.sample_ising. The dimod package provides tools for this task. The terms really depend on the problem structure.

  • $\begingroup$ Great! Thank you so much! $\endgroup$ Commented May 14, 2021 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.