机械优化设计惩罚函数内点法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
return s;
}
void jintuifa(double ab[m][m],int n,double x0[],double h,int ij,double a[],double b[],double r0)
{
int i,j,z;
double x1[m],x2[m],x3[m],f1,f2,f3;
void hongjinfa(int n,double a[],double b[],double flag,double x[],double r0);
void baoweifa(int n,double x0[],double h,double flag,double a[],double b[],double x[],double r0);
double s[m];
for(i = 0; i < n; i ++)
{
s[i]=ab[i][ij];
}
for(i=0;i<n;i++)
{
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;
double fahansu(double tt)
{
double ty;
if(tt<0) ty=-tt;else ty=0;
return ty;
}
double yuanhansu(double x[])
{
double s;
//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];
double x1[m],x2[m],f1,f2;
while(1)
{
for(i=0;i<n;i++)
x1[i]=b[i];
f1=f(x1,r0);
for(i=0;i<n;i++)
x2[i]=a[i];
f2=f(x2,r0);
if(fabs((f2-f1)/f2)<=flag)
{
for(i=0;i<n;i++)
for(i=0;i<n;i++)
x3[i]=x1[i];
f3=f1;
for(i=0;i<n;i++)
x1[i]=x2[i];
f1=f2;
for(i=0;i<n;i++)
x2[i]=x3[i];
f2=f3;
}
for(i=0;i<n;i++)
x3[i]=x2[i]+(double)h*s[i];
f3=f(x3,r0);
ab[i][j] = 1;
else
ab[i][j] =0;
}
}
while(1)
{
wo=f(x0,r0);
for(p=0;p<n;p++)
{
q=f(x0,r0);
jintuifa(ab,n,x0,h,p,a,b,r0);
hongjinfa(n,a,b,flag,x1,r0);
for(e=0;e<n;e++)
#include <stdio.h>
#include <math.h>
#define m 12
double f(double x[],double r);
void jintuifa(double ab[m][m],int n,double x0[],double h,int ij,double a[],double b[],double r0);
{
if(fn[0]<=fn[i])
{
fn[0]=fn[i];
r=i;
}
}
f0=f(x0,r0);
f1=f(x1,r0);
f2=f(x2,r0);
if(f2>=f0||((double)f0-(double)2*f1+(double)f2)*((double)f0-(double)f1-(double)fn[0])*((double)f0-(double)f1-(double)fn[0])>=0.5*fn[0]*(double)(f0-f2)*(double)(f0-f2))
while(f3<f2)
{
h=2*h;
for(i=0;i<n;i++)
x1[i]=x2[i];
f1=f2;
for(i=0;i<n;i++)
x2[i]=x3[i];
f2=f3;
for(i=0;i<n;i++)
x3[i]=x2[i]+(double)h*s[i];
f3=f(x3,r0);
}
for(i=0;i<n;i++)
{
if(x1[i]<x3[i])
{
a[i]=x1[i];
b[i]=x3[i];
}
else
{
a[i]=x3[i];
b[i]=x1[i];
}
}
}
void hongjinfa(int n,double a[],double b[],double flag,double x[],double r0)
{
int i;
{
int i,j,k,r,sum,p,e;
double x1[m],x2[m],abc[m],kr[m],f0,f1,f2,fn[m],c[m],q,wo;
k=0;
double ab[m][m];
for(i = 0; i < n; i ++)
{
for(j = 0; j < n; j ++)
{
if(i==j)
for(i=0;i<n;i++)
a[i]=x1[i];
else
for(i=0;i<n;i++)
b[i]=x2[i];
}
}
}
void baoweifa(int n,double x0[],double h,double flag,double a[],double b[],double x[],double r0)
return s;
}
double f(double x[],double r)
{
double s,t,t2;
//t=1-x[0];
t=1-x[0];t2=2-x[1];
// s=yuanhansu(x)-r*log(fahansu(t));
s=yuanhansu(x)-r*log(fahansu(t))-r*log(fahansu(t2));
x[i]=(double)(b[i]+a[i])/2.0;
break;
}
else
{
for(i=0;i<n百度文库i++)
x1[i]=b[i]-(double)0.618*(b[i]-a[i]);
for(i=0;i<n;i++)
x2[i]=a[i]+(double)0.618*(b[i]-a[i]);
if(f(x1,r0)>f(x2,r0))
{
x0[e]=x1[e];
}
fn[p]=(double)(q-f(x1,r0));
}
k=k+1;
for(i=0;i<n;i++)
x2[i]=(double)2*x1[i]-x0[i];
for(i=0;i<n;i++)
c[i]=(double)x1[i]-x0[i];
r=0;
for(i=0;i<n;i++)
相关文档
最新文档