ftp25.m
来自「基于matlab的约束非线性规划算法库」· M 代码 · 共 31 行
M
31 行
function [f, J] = ftp25(x, ctrl, u)
%Call: [f J]=ftp25(x,ctrl,u)
%Evaluate the residuals corresponding
%to the objective in a nonlinear lsq problem.
%If ctrl>0 the Jacobian J should be computed.
%Objective: 0.5*norm2(f)
%The problem is defined as
% min 0.5*norm2(f(x))
% s.t. 0.1<=x(1)<=100
% 0.0<=x(2)<=25.6
% 0.0<=x(3)<=5
% f(x,u)=exp(-(u(i)-x(2))^x(3)/x(1))-0.01*i
%and u(i) is given.
%
if ctrl == 0
t=1:99;
f=exp(-(u-x(2)).^x(3)./x(1))-0.01*t(:);
f=f(:);
J = [];
else
%The Jacobian is computed analytically
f=[];
term = (u-x(2)).^x(3)./x(1);
term = term(:);
u = u(:);
e1 = exp(-term);
J(:,1) = e1.*term/x(1);
J(:,2) = (u-x(2)).^(x(3)-1)*(x(3)/x(1)).*e1;
J(:,3) = -e1.*term.*log(u-x(2));
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?