As an example, let's consider the following simple QuadraticModel problem with just 3 INTEGER variables:

from dimod import QuadraticModel

qm = QuadraticModel()

qm.add_variable('INTEGER', 'x', lower_bound=-2, upper_bound=5)
qm.add_variable('INTEGER', 'y', lower_bound=1, upper_bound=5)
qm.add_variable('INTEGER', 'z', lower_bound=-3, upper_bound=5)
for var in qm.variables:
    qm.add_linear(v=var, bias=1)


This code will print out the (actually linear) polynomial "energy" function $E(x,y,z) = x+y+z$ and the solution of the minimization problem in this trivial case would be $x=-2, y=1, z=-3$ (taking into account the bounds of each variable), with a minimal "ground state" energy equal to $-4$.

So my question is the following: how can I get this exact solution using DWave Ocean classical solvers? I tried to use the ExactSolver class but it raises an error that I'm not sure to understand:

from dimod import ExactSolver

solver = ExactSolver()
sol = solver.sample(qm)
TypeError: expected input vartype to be one of: Vartype.SPIN, 'SPIN', {-1, 1}, Vartype.BINARY, 'BINARY', {0, 1}, Vartype.INTEGER, 'INTEGER', Vartype.REAL, or 'REAL'; received .

If this is not supported, can I formulate and construct the same problem so that I can find the exact solution in a classical way? I would like to possibly stick with DWave software, but I'm also open to other approaches based on different tools.



Your Answer

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

Browse other questions tagged or ask your own question.