int main() { double Delta_i, Delta_f, Ui; double* S; Delta_i=0.02; Delta_f=0.015; g_Ns=g_N*g_N; init_WK(); S=(double*)malloc(sizeof(double)*3*g_dim); //firt we should get g_Uf. g_Delta=Delta_f; g_Uf=init_S(S); //then initalize S using the same function g_Delta=Delta_i; Ui=init_S(S); printf("Delta_i=%lf U_i=%lf Delta_f=%lf U_f=%lf\n",Delta_i,Ui,Delta_f,g_Uf); evolution(S); printf("Delta_i=%lf U_i=%lf Delta_f=%lf U_f=%lf\n",Delta_i,Ui,Delta_f,g_Uf); free(S); free(g_WK); return 0; }
int main() { double Delta_i; double* S; Delta_i=0.5; g_Ns=g_N*g_N; g_dim=dim_of_k(); K=(double*)malloc(sizeof(double)*2*g_dim); init_K(K); S=(double*)malloc(sizeof(double)*3*g_dim); g_Delta=Delta_i; g_Uf=init_S(S); printf("Delta_i=%lf g_U=%lf",Delta_i,g_Uf); evolution(S); printf("Delta_i=%lf g_U=%lf",Delta_i,g_Uf); free(S); free(K); return 0; }
void KazeDescriptorExtractor::computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const { if (usePreloadedEnvironment) { environment->Feature_Description(keypoints, descriptors); } else { toptions options; defaultOptions(options); options.img_width = image.cols; options.img_height = image.rows; KAZE evolution(options); cv::Mat img_32; cv::Mat bw; if (image.channels() == 1) { image.convertTo(img_32,CV_32F,1.0/255.0,0); } else { cv::cvtColor(image, bw, CV_RGB2GRAY); bw.convertTo(img_32,CV_32F,1.0/255.0,0); } evolution.Create_Nonlinear_Scale_Space(img_32); evolution.Feature_Description(keypoints, descriptors); } }
int main( int argc, char ** argv ) { unsigned iLargeur = 0, iHauteur = 0; unsigned int iNbSnake = 0; unsigned int isFini = 0; unsigned int iTemps = 0; if( argc < 4 ) { printf( "Mauvaise utilisation du programme\n" ); printf( "snake <LARGEUR>x<HAUTEUR> <NB_SERPENTS> <TEMPS>\n" ); return EXIT_FAILURE; } sscanf( argv[1], "%dx%d", &iLargeur, &iHauteur ); char cPlateau[iHauteur*iLargeur]; sscanf( argv[2], "%d", &iNbSnake ); Tete tTete[iNbSnake]; sscanf( argv[3], "%d", &iTemps ); initialisation( (char * const)cPlateau, iHauteur, iLargeur, tTete , iNbSnake ); srand( time( NULL ) ); system( "clear" ); while( !isFini ) { attendre( iTemps ); system( "clear" ); afficher_cadre( (char * const)cPlateau, iHauteur, iLargeur ); isFini = evolution( (char * const)cPlateau, iHauteur, iLargeur, tTete, iNbSnake ); } statistiques( (char * const)cPlateau, iHauteur, iLargeur ); return EXIT_SUCCESS; }
/* Naive peak detection (both positive and negative ones). Note that, as this function is called for every value, the call to evolution(a, b, th) is the same as the call to evolution(b, c, th) of the previous call to peakp(). This could hence be optimized if needed. */ static bool peakp(int16_t a, int16_t b, int16_t c, int th) { int8_t le = evolution(a, b, th); int8_t ce = evolution(b, c, th); /* Positive peaks */ if (le >= 0 && ce < 0 && b > th) return true; #if 0 /* Negative peaks */ if (le <= 0 && ce > 0 && b < -th) return true; #endif return false; }
int main(int argc, const char *argv[]) { void **args; int i, j; unsigned int N; double K, C, h, a, L, T0, T1; h=0.001; args=arghandler(argc, argv); K=*(double *)args[0]; L=*(double *)args[1]; N=*(unsigned int *)args[2]; T0=*(double *)args[3]; T1=*(double *)args[4]; double **plane; plane=malloc(N*sizeof(double *)); for(i = 0; i < N; i++) plane[i]=calloc(N,sizeof(double)); for(i = 0; i < N; i++) { plane[0][i]=T0; plane[N-1][i]=T1; } a=L/N; C=K*h/a/a; if(C>0.5) fprintf(stderr,"Value of C higher than 0.5: %lf Might give wrong results\n",C); else if(C<5e-4) fprintf(stderr,"Value of C lower than 0.0005: %lf Might give wrong results\n",C); while(evolution(plane,N,C)); { if(bar[1]==INFINITY) { C/=10; fprintf(stderr,"WARNING: ALGORITHM DIVERGED. TRYING WITH LOWER C: %lf\n",C); for(i = 1; i < N-1; i++) for(j = 1; j < N-1; j++) plane[i][j]=0; } } for(i = 0; i < N; i++) for(j = 0; j < N; j++) printf("%d\t%d\t%lf\n",i,j,plane[i][j]); return 0; }
int main() { double* y; double t; N_half=N/2; Ns=N*N; t=0; y=(double*) malloc(sizeof(double)*16*Ns); //provide y at t=0,and U. comment off if the values read from data. U=inity(y); printf("U=%f\n",U); omp_set_num_threads(3); evolution(y,t); free(y); return 0; }
void Experiment::run() { for (decltype(number_of_runs_) times = 0; times < number_of_runs_; ++times) { // clone a Repository for each run auto repos = repository_->clone(); // initialize all evolutionary states repos->init(); // evolve the evolution repos->evolution()->evolve(repos); std::stringstream ss; ss << name_ << "_run" << times+1; statistics_->output_statistics_on_run(repos, ss.str()); statistics_->take_statistics(repos); } statistics_->output_statistics(name_ + ".csv"); }
int main() { double Delta_i, Delta_f, U_i; double* y; Delta_i=0.8; Delta_f=1; N=2*N_half+1; Ns=N*N; y=(double*)malloc(sizeof(double)*4*Ns); Delta=Delta_f; U_f=inity(y); Delta=Delta_i; U_i=inity(y); printf("Delta_i=%lf U_i=%lf Delta_f=%lf U_f=%lf\n",Delta_i,U_i,Delta_f,U_f); evolution(y); free(y); return 0; }
/* ************************************************************************* */ int main(int argc, char* argv[]) { // Variables libAKAZE::AKAZEOptions options; std::string img_path, kpts_path; // Variable for computation times. double tdet = 0.0, tdesc = 0.0; // Parse the input command line options if (parse_input_options(options, img_path, kpts_path, argc, argv)) { return -1; } if (options.verbosity) { std::cout << "Check AKAZE options:" << std::endl; std::cout << options << std::endl; } // Try to read the image and if necessary convert to grayscale. CImg will // throw an error and crash if the image could not be read. cimg_library::CImg<float> img(img_path.c_str()); RowMatrixXf img_32; libAKAZE::ConvertCImgToEigen(img, img_32); img_32 /= 255.0; // Don't forget to specify image dimensions in AKAZE's options. options.img_width = img_32.cols(); options.img_height = img_32.rows(); // Extract features. std::vector<libAKAZE::AKAZEKeypoint> kpts; timer::Timer timer; libAKAZE::AKAZE evolution(options); evolution.Create_Nonlinear_Scale_Space(img_32); evolution.Feature_Detection(kpts); tdet = timer.elapsedMs(); // Compute descriptors. libAKAZE::AKAZEDescriptors desc; timer.reset(); evolution.Compute_Descriptors(kpts, desc); tdesc = timer.elapsedMs(); // Summarize the computation times. evolution.Show_Computation_Times(); evolution.Save_Scale_Space(); std::cout << "Number of points: " << kpts.size() << std::endl; std::cout << "Time Detector: " << tdet << " ms" << std::endl; std::cout << "Time Descriptor: " << tdesc << " ms" << std::endl; // Save keypoints in ASCII format. if (!kpts_path.empty()) { if (options.descriptor < libAKAZE::MLDB_UPRIGHT) { libAKAZE::save_keypoints(kpts_path, kpts, desc.float_descriptor, true); } else { libAKAZE::save_keypoints(kpts_path, kpts, desc.binary_descriptor, true); } } // Convert the input image to RGB. cimg_library::CImg<float> rgb_image = img.get_resize(img.width(), img.height(), img.depth(), 3); libAKAZE::draw_keypoints(rgb_image, kpts); rgb_image.save("../output/detected_features.jpg"); }
int main(int argc, char *argv[]) { double u[NN], v[NN], p[NN], fat[NN], Vc[NN], w[NN][N2], a[NX+1][NY+1][NZ+1], B[NX+1][NY+1][NZ+1], u_ave[NN]; double xx[NN], yy[NN], zz[NN], r[NN]; double ageb[NN], agek[NN]; int state[NN], div_times[NN], touch[NN]; int lj[NN][N2]; int indx[NN]; // lj[i][0...indx-1] int ljd[NN][N2]; int ljd_indx[NN]; // ljd[i][0...ljd_indx-1] /* debug */ int pair[NN], pair2[NN], pair_indx = 0; double L[NN]; int other_cell[NN]; int tb[NN]; int ncell_var, num; int i, j, k; int KEY_INPUT_DATA; char celldata_name[100]; char str[100], str_chem[100]; FILE *finput, *fdebug; void checkstate(int [], int ); void checkparam(); int nmx = (int)(COMPRESS_FACTOR * LX/(2.0*R_memb)); int nmy = (int)(COMPRESS_FACTOR * LY/(2.0*R_memb)); printf("mkdir %s\n", OUTPUTDIR ); sprintf(str, "mkdir -p %s", OUTPUTDIR); system(str); checkparam(); if (fabs(dx-dh)>EPS || fabs(dy-dh)>EPS || fabs(dz-dh)>EPS) { printf("error: dx=%f dy=%f dz=%f.\n", dx, dy, dz); printf("grid size must be dh=%f.\n", dh); exit(1); } if (argc <= 1) { printf("input file name required\n"); exit(1); } strcpy(celldata_name, argv[1]); if((finput = fopen(celldata_name, "r")) == NULL) { printf("input file error2\n"); exit(1); } if ((num = count_line(finput)) != NN) { printf(" error: input data file not consistent.\n"); printf("input file lines = %d: NN = %d\n", num, NN); exit(5); } fclose(finput); if((finput = fopen(celldata_name, "r")) == NULL) { printf("input file error2\n"); exit(1); } initialize_state(state, ageb, agek, fat, Vc); /* input vales, initialize gj, return first blank cell's index*/ initialize_vars(finput, xx, yy, zz, lj, state, r, ageb, agek, div_times, fat, Vc, touch, L, other_cell, tb, &ncell_var, &NDER, &NMEMB); printf("variables initialized: NDER=%d NMEMB=%d ncell=%d NN=%d\n", NDER, NMEMB, ncell_var, NN); if (nmx != NMX || nmy != NMY) { printf("error: number of membrane particles inconsistent with parameter file\n"); exit(1); } checkstate(state, ncell_var); connect_lj(lj, state, ncell_var, xx, yy, zz, r, indx); printf("lj connection initialized\n"); check_pair(ncell_var, xx, yy, zz, pair, pair2, &pair_indx, L, other_cell); fclose(finput); initial_u(u, v, p, a, B, w); // initialization KEY_INPUT_DATA = atoi(argv[2]); if (KEY_INPUT_DATA != 1 && KEY_INPUT_DATA != 0) { printf("error: 2nd argument must be 0 or 1\n"); exit(3); } if (KEY_INPUT_DATA) { printf("chemical data read from recycled_data\n"); sprintf(str_chem, "recycled_data"); input_uvp(str_chem, u, v, p, a, B, w, ncell_var); } if (SYSTEM == WHOLE) { printf("computing the whole epidermis.\n"); // SYSTEM = WHOLE; } else if (SYSTEM == BASAL) { printf("computing only the basal layer and the dermis.\n"); // SYSTEM = BASAL; } else { printf("parameter SYSTEM must be 'WHOLE' or 'BASAL'\n"); exit(1); } if (KEY_FORCED_SC) printf("forced cornification enabled\n"); else printf("forced cornification disabled\n"); if (KEY_INPUT_DATA && KEY_FORCED_SC) { printf("error: forced cornification must be disabled\n"); exit(1); } else if (!KEY_INPUT_DATA && !KEY_FORCED_SC) { printf("WARNING: sc formation would take longer without forced cornification.\n"); } if (KEY_DERMAL_CHANGE) printf("computing dermal change\n"); else printf("fixed dermal shape\n"); printf("divmax=%d, accel_div=%f MALIGNANT=%d\n", div_max, accel_div, MALIGNANT); printf("K_TOTAL=%f, K_DESMOSOME_RATIO=%f\n", K_TOTAL, K_DESMOSOME_RATIO); evolution(u, v, p, w, a, B, xx, yy, zz, r, ageb, agek, state, div_times, fat, Vc, touch, lj, indx, &ncell_var, u_ave, pair, pair2, &pair_indx, L, other_cell, ljd, ljd_indx, tb); printf("finished\n"); return 0; }
// evolutionary multiobjective algorithm void nsga2(vector<Solution* > &initial_population, EfficientSolution &efficient_population, unsigned int numberOfLambda, std::vector<Box*> vectorBoxFinal, double P_c, double P_m, unsigned int nGenerations, Data & data) { srand((unsigned)time(0)); std::vector <Solution*> population = std::vector<Solution*>(); // Generate an initial population of nIndividuals initialization(efficient_population, population, numberOfLambda, vectorBoxFinal, data); /* int affectation1[90]={1,1,1,1,1,20,20,1,1,20,1,1,20,1,1,1,1,1,1,1,2,2,20,2,1,1,1,1,2,2,13,3,0,1,1,16,19,28,0,19,29,18,12,14,29,0,16,13,24,28,0,18,16,24,3,3,12,14,29,29,0,12,4,19,1,21,14,26,21,12,12,0,0,14,29,0,29,26,3,5,7,22,19,8,18,18,0,9,10,4}; int affectation2[90]={1,1,1,1,1,20,20,20,1,1,1,20,1,1,1,1,1,1,1,1,2,2,1,1,2,1,2,1,1,2,8,8,5,25,9,16,14,27,0,13,25,18,26,3,23,19,6,10,6,24,22,9,18,1,16,26,16,14,28,23,27,21,1,21,28,21,8,22,0,22,19,12,17,10,25,3,18,3,3,18,7,3,16,8,18,16,0,9,14,4}; int affectation3[90]={1,1,1,20,20,1,20,1,1,1,1,1,20,1,1,1,1,1,1,1,2,2,1,1,1,1,2,1,2,2,13,8,0,25,8,16,19,24,0,12,29,8,26,14,29,19,16,13,24,16,0,18,21,24,16,23,12,14,23,29,0,12,21,21,15,21,14,26,16,12,18,0,9,19,25,26,21,15,3,16,7,25,19,8,18,16,0,1,10,4}; vector<int> affect1=vector<int>(); vector<int> affect2=vector<int>(); vector<int> affect3=vector<int>(); vector<bool> open_dep1=vector<bool>(); vector<bool> open_dep2=vector<bool>(); vector<bool> open_dep3=vector<bool>(); for(int i=0; i<30; i++){ open_dep1.push_back(false); open_dep2.push_back(false); open_dep3.push_back(false); } vector<double> resid1=vector<double>(); vector<double> resid2=vector<double>(); vector<double> resid3=vector<double>(); for(int i=0; i<30; i++){ resid1.push_back(data.getFacility(i).getCapacity()); resid2.push_back(data.getFacility(i).getCapacity()); resid3.push_back(data.getFacility(i).getCapacity()); } for(int i=0; i<90; i++){ affect1.push_back(affectation1[i]); affect2.push_back(affectation2[i]); affect3.push_back(affectation3[i]); open_dep1[affectation1[i]]=true; open_dep2[affectation2[i]]=true; open_dep3[affectation3[i]]=true; resid1[affectation1[i]] -= data.getCustomer(i).getDemand(); resid2[affectation2[i]] -= data.getCustomer(i).getDemand(); resid3[affectation3[i]] -= data.getCustomer(i).getDemand(); } Solution* sol1=new Solution(affect1,open_dep1, data,resid1); Solution* sol2=new Solution(affect2,open_dep2,data,resid2); Solution* sol3=new Solution(affect3,open_dep3,data,resid3); population.push_back(sol1); population.push_back(sol2); population.push_back(sol3); efficient_population.addSolution(sol1); efficient_population.addSolution(sol2); efficient_population.addSolution(sol3); */ for(unsigned int i=0; i<population.size(); i++) initial_population.push_back(population[i]); ToFile::savePopulation(initial_population, data, "InitialPopulationNSGA"); //ToFile::gnuplot_interactive(initial_population); for(unsigned int k=0; k<nGenerations; k++){ std::vector <Solution*> offspring_population = std::vector<Solution*>(); std::vector <Solution*> result_population = std::vector<Solution*>(); //will contain the current population and its offspring one crowding(population); // this crowding function calls ranking function // recombination, and mutation operators to create a offspring population // O_t of size nIndividuals evolution(efficient_population, population, offspring_population, P_c, P_m, data); for(unsigned int i = 0; i < population.size(); i++){ result_population.push_back(population[i]); } for(unsigned int i = 0; i < offspring_population.size(); i++){ result_population.push_back(offspring_population[i]); } crowding(result_population); // the crowding function calls ranking function sort(result_population.begin(), result_population.end(), crowding_solution1_lower_than_solution_2); // std::cout << result_population.size() << std::endl; // we are sure that: result_population.size() >= population.size() for(unsigned int i=0; i<population.size(); i++){ population[i]= result_population[i]; result_population[i]=NULL; // in order to avoid the destruction of the solution. } // if you need to see the evolution of the population at each generation std::stringstream sstm2; sstm2 << "PopulationNSGA_" << k; ToFile::savePopulation(population, data, sstm2.str().c_str()); ToFile::gnuplot_interactive(population); } ToFile::savePopulation(population, data, "FinalPopulationNSGA"); }
int main(int argc, char** argv) { // TODO: Dodelat nacitani parametru z prikazovy radky parseCSV(); evolution(); return (EXIT_SUCCESS); }