Using user specified gradient function in fmincon and obtaining cost function value as well as optimized vector from optimization
1 次查看(过去 30 天)
显示 更早的评论
I have an objective function as folllows :
options = optimoptions('fmincon', 'Algorithm', 'interior-point','GradObj', 'on', 'Hessian','on','TolFun', 1e-3, 'TolX', 1e-3, 'Display', 'iter-detailed');
[res,cost]=fmincon(@(x) grad_cost(x,st,sr,N,f0,B,e),x0,[],[],[],[],[],[],mycon,options);
function [x,K]=grad_cost(x,st,sr,N,f0,B,e)
K=.....
end
I want to find the optimized vector and cost value. But it shows this error -
Error using fmincon (line 619)
Supplied objective function must return a scalar value
Where's the error ? And how do I add a user defined gradient calculation function for the optimization ? Should that function return a scalar or a vector of derivatives?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!