jncrusher

Untitled

Jan 6th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. double tau=1/sqrt(2.0);
  2.     ///////////////////TWORZENIE POPULACJI/////////////////
  3.     vector <osobnik2> populacja(ile);
  4.      
  5.    for(int i=0; i<ile; i++){
  6.         double a=(((rand () % 1025) - 512.0) / 100.0);
  7.         double b=(((rand () % 1025) - 512.0) / 100.0);
  8.         populacja[i] = osobnik2 (a, b);
  9.         populacja[i].wypisz_LOG();
  10.     }
  11.    //////////////////TWORZENIE WEKTORA SIGM///////////////
  12.    vector <double> sigma(ile);
  13.    
  14.    for(int i=0; i<ile; i++){
  15.     sigma[i]=(double)((rand()%100)/100.0)+0.01; //wartości sigm pocz. od 0.01 do 1.0
  16.     cout<<sigma[i]<<endl;
  17.    }
  18.  
  19.    ///////////////////MUTOWANIE///////////////////////////
  20.     mt19937 eng(static_cast<unsigned long>(time(nullptr)));
  21.    
  22.    
  23.     for(int j=0; j<100; j++){
  24.    
  25.     for(int i=0; i<ile; i++){
  26.         normal_distribution<double> dist(0, 1.0);
  27.         sigma[i]*=exp(tau*dist(eng));
  28.         normal_distribution<double> dist2(0, sigma[i]);
  29.         populacja[i].x1+=dist2(eng);
  30.         populacja[i].x2+=dist2(eng);   
  31.     }
  32.  
  33.     for(int i=0; i<ile; i++){
  34.         cout<<sigma[i]<<endl;
  35.     }
  36.  
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment