Quantum Annealing Search
AmplifySolver
Solver name is “Amplify”.
- class flopt.solvers.amplify_search.AmplifySearch[source]
API of Amplify Solver (https://amplify.fixstars.com/en/docs/index.html)
- Parameters:
timelimit (float or int) – time limit
token (str) – user token
Examples
AmplifySearch can solve the problem whose variables are Spin
import flopt x = flopt.Variable("x", cat="Spin") y = flopt.Variable("y", cat="Spin") prob = flopt.Problem() prob += 1 - x * y - x prob += x + y >= 0 prob.show() >>> Name: None >>> Type : Problem >>> sense : minimize >>> objective : 1-(x*y)-x >>> #constraints : 1 >>> #variables : 2 (Spin 2) >>> >>> C 0, name None, x+y >= 0
solver = flopt.Solver("Amplify") solver.setParams(token="xxx") # your token prob.solve(solver, msg=True) print() print("obj =", flopt.Value(prob.obj)) print("x =", flopt.Value(x)) print("y =", flopt.Value(y)) >>> obj = -1 >>> x = 1 >>> y = 1
In the case, the problem includes the binary variables, you should convert them to spin variables.
import flopt x = flopt.Variable("x", cat="Binary") y = flopt.Variable("y", cat="Binary") prob = flopt.Problem() prob += (1 - x * y - x).toSpin() prob += (x + y >= 0).toSpin() prob.show() >>> Name: None >>> Type : Problem >>> sense : minimize >>> objective : -0.25*(x_s*y_s)-(0.75*x_s)-(0.25*y_s)+0.25 >>> #constraints : 1 >>> #variables : 2 (Spin 2) >>> >>> C 0, name None, 0.5*x_s+(0.5*y_s)+1.0 >= 0