Ejemplo n.º 1
0
 def test_prob_poisson(self):
     self.assertEqual(round(b.get_prob_poisson(1, 10, 0.01), 15),
                      0.090483741803596)
     self.assertEqual(round(b.get_prob_poisson(4, 10, 0.0001), 27),
                      4.1625020826391e-14)
     self.assertEqual(round(b.get_prob_poisson(4, 1, 0.001), 27),
                      4.1625020826391e-14)
Ejemplo n.º 2
0
def get_prob_schedulable(msgs, mi, boot_time, sync = True):
    """Returns the probability that message m is successfully transmitted even
    in the presence of omission, commission, transmission faults. Here, although
    m represents a single message, we compute the probability of successful
    transmission collectively for all replicas of m, identified by a common
    'tid' field. """
    r = msgs.get_replication_factor(mi)
    rprime = int(mpmath.floor(r / 2.0) + 1)

    prob_msg_corrupted = 1 - br.get_prob_poisson(0, mi.deadline, msgs.po)
    prob_msg_omitted = 1 - br.get_prob_poisson(0, boot_time, msgs.po)

    # since pr(correct) is just a function of k <= r and pc,
    # we compute it beforehand for all values (pc is commission fault prob.)
    prob_correct = []
    for k in range(0, r + 1):
        if sync:
            prob_correct.append(get_prob_correct_sync(k, prob_msg_corrupted))
        else:
            prob_correct.append(get_prob_correct_async(k, prob_msg_corrupted, rprime))

    # need to iterate over all subsets of replica set of m
    replica_ids = []
    for mk in msgs:
        if mk.tid == mi.tid:
            replica_ids.append(mk.id)
    assert r == len(replica_ids)

    prob_success = 0
    for omitted_ids in powerset(replica_ids):
        for mk in msgs:
            if mk.id in omitted_ids:
                mk.omitted = True
            else:
                mk.omitted = False

        s = r - len(omitted_ids)
        prob_omitted = mpmath.power(prob_msg_omitted, r - s) * \
            mpmath.power(1 - prob_msg_omitted, s)

        prob_time_correct = 0
        for k in range(1, s + 1):
            prob_time_correct += get_prob_time_periodic(msgs, mi, k) * \
                                 prob_correct[k]

        prob_success += prob_omitted * prob_time_correct

    return min(prob_success, 1)
Ejemplo n.º 3
0
def get_prob_time_periodic(msgs, mi, k):
    """ Our timing analysis.
    """
    faults = 0
    prob = 0

    while True:

        timely_replicas = 0
        for mk in msgs:
            if mk.tid == mi.tid and mk.omitted == False:
                if msgs.get_wctt(mk, faults) + mk.jitter <= mk.deadline:
                    timely_replicas += 1

        if timely_replicas < k:
            break

        if timely_replicas == k: 
            prob += br.get_prob_poisson(faults, mi.deadline, msgs.mfr)

        faults += 1

    return prob 
Ejemplo n.º 4
0
 def test_prob_poisson(self):
     self.assertEqual(round(b.get_prob_poisson(1, 10, 0.01), 15), 0.090483741803596)
     self.assertEqual(round(b.get_prob_poisson(4, 10, 0.0001), 27), 4.1625020826391e-14)
     self.assertEqual(round(b.get_prob_poisson(4, 1, 0.001), 27), 4.1625020826391e-14)