Skip to main content

Sparse QUBO formulation for efficient embedding on hardware.

Project description

sparse-qubo

Release Build status codecov Commit activity License

Sparse QUBO formulation for efficient embedding on hardware.

sparse-qubo is a Python library that provides sparse QUBO (Quadratic Unconstrained Binary Optimization) formulations specifically for N-hot equality and inequality constraints. Constraint QUBOs are built from switching networks: each network is a list of Switch elements (left/right variable sets and constants), and the library converts them into QUBOs optimized for embedding on quantum annealing hardware (e.g. D-Wave) or other solvers.

The method is based on the paper Sparse QUBO Formulation for Efficient Embedding via Network-Based Decomposition of Equality and Inequality Constraints (Suda, Naito, Hasegawa, 2026).

Features

  • Constraint types: One-hot, equal-to, less-equal, greater-equal, clamp
  • Network types: Naive (single linear equality), divide-and-conquer, bubble sort, bitonic sort, Benes, odd-even merge sort, Clos (max degree / minimum edge)
  • Backends: D-Wave (dimod.BQM) and Fixstars Amplify (amplify.Model)
  • Examples: Shift scheduling and TSP in examples/ with notebooks and benchmarks

Installation

pip install sparse-qubo

With uv:

uv add sparse-qubo

Quick Start

import dimod
import sparse_qubo

variables = dimod.variables.Variables(["x0", "x1", "x2", "x3"])

# One-hot constraint (divide-and-conquer network)
bqm = sparse_qubo.create_constraint_dwave(
    variables,
    sparse_qubo.ConstraintType.ONE_HOT,
    sparse_qubo.NetworkType.DIVIDE_AND_CONQUER,
)

# Equal-to: sum = 2
bqm = sparse_qubo.create_constraint_dwave(
    variables, sparse_qubo.ConstraintType.EQUAL_TO,
    sparse_qubo.NetworkType.DIVIDE_AND_CONQUER,
    c1=2,
)

For Fixstars Amplify, use sparse_qubo.create_constraint_amplify with a list of amplify.Variable. See the documentation for more examples and the full API.

Examples

The examples/ directory includes:

  • Shift scheduling (examples/shift_scheduling/): Demo notebook comparing NAIVE vs DIVIDE_AND_CONQUER on D-Wave, plus create_scheduling_problem_bqm and benchmarks
  • TSP (examples/tsp/): Problem builder and benchmarks for traveling salesman formulations

Documentation

Reference

Kohei Suda, Soshun Naito, Yoshihiko Hasegawa. Sparse QUBO Formulation for Efficient Embedding via Network-Based Decomposition of Equality and Inequality Constraints. arXiv:2601.18108, 2026. https://arxiv.org/abs/2601.18108

Contributing

Contributions are welcome. See CONTRIBUTING.md for guidelines.

License

This project is licensed under the terms in LICENSE.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sparse_qubo-0.1.0.tar.gz (186.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sparse_qubo-0.1.0-py3-none-any.whl (26.2 kB view details)

Uploaded Python 3

File details

Details for the file sparse_qubo-0.1.0.tar.gz.

File metadata

  • Download URL: sparse_qubo-0.1.0.tar.gz
  • Upload date:
  • Size: 186.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sparse_qubo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0201da493f04ae2790a86d242f3e8cf27534dda19252ff85117bae053964dd78
MD5 9098ea2b3baa3fc51dc02d6044785cee
BLAKE2b-256 daccd31d62532d2579cf267cce25cf8cf0433fcc9f9eda59641c9b41864945da

See more details on using hashes here.

File details

Details for the file sparse_qubo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sparse_qubo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sparse_qubo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37cc76208d304bad50e0c547134d4358fa5ae9ef11c668ee25467976fd0f7995
MD5 856f36e555b9ee12cd7ade6a87a99a3b
BLAKE2b-256 b8a1e4927d20f8cc9bd138e96ba6ff34a1f8e570bcceeeb44b180af2dd3712ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page