Can I combine multiple objective functions that share same optimization parameters for lsqnonlin?
4 views (last 30 days)
Show older comments
Fernando Yemeslir
on 25 Mar 2022
Commented: Fernando Yemeslir
on 1 Apr 2022
Hello,
I have two objective functions that share common optimization parameters. Following the Matlab lsqnonlin documentation(https://www.mathworks.com/help/optim/ug/lsqnonlin.html) and this answer (https://www.mathworks.com/matlabcentral/answers/285211-how-to-combine-multiple-objective-functions-for-lsqnonlin), I combined these two functions using the following method:
%%% Example from https://www.mathworks.com/matlabcentral/answers/285211-how-to-combine-multiple-objective-functions-for-lsqnonlin
function [ rssOutput ] = objFunctions( params,X,Y)
a = params(1); % parameter 1
b = params(2); % parameter 2
rss1 = a.*exp(b.*X) - Y; % objective function 1 -> result in 1x21 vector
rss2 = a.*sin(b.*X) - Y; % objective function 2 -> result in 1x500 vector
rssOutput = [rss1; rss2]; % -> 1x521 vector || Why and how do we sum these two functions?
% How it is work? And why it is work well?
end
Initial parameters:
x0 = [1,1]';
Call lsqnonlin:
options = optimoptions('lsqnonlin','Display','iter','Algorithm','levenberg-marquardt',...
'DerivativeCheck','on','Diagnostics','on','ScaleProblem','jacobian');
options.StepTolerance = 1e-12;
options.FunctionTolerance = 1e-12;
options.OptimalityTolerance = 1e-12;
options.MaxFunctionEvaluations = 1e10;
options.MaxIterations = 200;
x=lsqnonlin(@objFunctions,x0,[],[],[],X,Y,options);
Don't we lose the weight of the functions with such simple summation?
Also, during the optimization process, we don't know which of the functions we are optimizing at the moment (which error do we reduce right now...although it depends more on the type of each objective function).
Can someone, please, explain me why and how it is work? What is the scientific (mathematical) explanation behind this "two objective function sum" action? How lsqnonlin handle with this? And why it works so well??? (If possible, please, provide proof/example of scientific articles, books, etc.)
Thank you very much!
0 Comments
Accepted Answer
Matt J
on 25 Mar 2022
Edited: Matt J
on 25 Mar 2022
No, lsqnonlin is not a multi-objective solver. It minimizes the single objective function sum(rssOutput.^2). If you want it to minimize a weighted sum of squares, you can apply weights when you compose rssOutput:
function [ rssOutput ] = objFunctions( params,X,Y,weights1, weights2)
....
rssOutput = [rss1.*sqrt(weights1); rss2.*sqrt(weights2)];
end
More Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox 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!