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!
0 件のコメント
回答 (1 件)
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
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
2017 年 3 月 15 日
Alan Weiss
MATLAB mathematical toolbox documentation
参考
カテゴリ
Help Center および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!