PyQrackIsing 9.16.0__tar.gz → 9.16.1__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.
Files changed (36) hide show
  1. {pyqrackising-9.16.0/pyqrackising.egg-info → pyqrackising-9.16.1}/PKG-INFO +1 -1
  2. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyproject.toml +1 -1
  3. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/maxcut_tfim.py +10 -14
  4. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/maxcut_tfim_sparse.py +11 -12
  5. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/maxcut_tfim_streaming.py +10 -11
  6. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/maxcut_tfim_util.py +2 -9
  7. {pyqrackising-9.16.0 → pyqrackising-9.16.1/pyqrackising.egg-info}/PKG-INFO +1 -1
  8. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/setup.py +1 -1
  9. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/LICENSE.md +0 -0
  10. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/MANIFEST.in +0 -0
  11. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/README.md +0 -0
  12. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/__init__.py +0 -0
  13. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  14. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/generate_tfim_samples.py +0 -0
  15. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/kernels.cl +0 -0
  16. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/otoc.py +0 -0
  17. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_bnb.py +0 -0
  18. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_bnb_sparse.py +0 -0
  19. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_bnb_streaming.py +0 -0
  20. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_exact.py +0 -0
  21. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_exact_sparse.py +0 -0
  22. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/solve_maxcut_exact_streaming.py +0 -0
  23. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/spin_glass_solver.py +0 -0
  24. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/spin_glass_solver_hybrid.py +0 -0
  25. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/spin_glass_solver_sparse.py +0 -0
  26. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  27. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/tfim_magnetization.py +0 -0
  28. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/tfim_square_magnetization.py +0 -0
  29. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/tsp.py +0 -0
  30. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising/tsp_maxcut.py +0 -0
  31. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising.egg-info/SOURCES.txt +0 -0
  32. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising.egg-info/dependency_links.txt +0 -0
  33. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising.egg-info/not-zip-safe +0 -0
  34. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising.egg-info/requires.txt +0 -0
  35. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/pyqrackising.egg-info/top_level.txt +0 -0
  36. {pyqrackising-9.16.0 → pyqrackising-9.16.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.16.0
3
+ Version: 9.16.1
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "pyqrackising"
10
- version = "9.16.0"
10
+ version = "9.16.1"
11
11
  requires-python = ">=3.8"
12
12
  description = "Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)"
13
13
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -34,18 +34,15 @@ wgs = opencl_context.work_group_size
34
34
 
35
35
 
36
36
  @njit(cache=True)
37
- def update_repulsion_choice(G_m, weights, n, used, node, repulsion_base):
37
+ def update_repulsion_choice(G_m, weights, n, node, repulsion_base):
38
38
  # Select node
39
- used[node] = True
39
+ weights[node] = 0.0
40
40
 
41
41
  if abs(1.0 - repulsion_base) <= epsilon:
42
42
  return
43
43
 
44
44
  # Repulsion: penalize neighbors
45
- for nbr in range(n):
46
- if used[nbr]:
47
- continue
48
- weights[nbr] *= repulsion_base ** (-G_m[node, nbr])
45
+ weights *= repulsion_base ** (-G_m[node])
49
46
 
50
47
 
51
48
  # Written by Elara (OpenAI custom GPT) and improved by Dan Strano
@@ -57,25 +54,24 @@ def local_repulsion_choice(G_m, repulsion_base, n, m, s):
57
54
  - After choosing a node, its neighbors' probabilities are further reduced
58
55
  """
59
56
 
60
- used = np.zeros(n, dtype=np.bool_) # False = available, True = used
61
-
62
57
  # First bit:
63
58
  node = s % n
64
59
  if m == 1:
60
+ used = np.zeros(n, dtype=np.bool_)
65
61
  used[node] = True
66
62
  return used
67
63
 
68
64
  weights = np.ones(n, dtype=np.float64)
69
- update_repulsion_choice(G_m, weights, n, used, node, repulsion_base)
65
+ update_repulsion_choice(G_m, weights, n, node, repulsion_base)
70
66
 
71
67
  for _ in range(1, m - 1):
72
- node = bit_pick(weights, used, n)
73
- update_repulsion_choice(G_m, weights, n, used, node, repulsion_base)
68
+ node = bit_pick(weights, n)
69
+ update_repulsion_choice(G_m, weights, n, node, repulsion_base)
74
70
 
75
- node = bit_pick(weights, used, n)
76
- used[node] = True
71
+ node = bit_pick(weights, n)
72
+ weights[node] = 0.0
77
73
 
78
- return used
74
+ return weights == 0.0
79
75
 
80
76
 
81
77
  @njit(parallel=True, cache=True)
@@ -35,9 +35,9 @@ wgs = opencl_context.work_group_size
35
35
 
36
36
 
37
37
  @njit(cache=True)
38
- def update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repulsion_base):
38
+ def update_repulsion_choice(G_data, G_rows, G_cols, weights, n, node, repulsion_base):
39
39
  # Select node
40
- used[node] = True
40
+ weights[node] = 0.0
41
41
 
42
42
  if abs(1.0 - repulsion_base) <= epsilon:
43
43
  return
@@ -45,12 +45,12 @@ def update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repu
45
45
  # Repulsion: penalize neighbors
46
46
  for j in range(G_rows[node], G_rows[node + 1]):
47
47
  nbr = G_cols[j]
48
- if used[nbr]:
48
+ if weights[nbr] == 0.0:
49
49
  continue
50
50
  weights[nbr] *= repulsion_base ** (-G_data[j])
51
51
 
52
52
  for nbr in range(node):
53
- if used[nbr]:
53
+ if weights[nbr] == 0.0:
54
54
  continue
55
55
  start = G_rows[nbr]
56
56
  end = G_rows[nbr + 1]
@@ -68,25 +68,24 @@ def local_repulsion_choice(G_data, G_rows, G_cols, repulsion_base, n, m, s):
68
68
  - After choosing a node, its neighbors' probabilities are further reduced
69
69
  """
70
70
 
71
- used = np.zeros(n, dtype=np.bool_) # False = available, True = used
72
-
73
71
  # First bit:
74
72
  node = s % n
75
73
  if m == 1:
74
+ used = np.zeros(n, dtype=np.bool_)
76
75
  used[node] = True
77
76
  return used
78
77
 
79
78
  weights = np.ones(n, dtype=np.float64)
80
- update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repulsion_base)
79
+ update_repulsion_choice(G_data, G_rows, G_cols, weights, n, node, repulsion_base)
81
80
 
