资源简介
1.用加步探索法确定一维最优化问题程序代码:
function [minx,maxx] = minJT(f,x0,h0,eps)
%进退方法求解极值区间
%目标函数:f
%初始点:x0
%初始步长:h0
%精度:eps
%区间左端点:minx
%区间右端点:maxx
format long;
if nargin == 3
eps = 1.0e-6;
end
x1 = x0;
k = 0;
h = h0;
while 1
x4 = x1 h;
k = k 1;
f4 = subs(f, findsym(f),x4);
f1 = subs(f, findsym(f),x1);
if f4 < f1
x2 = x1;
x1 = x4;
f2 = f1;
f1 = f4;
h = 2*h;
else
if k==1
h = -h;
x2 = x4;
f2 = f4;
else
x3 = x2;
x2 = x1;
x1 = x4;
break;
end
end
end
minx = min(x1,x3);
maxx = x1 x3 - minx;
format short;
2.用对分法求解该题的程序代码如下:
function [xmin,ymin] = minDF(f,x0,x1,eps)
%对分法求解极值
%目标函数:f
%搜索右区间:x0
%搜索左区间:h0
%精度:eps
%极小值点:xmin
%极小值:ymin
format long;
if nargin == 3
eps = 1.0e-6;
end
k=1;
plot(x0,subs(f , findsym(f),x0),'ro');
plot(x1,subs(f , findsym(f),x1),'ro');
while (x1-x0)>eps && k<100000
xm=(x1 x0)/2;
xl=(x0 xm)/2;
xr=(x1 xm)/2;
fm = subs(f , findsym(f),xm);
fl = subs(f , findsym(f),xl);
fr = subs(f , findsym(f),xr);
plot(x0,subs(f , findsym(f),x0),'ro');
plot(x1,subs(f , findsym(f),x1),'ro');
plot(xm,fm,'ro');
if fl < fm
x0 = xl;
x1 = xm;
else
if fr < fm
x0 = xm;
x1 = xr;
else
x0 = xl;
x1 = xr;
end
end
k = k 1;
end
if k == 100000
disp('找不到最小值!');
x = NaN;
minf = NaN;
return;
end
k
xmin = (x1 x0)/2;
ymin = subs(f, findsym(f),xmin);
format short;
3.用Newton法求解该题的程序代码如下:
function [x,minf] = minNT(f,x0,var,eps)
%牛顿方法
%目标函数:f
%初始点:x0
%自变量向量:var
%精度:eps
%极值点:x
%极值:minf
format long;
if nargin == 3
eps = 1.0e-6;
end
tol = 1;
x0 = transpose(x0);
gradf = jacobian(f,var);
jacf = jacobian(gradf,var);
while tol>eps
v = Funval(gradf,var,x0);
tol = norm(v);
pv = Funval(jacf,var,x0);
p = -inv(pv)*transpose(v);
p = double(p);
x1 = x0 p;
x0 = x1;
end
x = x1;
minf = Funval(f,var,x);
format short;
3实验结果
1.用加步探索法确定一维最优化问题的实验结果截图如下:
2.用对分法求解的实验结果截图如下:
精度
代码片段和文件信息
- 上一篇:易语言 百度注册 源码
- 下一篇:各种语言 注释符号 持续整理中
相关资源
- 微机原理与接口技术——基于8086和
- ScreenReceiver46接收rtp流解析并解码播放
- part3.PDF
- 张贤达《现代信号处理》第二版.pdf
- GoogleChromePortable.7z
- pt1101memeda_10737163.zip
- (4)LCD显示(1).rar
- ProgrammingGameAIByExample.pdf
- SMBMS.rar
- 断刃小组批量getshell工具.zip
- 12467230STM32L073xx_User_Manual.chm
- OAuth2实战.pdf
- 电分期末.zip
- 胡伟武_计算机体系结构课件_2017.zip
- ComputerArchitectureAQuantitativeApproach5th.p
- Classificationoftime-seriesimagesusingdeepcnn.
- 微擎小程序榆落微时光1.0.23小程序前
- S7-1200仿真教程.pdf
- 6908d19c7e04dbde289b4dec5403d7fb.rar
- 泛函分析:理论和应用.pdf
- _源代码.rar
- sogoupinyin-2.2.0.0102-2.zip
- 模式分析的核方法中文版和英文版合
- zw_qq_41143492-10381309-学生考试系统.zip
- zw_feifan50-9720417-MissionPlanner1.3.32PlayUA
- zw_weixin_42810059-10567648-数学分析考研笔
- 刺客.rar
- zw_DXF转G代码.zip
- 彩票开发源码.zip
- 斯坦福-IntroductiontoRobotics.zip
评论
共有 条评论