flopt
latest

Contents:

  • Installation
  • Tutorial
  • Case Studies
  • Solvers
    • Solver Selector
    • Iterative Search
    • Swarm Intelligence Search
    • Baysian Search
    • Evolution Search
    • Quadratic Programming Search
    • Linear Programming Search
    • non-Linear Programming Search
    • Quantum Annealing Search
      • AmplifySolver
        • AmplifySearch
  • API Reference
  • Internal Reference
  • Recipes
flopt
  • Solvers
  • Quantum Annealing Search
  • Edit on GitHub

Quantum Annealing Search

AmplifySolver

Solver name is “Amplify”.

https://img.shields.io/badge/Variable-Spin-blue.svghttps://img.shields.io/badge/Objective-Quadratic-orange.svghttps://img.shields.io/badge/Constraints-Linear-green.svg
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
Previous Next

© Copyright 2021, Nariaki Tateiwa. Revision ff418914.

Built with Sphinx using a theme provided by Read the Docs.