forked from frankschindler/OptimizedTensorContraction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrn_greedy.py
33 lines (25 loc) · 835 Bytes
/
rn_greedy.py
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
import sys
import numpy as np
import fn_tensors as fnt
from copy import deepcopy
from joblib import Parallel, delayed
L = 10 #sys.argv[1]
datroot = 'dataRandom' + str(L)
ntrials = 40
graph, num_bonds = fnt.randomtn(L,0.8)
#graph, num_bonds = fnt.squaretn(L)
bdims = [10 for i in range(num_bonds)]
np.save(datroot+'/graph',graph)
np.save(datroot+'/bdims',bdims)
def trials():
funlist = []
numlist = []
greedcost, numvals, bperm = fnt.greedy(deepcopy(graph), bdims, 2)
return (greedcost, numvals, bperm)
data = Parallel(n_jobs=ntrials)(delayed(trials)() for i in range(ntrials))
funlist = [el[0] for el in data]
numlist = [el[1] for el in data]
bpermlist = [el[2] for el in data]
np.save(datroot+'/funlist_greedy',funlist)
np.save(datroot+'/numlist_greedy',numlist)
np.save(datroot+'/bpermlist_greedy',bpermlist)