PyQrackIsing 1.8.3__tar.gz → 1.8.4__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.
- {pyqrackising-1.8.3/PyQrackIsing.egg-info → pyqrackising-1.8.4}/PKG-INFO +1 -1
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/maxcut_tfim.py +14 -4
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/spin_glass_solver.py +0 -1
- {pyqrackising-1.8.3 → pyqrackising-1.8.4/PyQrackIsing.egg-info}/PKG-INFO +1 -1
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/pyproject.toml +1 -1
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/setup.py +1 -1
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/CMakeLists.txt +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/LICENSE.md +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/MANIFEST.in +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/__init__.py +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/_pyqrack_ising.cpp +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/generate_tfim_samples.py +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/tfim_magnetization.py +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing/tfim_square_magnetization.py +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing.egg-info/SOURCES.txt +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing.egg-info/dependency_links.txt +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing.egg-info/not-zip-safe +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/PyQrackIsing.egg-info/top_level.txt +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/README.md +0 -0
- {pyqrackising-1.8.3 → pyqrackising-1.8.4}/setup.cfg +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import networkx as nx
|
|
2
2
|
import numpy as np
|
|
3
3
|
import tfim_sampler
|
|
4
|
+
from numba import njit
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
# Written by Elara (OpenAI custom GPT)
|
|
@@ -49,7 +50,7 @@ def local_repulsion_choice(adjacency, degrees, weights, n, m):
|
|
|
49
50
|
return mask
|
|
50
51
|
|
|
51
52
|
|
|
52
|
-
def evaluate_cut_edges(samples,
|
|
53
|
+
def evaluate_cut_edges(samples, edge_keys, edge_values):
|
|
53
54
|
best_value = float("-inf")
|
|
54
55
|
best_solution = None
|
|
55
56
|
best_cut_edges = None
|
|
@@ -57,10 +58,12 @@ def evaluate_cut_edges(samples, G):
|
|
|
57
58
|
for state in samples:
|
|
58
59
|
cut_edges = []
|
|
59
60
|
cut_value = 0
|
|
60
|
-
for
|
|
61
|
+
for i in range(len(edge_values)):
|
|
62
|
+
k = i << 1
|
|
63
|
+
u, v = edge_keys[k], edge_keys[k + 1]
|
|
61
64
|
if ((state >> u) & 1) != ((state >> v) & 1):
|
|
62
65
|
cut_edges.append((u, v))
|
|
63
|
-
cut_value +=
|
|
66
|
+
cut_value += edge_values[i]
|
|
64
67
|
|
|
65
68
|
if cut_value > best_value:
|
|
66
69
|
best_value = cut_value
|
|
@@ -103,6 +106,13 @@ def maxcut_tfim(
|
|
|
103
106
|
# Second dimension: permutation within Hamming weight
|
|
104
107
|
samples.append(local_repulsion_choice(G_dict, degrees, weights, n_qubits, m))
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
edge_keys = []
|
|
110
|
+
edge_values = []
|
|
111
|
+
for u, v, data in G.edges(data=True):
|
|
112
|
+
edge_keys.append(u)
|
|
113
|
+
edge_keys.append(v)
|
|
114
|
+
edge_values.append(data.get("weight", 1.0))
|
|
115
|
+
|
|
116
|
+
best_value, best_solution, best_cut_edges = evaluate_cut_edges(samples, edge_keys, edge_values)
|
|
107
117
|
|
|
108
118
|
return best_value, int_to_bitstring(best_solution, n_qubits), best_cut_edges
|
|
@@ -11,7 +11,7 @@ build-backend = "setuptools.build_meta"
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "PyQrackIsing"
|
|
14
|
-
version = "1.8.
|
|
14
|
+
version = "1.8.4"
|
|
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"}
|
|
@@ -51,7 +51,7 @@ ext_modules = [CMakeExtension('tfim_sampler')]
|
|
|
51
51
|
|
|
52
52
|
setup(
|
|
53
53
|
name='PyQrackIsing',
|
|
54
|
-
version='1.8.
|
|
54
|
+
version='1.8.4',
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|