资源描述:
《机械优化设计惩罚函数外点法.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#definem10doublef(doublex[],doubler);voidjintuifa(doubleab[m][m],intn,doublex0[],doubleh,intij,doublea[],doubleb[],doubler0);voidhongjinfa(intn,doublea[],doubleb[],doubleflag,doublex[],doubler0);voidbaoweifa(intn,doublex0[],doubleh,doubleflag,do
2、ublea[],doubleb[],doublex[],doubler0);doublefahansu(doublett){doublety;if(tt<=0)ty=0;elsety=tt*tt;returnty;}doubleyuanhansu(doublex[]){doubles;s=x[0]*x[0]+x[1]*x[1];//s=x[0]*x[0]+x[1]*x[1]+x[2]*x[2]+x[3]*x[3];returns;}doublef(doublex[],doubler){doubles,t,t2;t=1-x[0];//t=1-x[0];
3、t2=2-x[1];s=yuanhansu(x)+r*fahansu(t);//s=yuanhansu(x)+r*(fahansu(t)+fahansu(t2));returns;}voidjintuifa(doubleab[m][m],intn,doublex0[],doubleh,intij,doublea[],doubleb[],doubler0){inti,j,z;doublex1[m],x2[m],x3[m],f1,f2,f3;doubles[m];for(i=0;i4、++){x1[i]=x0[i];x2[i]=x0[i]+(double)h*s[i];}f1=f(x1,r0);f2=f(x2,r0);if(f2>=f1){h=(-1)*h;for(i=0;i5、++)x1[i]=x2[i];f1=f2;for(i=0;i6、x1[m],x2[m],f1,f2;while(1){for(i=0;i7、.618*(b[i]-a[i]);if(f(x1,r0)>f(x2,r0))for(i=0;i8、m];for(i=0;i