...
 
Commits (28)
#!/usr/bin/env python3.6
import sys import sys
import prrt import prrt
......
1. Clone the branch:
git clone --single-branch --branch feature/hecClasses https://git.nt.uni-saarland.de/LARN/PRRT.git
2. Find a pattern in files
grep -rnw '/path/to/somewhere/' -e 'pattern'
r = recursive i.e, search subdirectories within the current directory
n = to print the line numbers to stdout
i = case insensitive search
\ No newline at end of file
app_max_latency,app_max_residual_loss_rate,app_data_rate,app_pkt_length,ch_loss_rate,ch_rtt_prop_fwd,ch_data_rate_btl_fwd,sys_block_coding_dly,sys_red_pkt_trans_dly,sys_proc_dly,sys_pkt_loss_detection_dly,sys_src_pkt_interval
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0027,400.0,1e-06,3e-05,1e-05,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.0005,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,0.00014,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,4e-05,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,30.0,1e-05,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.0005,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.00014,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.00014,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.00014,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,0.00014,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,4e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,4e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,4e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,4e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,1e-05,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,1e-05,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,1e-05,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.0005,1e-05,0.0001
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.00014,0.0005,0.5
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.00014,0.0005,0.0292
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.00014,0.0005,0.0017
1.0,0.00073681,10000000.0,428.0,2.71e-06,0.0001,10000000.0,0.01,0.30652,0.00014,0.0005,0.0001
This diff is collapsed.
import prrt
import math
import numpy as np
import restricted_integer_composition as ric
import prrt_utils
class HECSearch:
def __init__(self, searchType, n_p_min, n_p_max, prrtApplicationParameters, prrtChannelParameters,
prrtSystemParameters):
self.n_max = 255
self.step_size = 1 # Step size in the estimation of the optimum code word length
self.n_p_min = n_p_min
self.n_p_max = n_p_max
self.prrtApplicationParameters = prrtApplicationParameters
self.prrtChannelParameters = prrtChannelParameters
self.prrtSystemParameters = prrtSystemParameters
self.searchType = searchType
pass
def search(self):
ri_opt = math.inf
k_opt = 0
n_opt = 0
n_p_opt = []
n_c_cap = 20
# Eq.5.9, page 125
fec_delay_min = self.prrtSystemParameters.source_packet_interval + \
self.n_p_max * self.prrtSystemParameters.redundancy_packet_transmission_delay + \
(self.prrtChannelParameters.rtt_prop_fwd + self.prrtSystemParameters.processing_delay) / 2 + \
self.prrtSystemParameters.packet_loss_detection_delay
# Eq.5.9 page 125 assumung D_sup = 0
req_delay = self.prrtChannelParameters.rtt_prop_fwd + \
self.n_p_max * self.prrtSystemParameters.redundancy_packet_transmission_delay + \
self.prrtSystemParameters.processing_delay
# Eq.5.10, page 125
n_c_max = math.ceil((self.prrtApplicationParameters.max_latency - fec_delay_min) / req_delay)
if n_c_max > n_c_cap:
n_c_max = n_c_cap
# self.k_lim = somewhat(prrtApplicationParameters.loss_tolerance, self.n_max)
if self.searchType == "FullSearch":
for n_c in range(n_c_max + 1):
# Eq.5.11, k(Nc, D_T), page 125
k_max = min(self.get_k(n_c, req_delay), self.get_k_lim(1, self.n_max))
for k in range(1, k_max + 1):
n = self.estimate_n_for_k(k)
repair_schedules = ric.gen_repair_schedules(n - k, n_c, self.n_p_min, self.n_p_max, False)
for repair_schedule in repair_schedules:
coding_conf = prrt.PrrtCodingConfiguration(n, k, repair_schedule, self.prrtApplicationParameters, self.prrtChannelParameters, self.prrtSystemParameters)
ri = coding_conf.get_redundant_information()
if ri < ri_opt:
k_opt = k
n_opt = n
n_p_opt = repair_schedule
return prrt.PrrtCodingConfiguration(n_opt, k_opt, n_p_opt)
if self.searchType == "GreedySearch":
for n_c in range(1, n_c_max + 1):
# print("n_c= " + str(n_c))
# Eq.5.11, k(Nc, D_T), page 125
k_max = min(self.get_k(n_c, req_delay), self.get_k_lim(1, self.n_max))
for k in [1, k_max]:
n = self.estimate_n_for_k(k)
redundancy = n - k
if redundancy < n_c:
continue
repair_schedule = ric.gen_repair_schedule(redundancy, n_c, self.n_p_min, self.n_p_max)
coding_conf = prrt.PrrtCodingConfiguration(n, k, repair_schedule, self.prrtApplicationParameters,
self.prrtChannelParameters, self.prrtSystemParameters)
ri = coding_conf.get_redundant_information()
if ri < ri_opt:
ri_opt = ri
k_opt = k
n_opt = n
n_p_opt = repair_schedule
return prrt.PrrtCodingConfiguration(n_opt, k_opt, n_p_opt)
def get_k(self, n_c, req_delay):
return math.ceil((self.prrtApplicationParameters.max_latency -
self.n_p_max * self.prrtSystemParameters.redundancy_packet_transmission_delay -
(self.prrtChannelParameters.rtt_prop_fwd + self.prrtSystemParameters.processing_delay) / 2 -
self.prrtSystemParameters.packet_loss_detection_delay -
n_c * req_delay) / self.prrtSystemParameters.source_packet_interval)
def get_k_lim(self, start, end):
if end < start:
return start
mid_point = math.ceil((end + start) / 2)
p_r = np.around(self.residual_packet_erasure_rate(mid_point, self.n_max, self.prrtChannelParameters.loss_rate_fwd), 8) # Pr(k, n_max)
if p_r == self.prrtApplicationParameters.max_residual_loss_rate:
return int(mid_point)
elif p_r > self.prrtApplicationParameters.max_residual_loss_rate:
return self.get_k_lim(start, mid_point - 1)
else:
return self.get_k_lim(mid_point + 1, end)
def estimate_n_for_k(self, k):
n = k + 1
while self.residual_packet_erasure_rate(k, n, self.prrtChannelParameters.loss_rate_fwd) > self.prrtApplicationParameters.max_residual_loss_rate \
and n <= self.n_max - self.step_size:
n = n + self.step_size
return n
def residual_packet_erasure_rate(self, k, n, ch_loss_rate):
# codingConf = prrt.PrrtCodingConfiguration(1,1,[0])
total_packet_erasure = 0
for i in range(1, k + 1):
for j in range(max(n - k + 1, i), n - k + i + 1):
packet_erasure_at_i = i * prrt_utils.hypergeometric_distribution(n, k, i, j) \
* prrt_utils.get_error_prob(j, n, ch_loss_rate)
total_packet_erasure += packet_erasure_at_i
residual_packet_erasure_rate = (1 / k) * total_packet_erasure # Pr(k, n)
return residual_packet_erasure_rate
This diff is collapsed.
from scipy.special import comb
# TODO: Maybe running in parallel to optimize runtime
# Pm(e, m), Eq. 3.45, Page 91
def get_error_prob(j, sent_packets_item, p_e):
return comb(sent_packets_item, j) * (p_e ** j) * ((1 - p_e) ** (sent_packets_item - j))
# TODO
# Check if it is able to fulfill application parameters given channel parameters.
def hypergeometric_distribution(n, k, i, j):
return (comb(k, i) * comb(n - k, j - i)) / comb(n, j)
\ No newline at end of file
# import pyximport; pyximport.install()
import itertools
def generate_ric(redundancy, positions, min, max):
cdef c_redundancy = redundancy
cdef c_positions = positions
cdef c_min = min
cdef c_max = max
if c_positions < 1:
raise StopIteration
if c_positions == 1:
if c_redundancy >= c_min and c_redundancy <= c_max:
yield (c_redundancy,)
raise StopIteration
for i in range(c_min, c_redundancy + 1):
for result in generate_ric(c_redundancy - i, c_positions - 1, i, c_max):
if i <= c_max:
yield (i,) + result
# is_order_ascending = False for full search.
def gen_repair_schedules(redundancy, positions, min, max, is_order_ascending):
arbitrary_schedules = []
ordered_schedules = set()
f = generate_ric(redundancy, positions, min, max)
for i in f:
arbitrary_schedules.append(i)
if not is_order_ascending:
for i in arbitrary_schedules:
ordered_schedules.add(itertools.permutations(i))
return list(ordered_schedules)
else:
return arbitrary_schedules
def gen_repair_schedule(redundancy, positions, min, max):
if min > max:
return []
# raise Exception(
# "Illegal input combinations. Make sure the min < max.")
if positions == 0:
return [redundancy]
opt_schedule = [min for p in range(positions)]
c_redundancy_left_over = redundancy - min * positions
last_index = positions - 1
while c_redundancy_left_over > 0:
if opt_schedule[last_index] < max:
opt_schedule[last_index] += 1
c_redundancy_left_over -= 1
else:
last_index -= 1
return opt_schedule
\ No newline at end of file
import os
import prrt
import time
import hec_search
import numpy as np
import pandas as pd
from multiprocessing import Pool
# ds_basename = os.listdir("../../hecps/code/ML/data/")
# ds_basename = ["in_12_param_4_sz_zzatql"]
# ds_rel_input_path = "../../hecps/code/ML/data/"
# ds_rel_result_path = "documents/result/"
#['documents/1','documents/2','documents/3','documents/4','documents/5','documents/6']
ds_basename = os.listdir("documents/debug/")
# ds_basename = ["in_12_param_4_sz_zzatql"]
ds_rel_input_path = "documents/debug/"
ds_rel_result_path = "documents/debug/"
def get_n_p_max(rtt_prop_fwd, pkt_length, data_rate_btl_fwd):
return rtt_prop_fwd * data_rate_btl_fwd / pkt_length
def evaluate(searchAlgorithm, appParams, channelParams, systemParams):
n_p_min = 1
n_p_max = np.round(get_n_p_max(channelParams.rtt_prop_fwd, appParams.pkt_length, channelParams.data_rate_btl_fwd), 0)
if n_p_min <= n_p_max:
start = time.time()
search = hec_search.HECSearch(searchAlgorithm, n_p_min, n_p_max, appParams, channelParams, systemParams)
search_result = search.search()
duration = time.time() - start
return [search_result, duration]
else:
return []
def test_case(dataset_basename):
counter = 0
save_result_to = pd.DataFrame()
# Load dataset in chunk
for df_in_chunk in pd.read_csv(ds_rel_input_path + dataset_basename, sep=',', chunksize=100):
for index, row in df_in_chunk.iterrows():
appParams = prrt.PrrtApplicationParameters(row['app_max_latency'], row['app_max_residual_loss_rate'], row['app_data_rate'], row['app_pkt_length'])
chnlParams = prrt.PrrtChannelParameters(row['ch_loss_rate'], 0, row['ch_rtt_prop_fwd'], 0, row['ch_data_rate_btl_fwd'], 0)
sysParams = prrt.PrrtSystemParameters(row['sys_block_coding_dly'], np.round(row['sys_red_pkt_trans_dly'], 5), row['sys_proc_dly'], row['sys_pkt_loss_detection_dly'], row['sys_src_pkt_interval'])
if index == 98:
for searchAlgorithm in ["GreedySearch"]:
print(str(index))
search_result = evaluate(searchAlgorithm, appParams, chnlParams, sysParams)
if len(search_result) != 0:
config = search_result[0]
save_result_to = save_result_to.append({'app_max_latency': row['app_max_latency'],
'app_max_residual_loss_rate': row['app_max_residual_loss_rate'],
'app_data_rate' : row['app_data_rate'],
'app_pkt_length' : row['app_pkt_length'],
'ch_loss_rate' : row['ch_loss_rate'],
'ch_rtt_prop_fwd' : row['ch_rtt_prop_fwd'],
'ch_data_rate_btl_fwd' : row['ch_data_rate_btl_fwd'],
'sys_block_coding_dly' : row['sys_block_coding_dly'],
'sys_red_pkt_trans_dly' : row['sys_red_pkt_trans_dly'],
'sys_proc_dly' : row['sys_proc_dly'],
'sys_pkt_loss_detection_dly' : row['sys_pkt_loss_detection_dly'],
'sys_src_pkt_interval' : row['sys_src_pkt_interval'],
'search': searchAlgorithm,
'config': [config.k, len(config.n_p), config.n_p],
'duration' : np.around(search_result[1],0)}, ignore_index=True, sort=False)
else:
save_result_to = save_result_to.append({'app_max_latency': row['app_max_latency'],
'app_max_residual_loss_rate': row['app_max_residual_loss_rate'],
'app_data_rate' : row['app_data_rate'],
'app_pkt_length' : row['app_pkt_length'],
'ch_loss_rate' : row['ch_loss_rate'],
'ch_rtt_prop_fwd' : row['ch_rtt_prop_fwd'],
'ch_data_rate_btl_fwd' : row['ch_data_rate_btl_fwd'],
'sys_block_coding_dly' : row['sys_block_coding_dly'],
'sys_red_pkt_trans_dly' : row['sys_red_pkt_trans_dly'],
'sys_proc_dly' : row['sys_proc_dly'],
'sys_pkt_loss_detection_dly' : row['sys_pkt_loss_detection_dly'],
'sys_src_pkt_interval' : row['sys_src_pkt_interval'],
'search': searchAlgorithm,
'config': ["INV_PRM_NPM"],
'duration' : 0}, ignore_index=True, sort=False)
counter += 1
#print("Chunk round: " + str(counter))
save_result_to.to_csv(ds_rel_result_path + dataset_basename.replace("in", "out", 1), sep=',', index = False)
test_case(ds_basename[0])
# if __name__ == '__main__':
# pool = Pool(processes=8)
# pool.map(test_case, ds_basename, chunksize=1)
...@@ -4,9 +4,13 @@ from Cython.Build import cythonize ...@@ -4,9 +4,13 @@ from Cython.Build import cythonize
import os, errno import os, errno
import versioneer import versioneer
ext = Extension(name='prrt', language="c", sources=["prrt/*.pyx"]) ext = [Extension(name='prrt', language="c", sources=["prrt/prrt.pyx"]),
Extension(name='restricted_integer_composition', language="c", sources=["prrt/restricted_integer_composition.pyx"])
]
try: try:
os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), "prrt/prrt.c")) os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), "prrt/prrt.c"))
os.remove(os.path.join(os.path.dirname(os.path.realpath(__file__)), "prrt/restricted_integer_composition.c"))
except OSError as e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
......
import unittest
import math
# import os, sys
# import pyximport
# pyximport.install()
# sys.path.append(os.path.join(os.path.dirname(__file__), '/home/local/Documents/thesis/hecps/code/PRRT/prrt'))
import prrt
# print(sys.path)
# print(dir(prrt.__path__))
# print(prrt.__file__)
class TestPrrtCodingConfiguration(unittest.TestCase):
def test_ri_01(self):
prrt_cp_obj = prrt.PrrtChannelParameters(0.1, 0, 0, 0, 0, 0)
prrt_cc_obj = prrt.PrrtCodingConfiguration(5, 2, [0, 1, 2])
ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
print("RI for test config: (n, k, n_p)=(5, 2, [0, 1, 2]) , p_e = 0.1 >> ", ri)
assert math.isclose(ri, 0.01445, rel_tol=1e-03)
def test_ri_02(self):
prrt_cp_obj = prrt.PrrtChannelParameters(0.01, 0, 0, 0, 0, 0)
prrt_cc_obj = prrt.PrrtCodingConfiguration(5, 2, [0, 1, 2])
ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
print("RI for test config: (n, k, n_p)=(5, 2, [0, 1, 2]), p_e = 0.01 >> ", ri)
assert math.isclose(ri, 0.0001490496, rel_tol=1e-03)
def test_ri_03(self):
prrt_cp_obj = prrt.PrrtChannelParameters(0.1, 0, 0, 0, 0, 0)
prrt_cc_obj = prrt.PrrtCodingConfiguration(8, 2, [1, 1, 2, 2])
ri = prrt_cc_obj.get_redundant_information(prrt_cp_obj)
print("RI for test config: (n, k, n_p)=(8, 2, [1, 1, 2, 2]), p_e = 0.1 >> ", ri)
assert math.isclose(ri, 0.50190719, rel_tol=1e-03)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file