PyQrackIsing 7.4.9__tar.gz → 7.5.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.
Files changed (30) hide show
  1. {pyqrackising-7.4.9/pyqrackising.egg-info → pyqrackising-7.5.0}/PKG-INFO +1 -1
  2. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyproject.toml +1 -1
  3. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim.py +24 -13
  4. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_sparse.py +26 -13
  5. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_streaming.py +25 -13
  6. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_sparse.py +1 -1
  7. {pyqrackising-7.4.9 → pyqrackising-7.5.0/pyqrackising.egg-info}/PKG-INFO +1 -1
  8. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/setup.py +1 -1
  9. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/CMakeLists.txt +0 -0
  10. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/LICENSE.md +0 -0
  11. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/MANIFEST.in +0 -0
  12. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/README.md +0 -0
  13. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/__init__.py +0 -0
  14. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/_pyqrack_ising.cpp +0 -0
  15. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/convert_tensor_network_to_tsp.py +0 -0
  16. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/generate_tfim_samples.py +0 -0
  17. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/kernels.cl +0 -0
  18. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/maxcut_tfim_util.py +0 -0
  19. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver.py +0 -0
  20. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_streaming.py +0 -0
  21. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/spin_glass_solver_util.py +0 -0
  22. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/tfim_magnetization.py +0 -0
  23. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/tfim_square_magnetization.py +0 -0
  24. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/tsp.py +0 -0
  25. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising/tsp_maxcut.py +0 -0
  26. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising.egg-info/SOURCES.txt +0 -0
  27. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising.egg-info/dependency_links.txt +0 -0
  28. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising.egg-info/not-zip-safe +0 -0
  29. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/pyqrackising.egg-info/top_level.txt +0 -0
  30. {pyqrackising-7.4.9 → pyqrackising-7.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 7.4.9
3
+ Version: 7.5.0
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
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "pyqrackising"
15
- version = "7.4.9"
15
+ version = "7.5.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"}
@@ -85,27 +85,38 @@ def compute_energy(sample, G_m, n_qubits):
85
85
 
86
86
  @njit(parallel=True)
87
87
  def sample_for_solution(G_m, shots, thresholds, weights, dtype):
88
+ shots = max(1, shots >> 1)
88
89
  n = len(G_m)
89
90
  max_weight = G_m.max()
90
91
 
91
92
  solutions = np.empty((shots, n), dtype=np.bool_)
92
93
  energies = np.empty(shots, dtype=dtype)
93
94
 
94
- for s in prange(shots):
95
- # First dimension: Hamming weight
96
- mag_prob = np.random.random()
97
- m = 0
98
- while thresholds[m] < mag_prob:
95
+ best_solution = solutions[0]
96
+ best_energy = float("inf")
97
+
98
+ improved = True
99
+ while improved:
100
+ improved = False
101
+ for s in prange(shots):
102
+ # First dimension: Hamming weight
103
+ mag_prob = np.random.random()
104
+ m = 0
105
+ while thresholds[m] < mag_prob:
106
+ m += 1
99
107
  m += 1
100
- m += 1
101
108
 
102
- # Second dimension: permutation within Hamming weight
103
- sample = local_repulsion_choice(G_m, max_weight, weights, n, m, s)
104
-
105
- solutions[s] = sample
106
- energies[s] = compute_energy(sample, G_m, n)
107
-
108
- best_solution = solutions[np.argmin(energies)]
109
+ # Second dimension: permutation within Hamming weight
110
+ sample = local_repulsion_choice(G_m, max_weight, weights, n, m, s)
111
+ solutions[s] = sample
112
+ energies[s] = compute_energy(sample, G_m, n)
113
+
114
+ best_index = np.argmin(energies)
115
+ energy = energies[best_index]
116
+ if energy < best_energy:
117
+ best_energy = energy
118
+ best_solution = solutions[best_index].copy()
119
+ improved = True
109
120
 
110
121
  best_value = 0.0
111
122
  for u in range(n):
@@ -90,33 +90,46 @@ def compute_energy(sample, G_data, G_rows, G_cols):
90
90
  for u in range(n_qubits):
91
91
  for col in range(G_rows[u], G_rows[u + 1]):
92
92
  v = G_cols[col]
93
- energy += G_data[col] * (1 if sample[u] == sample[v] else -1)
93
+ val = G_data[col]
94
+ energy += val if sample[u] == sample[v] else -val
94
95
 
95
96
  return energy
96
97
 
97
98
 
98
99
  @njit(parallel=True)
99
100
  def sample_for_solution(G_data, G_rows, G_cols, shots, thresholds, weights, dtype):
