Getting started
qubo-solver solves Quadratic Unconstrained Binary Optimization (QUBO) instances using either classical or quantum approaches. Here is the entire workflow in three steps: define an Instance from a QUBO matrix, pass it to a Solver, and call solve().
The example below uses the default configuration, which runs a quantum approach on a local emulator. See the next tutorial for how to configure quantum backends and classical algorithms explicitly.
In [ ]:
from __future__ import annotations
from qubosolver import ( Instance, Solver, analysis, matrix,)
# Define QUBOQ = matrix.tensor( [ [-0.2, 0.0, 1.0], [0.0, -1.0, 1.5], [1.0, 1.5, -0.1], ])instance = Instance(Q)# Solve it!solver = Solver(instance)solution = solver.solve()
print(analysis.to_dataframe([solution]))labels bitstrings costs counts probs 0 0 110 -1.2 989 0.989 1 0 001 -0.1 11 0.011
The output is a Solution, converted here to a dataframe listing each sampled bitstring, its cost, and its probability. Continue to the next tutorial, Solving a QUBO instance, for quantum backends and classical solver options.
