How to combine multiple objective functions for lsqnonlin?

38 次查看(过去 30 天)
Hello all,
I'm wondering how can I combine multiple objective functions into one so as to use "lsqnonlin" to optimize the 4 unknown parameters existing throughout each of the objective functions.
I'm currently able to optimize the parameters from a single objective function, which is comprised of "model prediction - experimental data", with the below expression:
function rss = objfnc1(params)
a = params(1);
b = params(2);
c = params(3);
d = params(4);
rss = (pred(:) - expt(:))./(expt(:))
[paramsopt,resnorm,residual,exitflag,output] = lsqnonlin(@objfnc1,params_0,lb,ub,options);
But I'd like to combine other objective functions from different experiments under different time/temperature, for instance if there are two more objective functions "objfnc2" and "objfnc3", how can I combine them with "objfunc1" to optimize the 4 known parameters?
Can I directly concatenate the objective functions together like the following? What would be the best way to do it? I think I will be dealing with around 5-10 objective functions
objfnc = [objfnc1; objfnc2; objfnc3];
[paramsopt,resnorm,residual,exitflag,output] = lsqnonlin(@objfnc,params_0,lb,ub,options);
Thank you in advance for your great help!

回答(1 个)

Abel Babu
Abel Babu 2016-8-8
Hi David,
One way to go about the question is to define all the objective functions in a MATLAB function that accepts the parameters, the input data and the output data and return the objective functions as a vector. For example :
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
rss2 = a.*sin(b.*X) - Y; % objective function 2
rssOutput = [rss1; rss2];
end
Now, initialize the parameters defined in the above function:
x0 = [1,1]'; % initial value of a and b
Then get the input data ('X') and output data ('Y') and then call the ' lsqnonlin ' in the following manner:
x=lsqnonlin(@objFunctions,x0,[],[],[],X,Y);
I have left lower bound , upper bound and options parameters empty for the sake of simplicity right now, but please have a look at the documentation of lsqnonlin , for details more on the same:
This should optimize the parameters over multiple objective functions.
Regards,
Abel Paul Babu
MathWorks.
  2 个评论
Carlos Ortega
Carlos Ortega 2017-3-15
Dear Abel,
I didn´t ask the original question, but your answer did help me with my problem.
You gave a very clear and easy-to-follow example. In my opinion the 'lsqnonlin' documentation could benefit a lot by adding this example you shared. Mostly, for user that doesn't have a very strong background in mathematics.
Something I'd like to highlight is taht you are passing variables X and Y to the lsqnonlin function. I also did it and it work, but Matlab documentation doesn't show this possibility (https://nl.mathworks.com/help/optim/ug/lsqnonlin.html#buuhch7-3). When you look at the input arguments it is not possible to add anything after the 'options' field
Thanks again!
Carlos
Alan Weiss
Alan Weiss 2017-3-15
For the documented, supported ways of passing extra parameters, see Passing Extra Parameters.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by