SpinorioSpinorio
Help Center
Open Lab
Browse documentation

Docs / Hilvarian / Optimization solver

Hilvarian Optimization Solver

Plan and run QAOA jobs from a Spinorio notebook and inspect the best solution found.


Plan a weighted MaxCut run

In an authenticated Spinorio Lab notebook, define the graph using one entry per undirected edge. Each edge contains two variable names and a weight. The local Aer executor runs the quantum circuits on a simulator.

python
from spinorio import Spinorio

client = Spinorio()
problem = {
    "schema": "spinorio.solver.model.v1",
    "problem_type": "maxcut",
    "variables": ["a", "b", "c"],
    "edges": [["a", "b", 2.0], ["b", "c", 3.0], ["a", "c", 1.0]],
}
plan = client.solver.plan(
    problem=problem,
    executor="local_aer",
    strategy="auto",
    budget={"max_total_shots": 100000},
)
plan.result(wait=True)

Run the plan and retrieve the solution

After reviewing the plan, submit it in a new cell. Save the run ID so you can retrieve the result from a later session.

python
run = plan.run()
run_id = run.run_id
print(run_id)
result = run.result(wait=True, timeout=600)
result

Inspect the returned solution for its assignment and objective. For this graph the maximum cut weight is 5, which gives you a reference for the result returned by the search.

python
run = client.solvers.get(run_id)  # Set run_id to the ID you saved.
run.status()

Choose a model and strategy

Hilvarian accepts weighted MaxCut, QUBO, and Ising models. Direct execution is limited by the capacity of the selected executor. For larger weighted MaxCut graphs, the multilevel strategy breaks the problem into smaller subproblems.


Previous

← Python SDK

Next

IBM Quantum →