Skip to main content

pqblocks-anneal-sa

Classical Simulated Annealing heuristic solver for Ising spin-glass and QUBO optimization problems with automatic parameter derivation.

CI License Python 3.11+



Overview

pqblocks-anneal-sa is a classical Simulated Annealing solver for Quadratic Unconstrained Binary Optimization (QUBO) and Ising optimization problems.

Inspired by thermal annealing in statistical physics, the solver progressively cools a spin system according to configurable temperature schedules (geometric, linear, or logarithmic). It features automatic parameter derivation to compute initial and final inverse temperatures ($\beta_0$, $\beta_f$) directly from the coupling matrix $J$ and linear bias vector $h$, eliminating manual hyperparameter tuning.

Key Highlights

  • Automatic Temperature Derivation: Derives high-temperature initialization ($\beta_0 \approx \ln(2) / \Delta E_{\text{mean}}$) and low-temperature freezing ($\beta_f \approx \ln(10000) / \Delta E_{\text{min}}$) automatically from problem coefficients.
  • Multiple Cooling Schedules: Supports geometric, linear, and logarithmic temperature decay schedules.
  • Optimized Kernel Execution: Fast incremental local-field updates ($\Delta E_i = 2 s_i h_i + 2 s_i \sum_j J_{ij} s_j$) with parallel reads.
  • Command-Line Interface: Built-in CLI for batch solving and JSON output pipelines.

Installation

pip install pqblocks-anneal-sa

Dependencies

Requires Python 3.11+, numpy, scipy, and dimod.


Quickstart

import numpy as np
from pqblocks_anneal_sa import simulated_annealing

# 1. Define 4-spin Ising problem (couplings J and linear biases h)
J = np.array([
    [0.0, 1.0, -1.0, 0.0],
    [1.0, 0.0, 1.0, -1.0],
    [-1.0, 1.0, 0.0, 1.0],
    [0.0, -1.0, 1.0, 0.0],
])
h = np.array([0.5, -0.3, 0.2, -0.1])

# 2. Solve with auto-derived parameters
result = simulated_annealing(J, h, num_sweeps=100, num_reads=10, seed=42)

# 3. Retrieve best solution
best_idx = np.argmin(result["energies"])
print(f"Best energy: {result['energies'][best_idx]:.6f}")
print(f"Sample: {result['samples'][best_idx].tolist()}")

Command-Line Usage

# Solve directly from the shell with JSON output
pqblocks-anneal-sa --j-matrix "[[0, 1], [1, 0]]" --h-vector "[0.5, -0.3]" --output json

Fair Benchmarking Disclaimer

When benchmarking simulated annealing against exact or heuristic solvers (such as Google OR-Tools CP-SAT, D-Wave Neal, or OpenJij):

  • Work Normalization: State total sweeps and read counts for all annealing solvers.
  • Latency vs Quality: Solvers with single-read execution report lower raw latency but may exhibit lower success probabilities than multi-read ensembles.
  • Problem Size: Classical SA excels on small-to-medium dense problems ($N \le 50$); exact solvers like CP-SAT may prove faster on structured sparse problems.

Verification & Testing

Tested across Python 3.11, 3.12, 3.13, and 3.14.

pytest

License

Licensed under the Apache License, Version 2.0. See LICENSE and NOTICE.

Metadata

Release files for pqblocks-anneal-sa 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pqblocks-anneal-sa 0.1.0
File Size Uploaded Provenance Actions
pqblocks_anneal_sa-0.1.0.tar.gz 26.9 kB Without provenance Details for pqblocks_anneal_sa-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pqblocks-anneal-sa 0.1.0
File Interpreter ABI Platform Actions
pqblocks_anneal_sa-0.1.0-py3-none-any.whl Python 3 none any Details for pqblocks_anneal_sa-0.1.0-py3-none-any.whl

Total release size: 46.3 kB

Release files / pqblocks_anneal_sa-0.1.0.tar.gz

Download URL pqblocks_anneal_sa-0.1.0.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4fd75646932dfcc3f36e9c3d42d341b49e499d9171657fe9bd632af3be96d10d
BLAKE2b-256 checksum
How to use checksums
d1de69a3c07a91d1b1aa2b7420e656d6d840b6200a3d63f6cdb5d417777b22df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pqblocks_anneal_sa-0.1.0-py3-none-any.whl

Download URL pqblocks_anneal_sa-0.1.0-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e059f4f11cb5613fd49670811f77f7eac46cf69089dde75619f4f79f0746649
BLAKE2b-256 checksum
How to use checksums
d411f01ff898336729f5dc6165f9627f55915f99baf0d7f4e92b0d9c5f5036b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pqblocks-anneal-sa 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page