第三章所用程序 【PTS-RNSA主程序】

来源:互联网 发布:html表白源码下载 编辑:程序博客网 时间:2024/06/03 22:23
 
#include "queue.h"#include <windows.h>#include<fstream>using namespace std;extern long double rs,r0;extern  int n_r;extern int n_time;extern long double s_all;extern long double sum;externconst double PI;vector <struct QueueElementType> detector;extern SeqQueue Q;extern SeqQueue *p1;extern   self_str self[NS];extern   square_A test[NT];unsigned int num_d=0;void main(void){srand((unsigned)time(NULL));ifstream fin("self.txt");ifstream fin1("test.txt");ifstream fin2("control.txt");ofstream   fout("PTS-result.xls",ios::app);long double cost;for(int i=0;i<NS;i++){fin>>self[i].x;fin>>self[i].y;}long double p_d;long double area_non;long double area[10];for(int i=0;i<NT;i++){fin1>>test[i].x;fin1>>test[i].y;fin1>>test[i].z;}fin2>>n_time;fin2>>n_r;long double *Array[3];for(int j=0;j<3;j++){Array[j]=new long double[n_r];}long double *Array_s[5];for(int j=0;j<5;j++){Array_s[j]=new long double[n_time];}for(int i=0;i<n_r;i++){fin2>>Array[0][i];                      //rsfin2>>Array[1][i];                      //r0fin2>>Array[2][i];                      //p_d}fout<<endl<<endl;fout<<"Radius"<<'\t'<<'\t'<<"dr_max"<<'\t'<<"dr_min"<<'\t'<<"dr_mean"<<'\t'<<"dr_sd"<<'\t'<<'\t'<<"can_max"<<'\t'<<"can_min"<<'\t'<<"can_mean"<<'\t'<<"can_sd"<<'\t'<<'\t'<<"mature_max"<<'\t'<<"mature_min"<<'\t'<<"mature_mean"<<'\t'<<"mature_sd"<<'\t'<<'\t'<<"cost_max"<<'\t'<<"cost_min"<<'\t'<<"cost_mean"<<'\t'<<"cost_sd"<<endl;for(int i=0;i<n_r;i++){rs=Array[0][i];r0=Array[1][i];p_d=Array[2][i];vector<int> self_init;for(int i1=0;i1<NS;i1++){self[i1].r=rs;   self_init.push_back(i1);}cout<<i+1<<endl;for(int j=0;j<n_time;j++){             area_non=0;srand((unsigned)time(NULL));                area_non=area_nonself(self);       long double  A_min;   A_min=area_non-1/sqrt(100000.0);   A_min=p_d*A_min;detector.clear();p1=&Q;InitQueue(p1);s_all=0;sum=0;QueueElementType e;e.x=0.5;e.y=0.5;e.rx=0.5;e.ry=0.5;EnQueue(p1,e);while(p1->front!=p1->rear)          //  Q if not null ............................................................................{DeQueue(p1,&e);PTS_detec(e.x,e.y,e.rx,e.ry,self_init);            if(s_all==A_min||s_all>A_min)break;//if(detector.size()>=num_d)//break;if(sum>1000000)break;}cost=sum/detector.size();Array_s[0][j]=sum;                     //    the number of the candidate detectorsArray_s[1][j]=detector.size();         //    the number of the mature detectorsArray_s[2][j]=cost;                    //    the cost to generate one mature detectorlong double count_1_true=0;long double count_1_false=0;long double count_2_flase=0;long double count_2_true=0;long double count_1=0;long double dr=0;long double fa=0;for(int i=0;i<NT;i++){intflag=0;for(unsigned int j=0;j<detector.size();j++){if(intersect(detector[j],test[i])){count_1++;flag=1;if(test[i].z==0)count_1_true++;// true abnormal   TNelsecount_1_false++;// false abnormal   FNbreak;}}if(flag==0){if(test[i].z==0)count_2_flase++;// false normal    FPelsecount_2_true++;//  true   normal    TP}}dr=count_1_true/(count_1_true+count_2_flase);                 //fa=count_1_false/(count_1_false+count_2_true);                 //Array_s[3][j]=dr;                                              //  the detection rateArray_s[4][j]=fa;                                              // false alarm rate}long  double can_max=_max(Array_s[0]);               // Maxlong double can_min=_min(Array_s[0]);                //Minlong double can_mean=mean(Array_s[0]);               // Meanlong double can_sd=sd(Array_s[0],can_mean);           // Stardard deviationlong  double mature_max=_max(Array_s[1]);long double mature_min=_min(Array_s[1]);long double mature_mean=mean(Array_s[1]);long double mature_sd=sd(Array_s[1],mature_mean);long  double cost_max=_max(Array_s[2]);long double cost_min=_min(Array_s[2]);long double cost_mean=mean(Array_s[2]);long double cost_sd=sd(Array_s[2],cost_mean);long  double dr_max=_max(Array_s[3]);long double dr_min=_min(Array_s[3]);long double dr_mean=mean(Array_s[3]);long double dr_sd=sd(Array_s[3],dr_mean);long  double fa_max=_max(Array_s[4]);long double fa_min=_min(Array_s[4]);long double fa_mean=mean(Array_s[4]);long double fa_sd=sd(Array_s[4],fa_mean);fout<<rs<<'\t'<<'\t'<<dr_max<<'\t'<<dr_min<<'\t'<<dr_mean<<'\t'<<dr_sd<<'\t'<<'\t'<<can_max<<'\t'<<can_min<<'\t'<<can_mean<<'\t'<<can_sd<<'\t'<<'\t'<<mature_max<<'\t'<<mature_min<<'\t'<<mature_mean<<'\t'<<mature_sd<<'\t'<<'\t'<<cost_max<<'\t'<<cost_min<<'\t'<<cost_mean<<'\t'<<cost_sd<<endl;}fout<<p_d<<endl;cout<<"ok!"<<endl;char c;cin>>c;}

原创粉丝点击