使用MATLAB内点法处理凸优化时出现这样的错误如何处理?

How to deal with such error when using MATLAB interior point method to handle convex optimization?

当我实现这样的MATLAB代码做凸优化时(下面的例子类似于here的MATLAB官方文档):

function [xsol,fval,history,searchdir] = runfmincon
clear;clc;
% Set up shared variables with outfun
history.x = [];
history.fval = [];
searchdir = [];
 
% Call optimization
x0 = [0.1 0.1];
options = optimoptions(@fmincon,'OutputFcn',@outfun,... 
    'Algorithm','interior-point','Display','iter');
[xsol,fval] = fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options);
 
 function stop = outfun(x,optimValues,state)
     stop = false;
 
     switch state
         case 'init'
             hold on
         case 'iter'
         % Concatenate current point and objective function
         % value with history. x must be a row vector.
           history.fval = [history.fval; optimValues.fval];
           history.x = [history.x; x];
         % Concatenate current search direction with 
         % searchdir.
           searchdir = [searchdir;... 
                        optimValues.searchdirection'];
           plot(x(1),x(2),'o');
         % Label points with iteration number and add title.
         % Add .15 to x(1) to separate label from plotted 'o'.
           text(x(1)+.15,x(2),... 
                num2str(optimValues.iteration));
           title('Sequence of Points Computed by fmincon');
         case 'done'
             hold off
         otherwise
     end
 end
 
 function f = objfun(x)
     f = -x(1)*x(2);
 end
 
 function [c, ceq] = confun(x)
     % Nonlinear inequality constraints
     c = [x(1)^2 + x(2)^2 -1];
     % Nonlinear equality constraints
     ceq = [];
 end
end

当我运行上面的代码时,出现错误:

出错 barrier

出错 fmincon (line 834)
    [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = barrier(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn, ...

出错 runfmincon (line 15)
[xsol,fval] = fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options);

此外,其他方法,如 sqpactive-set,工作正常,ONLY interior-point 会导致错误。 我已经检查了初始点,NOT 没有发现任何问题。 如何解决?请帮我!!!谢谢!!!

哦!我解决了!!!在实现interior-point方法时,只需删除参数searchdir,以及对应的代码即可——而对于sqpactive-set方法,保留该参数不会造成任何影响问题。