📄 lsdoc.cpp
字号:
if(tmpTypeIndex[ttt].IsData)
{
m_AverTypeIndex[ttt].AverArea+=tmpTypeIndex[ttt].AverArea;
m_AverTypeIndex[ttt].BlockNum+=tmpTypeIndex[ttt].BlockNum;
m_AverTypeIndex[ttt].Chip+=tmpTypeIndex[ttt].Chip;
m_TypeC0[ttt].AverArea+=tmpTypeIndex[ttt].AverArea*
tmpTypeIndex[ttt].AverArea;
m_TypeC0[ttt].BlockNum+=tmpTypeIndex[ttt].BlockNum*
tmpTypeIndex[ttt].BlockNum;
m_TypeC0[ttt].Chip+=tmpTypeIndex[ttt].Chip*
tmpTypeIndex[ttt].Chip;
}
}
// 计算整体平均值
m_AverAllIndex.Z_AverArea+=m_AllVarySpace[boxindex].AverArea;
m_AverAllIndex.Z_Blance+=m_AllVarySpace[boxindex].Blance;
m_AverAllIndex.Z_BlockNum+=m_AllVarySpace[boxindex].BlockNum;
m_AverAllIndex.Z_Chip+=m_AllVarySpace[boxindex].Chip;
m_AverAllIndex.Z_City+=m_AllVarySpace[boxindex].City;
m_AverAllIndex.Z_Diversity+=m_AllVarySpace[boxindex].Diversity;
m_AverAllIndex.Z_Jamming+=m_AllVarySpace[boxindex].Jamming;
m_AverAllIndex.Z_Plant+=m_AllVarySpace[boxindex].Plant;
m_AverAllIndex.Z_Risk+=m_AllVarySpace[boxindex].Risk;
m_AverAllIndex.Z_Vantage+=m_AllVarySpace[boxindex].Vantage;
m_AllC0.Z_AverArea+=m_AllVarySpace[boxindex].AverArea*
m_AllVarySpace[boxindex].AverArea;
m_AllC0.Z_Blance+=m_AllVarySpace[boxindex].Blance*
m_AllVarySpace[boxindex].Blance;
m_AllC0.Z_BlockNum+=m_AllVarySpace[boxindex].BlockNum*
m_AllVarySpace[boxindex].BlockNum;
m_AllC0.Z_Chip+=m_AllVarySpace[boxindex].Chip*
m_AllVarySpace[boxindex].Chip;
m_AllC0.Z_City+=m_AllVarySpace[boxindex].City*
m_AllVarySpace[boxindex].City;
m_AllC0.Z_Diversity+=m_AllVarySpace[boxindex].Diversity*
m_AllVarySpace[boxindex].Diversity;
m_AllC0.Z_Jamming+=m_AllVarySpace[boxindex].Jamming*
m_AllVarySpace[boxindex].Jamming;
m_AllC0.Z_Plant+=m_AllVarySpace[boxindex].Plant*
m_AllVarySpace[boxindex].Plant;
m_AllC0.Z_Risk+=m_AllVarySpace[boxindex].Risk*
m_AllVarySpace[boxindex].Risk;
m_AllC0.Z_Vantage+=m_AllVarySpace[boxindex].Vantage*
m_AllVarySpace[boxindex].Vantage;
waitdlg.m_ProgWait.StepIt();
}
// 求平均
m_AverAllIndex.Z_AverArea/=boxnum;
m_AverAllIndex.Z_Blance/=boxnum;
m_AverAllIndex.Z_BlockNum/=boxnum;
m_AverAllIndex.Z_Chip/=boxnum;
m_AverAllIndex.Z_City/=boxnum;
m_AverAllIndex.Z_Diversity/=boxnum;
m_AverAllIndex.Z_Jamming/=boxnum;
m_AverAllIndex.Z_Plant/=boxnum;
m_AverAllIndex.Z_Risk/=boxnum;
m_AverAllIndex.Z_Vantage/=boxnum;
m_AllC0.Z_AverArea=m_AllC0.Z_AverArea/boxnum-
m_AverAllIndex.Z_AverArea*m_AverAllIndex.Z_AverArea;
m_AllC0.Z_Blance=m_AllC0.Z_Blance/boxnum-
m_AverAllIndex.Z_Blance*m_AverAllIndex.Z_Blance;
m_AllC0.Z_BlockNum=m_AllC0.Z_BlockNum/boxnum-
m_AverAllIndex.Z_BlockNum*m_AverAllIndex.Z_BlockNum;
m_AllC0.Z_Chip=m_AllC0.Z_Chip/boxnum-
m_AverAllIndex.Z_Chip*m_AverAllIndex.Z_Chip;
m_AllC0.Z_City=m_AllC0.Z_City/boxnum-
m_AverAllIndex.Z_City*m_AverAllIndex.Z_City;
m_AllC0.Z_Diversity=m_AllC0.Z_Diversity/boxnum-
m_AverAllIndex.Z_Diversity*m_AverAllIndex.Z_Diversity;
m_AllC0.Z_Jamming=m_AllC0.Z_Jamming/boxnum-
m_AverAllIndex.Z_Jamming*m_AverAllIndex.Z_Jamming;
m_AllC0.Z_Plant=m_AllC0.Z_Plant/boxnum-
m_AverAllIndex.Z_Plant*m_AverAllIndex.Z_Plant;
m_AllC0.Z_Risk=m_AllC0.Z_Risk/boxnum-
m_AverAllIndex.Z_Risk*m_AverAllIndex.Z_Risk;
m_AllC0.Z_Vantage=m_AllC0.Z_Vantage/boxnum-
m_AverAllIndex.Z_Vantage*m_AverAllIndex.Z_Vantage;
for(int mls=0;mls<typenum;mls++)
{
m_AverTypeIndex[mls].AverArea/=boxnum;
m_AverTypeIndex[mls].BlockNum/=boxnum;
m_AverTypeIndex[mls].Chip/=boxnum;
m_TypeC0[mls].AverArea=m_TypeC0[mls].AverArea/boxnum-
m_AverTypeIndex[mls].AverArea*m_AverTypeIndex[mls].AverArea;
m_TypeC0[mls].BlockNum=m_TypeC0[mls].BlockNum/boxnum-
m_AverTypeIndex[mls].BlockNum*m_AverTypeIndex[mls].BlockNum;
m_TypeC0[mls].Chip=m_TypeC0[mls].Chip/boxnum-
m_AverTypeIndex[mls].Chip*m_AverTypeIndex[mls].Chip;
}
waitdlg.m_ProgWait.StepIt();
// 求EI0
CalcEI0();
waitdlg.m_ProgWait.StepIt();
waitdlg.DestroyWindow();
m_bEverAllSpace=TRUE;
}
void CLSDoc::CalcAllZValue()
{
// 公用变量
BYTE typenum=m_BlockTypes.GetSize();
long boxnum=m_nAllBoxNum;
// 临时变量
long mainindex;
long moveindex;
// For Both Moran I & Geary C
double S0, ew_S0, sn_S0, se_S0, sw_S0;
double S1, ew_S1, sn_S1, se_S1, sw_S1;
double S2, ew_S2, sn_S2, se_S2, sw_S2;
double EW, ew_EW, sn_EW, se_EW, sw_EW;
// For Moran I (Note: It both use EI0)
double EWIJ[10], ew_EWIJ[10], sn_EWIJ[10], se_EWIJ[10], sw_EWIJ[10];
double * typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * ew_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * sn_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * se_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * sw_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
// For Geary C
double gc_EWIJ[10],gc_ew_EWIJ[10],gc_sn_EWIJ[10],gc_se_EWIJ[10],gc_sw_EWIJ[10];
double gc_EIJ[10],gc_ew_EIJ[10],gc_sn_EIJ[10],gc_se_EIJ[10],gc_sw_EIJ[10];
double * gc_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_ew_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_sn_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_se_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_sw_typeEWIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_typeEIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_ew_typeEIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_sn_typeEIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_se_typeEIJ=(double *)malloc(sizeof(double)*typenum*3);
double * gc_sw_typeEIJ=(double *)malloc(sizeof(double)*typenum*3);
AllIndex thisAllIndex,thatAllIndex;
TypeIndex * theseTypeIndex=(TypeIndex *)malloc(sizeof(TypeIndex)*typenum);
TypeIndex * thoseTypeIndex=(TypeIndex *)malloc(sizeof(TypeIndex)*typenum);
// 变量初始化
ZeroMemory(typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(ew_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(sn_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(se_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(sw_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_ew_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_sn_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_se_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_sw_typeEWIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_typeEIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_ew_typeEIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_sn_typeEIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_se_typeEIJ,sizeof(double)*typenum*3);
ZeroMemory(gc_sw_typeEIJ,sizeof(double)*typenum*3);
EW=ew_EW=sn_EW=se_EW=sw_EW=0;
S1=ew_S1=sn_S1=se_S1=sw_S1=0;
S2=ew_S2=sn_S2=se_S2=sw_S2=0;
for(int mm=0;mm<10;mm++)
{
EWIJ[mm]=0;
ew_EWIJ[mm]=0;
sn_EWIJ[mm]=0;
se_EWIJ[mm]=0;
sw_EWIJ[mm]=0;
gc_EWIJ[mm]=0;
gc_ew_EWIJ[mm]=0;
gc_sn_EWIJ[mm]=0;
gc_se_EWIJ[mm]=0;
gc_sw_EWIJ[mm]=0;
gc_EIJ[mm]=0;
gc_ew_EIJ[mm]=0;
gc_sn_EIJ[mm]=0;
gc_se_EIJ[mm]=0;
gc_sw_EIJ[mm]=0;
}
m_TypeofIValues.RemoveAll();
m_TypeofIValues.SetSize(typenum);
m_TypeofZValues.RemoveAll();
m_TypeofZValues.SetSize(typenum);
m_EWTypeofIValues.RemoveAll();
m_EWTypeofIValues.SetSize(typenum);
m_EWTypeofZValues.RemoveAll();
m_EWTypeofZValues.SetSize(typenum);
m_SNTypeofIValues.RemoveAll();
m_SNTypeofIValues.SetSize(typenum);
m_SNTypeofZValues.RemoveAll();
m_SNTypeofZValues.SetSize(typenum);
m_SETypeofIValues.RemoveAll();
m_SETypeofIValues.SetSize(typenum);
m_SETypeofZValues.RemoveAll();
m_SETypeofZValues.SetSize(typenum);
m_SWTypeofIValues.RemoveAll();
m_SWTypeofIValues.SetSize(typenum);
m_SWTypeofZValues.RemoveAll();
m_SWTypeofZValues.SetSize(typenum);
// For Geary C
m_gc_TypeofIValues.RemoveAll();
m_gc_TypeofIValues.SetSize(typenum);
m_gc_TypeofZValues.RemoveAll();
m_gc_TypeofZValues.SetSize(typenum);
m_gc_EWTypeofIValues.RemoveAll();
m_gc_EWTypeofIValues.SetSize(typenum);
m_gc_EWTypeofZValues.RemoveAll();
m_gc_EWTypeofZValues.SetSize(typenum);
m_gc_SNTypeofIValues.RemoveAll();
m_gc_SNTypeofIValues.SetSize(typenum);
m_gc_SNTypeofZValues.RemoveAll();
m_gc_SNTypeofZValues.SetSize(typenum);
m_gc_SETypeofIValues.RemoveAll();
m_gc_SETypeofIValues.SetSize(typenum);
m_gc_SETypeofZValues.RemoveAll();
m_gc_SETypeofZValues.SetSize(typenum);
m_gc_SWTypeofIValues.RemoveAll();
m_gc_SWTypeofIValues.SetSize(typenum);
m_gc_SWTypeofZValues.RemoveAll();
m_gc_SWTypeofZValues.SetSize(typenum);
CWaitDlg waitdlg;
waitdlg.Create(IDD_WAIT,NULL);
waitdlg.m_ProgWait.SetRange(0,m_nAllBoxNum+1);
waitdlg.m_ProgWait.SetStep(1);
for(mainindex=0;mainindex<boxnum;mainindex++)
{
double EWj=0;
double ew_EWj=0;
double sn_EWj=0;
double se_EWj=0;
double sw_EWj=0;
thisAllIndex=m_AllVarySpace[mainindex];
for(int t=0;t<typenum;t++)
{
theseTypeIndex[t]=m_TypeVarySpace[mainindex*typenum+t];
}
double Wij;
for(moveindex=0;moveindex<boxnum;moveindex++)
{
if(moveindex==mainindex)
continue;
thatAllIndex=m_AllVarySpace[moveindex];
Wij=1/pow(sqrt(double((m_aBoxCoords[mainindex].x-m_aBoxCoords[moveindex].x)
*(m_aBoxCoords[mainindex].x-m_aBoxCoords[moveindex].x)+
(m_aBoxCoords[mainindex].y-m_aBoxCoords[moveindex].y)*
(m_aBoxCoords[mainindex].y-m_aBoxCoords[moveindex].y))),m_dPower);
S1+=Wij*Wij;
EWj+=Wij;
// 整体变量 EWIJ 计算
EWIJ[0]+=Wij*(thisAllIndex.AverArea-m_AverAllIndex.Z_AverArea)
*(thatAllIndex.AverArea-m_AverAllIndex.Z_AverArea);
EWIJ[1]+=Wij*(thisAllIndex.Blance-m_AverAllIndex.Z_Blance)*
(thatAllIndex.Blance-m_AverAllIndex.Z_Blance);
EWIJ[2]+=Wij*(thisAllIndex.BlockNum-m_AverAllIndex.Z_BlockNum)*
(thatAllIndex.BlockNum-m_AverAllIndex.Z_BlockNum);
EWIJ[3]+=Wij*(thisAllIndex.Chip-m_AverAllIndex.Z_Chip)*
(thatAllIndex.Chip-m_AverAllIndex.Z_Chip);
EWIJ[4]+=Wij*(thisAllIndex.City-m_AverAllIndex.Z_City)*
(thatAllIndex.City-m_AverAllIndex.Z_City);
EWIJ[5]+=Wij*(thisAllIndex.Diversity-m_AverAllIndex.Z_Diversity)*
(thatAllIndex.Diversity-m_AverAllIndex.Z_Diversity);
EWIJ[6]+=Wij*(thisAllIndex.Jamming-m_AverAllIndex.Z_Jamming)*
(thatAllIndex.Jamming-m_AverAllIndex.Z_Jamming);
EWIJ[7]+=Wij*(thisAllIndex.Plant-m_AverAllIndex.Z_Plant)*
(thatAllIndex.Plant-m_AverAllIndex.Z_Plant);
EWIJ[8]+=Wij*(thisAllIndex.Risk-m_AverAllIndex.Z_Risk)*
(thatAllIndex.Risk-m_AverAllIndex.Z_Risk);
EWIJ[9]+=Wij*(thisAllIndex.Vantage-m_AverAllIndex.Z_Vantage)*
(thatAllIndex.Vantage-m_AverAllIndex.Z_Vantage);
// For Geary C
gc_EWIJ[0]+=Wij*(thisAllIndex.AverArea-thatAllIndex.AverArea)
*(thisAllIndex.AverArea-thatAllIndex.AverArea);
gc_EWIJ[1]+=Wij*(thisAllIndex.Blance-thatAllIndex.Blance)*
(thisAllIndex.Blance-thatAllIndex.Blance);
gc_EWIJ[2]+=Wij*(thisAllIndex.BlockNum-thatAllIndex.BlockNum)*
(thisAllIndex.BlockNum-thatAllIndex.BlockNum);
gc_EWIJ[3]+=Wij*(thisAllIndex.Chip-thatAllIndex.Chip)*
(thisAllIndex.Chip-thatAllIndex.Chip);
gc_EWIJ[4]+=Wij*(thisAllIndex.City-thatAllIndex.City)*
(thisAllIndex.City-thatAllIndex.City);
gc_EWIJ[5]+=Wij*(thisAllIndex.Diversity-thatAllIndex.Diversity)*
(thisAllIndex.Diversity-thatAllIndex.Diversity);
gc_EWIJ[6]+=Wij*(thisAllIndex.Jamming-thatAllIndex.Jamming)*
(thisAllIndex.Jamming-thatAllIndex.Jamming);
gc_EWIJ[7]+=Wij*(thisAllIndex.Plant-thatAllIndex.Plant)*
(thisAllIndex.Plant-thatAllIndex.Plant);
gc_EWIJ[8]+=Wij*(thisAllIndex.Risk-thatAllIndex.Risk)*
(thisAllIndex.Risk-thatAllIndex.Risk);
gc_EWIJ[9]+=Wij*(thisAllIndex.Vantage-thatAllIndex.Vantage)*
(thisAllIndex.Vantage-thatAllIndex.Vantage);
// gc_EIJ
gc_EIJ[0]+=(thisAllIndex.AverArea-thatAllIndex.AverArea)
*(thisAllIndex.AverArea-thatAllIndex.AverArea);
gc_EIJ[1]+=(thisAllIndex.Blance-thatAllIndex.Blance)*
(thisAllIndex.Blance-thatAllIndex.Blance);
gc_EIJ[2]+=(thisAllIndex.BlockNum-thatAllIndex.BlockNum)*
(thisAllIndex.BlockNum-thatAllIndex.BlockNum);
gc_EIJ[3]+=(thisAllIndex.Chip-thatAllIndex.Chip)*
(thisAllIndex.Chip-thatAllIndex.Chip);
gc_EIJ[4]+=(thisAllIndex.City-thatAllIndex.City)*
(thisAllIndex.City-thatAllIndex.City);
gc_EIJ[5]+=(thisAllIndex.Diversity-thatAllIndex.Diversity)*
(thisAllIndex.Diversity-thatAllIndex.Diversity);
gc_EIJ[6]+=(thisAllIndex.Jamming-thatAllIndex.Jamming)*
(thisAllIndex.Jamming-thatAllIndex.Jamming);
gc_EIJ[7]+=(thisAllIndex.Plant-thatAllIndex.Plant)*
(thisAllIndex.Plant-thatAllIndex.Plant);
gc_EIJ[8]+=(thisAllIndex.Risk-thatAllIndex.Risk)*
(thisAllIndex.Risk-thatAllIndex.Risk);
gc_EIJ[9]+=(thisAllIndex.Vantage-thatAllIndex.Vantage)*
(thisAllIndex.Vantage-thatAllIndex.Vantage);
for(int ty=0;ty<typenum;ty++)
{
thoseTypeIndex[ty]=m_TypeVarySpace[moveindex*typenum+ty];
// 类型变量 EWIJ 计算
typeEWIJ[ty*3]+=Wij*
(theseTypeIndex[ty].AverArea-m_AverTypeIndex[ty].AverArea)*
(thoseTypeIndex[ty].AverArea-m_AverTypeIndex[ty].AverArea);
typeEWIJ[ty*3+1]+=Wij*
(theseTypeIndex[ty].BlockNum-m_AverTypeIndex[ty].BlockNum)*
(thoseTypeIndex[ty].BlockNum-m_AverTypeIndex[ty].BlockNum);
typeEWIJ[ty*3+2]+=Wij*
(theseTypeIndex[ty].Chip-m_AverTypeIndex[ty].Chip)*
(thoseTypeIndex[ty].Chip-m_AverTypeIndex[ty].Chip);
//For Geary C
gc_typeEWIJ[ty*3]+=Wij*
(theseTypeIndex[ty].AverArea-thoseTypeIndex[ty].AverArea)*
(theseTypeIndex[ty].AverArea-thoseTypeIndex[ty].AverArea);
gc_typeEWIJ[ty*3+1]+=Wij*
(theseTypeIndex[ty].BlockNum-thoseTypeIndex[ty].BlockNum)*
(theseTypeIndex[ty].BlockNum-thoseTypeIndex[ty].BlockNum);
gc_typeEWIJ[ty*3+2]+=Wij*
(theseTypeIndex[ty].Chip-thoseTypeIndex[ty].Chip)*
(theseTypeIndex[ty].Chip-thoseTypeIndex[ty].Chip);
// gc_typeEIJ
gc_typeEIJ[ty*3]+=
(theseTypeIndex[ty].AverArea-thoseTypeIndex[ty].AverArea)*
(theseTypeIndex[ty].AverArea-thoseTypeIndex[ty].AverArea);
gc_typeEIJ[ty*3+1]+=
(theseTypeIndex[ty].BlockNum-thoseTypeIndex[ty].BlockNum)*
(theseTypeIndex[ty].BlockNum-thoseTypeIndex[ty].BlockNum);
gc_typeEIJ[ty*3+2]+=
(theseTypeIndex[ty].Chip-thoseTypeIndex[ty].Chip)*
(theseTypeIndex[ty].Chip-thoseTypeIndex[ty].Chip);
}
//处理方向问题
BYTE direction;
if(m_aBoxCoords[mainindex].x!=m_aBoxCoords[moveindex].x)
{
double thearc=
double((m_aBoxCoords[mainindex].y-m_aBoxCoords[moveindex].y))/
(m_aBoxCoords[mainindex].x-m_aBoxCoords[moveindex].x);
if(fabs(thearc)<TANG)
{
direction=1;
}
else if(fabs(thearc)>1/TANG)
{
direction=2;
}
else
{
if(thearc>0)
{
direction=3;
}
else
{
direction=4;
}
}
}
else
{
direction=2;
}
switch(direction)
{
case 1:
ew_S1+=Wij*Wij;
ew_EWj+=Wij;
ew_EWIJ[0]+=Wij*(thisAllIndex.AverArea-m_AverAllIndex.Z_AverArea)
*(thatAllIndex.AverArea-m_AverAllIndex.Z_AverArea);
ew_EWIJ[1]+=Wij*(thisAllIn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -