How To Perform Global Optimization (Least Square Bounded) with Objective Function in Matrix From?
2 views (last 30 days)
Show older comments
Hello,
I have the following system A x = b with A(1000,1000), x and b both (1000,1). I would like to use a global optimization method such as particle swarm or global search to find the global minimum of the function (as defined in the lsqlin doc page):
function y = parameterfun(x,A,b)
y = zeros(size(b));
for i =1:size(A,1)
for j =1:size(A,2)
y(i) = 0.5*(norm(A(i,j)*x(i)-b(i)))^2;
end
end
However I get the following error:
Error using particleswarm>makeState
Objective function must return scalar values.
I can solve that problem just fine with lsqlin, but I find a local minima that doesn't correspond to what the solution should be. I want to find other minimas. Is there a way to go around that limitation of the objective function having to return a scalar (when I want a vector) and apply a global optimization method for my problem?
Thank you.
0 Comments
Answers (1)
Matt J
on 29 Oct 2018
Edited: Matt J
on 29 Oct 2018
Your function is convex, so if it has more than one solution, then they are all global solutions and the problem is numerically unstable. Trying other solvers may produce a different solution, but the difference will be meaningless and unpredictable.
In any case, the function implementation you are seeking is,
function y = parameterfun(x,A,b)
y=0.5*norm(A*x-b).^2;
end
0 Comments
See Also
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!