您好,欢迎访问三七文档
当前位置:首页 > 机械/制造/汽车 > 机械/模具设计 > 最优化方法中关于黄金分割的课题设计
1、阐述黄金分割的基本思路及原理基本思路:黄金分割法适用于[a,b]区间上的任何单股函数求极小值问题,对函数除要求”单峰”外不做其他要求,甚至可以不连续.因此,这种方法的适应面非常广,黄金分割法也是建立在区间消去法原理基础上的试探方法,即在搜索区间[a,b内适当插入两点a1,a2,并计算其函数值。a1,a2将区间分成三段,应用函数的单峰性质,通过函数值大小的比较,删除其中一段,是搜索区间得以缩小。然后再在保留下来的区间上作同样的处理,如此迭代下去,是搜索区间无限缩小,从而得到极小值的数值近似解。基本原理:在单谷区间],[ba内适当插入两点21,tt,由此把区间],[ba分为三段,然后再通过比较这两点函数值的大小,就可以确定是删去最左端还是最右端,或者同时删去左右两端保留中间段.如此继续下去可将单谷区间无缩小.基本原理:所谓黄金分割就是将一线段分为两段时,要求整段长L与较长段x的比值正好等于较长段x与较短段xL的比值(如图所示),即xLxxL于是有022LLxx,解出其正根LLx618.0215.由此可见长段的长度应为全长的618.0倍,而短段的长度应为全长的382.0倍.因为古代的人们认为按618.0的比率来分割线段时最协调,胜似黄金,故称之为黄金分割.2、黄金分割的算法步骤.(1)给定初始区间],[11ba,精度要求0。令)(382.01111aba,)(618.01111aba,并计算)(1f与)(1f。令1:k。(2)若kkab,停止,且2kkabx。否则,当)()(kkff时,转3;当)()(kkff时,转4。(3)令kkkkkkbba111,,,)(618.01111kkkkaba,计算)(1kf,令1:kk,转2。(4)令,,,111kkkkkkbaa)(382.01111kkkkaba,计算)(1kf,令1:kk,转2。3、黄金分割即0.618的算法流程图4、黄金分割即0.618的算法的MATLAB程序function[x,fval,iter]=f618(a,b)iter=0;whileabs(b-a)1e-5iter=iter+1;lambda=a+0.382*(b-a);miu=a+0.618*(b-a);[dy,f1]=fun1(lambda);[dy,f2]=fun1(miu);iff1f2a=lambda;disp(['the'num2str(iter)'iterationsearchareais:['num2str(a)','num2str(b)']'])elseb=miu;disp(['the'num2str(iter)'iterationsearchareais:['num2str(a)','num2str(b)']'])endendx=(a+b)/2;[dy,fval]=fun1(x);5、根据0.618算法编写程序,求函在计算机上实现黄金分割6、数值实验(5、6个表达式也写出)例1求数xexxxf306)1tan(sin在区间[0,1]上的极大值。解:令xexxxfxg306)1tan(sinFun1程序为:function[dy,val]=fun1(x)val=-((sin(x))^6*tan(1-x)*exp(30*x));dy=-(6*(sin(x))^5*cos(x)*tan(1-x)*exp(30*x)+(sin(x)^6*(1/cos(1-x))^2*(-1)*exp(30*x)+(sin(x))^6*tan(1-x)*exp(30*x)*30);end运行结果:[x,fval,iter]=f618(0,1)The1iterationsearchareais:[0.382,1]The2iterationsearchareais:[0.61808,1]The3iterationsearchareais:[0.76397,1]The4iterationsearchareais:[0.85413,1]The5iterationsearchareais:[0.90985,1]The6iterationsearchareais:[0.94429,1]The7iterationsearchareais:[0.94429,0.97872]The8iterationsearchareais:[0.95744,0.97872]The9iterationsearchareais:[0.96557,0.97872]The10iterationsearchareais:[0.96557,0.9737]The11iterationsearchareais:[0.96867,0.9737]The12iterationsearchareais:[0.96867,0.9737]The13iterationsearchareais:[0.96986,0.97178]The14iterationsearchareais:[0.96986,0.97104]The15iterationsearchareais:[0.97031,0.97104]The16iterationsearchareais:[0.97031,0.97077]The17iterationsearchareais:[0.97049,0.97077]The18iterationsearchareais:[0.97059,0.9737]The19iterationsearchareais:[0.97059,0.9707]The20iterationsearchareais:[0.97063,0.9707]The21iterationsearchareais:[0.97063,0.97067]The22iterationsearchareais:[0.97065,0.97067]The23iterationsearchareais:[0.97066,0.97067]The24iterationsearchareais:[0.97066,0.97067]x=0.9707fval=-4.1086e+010iter=24则)(min]1,0[xgx为4.1086e+010例2用黄金分割法求解)2()(minttt,已知初始单谷区间]5,3[],[ba,按精度001.0计算。解:,944.1056.053,056.08*382.0321tt,667136.7)(,115136.0)(21tt因为)()(21tt,则新的搜索区间为]944.1,3[;,987592.0)(,11392.1,115136.0)(,056.011221ttttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]056.0,3[;,987592.0)(,11392.1,306764.0)(,832608.12211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]056.0,832608.1[;,888075.0)(,665448.0,987592.0)(,11392.12211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]665448.0,832608.1[;,987592.0)(,11392.1,854402.0)(,386753.12211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]665448.0,386753.1[;,987592.0)(,11392.1,996518.0)(,940987.01122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]665448.0,111392.1[;,973038.0)(,835799.0,996518.0)(,940987.02211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]835799.0,111392.1[;,999962.0)(,006115.1,996518.0)(,940987.01122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]940987.0,111392.1[;,999962.0)(,006115.1,997857.0)(,046295.12211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]940987.0,046295.1[;,999962.0)(,006115.1,999647.0)(,981215.01122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]981215.0,046295.1[;,999962.0)(,006115.1,999540.0)(,021434.12211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]981215.0,021434.1[;,999962.0)(,006115.1,999987.0)(,996579.01122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]981215.0,006115.1[;,999914.0)(,990727.0,999987.0)(,996579.02211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]990727.0,006115.1[;,000016.1.0)(,000237.1,999987.0)(,996579.01122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]996579.0,006115.1[;,99999364.0)(,000237.1,000016.1)(,000237.11122tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]996579.0,002472.1[;,99999505.0)(,998830.0,000016.1)(,000237.11211tttt21tt,继续迭代,因为)()(21tt,则新的搜索区间为]998830.0,002472.1[;,00000016.1)(,000237.1,999999075.0)(,001081.11211tttt因为21tt,停止迭代。所以:9999999565.0)(,000659.12**21*tttt例3求函数tteet在[-1,1]内的极小值。解:fun1程序为:function[dy,val]=fun1(x)val=exp(-x)+exp(x);dy=-exp(-x)+exp(x);end令eps=1e-5运行结果:[x,fval,iter]=f618(-1,1)The1iterationsearchareais:[-1,0.236]The2iterationsearchareais:[-0.52785,0.236]The3iterationsearchareais:[-0.23606,0.236]The4iterationsearchareais:[-0.055732,0.236]The5iterationsearchareais:[-0.055732,0
本文标题:最优化方法中关于黄金分割的课题设计
链接地址:https://www.777doc.com/doc-7219854 .html