资源描述:
《优化设计--复合形法》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、优化设计作业复合形法题目:课本例l-lo程序如下:#include#include#includevoidcom(intnjntk,intkg,floatcp,floatx[],floatbl[],floatbu[],floatxc[][100],float*f);voidconstraint(floatx[],floatg[]);voidxcent(intn,intk,intll.intlh,floatxO[J,floatxcom[JL100J);voidfxsc
2、(intn,intk,floatx[],floatxcom[][100],floatfxk[]);floatobjfx(floatx[]);intgau(floatx[J,floatgLJ,intkg);floatobjfx(floatx[]){floatfl;fl=120*x[0]+x[l];returnfl;}voidconstraint(floatx[l,floatgf]){g[0]=-x[0]+0.1;g[l]=-x[l]+l;gL2J=x[0J-3;g[3]=x[l]-8;g[4]=l-0.25*x[ll;g
3、[5]=l-7*x[0]*x[l]/45;g[6]=1-7*x[0]*x[0]*x[0]*x[l]/45;}intgau(floatx[],floatg[J,intkg){inti;constraint(x,g);for(i=0;i0)return();;)return1;}voidxcent(intn,intk,int11,intlh,floatx0[],floatxcom[
4、[100J){inti,l;floatxs;for(i=0;i5、-l)x0[i]=xs/(ll-l);elsexO[i]=xs/ll;}voidfxse(intn,intk,floatx[],floatxcom[J[100],floatfxk[J){intl,lp,lpl,i;floatte;for(l=0;l6、l]=tc;for(i=0;i7、float*xh=(float*)calloc(n,sizeof(float));float*xr=(float*)calloc(n,sizeof(float));float*fxk=(float*)calloc(k,sizeof(float));float*g=(float*)calloc(kg,sizeof(float));si:for(i=0;i8、;i9、)x[i]=x0[i]+0.5*(x[i]-x0[i]);gotos2;elsefor(i=0;i