Skip to content

Commit 2a47ee3

Browse files
Initial dbsw-tabu-qaoa package
1 parent 3591507 commit 2a47ee3

46 files changed

Lines changed: 3934 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Install
19+
run: python -m pip install -e ".[dev]"
20+
- name: Test
21+
run: pytest

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__pycache__/
2+
*.py[cod]
3+
*.pyo
4+
.pytest_cache/
5+
.mypy_cache/
6+
.ruff_cache/
7+
.coverage
8+
htmlcov/
9+
dist/
10+
build/
11+
*.egg-info/
12+
.venv/
13+
venv/
14+
env/
15+
.idea/
16+
.vscode/
17+
*.log
18+
results/
19+
*.jsonl

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
## 0.1.0
4+
5+
- Initial GitHub-ready package layout.
6+
- Added Python API and CLI for Tabu-QAOA solving.
7+
- Added exact and QCover/Qulacs subproblem backends.
8+
- Added examples, tests, CI, and input-format documentation.

CITATION.cff

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cff-version: 1.2.0
2+
message: "If you use dbsw-qaoa in academic work, please cite this repository."
3+
title: "dbsw-tabu-qaoa: A packaged Tabu-QAOA solver"
4+
version: "0.1.0"
5+
date-released: "2026-06-01"
6+
authors:
7+
- name: "DBSW-QAOA contributors"

LICENSE

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
Apache License
2+
Version 2.0, January 2004
3+
http://www.apache.org/licenses/
4+
5+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6+
7+
1. Definitions.
8+
9+
"License" shall mean the terms and conditions for use, reproduction, and
10+
distribution as defined by Sections 1 through 9 of this document.
11+
12+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
13+
owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all other entities
16+
that control, are controlled by, or are under common control with that entity.
17+
For the purposes of this definition, "control" means (i) the power, direct or
18+
indirect, to cause the direction or management of such entity, whether by
19+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
20+
outstanding shares, or (iii) beneficial ownership of such entity.
21+
22+
"You" (or "Your") shall mean an individual or Legal Entity exercising
23+
permissions granted by this License.
24+
25+
"Source" form shall mean the preferred form for making modifications, including
26+
but not limited to software source code, documentation source, and configuration
27+
files.
28+
29+
"Object" form shall mean any form resulting from mechanical transformation or
30+
translation of a Source form, including but not limited to compiled object code,
31+
generated documentation, and conversions to other media types.
32+
33+
"Work" shall mean the work of authorship, whether in Source or Object form,
34+
made available under the License, as indicated by a copyright notice that is
35+
included in or attached to the work.
36+
37+
"Derivative Works" shall mean any work, whether in Source or Object form, that
38+
is based on (or derived from) the Work and for which the editorial revisions,
39+
annotations, elaborations, or other modifications represent, as a whole, an
40+
original work of authorship. For the purposes of this License, Derivative Works
41+
shall not include works that remain separable from, or merely link (or bind by
42+
name) to the interfaces of, the Work and Derivative Works thereof.
43+
44+
"Contribution" shall mean any work of authorship, including the original
45+
version of the Work and any modifications or additions to that Work or
46+
Derivative Works thereof, that is intentionally submitted to Licensor for
47+
inclusion in the Work by the copyright owner or by an individual or Legal Entity
48+
authorized to submit on behalf of the copyright owner.
49+
50+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
51+
of whom a Contribution has been received by Licensor and subsequently
52+
incorporated within the Work.
53+
54+
2. Grant of Copyright License.
55+
56+
Subject to the terms and conditions of this License, each Contributor hereby
57+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
58+
irrevocable copyright license to reproduce, prepare Derivative Works of,
59+
publicly display, publicly perform, sublicense, and distribute the Work and such
60+
Derivative Works in Source or Object form.
61+
62+
3. Grant of Patent License.
63+
64+
Subject to the terms and conditions of this License, each Contributor hereby
65+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
66+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
67+
and otherwise transfer the Work.
68+
69+
4. Redistribution.
70+
71+
You may reproduce and distribute copies of the Work or Derivative Works thereof
72+
in any medium, with or without modifications, and in Source or Object form,
73+
provided that You meet the following conditions:
74+
75+
(a) You must give any other recipients of the Work or Derivative Works a copy of
76+
this License; and
77+
78+
(b) You must cause any modified files to carry prominent notices stating that
79+
You changed the files; and
80+
81+
(c) You must retain, in the Source form of any Derivative Works that You
82+
distribute, all copyright, patent, trademark, and attribution notices from the
83+
Source form of the Work; and
84+
85+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
86+
any Derivative Works that You distribute must include a readable copy of the
87+
attribution notices contained within such NOTICE file.
88+
89+
5. Submission of Contributions.
90+
91+
Unless You explicitly state otherwise, any Contribution intentionally submitted
92+
for inclusion in the Work by You to the Licensor shall be under the terms and
93+
conditions of this License, without any additional terms or conditions.
94+
95+
6. Trademarks.
96+
97+
This License does not grant permission to use the trade names, trademarks,
98+
service marks, or product names of the Licensor, except as required for
99+
reasonable and customary use in describing the origin of the Work.
100+
101+
7. Disclaimer of Warranty.
102+
103+
Unless required by applicable law or agreed to in writing, Licensor provides the
104+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
105+
express or implied, including, without limitation, any warranties or conditions
106+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE.
107+
You are solely responsible for determining the appropriateness of using or
108+
redistributing the Work and assume any risks associated with Your exercise of
109+
permissions under this License.
110+
111+
8. Limitation of Liability.
112+
113+
In no event and under no legal theory, whether in tort (including negligence),
114+
contract, or otherwise, unless required by applicable law or agreed to in
115+
writing, shall any Contributor be liable to You for damages, including any
116+
direct, indirect, special, incidental, or consequential damages arising as a
117+
result of this License or out of the use or inability to use the Work.
118+
119+
9. Accepting Warranty or Additional Liability.
120+
121+
While redistributing the Work or Derivative Works thereof, You may choose to
122+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
123+
other liability obligations. However, in accepting such obligations, You may act
124+
only on Your own behalf and on Your sole responsibility.

