problem using fminsearch, as parameters that I want to optimize is not input for the handle function

4 次查看(过去 30 天)
What if my model is composited by many subfunctions, and the handle function I am going to use in fminsearch doesn't include the parameters I want to optimize?
For example:
handle function is RMSD(prediction, experiment)
but the parameters I want to optimize is lambda1 and lambda2 which is in the mainfunction where RMSD is called?
How should I write the fminsearch then?
so far i write
[optimal,rmsdmin,exitflag,optimaloutput]=fminsearch(RMSD,@mainfunction,optimal0);
doesn't work

回答(2 个)

Yogananda Jeppu
Yogananda Jeppu 2017-11-11
I am not sure how to do this. I have been using global in my function and optimizing using fminsearch (fmins before). It always works for me - though not a very elegant solution. My take has been I want the optimized solution not the code!

Alan Weiss
Alan Weiss 2017-11-13
This is a question of thinking deliberately. If I understand you correctly, you want to find the control variable lambda = (lambda(1),lambda(2)) that gives the lowest value of RMSD. But RMSD does not depend explicitly on lambda.
Here is where deliberate thinking comes in. fminsearch wants a function that accepts lambda and gives the value of RMSD. If you think about it, you should realize that is exactly what you want, too: the value of RMSD for a given value of lambda. Either you can compute these values or you cannot. If you can compute them, then think about how you do it, and write a MATLAB function that takes a value lambda and returns the RMSD value (this function may well call RMSD).
For examples that use extra parameters (this may help), 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