4.3 Using Ocean to formulate and transform optimization problems
As we have just seen, the BinaryQuadraticModel
class can be used to define both Ising and QUBO problems. But dimod
also offers other models and utilities that will make our lives a little bit easier. Let’s start by studying how we can conveniently define problems with linear restrictions.
4.3.1 Constrained quadratic models in Ocean
You surely remember that a problem like
is an instance of binary linear programming. In Section 3.4.1, we studied this family of problems in detail and we showed that they can be transformed into the QUBO and Ising models by using slack variables and penalty terms.
So, imagine that you want to solve the preceding problem in a quantum annealer. Do you need to perform all those boring transformations in order to obtain the QUBO coefficients and then use them to define a BinaryQuadraticModel
object? No! Fortunately, dimod
provides the ConstrainedQuadraticModel
class, which simplifies...