How do I address "Error using barrier (line 31) Gradient at initial point contains Inf, NaN, or complex values. Fmincon cannot continue."
4 次查看(过去 30 天)
显示 更早的评论
I have created an output function that I am using with fmincon that provides a gradient as an output. When optimizing, I keep getting the following error:
----------------------------------------------
Error using barrier (line 31)
Gradient at initial point contains Inf, NaN, or complex values. Fmincon cannot continue.
Error in fmincon (line 799)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...
Error in loop_gradtest>(parfor body) (line 13)
wts_out(:,i) = fmincon(@(x)utility_gradtest(x,score_param1,
score_param2,rets),x,[],[],[mean(returns_grid_parallel)*12;ones(1,size(returns_grid_parallel,2))],[.05;1],double(limits_min(:,2)),double(limits_max(:,2)),[],fmin_options);
Error in loop_gradtest (line 9)
parfor i=1:10000;
------------------------------------------------------------
The function gradtest is used to all another function, utility_gradtest that is used to calculate maximum (min negative) utility given a vector of weights. In this function, using finite differencing, I calculate a gradient that is then supplied as part of the output for utility_gradtest.
I've used the following input in setting my options:
fmin_options = optimset('Algorithm','interior-point','GradObj','on','MaxFunEvals',10000,'MaxIter',500,'TolCon',10e-16,'TolX',10e-16,'Display','off','UseParallel',true);
Do I need to incorporate error handling capability to account for when the gradient contains an undefined point?
6 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!