PyQrackIsing 5.5.2__tar.gz → 5.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyqrackising-5.5.2/pyqrackising.egg-info → pyqrackising-5.6.0}/PKG-INFO +1 -1
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/README.md +2 -2
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyproject.toml +1 -1
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/maxcut_tfim.py +3 -3
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/maxcut_tfim_sparse.py +3 -3
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/maxcut_tfim_streaming.py +2 -2
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/spin_glass_solver.py +2 -2
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/spin_glass_solver_sparse.py +2 -2
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/spin_glass_solver_streaming.py +1 -1
- {pyqrackising-5.5.2 → pyqrackising-5.6.0/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/setup.py +1 -1
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/CMakeLists.txt +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/LICENSE.md +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/MANIFEST.in +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/__init__.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising/tsp.py +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-5.5.2 → pyqrackising-5.6.0}/setup.cfg +0 -0
|
@@ -53,7 +53,7 @@ G = nx.petersen_graph()
|
|
|
53
53
|
best_solution_bit_string, best_cut_value, best_node_groups = maxcut_tfim(G, quality=2, is_alt_gpu_sampling=True)
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
We also provide `maxcut_tfim_sparse(G)`, for `scipy` CSR sparse arrays (or `networkx` graphs). The (integer) `quality` setting is optional, with a default value of `
|
|
56
|
+
We also provide `maxcut_tfim_sparse(G)`, for `scipy` CSR sparse arrays (or `networkx` graphs). The (integer) `quality` setting is optional, with a default value of `2`, but you can turn it up for higher-quality results, or turn it down to save time. (You can also optionally specify the number of measurement `shots` as an argument, if you want specific fine-grained control over resource usage.) `is_alt_gpu_sampling` is `False` by default and, if set to `True`, will dispatch almost the entire algorithm on GPU, instead of just the TFIM-heuristic component (although solution quality is often lower). If you want to run MAXCUT on a graph with non-uniform edge weights, specify them as the `weight` attribute of each edge, with `networkx`. (If any `weight` attribute is not defined, the solver assumes it's `1.0` for that edge.)
|
|
57
57
|
|
|
58
58
|
Based on a combination of the TFIM-inspired MAXCUT solver and another technique for finding ground-state energy in quantum chemistry that we call the _"binary Clifford eigensolver,"_ we also provide an (approximate) spin glass ground-state solver:
|
|
59
59
|
```py
|
|
@@ -76,7 +76,7 @@ G = generate_spin_glass_graph(n_nodes=64, seed=42)
|
|
|
76
76
|
solution_bit_string, cut_value, node_groups, energy = spin_glass_solver(G, quality=2, best_guess=None, is_alt_gpu_sampling=True)
|
|
77
77
|
# solution_bit_string, cut_value, node_groups, energy = spin_glass_solver(G, best_guess=maxcut_tfim(G, quality=6)[0])
|
|
78
78
|
```
|
|
79
|
-
We also provide `spin_glass_solver_sparse(G)`, for `scipy` **upper-triangular** CSR sparse arrays (or `networkx` graphs). The (integer) default `quality` setting is `
|
|
79
|
+
We also provide `spin_glass_solver_sparse(G)`, for `scipy` **upper-triangular** CSR sparse arrays (or `networkx` graphs). The (integer) default `quality` setting is `2`. `best_guess` gives the option to seed the algorithm with a best guess as to the maximal cut (as an integer, binary string, or list of booleans). By default, `spin_glass_solver()` uses `maxcut_tfim(G)` with passed-through `quality` as `best_guess`, which typically works well, but it could be seeded with higher `maxcut_tfim()` `quality` or Goemans-Williamson, for example. This function is designed with a sign convention for weights such that it can immediately be used as a MAXCUT solver itself: you might need to reverse the sign convention on your weights for spin glass graphs, but this is only convention.
|
|
80
80
|
|
|
81
81
|
From the `spin_glass_solver()`, we provide a (recursive) Traveling Salesman Problem (TSP) solver:
|
|
82
82
|
```py
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "5.
|
|
15
|
+
version = "5.6.0"
|
|
16
16
|
requires-python = ">=3.8"
|
|
17
17
|
description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
|
|
18
18
|
readme = {file = "README.txt", content-type = "text/markdown"}
|
|
@@ -22,7 +22,7 @@ def update_repulsion_choice(G_m, max_weight, weights, n, used, node):
|
|
|
22
22
|
for nbr in range(n):
|
|
23
23
|
if used[nbr]:
|
|
24
24
|
continue
|
|
25
|
-
weights[nbr] *= max(2e-
|
|
25
|
+
weights[nbr] *= max(2e-8, 1 - G_m[node, nbr] / max_weight)
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
# Written by Elara (OpenAI custom GPT) and improved by Dan Strano
|
|
@@ -240,7 +240,7 @@ def maxcut_tfim(
|
|
|
240
240
|
G,
|
|
241
241
|
quality=None,
|
|
242
242
|
shots=None,
|
|
243
|
-
is_alt_gpu_sampling =
|
|
243
|
+
is_alt_gpu_sampling = False,
|
|
244
244
|
is_g_buf_reused = False
|
|
245
245
|
):
|
|
246
246
|
nodes = None
|
|
@@ -270,7 +270,7 @@ def maxcut_tfim(
|
|
|
270
270
|
return "01", weight, ([nodes[0]], [nodes[1]])
|
|
271
271
|
|
|
272
272
|
if quality is None:
|
|
273
|
-
quality =
|
|
273
|
+
quality = 2
|
|
274
274
|
|
|
275
275
|
if shots is None:
|
|
276
276
|
# Number of measurement shots
|
|
@@ -52,7 +52,7 @@ def update_repulsion_choice(G_cols, G_data, G_rows, max_weight, weights, n, used
|
|
|
52
52
|
end = G_rows[nbr + 1]
|
|
53
53
|
j = binary_search(G_cols[start:end], node) + start
|
|
54
54
|
if j < end:
|
|
55
|
-
weights[nbr] *= max(2e-
|
|
55
|
+
weights[nbr] *= max(2e-8, 1 - G_data[j] / max_weight)
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
# Written by Elara (OpenAI custom GPT) and improved by Dan Strano
|
|
@@ -305,7 +305,7 @@ def maxcut_tfim_sparse(
|
|
|
305
305
|
G,
|
|
306
306
|
quality=None,
|
|
307
307
|
shots=None,
|
|
308
|
-
is_alt_gpu_sampling =
|
|
308
|
+
is_alt_gpu_sampling = False,
|
|
309
309
|
is_g_buf_reused = False
|
|
310
310
|
):
|
|
311
311
|
nodes = None
|
|
@@ -335,7 +335,7 @@ def maxcut_tfim_sparse(
|
|
|
335
335
|
return "01", weight, ([nodes[0]], [nodes[1]])
|
|
336
336
|
|
|
337
337
|
if quality is None:
|
|
338
|
-
quality =
|
|
338
|
+
quality = 2
|
|
339
339
|
|
|
340
340
|
if shots is None:
|
|
341
341
|
# Number of measurement shots
|
|
@@ -22,7 +22,7 @@ def update_repulsion_choice(G_func, G_func_args_tuple, nodes, max_weight, weight
|
|
|
22
22
|
for nbr in range(n):
|
|
23
23
|
if used[nbr]:
|
|
24
24
|
continue
|
|
25
|
-
weights[nbr] *= max(2e-
|
|
25
|
+
weights[nbr] *= max(2e-8, 1 - G_func((nodes[node], nodes[nbr]), G_func_args_tuple) / max_weight)
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
# Written by Elara (OpenAI custom GPT) and improved by Dan Strano
|
|
@@ -193,7 +193,7 @@ def maxcut_tfim_streaming(
|
|
|
193
193
|
return "01", weight, ([nodes[0]], [nodes[1]])
|
|
194
194
|
|
|
195
195
|
if quality is None:
|
|
196
|
-
quality =
|
|
196
|
+
quality = 2
|
|
197
197
|
|
|
198
198
|
if shots is None:
|
|
199
199
|
# Number of measurement shots
|
|
@@ -140,7 +140,7 @@ def spin_glass_solver(
|
|
|
140
140
|
quality=None,
|
|
141
141
|
shots=None,
|
|
142
142
|
best_guess=None,
|
|
143
|
-
is_alt_gpu_sampling=
|
|
143
|
+
is_alt_gpu_sampling=False
|
|
144
144
|
):
|
|
145
145
|
nodes = None
|
|
146
146
|
n_qubits = 0
|
|
@@ -169,7 +169,7 @@ def spin_glass_solver(
|
|
|
169
169
|
return "01", weight, ([nodes[0]], [nodes[1]]), -weight
|
|
170
170
|
|
|
171
171
|
if quality is None:
|
|
172
|
-
quality =
|
|
172
|
+
quality = 2
|
|
173
173
|
|
|
174
174
|
bitstring = ""
|
|
175
175
|
if isinstance(best_guess, str):
|
|
@@ -157,7 +157,7 @@ def spin_glass_solver_sparse(
|
|
|
157
157
|
quality=None,
|
|
158
158
|
shots=None,
|
|
159
159
|
best_guess=None,
|
|
160
|
-
is_alt_gpu_sampling=
|
|
160
|
+
is_alt_gpu_sampling=False
|
|
161
161
|
):
|
|
162
162
|
nodes = None
|
|
163
163
|
n_qubits = 0
|
|
@@ -186,7 +186,7 @@ def spin_glass_solver_sparse(
|
|
|
186
186
|
return "01", weight, ([nodes[0]], [nodes[1]]), -weight
|
|
187
187
|
|
|
188
188
|
if quality is None:
|
|
189
|
-
quuality =
|
|
189
|
+
quuality = 2
|
|
190
190
|
|
|
191
191
|
bitstring = ""
|
|
192
192
|
if isinstance(best_guess, str):
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='5.
|
|
54
|
+
version='5.6.0',
|
|
55
55
|
author='Dan Strano',
|
|
56
56
|
author_email='stranoj@gmail.com',
|
|
57
57
|
description='Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|