Using derivatives function, diff and GA toolbox

5 次查看(过去 30 天)
Hi,
I wrote a code using diff function to model some parameters. Now, I need to adjust some parameters with GA Matlab Toolbox. The parameters that I am aiming to optimize, have been used in the diff function, as well.
Is that work? I mean, can I optimize parameters that is used in the diff function? If yes, useing diff may decrease the spead of calculation? Is it recommneded to apply analytican deriviative instead of diff approximation?
Tnx

采纳的回答

Alan Weiss
Alan Weiss 2020-9-1
You don't show any code, so my answer might be irrelevant.
Are you using diff as a symbolic derivative or as a standard MATLAB finite difference? If you are using a symbolic derivative, then ga does not apply until you convert the symbolic function to a standard MATLAB function using, for example, matlabFunction. See Symbolic Math Toolbox Calculates Gradients and Hessians.
But this brings up a more important point. If your problem is smooth, then don't use ga. Instead, use an appropriate Optimization Toolbox solver such as fmincon. Or for a global solution instead of a local solution, use MultiStart. I assume that your problem is smooth because you talk about analytic derivatives.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  3 个评论
Alan Weiss
Alan Weiss 2020-9-1
It appears the you are trying to use a Newton step to find the best fitting parameters for data. I think that you should use the solvers designed for this, lsqcurvefit or lsqnonlin to solve your problem, instead of ga. If you can supply analytic derivatives for your objective function, you can indicate so using the SpecifyObjectiveGradient option.
Alan Weiss
MATLAB mathematical toolbox documentation

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by