欢迎来到天天文库
浏览记录
ID:52786984
大小:22.50 KB
页数:5页
时间:2020-03-30
《优化设计-鲍威尔法程序(c语言).doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#definem10/*数组长度m>=维数n*/floatf(floatx[]);voidmjtf(intn,floatx0[],floath,floats[],floata[],floatb[]);voidmhjfgf(intn,floata[],floatb[],floatflag,floatx[]);voidmbwef(intn,floatx0[],floath,floatflag,floata[],floatb[],flo
2、atx[]);floatf(floatx[]){floatresult;result=60-10*x[0]-4*x[1]+x[0]*x[0]+x[1]*x[1]-x[0]*x[1];returnresult;}/*多维进退法子程序*/voidmjtf(intn,floatx0[],floath,floats[],floata[],floatb[]){inti;floatx1[m],x2[m],x3[m],f1,f2,f3;for(i=0;i3、i];x2[i]=x0[i]+h*s[i];}f1=f(x1);f2=f(x2);if(f2>=f1)/*判断搜索方向*/{/*搜索方向为反向,转身*/h=(-1)*h;for(i=0;i4、3);while(f35、;b[i]=x1[i];}}}/*多维黄金分割法子程序*/voidmhjfgf(intn,floata[],floatb[],floatflag,floatx[]){inti;floatx1[m],x2[m],f1,f2,sum;for(i=0;i6、{if(f1<=f2)/*判断消去区间*/{/*消去右*/for(i=0;i7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
3、i];x2[i]=x0[i]+h*s[i];}f1=f(x1);f2=f(x2);if(f2>=f1)/*判断搜索方向*/{/*搜索方向为反向,转身*/h=(-1)*h;for(i=0;i4、3);while(f35、;b[i]=x1[i];}}}/*多维黄金分割法子程序*/voidmhjfgf(intn,floata[],floatb[],floatflag,floatx[]){inti;floatx1[m],x2[m],f1,f2,sum;for(i=0;i6、{if(f1<=f2)/*判断消去区间*/{/*消去右*/for(i=0;i7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
4、3);while(f35、;b[i]=x1[i];}}}/*多维黄金分割法子程序*/voidmhjfgf(intn,floata[],floatb[],floatflag,floatx[]){inti;floatx1[m],x2[m],f1,f2,sum;for(i=0;i6、{if(f1<=f2)/*判断消去区间*/{/*消去右*/for(i=0;i7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
5、;b[i]=x1[i];}}}/*多维黄金分割法子程序*/voidmhjfgf(intn,floata[],floatb[],floatflag,floatx[]){inti;floatx1[m],x2[m],f1,f2,sum;for(i=0;i6、{if(f1<=f2)/*判断消去区间*/{/*消去右*/for(i=0;i7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
6、{if(f1<=f2)/*判断消去区间*/{/*消去右*/for(i=0;i7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
7、]+(float)0.618*(b[i]-a[i]);f2=f(x2);}sum=0;for(i=0;iflag*0.1);for(i=0;i8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
8、r;floatx1[m],x2[m],f0,f1,f2,fn[m],s[m][m],sum;for(i=0;i
此文档下载收益归作者所有