?? ethylopt.cpp
字號:
#include "math.h"
//#include " "//DFP的頭文件
class CComponent
{
public:
double RON;
double MON;
double OLE;
double ARO;
friend class CExperiment;
};
class CProduct
{
public:
};
class CExperiment
{
public:
double *vol;
double RON;
double MON;
double RVP;
double RON_blend;
double MON_blend;
double b[8];
void Compute(CComponent ** components,int CNum)
{
int i;
double rs,s,ms,O,O2,A,A2;
for(i=0;i<CNum;i++)
{
b[0]+=components[i]->RON*vol[i];
rs+=components[i]->RON*(components[i]->RON-components[i]->MON)*vol[i];
s+=(components[i]->RON-components[i]->MON)*vol[i];
ms+=components[i]->MON*(components[i]->RON-components[i]->MON)*vol[i];
b[4]+=components[i]->MON*vol[i];
ms+=components[i]->MON*(components[i]->RON-components[i]->MON)*vol[i];
O+=components[i]->OLE*vol[i];
O2+=components[i]->OLE*components[i]->OLE*vol[i];
A+=components[i]->ARO*vol[i];
A2+=pow(components[i]->ARO,2)*vol[i];
}
b[1]=rs-b[0]*s;
b[2]=O2-O*O;
b[3]=A2-A*A;
b[5]=ms-b[4]*s;
b[6]=b[2];
b[7]=pow(b[3]/100,2);
}
double RON_err(double *x)
{
return(RON_blend-(b[0]+x[1]*b[1]+x[2]*b[2]+x[3]*b[3]));
}
double MON_err(double *x)
{
return(MON_blend-(b[4]+x[1]*b[5]+x[2]*b[6]+x[3]*b[7]));
}
};
int expNum ;
CExperiment *experiments;
double target1(double *x)
{
double ret=0;
int i;
for(i=0;i<expNum;i++)
ret+=pow(experiments[i].RON_err(x),2);
return(ret);
}
double target2(double *x)
{
double ret=0;
int i;
for(i=0;i<expNum;i++)
ret+=pow(experiments[i].MON_err(x),2);
return(ret);
}
void EthylOpt( )
{
double a[3]={0,0,0};//a1,a2,a3初值待定
double b[3]={0,0,0};//a4,a5,a6初值待定
DFP(target1,3,a);
DFP(target2,3,b);
//完成了a1至a6的參數辯識,采用最小二乘規則
}
void main(void)
{
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -