欢迎来到天天文库
浏览记录
ID:59172078
大小:79.73 KB
页数:8页
时间:2020-10-30
《复合形法C语言程序.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、现代设计理论与方法实验一、实验名称:复合形法参考程序上机实验二、实验目的:1:掌握复合形法优化问题的寻优策略2:能读懂程序并应用程序计算一些目标函数的最优解三、实验流程:1、题目:求如下约束优化问题的最优解()=S.t.已知:N=2,取k=4,。2、编写黄金分割法的C语言程序代码;3、利用visualc程序运行C程序代码;#include"math.h"#include"stdio.h"#include"stdlib.h"#defineE10.001#defineep0.00001#definen2#definek4doubleaf;inti,j;doubleX0[n],
2、XX[n],X[k][n],FF[k];doublea[n],b[n];doublerm=.0;doubleF(doubleC[n]){doubleF;F=pow(C[0]-3,2)+pow(C[1]-4,2);returnF;}intcons(doubleD[n]){if((D[0]>=0)&&(D[1]>=0)&&(D[0]<=6)&&(D[1]<=8)&&((2.5-D[0]+D[1])>=0)&&((5-D[0]-D[1])>=0))return1;elsereturn0;}voidbou(){a[0]=0;b[0]=6;a[1]=0;b[1]=8;}double
3、r(){doubler1,r2,r3,rr;r1=pow(2,35);r2=pow(2,36);r3=pow(2,37);rm=5*rm;if(rm>=r3){rm=rm-r3;}if(rm>=r2){rm=rm-r2;}if(rm>=r1){rm=rm-r1;}rr=rm/r1;returnrr;}voidproduce(doubleA[n],doubleB[n]){intjj;doubleS;sl:for(i=0;i4、++){X[0][i]=XX[i];}for(j=1;j5、=X0[i]+0.5*(X[j][i]-X0[i]);XX[i]=X[j][i];}}}}main(){doubleEE,Xc[n],Xh[n],Xg[n],X1[n],Xr[n],Xs[n],w;intl,lp,lp1;bou();s111:produce(a,b);s222:for(j=0;j6、[lp1];FF[lp1]=w;for(i=0;i7、k+0.0)*EE),0.5);if(EE<=E1){gotos333;}for(i=0;i=F(Xh)){if(af<=ep){for(i=0;i
4、++){X[0][i]=XX[i];}for(j=1;j5、=X0[i]+0.5*(X[j][i]-X0[i]);XX[i]=X[j][i];}}}}main(){doubleEE,Xc[n],Xh[n],Xg[n],X1[n],Xr[n],Xs[n],w;intl,lp,lp1;bou();s111:produce(a,b);s222:for(j=0;j6、[lp1];FF[lp1]=w;for(i=0;i7、k+0.0)*EE),0.5);if(EE<=E1){gotos333;}for(i=0;i=F(Xh)){if(af<=ep){for(i=0;i
5、=X0[i]+0.5*(X[j][i]-X0[i]);XX[i]=X[j][i];}}}}main(){doubleEE,Xc[n],Xh[n],Xg[n],X1[n],Xr[n],Xs[n],w;intl,lp,lp1;bou();s111:produce(a,b);s222:for(j=0;j6、[lp1];FF[lp1]=w;for(i=0;i7、k+0.0)*EE),0.5);if(EE<=E1){gotos333;}for(i=0;i=F(Xh)){if(af<=ep){for(i=0;i
6、[lp1];FF[lp1]=w;for(i=0;i7、k+0.0)*EE),0.5);if(EE<=E1){gotos333;}for(i=0;i=F(Xh)){if(af<=ep){for(i=0;i
7、k+0.0)*EE),0.5);if(EE<=E1){gotos333;}for(i=0;i=F(Xh)){if(af<=ep){for(i=0;i
此文档下载收益归作者所有