Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
QKDNet/data_gathering.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
265 lines (221 sloc)
9.58 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Simulator import * | |
import os | |
from multiprocessing import Process | |
its = 100000 | |
_size = 5 | |
def gather_all_data_global(data_file, log_file, simple): | |
N = its #10,000 takes 530 seconds for all data | |
size = _size | |
L = 1 #15 | |
Q = .85 | |
E = .02 | |
glob = True | |
dumb = True | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
#size_range = [5,7,9,11,13,15] | |
size_range = [7,11,13] | |
#size_range = [2,3,4,5,6,7,8,9,10] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
# E_range = [0, .02, .035, .05, .065] | |
E_range = [.01, .04, .045, .06, .065, .07] | |
filename = "global"+data_file | |
with open(filename, "w+") as f: | |
T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
# T0p, T1p = gather_data(glob, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_smart(data_file, log_file, simple): | |
N = its #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = _size | |
L = 1 #15 | |
Q = .85 | |
E = .02 | |
glob = False | |
dumb = False | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13,15] | |
#size_range = [2,3,4,5,6,7,8,9,10] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
# E_range = [0, .02, .035, .05, .065] | |
E_range = [.01, .04, .045, .06, .065, .07] | |
filename = "Smart"+data_file | |
with open(filename, "w+") as f: | |
T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
#T0p, T1p = gather_data(glob, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
#T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_naive(data_file, log_file, simple): | |
N = its #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = _size | |
L = 1 #15 | |
Q = .85 | |
E = .02 | |
glob = False | |
dumb = True | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13,15] | |
#size_range = [2,3,4,5,6,7,8,9,10] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
#E_range = [0, .02, .035, .05, .065] | |
E_range = [.01, .04, .045, .06, .065, .07] | |
filename = "Naive"+data_file | |
with open(filename, "w+") as f: | |
T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
#T0p, T1p = gather_data(glob, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
#T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_size(data_file, log_file, simple): | |
N = its #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = 5 | |
L = 1 #15 | |
Q = .85 | |
E = .02 | |
glob = False | |
dumb = True | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13,15] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
E_range = [0, .02, .035, .05, .065] | |
filename = "Size"+data_file | |
with open(filename, "w+") as f: | |
# T0p, T1p = gather_data(glob, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_fixed7(data_file, log_file, simple): | |
N = its #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = 7 | |
L = 10 | |
Q = .85 | |
E = .02 | |
glob = False | |
dumb = True | |
fixed_len = True | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
E_range = [0, .02, .035, .05, .065] | |
filename = "fixed7"+data_file | |
with open(filename, "w+") as f: | |
# T0p, T1p = gather_data(glob, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_5_errglobal(data_file, log_file, simple): | |
N = its*10 #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = 5 | |
L = 1 | |
Q = .85 | |
E = .05 | |
glob = False | |
dumb = True | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
E_range = [0, .02, .035, .05, .065] | |
filename = "5_err global"+data_file | |
with open(filename, "w+") as f: | |
T0p, T1p = gather_data(True, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0p, T1p = gather_data(False, False, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0p, T1p = gather_data(False, True, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
def gather_all_data_5_errlocal(data_file, log_file, simple): | |
N = its*10 #10,000 takes 530 seconds for all data | |
#~1 minute per thousand iterations | |
size = 5 | |
L = 1 | |
Q = .85 | |
E = .05 | |
glob = False | |
dumb = True | |
fixed_len = False | |
simple = False | |
Pz = 1/2 | |
Px = 1 - Pz | |
size_range = [5,7,9,11,13] | |
L_range = [1,3,5,10,15] | |
Q_range = [1,.95, .85, .75, .65][::-1] | |
E_range = [0, .02, .035, .05, .065] | |
filename = "5_errlocal"+data_file | |
with open(filename, "w+") as f: | |
# T0p, T1p = gather_data(True, dumb, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
T0p, T1p = gather_data(False, False, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
T0p, T1p = gather_data(False, True, simple,fixed_len, N, size, L_range, Q, E, Pz, Px, "P", f) | |
# T0q, T1q = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q_range, E, Pz, Px, "Q", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size, L, Q, E_range, Pz, Px, "E", f) | |
# T0e, T1e = gather_data(glob, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, True, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(False, False, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
# T0e, T1e = gather_data(True, dumb, simple,fixed_len, N, size_range, L, Q, E, Pz, Px, "S", f) | |
if __name__=="__main__": | |
proc = [] | |
#proc.append(Process(target=gather_all_data_global, args=("asymTN100k_err.csv", "logfile", False))) | |
data_file = sys.argv[2] | |
log_file = "/dev/null" | |
if sys.argv[1] == "1": | |
gather_all_data_global(data_file, log_file, False) | |
if sys.argv[1] == "2": | |
gather_all_data_smart(data_file, log_file, False) | |
if sys.argv[1] == "3": | |
gather_all_data_naive(data_file, log_file, False) | |
if sys.argv[1] == "4": | |
gather_all_data_size(data_file, log_file, False) | |
if sys.argv[1] == "5": | |
gather_all_data_5_errglobal(data_file, log_file, False) | |
if sys.argv[1] == "6": | |
gather_all_data_5_errlocal(data_file, log_file, False) | |
# proc.append(Process(target=gather_all_data_smart, args=("asymTN100k_err.csv", "logfile", False))) | |
# proc.append(Process(target=gather_all_data_naive, args=("asymTN100k_err.csv", "logfile", False))) | |
# proc.append(Process(target=gather_all_data_size, args=("asymTN100k_size.csv", "logfile", False))) | |
# for p in proc: | |
# p.start() | |
# for p in proc: | |
# p.join() |