标题:求反求参数(无约束非线性优化方法)的matlab实现
只看楼主
shuitu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-4-21
 问题点数:0 回复次数:0 
求反求参数(无约束非线性优化方法)的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<max1)|cnt<min1
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<Y(ho))
if(Y(li)<yR)
V(hi,1:n)=R;
Y(hi)=yR;
else
E=2*R-M;
yE=feval(F,E);
if(yE<Y(li))
V(hi,1:n)=E;
Y(hi)=yE;
else
V(hi,1:n)=E;
Y(hi)=yR;
end
end
else
if(yR<Y(hi))
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<yc)
c=c2;
yc=yc2;
end
if(yc<Y(hi))
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

搜索更多相关主题的帖子: matlab 非线性 参数 
2007-04-21 09:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-133655-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044568 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved