【问题标题】:hessian for inequality constraint in fminconfmincon中不等式约束的粗麻布
【发布时间】:2018-11-16 09:40:55
【问题描述】:

我试图通过提供梯度向量和 Hessian 矩阵来帮助 fmincon 更快地收敛。我正在使用内点算法,并且我意识到在这种情况下,我必须使用对分配给我的 OPTIOINS 的 HessFcn 的另一个函数的调用来提供 Hessian。我只有不等式约束(C)。它是二次形式。

gbee_r_i,p_in,nel,nhp 是已知的矩阵或变量。

我定义约束如下:

function [ c,ceq,DC,DCeq] = cond5( x,gbee_r_i,p_in,nel,nhp)


nn=0;
bb=0;
    for i=1:nel
        for j=1:nhp
            nn=nn+1;
            bb(nn,:)=1*x'*(gbee_r_i(:,:,j,i))'*p_in*gbee_r_i(:,:,j,i)*x;
            rr(:,nn)=(gbee_r_i(:,:,j,i))'*p_in*gbee_r_i(:,:,j,i)*x;
        end
    end
    DCeq=[];
    DC=rr;
    ceq=[];
c=bb;
end

这样定义选项:

     options = optimoptions(@fmincon,...
        'GradObj','on','GradConstr','on','Hessian','user-supplied',...
    HessFcn',@(x)hessinterior(x,lambda,gbee_r_i,p_in,nel,nhp),'Display',...
'iter','Algorithm','interior-point','maxFunEvals',20000000000000,'MaxIter',5000,'TolFun',1e-3);

`@(x)hessinterior(x,lambda,gbee_r_i,p_in,nel,nhp)

是 HessFcn,定义如下。

function [ h ] = hessinterior(x,lambda,gbee_r_i,p_in,nel,nhp)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here
nn=0;
h=0;
for i=1:nel
    for j=1:nhp
        nn=nn+1;
    h=h+lambda.ineqnonlin(nn)*(gbee_r_i(:,:,j,i))'*p_in*gbee_r_i(:,:,j,i);
    end
end
end

运行程序后显示此错误

使用@(x)hessinterior(x,lambda,gbee_r_i,p_in,nel,nhp) 时出错
输入参数过多。

C:\Program Files\MATLAB\R2013a\toolbox\optim\optim\private\computeHessian.p>computeHessian 中的错误 (第 36 行)

C:\Program Files\MATLAB\R2013a\toolbox\optim\optim\barrier.p>barrier 中的错误(第 300 行)

fmincon 中的错误(第 900 行) [X,FVAL,EXITFLAG,输出,拉姆达,梯度,黑森] = 屏障(funfcn,X,A,B,Aeq,Beq,l,u,confcn,options.HessFcn,...

【问题讨论】:

    标签: matlab nonlinear-optimization hessian-matrix


    【解决方案1】:

    您需要制作一个定义的函数,例如

    hess = @(x,lambda) cond5( x,lambda,gbee_r_i,p_in,nel,nh)
    

    然后将您的选项定义为(您需要在上面定义它

     options = optimoptions(@fmincon,...
        'GradObj','on','GradConstr','on','Hessian','user-supplied',...
    HessFcn',hess,'Display','iter','Algorithm','interior-point','maxFunEvals',20000000000000,'MaxIter',5000,'TolFun',1e-3);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多