-
Notifications
You must be signed in to change notification settings - Fork 0
/
random_3_vary_base.py
41 lines (35 loc) · 1.4 KB
/
random_3_vary_base.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
34
35
36
37
38
39
40
import subprocess
import sys
import os
DIR='random_vary_base'
try:
os.mkdir(DIR)
except:
pass
CMR_BUILD = './build'
CMR_GENERATE_SERIES_PARALLEL = CMR_BUILD + '/cmr-generate-series-parallel'
CMR_PERTURB = CMR_BUILD + '/cmr-perturb-random'
CMR_SERIES_PARALLEL = CMR_BUILD + '/cmr-series-parallel'
N = 10000
#N = 1000 # for debugging
repetitions = 100
#repetitions = 2 # for debugging
for kary in ['binary', 'ternary']:
for alpha in [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]:
PROBABILITY = 0.5
BASE = max(1, int(alpha*N))
beta = 0.5*(1-alpha)
UNIT = int(beta*N)
gamma = 0.5*(1-alpha)
COPY = N - BASE - UNIT
assert COPY >= 0
delta = 0.0
makeTernary = '-t' if kary == 'ternary' else ''
testBinary = '-b' if kary == 'binary' else ''
PREFIX=f'{DIR}/{kary}-{N}-{alpha:.2f}-{beta:.2f}-{gamma:.2f}-{delta:.2f}-{PROBABILITY}'
open(f'{PREFIX}.sp', 'w').close()
for i in range(repetitions):
subprocess.call(f'{CMR_GENERATE_SERIES_PARALLEL} {BASE} {BASE} -p {PROBABILITY} -u {UNIT} {UNIT} -c {COPY} {COPY} {makeTernary} > {PREFIX}-{i}.sparse', shell=True)
subprocess.call(f'{CMR_SERIES_PARALLEL} -i sparse {PREFIX}-{i}.sparse {testBinary} -R {PREFIX}-{i}.reduced -N - -s >> {PREFIX}.sp', shell=True)
os.unlink(f'{PREFIX}-{i}.reduced')
os.unlink(f'{PREFIX}-{i}.sparse')