NOTICE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
dbsw-tabu-qaoa
2+
Copyright 2026 DBSW-QAOA contributors
3+
4+
This project includes QCover/Qulacs simulator components copied from Qcover:
5+
6+
Qcover
7+
Copyright BAQIS 2021, 2022
8+
Licensed under the Apache License, Version 2.0.
9+
10+
The original source files in D:\Google\qaoa_solve\Tabu-QAOA were not modified
11+
while preparing this package.

docs/input-format.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Input Format
2+
3+
`dbsw-qaoa solve` accepts three input formats.
4+
5+
## QUBO Edge List
6+
7+
Use `--format qubo`.
8+
9+
```text
10+
problem_size 4
11+
0 0 1.0
12+
0 1 2.0
13+
1 1 -1.0
14+
2 3 0.5
15+
```
16+
17+
The optional `problem_size` line gives the number of binary variables. Each
18+
remaining line is:
19+
20+
```text
21+
i j coefficient
22+
```
23+
24+
Variables are zero-indexed. If both `(i, j)` and `(j, i)` are present with the
25+
same coefficient, the duplicate is kept once. If the two directions differ,
26+
their values are summed.
27+
28+
## Dense Matrix
29+
30+
Use `--format matrix`.
31+
32+
```text
33+
1.0 2.0 0.0
34+
0.0 -1.0 0.5
35+
0.0 0.0 2.0
36+
```
37+
38+
Rows may be whitespace-separated or comma-separated. The matrix must be square.
39+
40+
## Max-Cut Edge List
41+
42+
Use `--format maxcut`.
43+
44+
```text
45+
problem_size 3
46+
0 1 1.0
47+
1 2 1.0
48+
0 2 1.0
49+
```
50+
51+
Each non-comment line is an undirected weighted graph edge:
52+
53+
```text
54+
u v weight
55+
```
56+
57+
The loader converts the graph to a QUBO with diagonal node-degree terms and
58+
off-diagonal `-2 * weight` terms.
59+
60+
## Comments
61+
62+
All formats allow comments beginning with `#`.

examples/basic_usage.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from dbsw_qaoa import SolverConfig, solve_tabu_qaoa
2+
3+
4+
def main() -> None:
5+
qubo = {
6+
(0, 0): 1.0,
7+
(1, 1): 1.0,
8+
(0, 1): 2.0,
9+
}
10+
config = SolverConfig(iterations=1, submatrix=2, backend="exact", seed=3)
11+
result = solve_tabu_qaoa(qubo, size=2, config=config)
12+
13+
print(result.to_dict())
14+
15+
16+
if __name__ == "__main__":
17+
main()

examples/maxcut_triangle.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Weighted triangle Max-Cut instance.
2+
problem_size 3
3+
0 1 1.0
4+
1 2 1.0
5+
0 2 1.0

examples/qubo_4.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Small QUBO example.
2+
problem_size 4
3+
0 0 1.0
4+
1 1 1.0
5+
2 2 -1.0
6+
3 3 -1.0
7+
0 1 2.0
8+
2 3 0.5

0 commit comments

Comments
 (0)