101
+ shots = max(1, shots >> 1)
100
102
  n = G_rows.shape[0] - 1
101
103
  max_weight = G_data.max()
102
104
 
103
105
  solutions = np.empty((shots, n), dtype=np.bool_)
104
106
  energies = np.empty(shots, dtype=dtype)
105
107
 
106
- for s in prange(shots):
107
- # First dimension: Hamming weight
108
- mag_prob = np.random.random()
109
- m = 0
110
- while thresholds[m] < mag_prob:
108
+ best_solution = solutions[0]
109
+ best_energy = float("inf")
110
+
111
+ improved = True
112
+ while improved:
113
+ improved = False
114
+ for s in prange(shots):
115
+ # First dimension: Hamming weight
116
+ mag_prob = np.random.random()
117
+ m = 0
118
+ while thresholds[m] < mag_prob:
119
+ m += 1
111
120
  m += 1
112
- m += 1
113
121
 
114
- # Second dimension: permutation within Hamming weight
115
- sample = local_repulsion_choice(G_cols, G_data, G_rows, max_weight, weights, n, m, s)
116
- solutions[s] = sample
117
- energies[s] = compute_energy(sample, G_data, G_rows, G_cols)
118
-
119
- best_solution = solutions[np.argmin(energies)]
122
+ # Second dimension: permutation within Hamming weight
123
+ sample = local_repulsion_choice(G_cols, G_data, G_rows, max_weight, weights, n, m, s)
124
+ solutions[s] = sample
125
+ energies[s] = compute_energy(sample, G_data, G_rows, G_cols)
126
+
127
+ best_index = np.argmin(energies)
128
+ energy = energies[best_index]
129
+ if energy < best_energy:
130
+ best_energy = energy
131
+ best_solution = solutions[best_index].copy()
132
+ improved = True
120
133
 
121
134
  best_value = 0.0
122
135
  for u in range(n):
@@ -89,24 +89,36 @@ def compute_energy(sample, G_func, nodes, n_qubits):
89
89
 
90
90
  @njit(parallel=True)
91
91
  def sample_for_solution(G_func, nodes, max_weight, shots, thresholds, degrees_sum, weights, n, dtype):
92
+ shots = max(1, shots >> 1)
93
+
92
94
  solutions = np.empty((shots, n), dtype=np.bool_)
93
95
  energies = np.empty(shots, dtype=dtype)
94
96
 
95
- for s in prange(shots):
96
- # First dimension: Hamming weight
97
- mag_prob = np.random.random()
98
- m = 0
99
- while thresholds[m] < mag_prob:
97
+ best_solution = solutions[0]
98
+ best_energy = float("inf")
99
+
100
+ improved = True
101
+ while improved:
102
+ improved = False
103
+ for s in prange(shots):
104
+ # First dimension: Hamming weight
105
+ mag_prob = np.random.random()
106
+ m = 0
107
+ while thresholds[m] < mag_prob:
108
+ m += 1
100
109
  m += 1
101
- m += 1
102
-
103
- # Second dimension: permutation within Hamming weight
104
- sample = local_repulsion_choice(G_func, nodes, max_weight, weights, n, m, s)
105
-
106
- solutions[s] = sample
107
- energies[s] = compute_energy(sample, G_func, nodes, n)
108
110
 
109
- best_solution = solutions[np.argmin(energies)]
111
+ # Second dimension: permutation within Hamming weight
112
+ sample = local_repulsion_choice(G_func, nodes, max_weight, weights, n, m, s)
113
+ solutions[s] = sample
114
+ energies[s] = compute_energy(sample, G_func, nodes, n)
115
+
116
+ best_index = np.argmin(energies)
117
+ energy = energies[best_index]
118
+ if energy < best_energy:
119
+ best_energy = energy
120
+ best_solution = solutions[best_index].copy()
121
+ improved = True
110
122
 
111
123
  best_value = 0.0
112
124
  for u in range(n):
@@ -192,7 +192,7 @@ def spin_glass_solver_sparse(
192
192
  if isinstance(G, nx.Graph):
193
193
  nodes = list(G.nodes())
194
194
  n_qubits = len(nodes)
195
- G_m = to_scipy_sparse_upper_triangular(G, nodes, n_qubits)
195
+ G_m = to_scipy_sparse_upper_triangular(G, nodes, n_qubits, dtype)
196
196
  else:
197
197
  n_qubits = G.shape[0]
198
198
  nodes = list(range(n_qubits))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyqrackising
3
- Version: 7.4.9
3
+ Version: 7.5.0
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
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
51
51
 
52
52
  setup(
53
53
  name='pyqrackising',
54
- version='7.4.9',
54
+ version='7.5.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