PyQrackIsing 7.0.2__tar.gz → 7.1.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-7.0.2/pyqrackising.egg-info → pyqrackising-7.1.0}/PKG-INFO +1 -1
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/README.md +12 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyproject.toml +1 -1
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/__init__.py +1 -0
- pyqrackising-7.1.0/pyqrackising/tsp_maxcut.py +49 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0/pyqrackising.egg-info}/PKG-INFO +1 -1
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising.egg-info/SOURCES.txt +1 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/setup.py +1 -1
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/CMakeLists.txt +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/LICENSE.md +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/MANIFEST.in +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/generate_tfim_samples.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/kernels.cl +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/maxcut_tfim.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/maxcut_tfim_sparse.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/maxcut_tfim_streaming.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/maxcut_tfim_util.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/spin_glass_solver.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/spin_glass_solver_sparse.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/spin_glass_solver_streaming.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/spin_glass_solver_util.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/tfim_magnetization.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/tfim_square_magnetization.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising/tsp.py +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising.egg-info/not-zip-safe +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/pyqrackising.egg-info/top_level.txt +0 -0
- {pyqrackising-7.0.2 → pyqrackising-7.1.0}/setup.cfg +0 -0
|
@@ -139,6 +139,18 @@ solution_bit_string, cut_value, node_groups, energy = spin_glass_solver_streamin
|
|
|
139
139
|
# solution_bit_string, cut_value, node_groups = maxcut_tfim_streaming(G_func, nodes, G_func_args_tuple=args_tuple)
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
Finally, combining insights from both the (Monte Carlo) TSP and MAXCUT solvers, we have `tsp_maxcut(G)`:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
from pyqrackising import tsp_maxcut
|
|
146
|
+
import networkx as nx
|
|
147
|
+
|
|
148
|
+
G = nx.petersen_graph()
|
|
149
|
+
best_partition, best_cut_value = tsp_maxcut(G, k_neighbors=20)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
This solver is entirely serial and can be parallelized over CPU processing elements by user code, easily.
|
|
153
|
+
|
|
142
154
|
## Environment Variables
|
|
143
155
|
|
|
144
156
|
We expose an environment variable, "`PYQRACKISING_MAX_GPU_PROC_ELEM`", for when `is_alt_gpu_sampling=True`. The default value (when the variable is not set) is queried from the OpenCL device properties. You might see performance benefit from tuning this manually to several times your device's number of "compute units" (or tune it down to reduce private memory usage).
|
|
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "pyqrackising"
|
|
15
|
-
version = "7.0
|
|
15
|
+
version = "7.1.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"}
|
|
@@ -8,4 +8,5 @@ from .spin_glass_solver import spin_glass_solver
|
|
|
8
8
|
from .spin_glass_solver_sparse import spin_glass_solver_sparse
|
|
9
9
|
from .spin_glass_solver_streaming import spin_glass_solver_streaming
|
|
10
10
|
from .tsp import tsp_symmetric, tsp_asymmetric
|
|
11
|
+
from .tsp_maxcut import tsp_maxcut
|
|
11
12
|
from .convert_tensor_network_to_tsp import convert_tensor_network_to_tsp, convert_quimb_tree_to_tsp
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from .tsp import tsp_symmetric
|
|
2
|
+
|
|
3
|
+
def tsp_to_maxcut_bipartition(tsp_path, weights):
|
|
4
|
+
n = len(tsp_path)
|
|
5
|
+
best_cut_value = -float('inf')
|
|
6
|
+
best_partition = None
|
|
7
|
+
direction = 0
|
|
8
|
+
|
|
9
|
+
for offset in [-1, 0, 1]:
|
|
10
|
+
mid = n // 2 + offset
|
|
11
|
+
A = tsp_path[:mid]
|
|
12
|
+
B = tsp_path[mid:]
|
|
13
|
+
cut_value = sum(
|
|
14
|
+
weights[u, v]
|
|
15
|
+
for u in A
|
|
16
|
+
for v in B
|
|
17
|
+
)
|
|
18
|
+
if cut_value > best_cut_value:
|
|
19
|
+
best_cut_value = cut_value
|
|
20
|
+
best_partition = (A, B)
|
|
21
|
+
direction = offset
|
|
22
|
+
|
|
23
|
+
if direction == 0:
|
|
24
|
+
return best_partition, best_cut_value
|
|
25
|
+
|
|
26
|
+
improved = True
|
|
27
|
+
best_offset = direction
|
|
28
|
+
while improved:
|
|
29
|
+
improved = False
|
|
30
|
+
offset = best_offset + direction
|
|
31
|
+
mid = n // 2 + offset
|
|
32
|
+
A = tsp_path[:mid]
|
|
33
|
+
B = tsp_path[mid:]
|
|
34
|
+
cut_value = sum(
|
|
35
|
+
weights[u, v]
|
|
36
|
+
for u in A
|
|
37
|
+
for v in B
|
|
38
|
+
)
|
|
39
|
+
if cut_value > best_cut_value:
|
|
40
|
+
best_cut_value = cut_value
|
|
41
|
+
best_partition = (A, B)
|
|
42
|
+
best_offset = offset
|
|
43
|
+
improved = True
|
|
44
|
+
|
|
45
|
+
return best_partition, best_cut_value
|
|
46
|
+
|
|
47
|
+
def tsp_maxcut(G, k_neighbors=20):
|
|
48
|
+
path, length = tsp_symmetric(G=G, is_cyclic=False, monte_carlo=True, k_neighbors=k_neighbors)
|
|
49
|
+
return tsp_to_maxcut_bipartition(path, G)
|
|
@@ -20,6 +20,7 @@ pyqrackising/spin_glass_solver_util.py
|
|
|
20
20
|
pyqrackising/tfim_magnetization.py
|
|
21
21
|
pyqrackising/tfim_square_magnetization.py
|
|
22
22
|
pyqrackising/tsp.py
|
|
23
|
+
pyqrackising/tsp_maxcut.py
|
|
23
24
|
pyqrackising.egg-info/PKG-INFO
|
|
24
25
|
pyqrackising.egg-info/SOURCES.txt
|
|
25
26
|
pyqrackising.egg-info/dependency_links.txt
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='pyqrackising',
|
|
54
|
-
version='7.0
|
|
54
|
+
version='7.1.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|