项目作者: quantum-circle

项目描述 :
API for the Quantum Annealing Simulator and the QUBO Generator
高级语言: Python
项目地址: git://github.com/quantum-circle/qc_qubosolv.git
创建时间: 2021-03-04T19:01:38Z
项目社区:https://github.com/quantum-circle/qc_qubosolv

开源协议:Other

下载


Full contents

Installation Notes

After downloading and unzipping the repository, you will be able to install the library using either native python setuptools:

  1. python setup.py install

or the pip package manager:

  1. pip install .

This will also automatically download all required 3rd party packages.

A Minimal Example

The following code snippet demonstrates how to use Quantum Circle’s QUBO solver module qc_qubosolv.

More detailed Jupyter notebook examples can be found in the /examples directory, including descriptions of the functionality and an introduction to simulated (quantum) annealing solvers.

  1. >>> from qc_qubosolv import Solver
  2. >>>
  3. >>>
  4. >>> # 1. Create the QUBO matrix to be solved
  5. ... qubo_matrix = [
  6. ... [-1, 2],
  7. ... [2, -4]
  8. ... ]
  9. >>>
  10. >>> # 2. Initialize the solver client
  11. ... solver = Solver(
  12. ... username='YOUR_USERNAME_HERE',
  13. ... password='YOUR_PASSWORD_HERE'
  14. ... )
  15. >>>
  16. >>> # 3. Solve the previously created QUBO problem
  17. ... result = solver.solve(qubo_matrix, algorithm='sqa')
  18. >>>
  19. >>> # 4. Print the optimal bitstring and its corresponding objective function value
  20. ... print(f"Optimal bitstring: x = {result.optimal_bitstring}")
  21. Optimal bitstring: x = [0 1]
  22. >>> print(f"Optimal energy: f(x) = {result.optimal_energy}")
  23. Optimal energy: f(x) = -4.0

Help and documentation

If you’re looking for help learning about the API, start with these resources:

License

Apache.