PyQrackIsing 3.4.1__tar.gz → 3.4.3__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 (22) hide show
  1. {pyqrackising-3.4.1/pyqrackising.egg-info → pyqrackising-3.4.3}/PKG-INFO +1 -1
  2. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyproject.toml +1 -1
  3. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/tsp.py +22 -24
  4. {pyqrackising-3.4.1 → pyqrackising-3.4.3/pyqrackising.egg-info}/PKG-INFO +1 -1
  5. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/setup.py +1 -1
  6. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/CMakeLists.txt +0 -0
  7. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/LICENSE.md +0 -0
  8. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/MANIFEST.in +0 -0
  9. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/README.md +0 -0
  10. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/__init__.py +0 -0
  11. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/_pyqrack_ising.cpp +0 -0
  12. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/generate_tfim_samples.py +0 -0
  13. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/kernels.cl +0 -0
  14. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/maxcut_tfim.py +0 -0
  15. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/spin_glass_solver.py +0 -0
  16. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/tfim_magnetization.py +0 -0
  17. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising/tfim_square_magnetization.py +0 -0
  18. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising.egg-info/SOURCES.txt +0 -0
  19. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising.egg-info/dependency_links.txt +0 -0
  20. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising.egg-info/not-zip-safe +0 -0
  21. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/pyqrackising.egg-info/top_level.txt +0 -0
  22. {pyqrackising-3.4.1 → pyqrackising-3.4.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 3.4.1
3
+ Version: 3.4.3
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
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
11
11
 
12
12
  [project]
13
13
  name = "pyqrackising"
14
- version = "3.4.1"
14
+ version = "3.4.3"
15
15
  requires-python = ">=3.8"
16
16
  description = "Near-ideal closed-form solutions for transverse field Ising model (TFIM)"
17
17
  readme = {file = "README.txt", content-type = "text/markdown"}
@@ -207,7 +207,7 @@ def init_G_a_b(G_m, a, b):
207
207
 
208
208
 
209
209
  @njit
210
- def stitch(G_m, path_a, path_b, sol_weight):
210
+ def stitch(G_m, path_a, path_b, is_asym):
211
211
  is_single_a = len(path_a) == 1
212
212
  is_single_b = len(path_b) == 1
213
213
  best_path = [0]
@@ -245,25 +245,32 @@ def stitch(G_m, path_a, path_b, sol_weight):
245
245
  terminals_a = [path_a[0], path_a[-1]]
246
246
  terminals_b = [path_b[0], path_b[-1]]
247
247
 
248
- best_weight = G_m[terminals_a[1], terminals_b[0]]
248
+ best_connect = G_m[terminals_a[1], terminals_b[0]]
249
249
  best_path = path_b.copy()
250
250
  weight = G_m[terminals_a[0], terminals_b[1]]
251
- if weight < best_weight:
252
- best_weight = weight
251
+ if weight < best_connect:
252
+ best_connect = weight
253
253
  best_path += path_a
254
254
  else:
255
255
  best_path = path_a + best_path
256
256
 
257
+ if not is_asym:
258
+ path_weight = path_length(path_a, G_m) + path_length(path_a, G_m)
259
+ best_weight = best_connect + path_weight
260
+
257
261
  for _ in range(2):
258
262
  for _ in range(2):
263
+ if is_asym:
264
+ path_weight = path_length(path_a, G_m) + path_length(path_a, G_m)
265
+ best_weight = best_connect + path_weight
259
266
  for i in range(1, len(path_b)):
260
267
  weight = (
261
268
  G_m[terminals_a[0], path_b[i - 1]] +
262
269
  G_m[terminals_a[1], path_b[i]] -
263
270
  G_m[path_b[i - 1], path_b[i]]
264
271
  )
265
- if weight < best_weight:
266
- best_weight = weight
272
+ if (weight + path_weight) < best_weight:
273
+ best_weight = weight + path_weight
267
274
  best_path = path_b.copy()
268
275
  best_path[i:i] = path_a
269
276
  path_a.reverse()
@@ -271,7 +278,7 @@ def stitch(G_m, path_a, path_b, sol_weight):
271
278
  path_a, path_b = path_b, path_a
272
279
  terminals_a, terminals_b = terminals_b, terminals_a
273
280
 
274
- return best_path, best_weight
281
+ return best_path
275
282
 
276
283
 
277
284
 
@@ -375,13 +382,8 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=2, shots=None, corr
375
382
  path_a = [a[x] for x in sol_a[0]]
376
383
  path_b = [b[x] for x in sol_b[0]]
377
384
 
378
- sol_weight = sol_a[1] + sol_b[1]
379
-
380
- if len(c):
381
- sol_weight += G_m[b[-1], c[0]]
382
-
383
385
  if start_node is None:
384
- best_path, best_weight = stitch(G_m, path_a, path_b, sol_weight)
386
+ best_path = stitch(G_m, path_a, path_b, False)
385
387
  else:
386
388
  best_path = path_a + path_b
387
389
  best_weight = G_m[path_a[0], path_b[0]]
@@ -390,11 +392,9 @@ def tsp_symmetric(G, start_node=None, end_node=None, quality=2, shots=None, corr
390
392
  path_b.reverse()
391
393
  best_path = path_a + path_b
392
394
  best_weight = weight
393
- best_weight += sol_weight
394
395
 
395
396
  if len(c):
396
397
  best_path += c
397
- best_weight += G_m[best_path[-1], c[0]]
398
398
 
399
399
  if is_top_level:
400
400
  if is_cyclic:
@@ -437,7 +437,6 @@ def tsp_asymmetric(G, start_node=None, end_node=None, quality=1, shots=None, cor
437
437
  start_node = None
438
438
  end_node = None
439
439
 
440
-
441
440
  if n_nodes < 3:
442
441
  if n_nodes == 2:
443
442
  weight = G_m[0, 1]
@@ -453,9 +452,12 @@ def tsp_asymmetric(G, start_node=None, end_node=None, quality=1, shots=None, cor
453
452
  return (nodes, 0)
454
453
 
455
454
 
455
+ is_reversed = False
456
456
  if (start_node is None) and not (end_node is None):
457
+ is_reversed = True
457
458
  start_node = end_node
458
459
  end_node = None
460
+ G_m = G_m.T
459
461
 
460
462
  a = []
461
463
  b = []
@@ -489,13 +491,8 @@ def tsp_asymmetric(G, start_node=None, end_node=None, quality=1, shots=None, cor
489
491
  path_a = [a[x] for x in sol_a[0]]
490
492
  path_b = [b[x] for x in sol_b[0]]
491
493
 
492
- sol_weight = sol_a[1] + sol_b[1]
493
-
494
- if len(c):
495
- sol_weight += G_m[b[-1], c[0]]
496
-
497
494
  if start_node is None:
498
- best_path, best_weight = stitch(G_m, path_a, path_b, sol_weight)
495
+ best_path = stitch(G_m, path_a, path_b, True)
499
496
  else:
500
497
  best_path = path_a + path_b
501
498
  best_weight = G_m[path_a[0], path_b[0]]
@@ -504,11 +501,9 @@ def tsp_asymmetric(G, start_node=None, end_node=None, quality=1, shots=None, cor
504
501
  path_b.reverse()
505
502
  best_path = path_a + path_b
506
503
  best_weight = weight
507
- best_weight += sol_weight
508
504
 
509
505
  if len(c):
510
506
  best_path += c
511
- best_weight += G_m[best_path[-1], c[0]]
512
507
 
513
508
  if is_top_level:
514
509
  if is_cyclic:
@@ -557,4 +552,7 @@ def tsp_asymmetric(G, start_node=None, end_node=None, quality=1, shots=None, cor
557
552
  best_weight += G_m[cycle_node, best_path[-1]]
558
553
  best_path += [cycle_node]
559
554
 
555
+ if is_reversed:
556
+ final_path.reverse()
557
+
560
558
  return [nodes[x] for x in final_path], best_weight
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 3.4.1
3
+ Version: 3.4.3
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
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='3.4.1',
54
+ version='3.4.3',
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