82
81
  for _ in range(1, m - 1):
83
- node = bit_pick(weights, used, n)
84
- update_repulsion_choice(G_data, G_rows, G_cols, weights, n, used, node, repulsion_base)
82
+ node = bit_pick(weights, n)
83
+ update_repulsion_choice(G_data, G_rows, G_cols, weights, n, node, repulsion_base)
85
84
 
86
- node = bit_pick(weights, used, n)
87
- used[node] = True
85
+ node = bit_pick(weights, n)
86
+ weights[node] = 0.0
88
87
 
89
- return used
88
+ return weights == 0.0
90
89
 
91
90
 
92
91
  @njit(parallel=True, cache=True)
@@ -23,16 +23,16 @@ dtype = opencl_context.dtype
23
23
 
24
24
 
25
25
  @njit(cache=True)
26
- def update_repulsion_choice(G_func, nodes, weights, n, used, node, repulsion_base):
26
+ def update_repulsion_choice(G_func, nodes, weights, n, node, repulsion_base):
27
27
  # Select node
28
- used[node] = True
28
+ weights[node] = 0.0
29
29
 
30
30
  if abs(1.0 - repulsion_base) <= epsilon:
31
31
  return
32
32
 
33
33
  # Repulsion: penalize neighbors
34
34
  for nbr in range(n):
35
- if used[nbr]:
35
+ if weights[nbr] == 0.0:
36
36
  continue
37
37
  weights[nbr] *= repulsion_base ** (-G_func(nodes[node], nodes[nbr]))
38
38
 
@@ -46,25 +46,24 @@ def local_repulsion_choice(G_func, nodes, repulsion_base, n, m, s):
46
46
  - After choosing a node, its neighbors' probabilities are further reduced
47
47
  """
48
48
 
49
- used = np.zeros(n, dtype=np.bool_) # False = available, True = used
50
-
51
49
  # First bit:
52
50
  node = s % n
53
51
  if m == 1:
52
+ used = np.zeros(n, dtype=np.bool_)
54
53
  used[node] = True
55
54
  return used
56
55
 
57
56
  weights = np.ones(n, dtype=np.float64)
58
- update_repulsion_choice(G_func, nodes, weights, n, used, node, repulsion_base)
57
+ update_repulsion_choice(G_func, nodes, weights, n, node, repulsion_base)
59
58
 
60
59
  for _ in range(1, m - 1):
61
- node = bit_pick(weights, used, n)
62
- update_repulsion_choice(G_func, nodes, weights, n, used, node, repulsion_base)
60
+ node = bit_pick(weights, n)
61
+ update_repulsion_choice(G_func, nodes, weights, n, node, repulsion_base)
63
62
 
64
- node = bit_pick(weights, used, n)
65
- used[node] = True
63
+ node = bit_pick(weights, n)
64
+ weights[node] = 0.0
66
65
 
67
- return used
66
+ return weights == 0.0
68
67
 
69
68
 
70
69
  @njit(parallel=True, cache=True)
@@ -708,21 +708,14 @@ def sample_mag(cum_prob):
708
708
 
709
709
 
710
710
  @njit(cache=True)
711
- def bit_pick(weights, used, n):
711
+ def bit_pick(weights, n):
712
712
  # Count available
713
- p = 0.0
714
- for i in range(n):
715
- if used[i]:
716
- continue
717
- p += weights[i]
718
-
713
+ p = weights.sum()
719
714
  # Normalize & sample
720
715
  p *= np.random.rand()
721
716
  cum = 0.0
722
717
  node = 0
723
718
  for i in range(n):
724
- if used[i]:
725
- continue
726
719
  cum += weights[i]
727
720
  if p < cum:
728
721
  node = i
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 9.16.0
3
+ Version: 9.16.1
4
4
  Summary: Fast MAXCUT, TSP, and sampling heuristics from near-ideal transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -7,7 +7,7 @@ with open(README_PATH) as readme_file:
7
7
 
8
8
  setup(
9
9
  name="pyqrackising",
10
- version="9.16.0",
10
+ version="9.16.1",
11
11
  author="Dan Strano",
12
12
  author_email="stranoj@gmail.com",
13
13
  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