Commit 9190fe2b authored by Ali Safari's avatar Ali Safari
Browse files

seed start and seed end are added

parent 878552e3
Loading
Loading
Loading
Loading
+79 −60
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ int main(int argc, char **argv)

    /* Declaration of local variables */
    conf.registerRealParameter("prob");
    conf.registerIntParameter("seed");
    conf.registerIntParameter("seedend");
    conf.registerIntParameter("seedstart");
    conf.registerIntParameter("N");
    conf.registerIntParameter("realizations");
    conf.registerIntParameter("steps");
@@ -65,8 +66,6 @@ int main(int argc, char **argv)
        /* "Usage messages" are a conventional way of telling the user
         * how to run a program if they enter the command incorrectly.
         */


    }
    else {
    inputfilepath = argv[1];
@@ -79,7 +78,8 @@ int main(int argc, char **argv)
    conf.printParameters();

    double prob = conf.getRealParameter("prob");
    int seed = conf.getIntParameter("seed");
    int seedend = conf.getIntParameter("seedend");
    int seedstart = conf.getIntParameter("seedstart");
    int N = conf.getIntParameter("N");
    int steps = conf.getIntParameter("steps");
    int fixed_links = conf.getIntParameter("fixed_links");
@@ -88,27 +88,77 @@ int main(int argc, char **argv)
    double Emax = conf.getRealParameter("Emax");
    MKL_INT loop = conf.getIntParameter("loop");    /* Number of refinement loop */
    MKL_INT M0 = conf.getIntParameter("M0");   /* Initial guess for subspace dimension to be used */
    MKL_INT M = conf.getIntParameter("M");    /* Total number of eigenvalues found in the interval */
    //MKL_INT M = conf.getIntParameter("M");    /* Total number of eigenvalues found in the interval */
    double epsout = conf.getRealParameter("epsout");  /* Relative error on the trace */
    MKL_INT info = conf.getIntParameter("info");          /* Errors */


    Ensemble one(seed,N,steps,fixed_links); //(seed,N,steps,alpha)
    for(int i=0; i<realizations; ++i) {
        if(!(i%100)) cout << i << endl;
        cout << "Build AdjList" <<" with"<< " "<<N<<" "<<"nodes"<<" "<<"and"<<" "<<steps<<" "<<"steps"<< endl;
    //mkl initiallizations
    /* Step 1. Call  FEASTINIT to define the default values for the input FEAST parameters */
        cout << "Solve Standard Eigenvalue Problem" << endl;
        feastinit(fpm);

        fpm[0] =  1; /* Extended Eigensolver routines print runtime status to the screen. */
        fpm[13] = 0;
        fpm[26] = 1;//check input matrices
        fpm[27] = 0;//1,checks if matrix B positive definite
        fpm[2]=12;
        fpm[5]=1;//extended eigensolver stopping test
        fpm[1]=32;//{3,4,5,6,8,10,12,16,20,24,32,40,48}
        fpm[6]=10;//Error tarce single precision stopping crieteria
        fpm[64+0] = 1; /* No solver default */
        fpm[64+1] = 0;         /* modified -- minimum degree algorithm */
        fpm[64+3] = 0;         /* No iterative-direct algorithm */
        fpm[64+4] = 0;         /* No user fill-in reducing permutation */
        fpm[64+7] = 2;         /* Max numbers of iterative refinement steps */
        fpm[64+9] = 13;        /* Perturb the pivot elements with 1E-13 */
        fpm[64+10] = 0;        /* Do no use nonsymmetric permutation and scaling MPS */
        fpm[64+12] = 0;        /* Maximum weighted matching algorithm is switched-off (default for symmetric). Try iparm[12] = 1 in case of inappropriate accuracy */
        fpm[64+13] = 0;        /* Output: Number of perturbed pivots */
        fpm[64+17] = 0;       /* Input/Output: no Number of nonzeros in the factor LU */
        fpm[64+18] = 0;       /* Input/Output: no Mflops for LU factorization */
        fpm[64+19] = 0;        /* Output: Numbers of CG Iterations */

        //double  *a;
	      //MKL_INT *ja;
	      //MKL_INT *ia;
        //double    *   E ; /* Eigenvalues */
        //double    *   X  ;      /* Eigenvectors */
        //double    *  res  ;/* Residual */


    //initiallization for eigenvalue writing procedure
    ofstream processed_data;
    processed_data.open("processed_data.dat");
    processed_data<<"#eigenvalue"<<" "<<"#network"<<" "<<"#T1"<<" "<<"#C1"<<" "<<"#T2"<<" "<<"#C2"<<"#T3"<<" "
                  <<"#C3"<<" "<<"#T4"<<" "<<"#C4"<<" "<<"#T5"<<" "<<"#C5"<<" "<<"#T6"<<" "<<"#C6"<<" "<<"#T7"<<" "
                  <<"#C7"<<" "<<"#T8"<<" "<<"#C8"<<" "<<"#T9"<<" "<<"#C9"<<std::endl;

    std::cout<<"TEST PURPOSE"<<"---------------------- "<<"before defining thresholds"<<std::endl;
        double threshold[] = {1e-3,2e-3,3e-3,1e-2,2e-2,3e-2,1e-1,2e-1,3e-1};
	vector<double> thresholds (threshold, threshold + sizeof(threshold) / sizeof(double) );
        vector<double> counter (thresholds.size(),0);

// main loop for solving eigenvalue problem

    for(int k=0; k<realizations; ++k) {
      for(int s=seedstart; s<=seedend; ++s) {
        std::cout<<"Number of Networks are"<<" "<<seedend - seedstart+1<<" "<<"and now we are at Network with seed"<<"  "<<s<<std::endl;
        Ensemble one(s,N,steps,fixed_links); //(seed,N,steps,alpha)
        MKL_INT M = conf.getIntParameter("M");
        if(!(k%100)) cout << "reallization= "<<k << endl;
        cout << "Build AdjList" <<" with"<< " "<<N<<" "<<"nodes"<<" "<<"and"<<" "<<steps<<" "<<"steps"<<" "<<"<<and seed= "<<s<< endl;
        one.build_network_fixed();
        //std::cout<<"output Network"<<std::endl;
        //one.output_edgelist(one.return_network_ref());

        one.release_link_diluted_copy(prob);           //percolation starts
        //std::cout<<"output Percolated Network"<<std::endl;
        //one.output_edgelist(one.return_Percolated_network_ref());
        one.destroy_network();
        one.Giant_Component_of_network();
        one.release_GC_of_network();
        std::cout<<"output GC of Percolated Network "<<std::endl;
        one.output_edgelist_GC(one.return_GC_of_Percolated_network_ref());
        //std::cout<<"output GC of Percolated Network "<<std::endl;
        //one.output_edgelist_GC(one.return_GC_of_Percolated_network_ref());
        one.relable_GC_of_network();
        one.degree_distribution();
        //std::cout<<"output Relabled GC of Percolated Network "<<std::endl;
@@ -142,44 +192,24 @@ int main(int argc, char **argv)
      //  std::cout<<ia[0]<<" "<<ia[1]<<" "<<ia[2]<<" "<<ia[3]<<" "<<ia[4]<<" "<<ia[5]<<std::endl;
     //    std::cout<<ja[0]<<" "<<ja[1]<<" "<<ja[2]<<" "<<ja[3]<<" "<<ja[4]<<" "<<ja[5]<<" "<<ja[6]<<" "<<ja[7]<<" "<<ja[8]<<std::endl;
      //  std::cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<" "<<a[5]<<" "<<a[6]<<" "<<a[7]<<" "<<a[8]<<std::endl;
        //now invoke eigensolver with arguments n,ia,ja,a etc.
        /* Step 1. Call  FEASTINIT to define the default values for the input FEAST parameters */
        cout << "Solve Standard Eigenvalue Problem" << endl;
        feastinit(fpm);

        fpm[0] =  1; /* Extended Eigensolver routines print runtime status to the screen. */
        fpm[13] = 0;
        fpm[26] = 1;//check input matrices
        fpm[27] = 0;//1,checks if matrix B positive definite
        fpm[2]=12;
        fpm[5]=1;//extended eigensolver stopping test
        fpm[1]=32;//{3,4,5,6,8,10,12,16,20,24,32,40,48}
        fpm[6]=10;//Error tarce single precision stopping crieteria




        fpm[64+0] = 1; /* No solver default */
        fpm[64+1] = 0;         /* modified -- minimum degree algorithm */
        fpm[64+3] = 0;         /* No iterative-direct algorithm */
        fpm[64+4] = 0;         /* No user fill-in reducing permutation */
        fpm[64+7] = 2;         /* Max numbers of iterative refinement steps */
        fpm[64+9] = 13;        /* Perturb the pivot elements with 1E-13 */
        fpm[64+10] = 0;        /* Do no use nonsymmetric permutation and scaling MPS */
        fpm[64+12] = 0;        /* Maximum weighted matching algorithm is switched-off (default for symmetric). Try iparm[12] = 1 in case of inappropriate accuracy */
        fpm[64+13] = 0;        /* Output: Number of perturbed pivots */
        fpm[64+17] = 0;       /* Input/Output: no Number of nonzeros in the factor LU */
        fpm[64+18] = 0;       /* Input/Output: no Mflops for LU factorization */
        fpm[64+19] = 0;        /* Output: Numbers of CG Iterations */
        fpm[64+34] = 0;        /* PARDISO use Fortran-style indexing for ia and ja arrays */


        std::cout<<"TEST PURPOSE"<<"--------------------------------"<<"before feast function"<<std::endl;
        /* Step 2. Solve the standard Ax = ex eigenvalue problem. */
        dfeast_scsrev (&UPLO, &newN, a, ia, ja, fpm, &epsout, &loop, &Emin, &Emax, &M0, E, X, &M, res, &info);
        std::cout<<"TEST PURPOSE"<<"--------------------------------"<<"after feast function"<<std::endl;


        mkl_free(a);
        std::cout<<"TEST PURPOSE"<<"---------------------- "<<"after mkl free a"<<std::endl;
        mkl_free(ja);
        std::cout<<"TEST PURPOSE"<<"---------------------- "<<"after mkl free ja"<<std::endl;
        mkl_free(ia);
        std::cout<<"TEST PURPOSE"<<"---------------------- "<<"after mkl free ia"<<std::endl;




        printf("FEAST OUTPUT INFO %d \n",info);
        if ( info != 0 )
        {
@@ -188,17 +218,7 @@ int main(int argc, char **argv)
        }

        //writing eigenvalues for network
        double threshold[] = {1e-3,2e-3,3e-3,1e-2,2e-2,3e-2,1e-1,2e-1,3e-1};
        vector<double> thresholds (threshold, threshold + sizeof(threshold) / sizeof(double) );
        ofstream processed_data;
        vector<double> counter (thresholds.size(),0);

        processed_data.open("processed_data.dat");
        /*
        processed_data<<"eigenvalues"<<" "<<"threshold1"<<" "<<"counters1"<<" "<<"threshold2"<<" "<<"counters2"<<" "<<"threshold3"<<" "<<"counters3"<<" "
        <<"threshold4"<<" "<<"counters4"<<" "<<"threshold5"<<" "<<"counters5"<<" "<<"threshold6"<<" "<<"counters6"<<" "<<"threshold7"<<" "<<"counters7"
        <<" "<<"threshold8"<<" "<<"counters8"<<" "<<"threshold9"<<" "<<"counters9"<<endl;*/

	       std::cout<<"TEST PURPOSE"<<"---------------------- "<<"before writing eigenvalues"<<std::endl;
          for (int i=0; i<M; i++)
          {
            processed_data <<setprecision(8)<< E[i]<<" " ;
@@ -209,18 +229,17 @@ int main(int argc, char **argv)
                if( abs( X[(i*newN)+j] ) > thresholds[t] )
                counter[t]+=1;
              }
            processed_data << counter[t] <<" "<< thresholds[t]<<" " ;
            processed_data << s <<" "<<counter[t] <<" "<< thresholds[t]<<" " ;
            counter[t] = 0;
           }
           processed_data <<endl;

         }
        processed_data.close();

         std::cout<<"TEST PURPOSE"<<"---------------------- "<<"after writing eigenvalues"<<std::endl;
         one.destroy_Percolated_GC_network();
    }//end of network loop

  }//end of reallization loop

    }


        processed_data.close();
}