How to impove multistart/lsqnonlin solution selection when difference between Fvals is too small to discern from rounding noise.
55 views (last 30 days)
Show older comments
I am solving a 2.5D hyperbolic acoustic TDOA localisation problem in MATLAB using the lsqnonlin optimisation solver. The objective is to minimise the variable 'residuals'. As per the documentation for lsqnonlin, I am passing 'residuals' to the solver as a signed, three element vector, rather than using the L2 norm of 'residuals' or some other scalar value. The cost function that computes 'residuals' is included below.
I am solving using "multistart", which returns multiple candidate solutions. In approximately 65% of my test cases, the system returns a reasonably good, high precision location estimate. In certain edge cases however, the difference in the final function value 'Fval' between candidate solutions is on the order of 1e-30, which means that the meaningful differences between solutions' final residual values are lost in rounding errors.
In these edge cases, the multistart solver picks the wrong solution, resulting in high localisation error. In almost all of these cases, one of the other candidate solutions has in fact found the correct location, but not seleted it, because multistart doesn't consider this solution "optimal" as defined by either Fval, first order optimality, or some combination of these metrics. I have attached a figure to illustrate this point.
In order words, the solver is converging to a valid set of local minima, one of which is almost always the global minimum, but the variation in "Fval" for these local minima is so small that we are unable to tell which is the global minimum, due to the noise in Fval caused by numeric precision errors.
I have tried calculating the residuals using VPA arrays at 35 significant digits, but lsqnonlin() only supports double precision inputs. Converting the VPA residual to double obviously results in rounding to 16 significant digits, and this is not sufficient to chose the correct solution by Fval. I have tried all kinds of residual scalings and alternate cost fuctions (huber, log1p, MLE etc.), and endless hyperparameter tinkering, but everything results in the same solution selection problem, in some non-trivial proportion of test cases.
I would really appreciate it if somebody could give me some advice for solving this.
Many thanks,
Ben
function final_residuals = calcResiduals(x, problemData)
% Insert z coord into candidate location for propagation modelling
x = [x, problemData.zVal];
% Set VPA array to use 35 significant digits
digits(35)
% Calculate simulated TDOAs - use variable precision arrays
modelTdoas = vpa(zeros(size(problemData.measuredTdoas)));
for i = 1:length(problemData.rcvPairs)
prop1 = propagationSim(x, problemData.rcvPos(problemData.rcvPairs(i,1),:), ...
problemData.T, problemData.S, problemData.Fs, problemData.lat, problemData.lon);
prop2 = propagationSim(x, problemData.rcvPos(problemData.rcvPairs(i,2),:), ...
problemData.T, problemData.S, problemData.Fs, problemData.lat, problemData.lon);
modelTdoas(i) = prop1.propDelay - prop2.propDelay;
end
% Set timing precision (in seconds)
samplingPrecision = vpa(1/problemData.Fs);
gpsPrecision = vpa(1e-8);
timingPrecision = samplingPrecision - gpsPrecision;
% Normalize TDOAs by timing precision
normalizedModelTdoas = modelTdoas / timingPrecision;
normalizedMeasuredTdoas = vpa(problemData.measuredTdoas) / timingPrecision;
% Calculate residuals
normalized_residuals = normalizedModelTdoas - normalizedMeasuredTdoas;
% Return the final residual as a double
final_residuals = double(normalized_residuals);
end
0 Comments
Answers (1)
Matt J
on 9 Dec 2024 at 16:03
Edited: Matt J
on 10 Dec 2024 at 14:47
I have tried calculating the residuals using VPA arrays at 35 significant digits
Do you really need to keep all 35? I imagine you wouldn't when the iterations approach convergence. Perhaps discard the most significant 20 digits and convert the final 15 back to double.
3 Comments
Matt J
on 12 Dec 2024 at 2:18
Well, it does sound like you have a bad cost function formulation, although I don't know the engineering application well enough to recommend how to fix it.
But a fundamental assumption of an inverse problem is that the cost function global minimum is unique and distinct, both in its Fval and in the X that attains it. You on the other hand have a cost function which barely distinguishes the desired solution X from spurious solutions at all...
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!