优化方法 2016.docx

  1. 1、本文档共21页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
优化方法 2016

优化方法上机大作业上机大作业Ⅰ:编写程序求解下述问题 min x f(x) = (1?x1)2 + 100(x2 –x12)2. 初始点取 x0 = 0, 精度取ε=1e?4,步长由 Armijo 线有哪些信誉好的足球投注网站生成, 方向分别由下列方法生成: 1 最速下降法2 牛顿法3 BFGS 方法4 共轭梯度法最速下降法源程序如下:function x_star = steepest(x0,eps) gk = grad(x0); res = norm(gk); k = 0; while res eps k=1000 dk = -gk; ak =1; f0 = fun(x0); f1 = fun(x0+ak*dk); slope = dot(gk,dk); while f1 f0 + 0.1*ak*slope ak = ak/2; xk = x0 + ak*dk; f1 = fun(xk); end k = k+1; x0 = xk; gk = grad(xk);res = norm(gk); fprintf(--The %d-th iter, the residual is %f\n,k,res); end x_star = xk; end function f = fun(x) f = (1-x(1))^2 + 100*(x(2)-x(1)^2)^2; endfunction g = grad(x) g = zeros(2,1); g(1)=2*(x(1)-1)+400*x(1)*(x(1)^2-x(2)); g(2) = 200*(x(2)-x(1)^2); end 运行结果: x0=[0,0];eps=1e-4eps = 1.0000e-004 xk=steepest(x0,eps)--The 1-th iter, the residual is 3.271712--The 2-th iter, the residual is 2.504194--The 3-th iter, the residual is 2.073282……………………………--The 998-th iter, the residual is 0.449447--The 999-th iter, the residual is 0.449447--The 1000-th iter, the residual is 0.449447--The 1001-th iter, the residual is 0.449447xk = 0.63690.4038牛顿法源程序如下:function x_star = newton(x0,eps) gk = grad(x0); bk = [grad2(x0)]^(-1); res = norm(gk); k = 0; while res eps k=1000 dk=-bk*gk; xk=x0+dk; k = k+1; x0 = xk; gk = grad(xk); bk = [grad2(xk)]^(-1); res = norm(gk); fprintf(--The %d-th iter, the residual is %f\n,k,res); end x_star = xk; end function f = fun(x) f = (1-x(1))^2 + 100*(x(2)-x(1)^2)^2; endfunction g = grad2(x) g = zeros(2,2); g(1,1)=2+400*(3*x(1)^2-x(2)); g(1,2)=-400*x(1); g(2,1)=-400*x(1); g(2,2)=200; end function g = grad(x) g = zeros(2,1); g(1)=2*(x(1)-1)+400*x(1)*(x(1)^2-x(2)); g(2) = 200*(x(2)-x(1)^2); end 运行结果: x0=[0,0];eps=1e-4; xk=newton(x0,eps)--The 1-th iter, the residual is 447.213595--The 2-th iter, the residual is 0.000000xk = 1.0000 1.0000BFGS方法源程序如下:function x_star = bfgs(x0,eps) g0 = grad(x0); gk=g0; res = norm(gk); Hk=eye(2); k = 0; while res eps k=1000 dk = -Hk*gk

文档评论(0)

yaocen + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档