PyQrackIsing 1.26.2__tar.gz → 1.26.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 (21) hide show
  1. {pyqrackising-1.26.2/PyQrackIsing.egg-info → pyqrackising-1.26.3}/PKG-INFO +1 -1
  2. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/maxcut_tfim.py +18 -16
  3. {pyqrackising-1.26.2 → pyqrackising-1.26.3/PyQrackIsing.egg-info}/PKG-INFO +1 -1
  4. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/pyproject.toml +1 -1
  5. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/setup.py +1 -1
  6. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/CMakeLists.txt +0 -0
  7. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/LICENSE.md +0 -0
  8. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/MANIFEST.in +0 -0
  9. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/__init__.py +0 -0
  10. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
  11. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/generate_tfim_samples.py +0 -0
  12. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/spin_glass_solver.py +0 -0
  13. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/tfim_magnetization.py +0 -0
  14. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/tfim_square_magnetization.py +0 -0
  15. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing/tsp_symmetric.py +0 -0
  16. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
  17. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
  18. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing.egg-info/not-zip-safe +0 -0
  19. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/PyQrackIsing.egg-info/top_level.txt +0 -0
  20. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/README.md +0 -0
  21. {pyqrackising-1.26.2 → pyqrackising-1.26.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.26.2
3
+ Version: 1.26.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
@@ -162,7 +162,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
162
162
 
163
163
  weights = weights.copy()
164
164
  chosen = np.zeros(m, dtype=np.int32) # store chosen indices
165
- available = np.ones(n, dtype=np.int32) # 1 = available, 0 = not
165
+ available = np.ones(n, dtype=np.bool_) # True = available, False = not
166
166
  mask = np.zeros(n, dtype=np.bool_)
167
167
  chosen_count = 0
168
168
 
@@ -170,7 +170,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
170
170
  # Count available
171
171
  total_w = 0.0
172
172
  for i in range(n):
173
- if available[i] == 1:
173
+ if available[i]:
174
174
  total_w += weights[i]
175
175
  if total_w <= 0:
176
176
  break
@@ -180,7 +180,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
180
180
  cum = 0.0
181
181
  node = -1
182
182
  for i in range(n):
183
- if available[i] == 1:
183
+ if available[i]:
184
184
  cum += weights[i] / total_w
185
185
  if r < cum:
186
186
  node = i
@@ -192,14 +192,15 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
192
192
  # Select node
193
193
  chosen[chosen_count] = node
194
194
  chosen_count += 1
195
- available[node] = 0
196
- mask[node] = 1
195
+ available[node] = False
196
+ mask[node] = True
197
197
 
198
198
  # Repulsion: penalize neighbors
199
- deg = degrees[node]
200
- for j in range(deg):
199
+ for j in range(degrees[node]):
201
200
  nbr = adjacency[node, j]
202
- if nbr >= 0 and available[nbr] == 1:
201
+ if nbr < 0:
202
+ break
203
+ if available[nbr]:
203
204
  weights[nbr] *= 0.5 # tunable penalty factor
204
205
 
205
206
  return mask
@@ -217,7 +218,10 @@ def compute_energy(sample, G_m, n_qubits):
217
218
 
218
219
 
219
220
  @njit(parallel=True)
220
- def sample_for_solution(G_m, shots, thresholds, adjacency, degrees, weights, n):
221
+ def sample_for_solution(G_m, shots, thresholds, degrees, J_eff, n):
222
+ adjacency = compute_adjacency(G_m, degrees.max())
223
+ weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
224
+
221
225
  best_solution = np.zeros(n, dtype=np.bool_)
222
226
  best_energy = compute_energy(best_solution, G_m, n)
223
227
 
@@ -303,11 +307,11 @@ def init_theta(delta_t, tot_t, h_mult, n_qubits, J_eff, degrees):
303
307
 
304
308
  return theta
305
309
 
306
- @njit
307
- def compute_adjacency(G_m):
310
+ @njit(parallel=True)
311
+ def compute_adjacency(G_m, max_degree):
308
312
  n_qubits = len(G_m)
309
- adjacency = np.full((n_qubits, n_qubits), -1, dtype=np.int32)
310
- for i in range(n_qubits):
313
+ adjacency = np.full((n_qubits, max_degree), -1, dtype=np.int32)
314
+ for i in prange(n_qubits):
311
315
  k = 0
312
316
  for j in range(n_qubits):
313
317
  if i == j:
@@ -383,9 +387,7 @@ def maxcut_tfim(
383
387
  else:
384
388
  maxcut_hamming_cdf(n_qubits, J_eff, degrees, quality, thresholds)
385
389
 
386
- adjacency = compute_adjacency(G_m)
387
- weights = 1.0 / (1.0 + (2 ** -52) - J_eff)
388
- best_solution, best_value = sample_for_solution(G_m, shots, thresholds, adjacency, degrees, weights, n_qubits)
390
+ best_solution, best_value = sample_for_solution(G_m, shots, thresholds, degrees, J_eff, n_qubits)
389
391
 
390
392
  bit_string = "".join(["1" if b else "0" for b in best_solution])
391
393
  bit_list = list(bit_string)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyQrackIsing
3
- Version: 1.26.2
3
+ Version: 1.26.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
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "PyQrackIsing"
15
- version = "1.26.2"
15
+ version = "1.26.3"
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.26.2',
54
+ version='1.26.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