Skip to content

Commit

Permalink
cholesky update (#338)
Browse files Browse the repository at this point in the history
make symmetric and positive definite before cholesky in bwe
  • Loading branch information
olofkallander authored Nov 14, 2023
1 parent dc15a1a commit fc23bb4
Show file tree
Hide file tree
Showing 6 changed files with 1,127 additions and 126 deletions.
6 changes: 5 additions & 1 deletion bwe/BandwidthEstimator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ void BandwidthEstimator::update(uint32_t packetSize, uint64_t transmitTimeNs, ui
const auto kalmanGain = crossCovariance * (1.0 / covDelay);
_state = predictedMeanState + kalmanGain * (observedDelay - predictedMeanDelay);
_covarianceP = statePredictionCovariance - kalmanGain * covDelay * math::transpose(kalmanGain);
math::makeSymmetric(_covarianceP);
assert(math::isSymmetric(_covarianceP));
assert(math::isValid(_covarianceP));

_observedDelay = observedDelay;
_state(0) = std::max(0.0, std::min(_state(0), _config.maxNetworkQueue * 8));

Expand Down Expand Up @@ -257,7 +260,8 @@ void BandwidthEstimator::generateSigmaPoints(const math::Matrix<double, 3>& stat
const math::Matrix<double, 3>& processNoise,
std::array<math::Matrix<double, 3>, SIGMA_POINTS>& sigmaPoints)
{
auto squareRoot = math::choleskyDecompositionLL(covP);
static const auto seed = covP.I() * 0.0000001; // will make it positive definite
const auto squareRoot = math::choleskyDecompositionLL(covP + seed);
sigmaPoints[0] = _state;

int startIndex = 1;
Expand Down
8 changes: 6 additions & 2 deletions bwe/Research.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Tuning the filter
# Tuning the bandwidth estimation filter

The Unscented Kalman Filter has a state of current queue length Q, bandwidth BW, and clock offset CO.
These three values evolve over time to predict the observed absolute difference between local receive time
and remote transmit time of packets. What makes this a bit sensitive is that higher delay can be explained
by lower BW, higher CO or larger Q. If any of process noise values have a bad setting, the state
by lower BW, higher CO or larger Q. If any of process noise values has a bad setting, the state
may start to drift in the wrong direction.

The state units are bits, kbps, ms.
The reason for this is to condition the matrix into having comparable magnitudes in the elements.
There are matrix addition, multiplcation and decomposition that will cause

## Parameter tuning experiments

### Tuning clock drift
Expand Down
Loading

0 comments on commit fc23bb4

Please sign in to comment.