-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisingTest.py
More file actions
42 lines (27 loc) · 937 Bytes
/
isingTest.py
File metadata and controls
42 lines (27 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
from benchmark import benchmark
import brute
import greedy
import matplotlib.pyplot as plt
plt.style.use('ggplot')
dataB = []
dataG = []
J = 1.0
for n in range(4,11):
si = np.array(np.meshgrid(*[[0,1] for _ in range(n)], indexing='ij'))
print(si.shape)
x = np.exp(-J*np.sum(si[:-1]*si[1:], axis=0))
print(x.shape)
dt, b = benchmark(brute.findBest, x, 1e-6)
dataB.append([n,sum([v.size for v in b[2]]) * 1./x.size, dt])
dt, g = benchmark(greedy.findBest, x, 1e-6)
dataG.append([n,sum([v.size for v in g]) * 1./x.size, dt])
for n in range(11,17):
si = np.array(np.meshgrid(*[[0,1] for _ in range(n)], indexing='ij'))
print(si.shape)
x = np.exp(-J*np.sum(si[:-1]*si[1:], axis=0))
print(x.shape)
dt, g = benchmark(greedy.findBest, x, 1e-6)
dataG.append([n,sum([v.size for v in g]) * 1./x.size, dt])
np.savetxt('../Data/isingDecomp1b.dat', dataB)
np.savetxt('../Data/isingDecomp1g.dat', dataG)