# include # include # include # include # include # include # include #define int8 unsigned int #define Min(a,b) (a=q) {///// replce x by xtry by prob/////////// *(*(x+ind+1)+tran1)=*(*(xtry+ind+1)+tran1); *(*(x+ind+1)+tran2)=*(*(xtry+ind+1)+tran2); ichange=1; crit=crittry; cor=cortry; newcrit=newcrittry; }/////////////////////////////////// else {///// reset x try to x for the next pertubation *(*(xtry+ind+1)+tran1)=*(*(x+ind+1)+tran1); *(*(xtry+ind+1)+tran2)=*(*(x+ind+1)+tran2); }////////////////////////////////////////// ////////////////////////////////////////////////////////// } } } //// end of constant temperature loop //////////// temp=temp*tfac; } ///////// End of variable temperature loop/////////////////// ////// result of this search////////////////////////////// if(newcritbest<(bestyet+eps)) { nbestyet=nbestyet+1; } if(newcritbest<(bestyet-eps)) { bestyet=newcritbest; nbestyet=1; } for(int ii=0;ii=te) { *(r+c1)=*(r+c1+1); } } }//cout<<"\n"; } return(LHD); for(int iiii=0;iiii= del) rctwo++; return(rctwo); } int rc(int n,double seed ) // choose randomly from 0 to (n-1) { int r; double u; // assume I can find number from U(0,1) u = (double) (rand()*autoseed(seed)%MAX)/MAX; r=(int)(n*u); return(r); } double runif(double seed) { double runif; runif= (double) (rand()*autoseed(seed)%MAX)/MAX; return(runif); } double score(int **A, int n, int k,int p) // try to input a LHD metrix A[][] { // int A[3][6]; //int n=6; // number of points //int k=3; // number of dimention int i; int dim=n*(n-1)/2; double score=0; int count=0; int c=0; int *d; int *j; d=new int[dim]; j=new int[dim]; for(i=0;id[k5]) { Mmd= d[k5]; Mmj= j[k5]; } } Mminf[0] = Mmd; Mminf[1] = Mmj; delete [] d; delete [] j; } double corrd(int **A, int n,int a, int b) { double cor=0; double cov=0; double var=0; const double p2tm1 = pow(2,(-1)); for(int i1=0;i1= maxcorr) { maxcorr = correlation[p1]; col=p1; } } delete [] correlation; return(col); } int element(int **A, int n, int k,int p) { int ele=0; double distan=0; double maxscore=0; double *dist; dist=new double[n]; int pp1, pp2, pp3; int i; for(i=0; imaxscore) { maxscore = dist[i]; ele=i; } } delete [] dist; return ele; }