newtonc.m
来自「基于matlab的约束非线性规划算法库」· M 代码 · 共 32 行
M
32 行
function [pN, flag] = NewtonC(Aset,Abounds,nMnfixed,J1,f,X,DeltaP1,Q1,P2,J2,lambda,ffun,cfun,params)
%Call: [pN, flag] = NewtonC(Aset,Abounds,n,J1,f,X,DeltaY1,Q1,P2,J2,lambda,ffun,cfun,params)
%Compute pN, the Newton direction for the constrained case
%Form W=E+B where B=J'*J and E=P2'*Q1'*(G-H)*Q1*P2 where G is sum(f(j)*G(j) and G(J) is the
%Hessian of f(j). Similarly H is sum(v(j)*H(j) where v(j) is the Lagrange multipliers and
%H(j) is the Hessian to the corresponding equality constraint c(j) in current working set.
%
n = length(X);
free = find(Abounds == 0);
J1 = J1*P2;
B = [J1'*J1 J1'*J2; J2'*J1 J2'*J2];
G = hessianG(ffun,X,f,params);
G = G(free,free);
H = hessianH(cfun,Aset,X,lambda,params);
H = H(free,free);
E = Q1'*(G-H)*Q1;
W = E+B;
prankA = length(DeltaP1);
nmr = nMnfixed-prankA;
W21 = W(prankA+1:nMnfixed,1:prankA);
W22 = W(prankA+1:nMnfixed,prankA+1:nMnfixed);
b = -W21*DeltaP1-J2'*f;
[R flag] = chol(W22);
if flag ~= 0
disp('Not pos. def. W22 in chol')
flag = -1002
pN = [];
else
pN = zeros(n,1);
DeltaP2 = R\(R'\b);
pN(free) = Q1*[P2*DeltaP1; DeltaP2];
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?