Loading prrt/prrt.pyx +4 −6 Original line number Diff line number Diff line Loading @@ -150,13 +150,13 @@ class ApplicationParameters: class PrrtCodingConfiguration: def __init__(self, n, k, p_e, n_p=None): p_e = 0.0 def __init__(self, n, k, n_p=None): if n < k: raise ValueError("n must be greater or equal k.") self.n = n self.k = k self.r = n - k self.p_e = p_e if self.r != 0 and n_p is None: raise ValueError("n_p cannot be None if (n-k) != 0.") Loading @@ -181,21 +181,19 @@ class PrrtCodingConfiguration: error_prob = 0 for i in range(sent_packets_item + 1, sent_packets_item + self.k + 1): error_prob += self.get_error_prob(i, sent_packets_item + self.k) print(error_prob) return error_prob def get_error_prob(self, i, sent_packets_item): return comb(sent_packets_item, i) * (self.p_e ** i) * ((1 - self.p_e) ** (sent_packets_item - i)) def get_redundant_information(self): def get_redundant_information(self, prrtChannelParameters): self.p_e = prrtChannelParameters.loss_rate_fwd sent_redundant_packets = np.cumsum(self.n_p) # Cumulative sum of all redundant packets up to each cycle print(sent_redundant_packets) error_prob_up_to_every_cycle = list(map(lambda x : self.sum_error_prob_over_sent_packets(x), sent_redundant_packets[1:])) ri = 1 / self.k * self.n_p[0] + 1 / self.k * np.dot(error_prob_up_to_every_cycle, self.n_p[1:]) return ri # TODO # Check if it is able to fulfill application parameters given channel parameters. # def is_valid_for(applicationParameters, channelParameters) Loading Loading
prrt/prrt.pyx +4 −6 Original line number Diff line number Diff line Loading @@ -150,13 +150,13 @@ class ApplicationParameters: class PrrtCodingConfiguration: def __init__(self, n, k, p_e, n_p=None): p_e = 0.0 def __init__(self, n, k, n_p=None): if n < k: raise ValueError("n must be greater or equal k.") self.n = n self.k = k self.r = n - k self.p_e = p_e if self.r != 0 and n_p is None: raise ValueError("n_p cannot be None if (n-k) != 0.") Loading @@ -181,21 +181,19 @@ class PrrtCodingConfiguration: error_prob = 0 for i in range(sent_packets_item + 1, sent_packets_item + self.k + 1): error_prob += self.get_error_prob(i, sent_packets_item + self.k) print(error_prob) return error_prob def get_error_prob(self, i, sent_packets_item): return comb(sent_packets_item, i) * (self.p_e ** i) * ((1 - self.p_e) ** (sent_packets_item - i)) def get_redundant_information(self): def get_redundant_information(self, prrtChannelParameters): self.p_e = prrtChannelParameters.loss_rate_fwd sent_redundant_packets = np.cumsum(self.n_p) # Cumulative sum of all redundant packets up to each cycle print(sent_redundant_packets) error_prob_up_to_every_cycle = list(map(lambda x : self.sum_error_prob_over_sent_packets(x), sent_redundant_packets[1:])) ri = 1 / self.k * self.n_p[0] + 1 / self.k * np.dot(error_prob_up_to_every_cycle, self.n_p[1:]) return ri # TODO # Check if it is able to fulfill application parameters given channel parameters. # def is_valid_for(applicationParameters, channelParameters) Loading