PyQrackIsing 1.24.1__tar.gz → 1.24.2__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 (21) hide show
  1. {pyqrackising-1.24.1/PyQrackIsing.egg-info → pyqrackising-1.24.2}/PKG-INFO +1 -1
  2. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/tsp_symmetric.py +37 -10
  3. {pyqrackising-1.24.1 → pyqrackising-1.24.2/PyQrackIsing.egg-info}/PKG-INFO +1 -1
  4. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/pyproject.toml +1 -1
  5. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/setup.py +1 -1
  6. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/CMakeLists.txt +0 -0
  7. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/LICENSE.md +0 -0
  8. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/MANIFEST.in +0 -0
  9. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/__init__.py +0 -0
  10. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
  11. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/generate_tfim_samples.py +0 -0
  12. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/maxcut_tfim.py +0 -0
  13. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/spin_glass_solver.py +0 -0
  14. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/tfim_magnetization.py +0 -0
  15. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing/tfim_square_magnetization.py +0 -0
  16. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
  17. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
  18. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing.egg-info/not-zip-safe +0 -0
  19. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/PyQrackIsing.egg-info/top_level.txt +0 -0
  20. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/README.md +0 -0
  21. {pyqrackising-1.24.1 → pyqrackising-1.24.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.24.1
3
+ Version: 1.24.2
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -20,12 +20,35 @@ def path_length(path, G_m):
20
20
  return tot_len
21
21
 
22
22
 
23
+ @njit
24
+ def one_way_two_opt(path, G):
25
+ improved = True
26
+ best_path = path
27
+ best_dist = path_length(best_path, G)
28
+ path_len = len(path)
29
+
30
+ while improved:
31
+ improved = False
32
+ for i in range(1, path_len - 1):
33
+ for j in range(i+1, path_len + 1):
34
+ if j - i == 1: # adjacent edges, skip
35
+ continue
36
+ new_path = best_path[:]
37
+ new_path[i:j] = best_path[j-1:i-1:-1]
38
+ new_dist = path_length(new_path, G)
39
+ if new_dist < best_dist:
40
+ best_path, best_dist = new_path, new_dist
41
+ improved = True
42
+ path = best_path
43
+ return best_path, best_dist
44
+
45
+
23
46
  @njit
24
47
  def two_opt(path, G):
25
48
  improved = True
26
49
  best_path = path
27
50
  best_dist = path_length(best_path, G)
28
-
51
+
29
52
  while improved:
30
53
  improved = False
31
54
  for i in range(1, len(path) - 2):
@@ -185,14 +208,14 @@ def stitch(G_m, path_a, path_b, sol_weight):
185
208
  terminals_a = [path_a[0], path_a[-1]]
186
209
  terminals_b = [path_b[0], path_b[-1]]
187
210
 
211
+ best_weight = G_m[terminals_a[1], terminals_b[0]]
212
+ best_path = path_a + path_b
213
+ weight = G_m[terminals_a[0], terminals_b[1]]
214
+ if weight < best_weight:
215
+ best_weight = weight
216
+ best_path = path_b + path_a
188
217
  for _ in range(2):
189
218
  for _ in range(2):
190
- best_weight = G_m[terminals_a[1], terminals_b[0]]
191
- best_path = path_a + path_b
192
- weight = G_m[terminals_b[1], terminals_a[0]]
193
- if weight < best_weight:
194
- best_weight = weight
195
- best_path = path_b + path_a
196
219
  for i in range(1, len(path_b)):
197
220
  weight = (
198
221
  G_m[terminals_a[0], path_b[i - 1]] +
@@ -286,8 +309,12 @@ def tsp_symmetric(G, quality=1, shots=None, correction_quality=2, monte_carlo=Fa
286
309
  cycle_index = best_path.index(cycle_node)
287
310
  best_weight -= G_m[best_path[cycle_index], best_path[cycle_index + 1]]
288
311
  best_path = best_path[cycle_index + 1:] + best_path[:cycle_index]
289
- elif is_cyclic:
290
- cycle_node = best_path[0]
291
- best_path += [cycle_node]
312
+ else:
313
+ best_path, best_weight = one_way_two_opt(best_path, G_m)
314
+
315
+ if is_cyclic:
316
+ cycle_node = best_path[0]
317
+ best_weight += G_m[cycle_node, best_path[-1]]
318
+ best_path += [cycle_node]
292
319
 
293
320
  return [nodes[x] for x in best_path], best_weight
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.24.1
3
+ Version: 1.24.2
4
4
  Summary: Near-ideal closed-form solutions for transverse field Ising model (TFIM)
5
5
  Home-page: https://github.com/vm6502q/PyQrackIsing
6
6
  Author: Dan Strano
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "PyQrackIsing"
15
- version = "1.24.1"
15
+ version = "1.24.2"
16
16
  requires-python = ">=3.8"
17
17
  description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
18
18
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='PyQrackIsing',
54
- version='1.24.1',
54
+ version='1.24.2',
55
55
  author='Dan Strano',
56
56
  author_email='stranoj@gmail.com',
57
57
  description='Near-ideal closed-form solutions for transverse field Ising model (TFIM)',
File without changes
File without changes
File without changes
File without changes