# How to get multi-solution using 'lsqnonlin'?

3 views (last 30 days)
Runze Zhang on 19 Jan 2022
Commented: Runze Zhang on 26 Jan 2022
Hello everyone,
I'm now trying using 'lsqnonlin' to solve 32 equations to get the values of 10 variables. Theoretically speaking, there will be more than one solution on the interval [lb,ub], one of which should be the best. But I only got one solution in the end, which is shown as x_s. Another one should be at around x0, which is also my initial value. The subfunction F was to return all of 32 equations that should be solved, because that was too long, I don't put it here. I'm not expert in matlab, maybe I should use some other solvers instead of lsqnonlin. So do you anyone have better advice? Any help will be appreciated. Thanks in advance!
clear all
x0 = [36e-3,36e-3,36e-3,36e-3,45e-6,760e-6,3e-3,500e-6,45e-6,1e-3];
lb = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
ub = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1];
options = optimoptions('lsqnonlin','Algorithm','levenberg-marquardt','Display','iter','MaxFunEvals',5e7,'MaxIter',5e6,'StepTolerance',1e-9, 'TolFun',1e-18);
L = lsqnonlin(@equ,x0,lb,ub,options);
% x_s = [0.0360,0.0360,0.0359,0.0359,0.0034,0.0048,0.0034,6.2068e-11,3.2405e-4,0.0126];
function F = equ(x)
.
.
.
return
end

John D'Errico on 19 Jan 2022
lsqnonlin is a numerical optimization tool. It iterations fro mthe start point to a solution. And the solution you get is dependent on where you start.
The analogy I use is to imagine a blind person, set down on the face of the earth, and tasked with finding the point of lowest elevation. All he can do to determine where to walk next is a cane. Please, give him some scuba gear. But it matters a lot if you put him down in different locations. Near the dead sea, for example, would be a bad start point, since he will get stuck in an unfortunate spot. When the person can no longer find a route down from where they are standing, they stop, and annnounce a solution.
There is a concept known as the basin of attraction. So if you picked many start points, all of which were close to the same spot, then they will all end up at essentially the same final point. The basin of attraction for any solution is the set of start points that will converge to that solution.
The point is, you get ONE answer, and one only. If you want multiple solutions, then start at multiple various start points, and hope that one of them is near the lowest point. Intelligently chosen start points are likely better than not.
Runze Zhang on 26 Jan 2022
Thanks, Alan. I'm sorry that I overlooked it.

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!