matlab 无约束非线性优化,求反求参数(无约束非线性优化方法)的matlab实现

求反求参数(无约束非线性优化方法)的matlab实现

求反求参数(无约束非线性优化方法)的matlab实现

参数k,d。初始值代入差分得到计算值T算,(由程序),

给出实测值T测,目标函数各点计算值与实测值的差最小。

?因参数和目标函数间通过一系列数值计算,不知有下面的方法能否得到k ,d

想用Nelder-Mead 法(单纯形法)优化:

%Nelder-Mead法解最优化问题

%-函数f(x1,x2,...,xn)是一个有N个实数变量的函数,而且给定N+1个初始点

% Vk=(vk,1,...,vk,N),k=0,1,...,N

function[v0,y0,dv,dy]=nelder(F,V,min1,max1,epsilon,show)

% Input - F is the object function input as string 'F'

% - V is a 3*n matrix contaioning staring simplex

% - min1 & max1 are minimun and maximun number

% of iterations

% - epsilon is the tolerance

% - show ==1 displays iterations (p and Q)

% output -v0 is the vertex for the minimun

% - y0 is the function value F(v0)

% - dV is the size of the final simplex

% - dy is the error bound for the minimum

% - p is a matrix containing the vertex iterations

% - Q is an array containing the iterations for F(p)

if nargin==5,

show=0;

end

[mm n]=size(V);

% Order the vertices

for j=1:n+1

z=V(j,1:n);

Y(j)=feval(F,z);

end

[mm lo]=min(Y);

[mm hi]=max(Y);

li=hi;

ho=lo;

for j=1:n+1

if(j~=lo&j~=hi&Y(j)<=Y(li))

li=j;

end

if(j~=hi&j~=lo&Y(j)>Y(li))

ho=j;

end

end

cnt=0;

%Start of nelder-Mead algorithm

While(Y(hi)>Y(lo)+epsilon&cnt

s=zeros(1,1:n);

for j=1:n+1

s=s+V(j,1:n);

end

M=(s-V(hi,1:n))/n;

R=2*M-V(hi,1:n);

yR=feval(F,R);

if(yR

if(Y(li)

V(hi,1:n)=R;

Y(hi)=yR;

else

E=2*R-M;

yE=feval(F,E);

if(yE

V(hi,1:n)=E;

Y(hi)=yE;

else

V(hi,1:n)=E;

Y(hi)=yR;

end

end

else

if(yR

V(hi,1:n)=R;

Y(hi)=yR;

end

c=(V(hi,1:n)+M)/2;

yc=feval(F,c);

c2(M+R)/2;

yc2=feval(F,c2);

if(yc2

c=c2;

yc=yc2;

end

if(yc

V(hi,1:n)=c;

Y(hi)=yc;

else

for j=1:n+1

if(j~=lo)

V(j,1:n)=(V(j,1:n)+V(lo,1:n))/2;

z=V(j,1:n);

Y(j)=feval(F,z);

end

end

end

end

[mm lo]=min(Y);

[mm hi]=max(Y);

li=hi;

ho=lo;

for j=1;n+1

if(j~=lo&j~=hi&Y(j)<=Y(li))

li=j;

end

if(j~=hi&j~=lo&Y(j)>Y(ho))

ho=j;

end

end

cnt=cnt+1;

p(cnt,:)=V(lo,:);

Q(cnt)=Y(lo);

end

% End of Nelder-Mead algorithm

% Determine size of simplex

snorm=0;

for j=1:n+1

s=norm(V(j)-V(lo));

if(s>=snorm)

snorm=s;

end

end

Q=Q';

V0=V(lo,1:n);

y0=Y(lo);

dV=snorm;

dy=abs(Y(hi)-Y(lo));

if(show==1)

disp(p);

disp(Q);

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值