aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/PLRsearch/PLRsearch.py
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/python/PLRsearch/PLRsearch.py')
-rw-r--r--resources/libraries/python/PLRsearch/PLRsearch.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/resources/libraries/python/PLRsearch/PLRsearch.py b/resources/libraries/python/PLRsearch/PLRsearch.py
index ec58fbd10f..226b482d76 100644
--- a/resources/libraries/python/PLRsearch/PLRsearch.py
+++ b/resources/libraries/python/PLRsearch/PLRsearch.py
@@ -54,7 +54,7 @@ class PLRsearch:
def __init__(
self, measurer, trial_duration_per_trial, packet_loss_ratio_target,
- trial_number_offset=0, timeout=1800.0, trace_enabled=False):
+ trial_number_offset=0, timeout=7200.0, trace_enabled=False):
"""Store rate measurer and additional parameters.
The measurer must never report negative loss count.
@@ -205,7 +205,7 @@ class PLRsearch:
if (trial_number - self.trial_number_offset) <= 1:
next_load = max_rate
elif (trial_number - self.trial_number_offset) <= 3:
- next_load = (measurement.receive_rate / (
+ next_load = (measurement.relative_receive_rate / (
1.0 - self.packet_loss_ratio_target))
else:
next_load = (avg1 + avg2) / 2.0
@@ -439,7 +439,7 @@ class PLRsearch:
:param lfit_func: Fitting function, typically lfit_spread or lfit_erf.
:param trial_result_list: List of trial measurement results.
:param mrr: The mrr parameter for the fitting function.
- :param spread: The spread parameter for the fittinmg function.
+ :param spread: The spread parameter for the fitting function.
:type trace: function (str, object) -> None
:type lfit_func: Function from 3 floats to float.
:type trial_result_list: list of MLRsearch.ReceiveRateMeasurement
@@ -455,20 +455,21 @@ class PLRsearch:
trace(u"for tr", result.target_tr)
trace(u"lc", result.loss_count)
trace(u"d", result.duration)
- log_avg_loss_per_second = lfit_func(
+ # _rel_ values use units of target_tr (transactions per second).
+ log_avg_rel_loss_per_second = lfit_func(
trace, result.target_tr, mrr, spread
)
- log_avg_loss_per_trial = (
- log_avg_loss_per_second + math.log(result.duration)
+ # _abs_ values use units of loss count (maybe packets).
+ # There can be multiple packets per transaction.
+ log_avg_abs_loss_per_trial = log_avg_rel_loss_per_second + math.log(
+ result.transmit_count / result.target_tr
)
- # Poisson probability computation works nice for logarithms.
- log_trial_likelihood = (
- result.loss_count * log_avg_loss_per_trial
- - math.exp(log_avg_loss_per_trial)
- )
- log_trial_likelihood -= math.lgamma(1 + result.loss_count)
+ # Geometric probability computation for logarithms.
+ log_trial_likelihood = log_plus(0.0, -log_avg_abs_loss_per_trial)
+ log_trial_likelihood *= -result.loss_count
+ log_trial_likelihood -= log_plus(0.0, +log_avg_abs_loss_per_trial)
log_likelihood += log_trial_likelihood
- trace(u"avg_loss_per_trial", math.exp(log_avg_loss_per_trial))
+ trace(u"avg_loss_per_trial", math.exp(log_avg_abs_loss_per_trial))
trace(u"log_trial_likelihood", log_trial_likelihood)
return log_likelihood