⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 examp073.m

📁 1、掌握MATLAB优化工具箱的基本用法
💻 M
字号:
% comparing different algorithms: without using gradient vector
format short e
x0=[-1.9,2];
'---case1: bfgs, hybrid 2,3 poly-------'
fopt=optimset('LargeScale','off', 'MaxFunEvals',1000);
[x1,v1,exit1,out1]=fminunc('rosen',x0,fopt)
pause
'---case2:  dfp, hybrid 2,3 poly-------'
fopt=optimset('LargeScale','off','HessUpdate','dfp', 'MaxFunEvals',1000);
[x2,v2,exit2,out2]=fminunc('rosen',x0,fopt)
pause
'---case3: steep, hybrid 2,3 poly-------'
fopt=optimset('LargeScale','off','HessUpdate','steepdesc', 'MaxFunEvals',1000);
[x3,v3,exit3,out3]=fminunc('rosen',x0,fopt)
pause
'---case4: bfgs, 3rd poly-------'
fopt=optimset('LargeScale','off','LineSearchType','cubicpoly', 'MaxFunEvals',1000);
[x4,v4,exit4,out4]=fminunc('rosen',x0,fopt)
pause
'---case5:  dfp, 3rd poly-------'
fopt=optimset('LargeScale','off','HessUpdate','dfp','LineSearchType','cubicpoly', 'MaxFunEvals',1000);
[x5,v5,exit5,out5]=fminunc('rosen',x0,fopt)
pause
'---case6: steep, 3rd poly-------'
fopt=optimset('LargeScale','off','HessUpdate','steepdesc','LineSearchType','cubicpoly', 'MaxFunEvals',1000);
[x6,v6,exit6,out6]=fminunc('rosen',x0,fopt)
pause

'++++    results of solutions ++++++'
solutions=[x1;x2;x3;x4;x5;x6]'
funvalues=[v1,v2,v3,v4,v5,v6]
iterations=[out1.funcCount,out2.funcCount,out3.funcCount,out4.funcCount,out5.funcCount,out6.funcCount]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -