static kernel::se3 estimatePose(const KernelCollection &objectEvidence, const KernelCollection &sceneEvidence, const int nChains, const int n) { KernelCollection poses; coord_t objectSize = objectEvidence.moments()->getLocH(); if (!hasOpenMP()) { NUKLEI_WARN("Nuklei has not been compiled with OpenMP support. " "Multithreaded execution of this program will not be optimal " "(sync through POSIX threads, which seems slower than " "OpenMP's critical."); } #pragma omp parallel for for (int i = 0; i < nChains; ++i) { kernel::se3 tmp = mcmc(objectEvidence, sceneEvidence, objectSize, n); #pragma omp critical(pe_merge_poses) { poses.add(tmp); std::cout << "Finished chain " << i << std::endl; } } return kernel::se3(*poses.sortBegin(1)); }
int main(int ArgI, char* ArgC[]) { COption op; CRec geneticmap; for (int i = 0; i != ArgI-1; ++i) { if (strcmp(ArgC[i], "-interval") == 0 && i + 2 < ArgI) { op.minpos = atoi(ArgC[i+1]); op.maxpos = atoi(ArgC[i+2]); } if (strcmp(ArgC[i], "-include-variant") == 0) op.fn0 = ArgC[i+1]; if (strcmp(ArgC[i], "-exclude-vatiant") == 0) op.fn1 = ArgC[i+1]; if (strcmp(ArgC[i], "-genetic-map") == 0) geneticmap.Init(ArgC[i+1]); if (strcmp(ArgC[i], "-buffer") == 0) op.intv = atoi(ArgC[i+1]); if (strcmp(ArgC[i], "-include-sample") == 0) op.GetIncludedSamples(ArgC[i+1]); if (strcmp(ArgC[i], "-exclude-sample") == 0) op.GetExcludedSamples(ArgC[i+1]); if (strcmp(ArgC[i], "-output") == 0) op.fnoutput = ArgC[i+1]; } op.GetData(); CData dhap (&op); CData dlk (&op); for (int i = 0; i != ArgI-1; ++i) { if (strcmp(ArgC[i], "-hap") == 0) dhap.GetHaplotype(ArgC[i+1]); if (strcmp(ArgC[i], "-lk") == 0) dlk.GetLK(ArgC[i+1]); } dhap.MatchData(dlk.GetSamples()); dhap.CM_Location(geneticmap); dlk.CM_Location(geneticmap); dhap.Estimate_Panel_ID(200); CMCMC mcmc(&dhap, &op, &geneticmap, &dlk); dlk.Output(op.GetfnOutput()); return 0; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { //declare variables mxArray *u_m,*y_m,*theta_m,*theta_0_m; const mwSize *dims; long int N; int order,num_samples; double elim; double *u,*y,*theta,*theta_0; //associate inputs u_m = mxDuplicateArray(prhs[0]); y_m = mxDuplicateArray(prhs[1]); theta_0_m = mxDuplicateArray(prhs[4]); N = (long int)mxGetScalar(prhs[2]); order = (int)mxGetScalar(prhs[3]); elim = (double)mxGetScalar(prhs[5]); dims = mxGetDimensions(prhs[0]); num_samples = (int)dims[1]; //associate outputs theta_m = plhs[0] = mxCreateDoubleMatrix((mwSize)N,2*(order+1),mxREAL); //associate pointers u = mxGetPr(u_m); y = mxGetPr(y_m); theta = mxGetPr(theta_m); theta_0 = mxGetPr(theta_0_m); mcmc(u,y,theta,N,order,num_samples,theta_0,elim); // mxFree(u_m); // mxFree(y_m); // mxFree(theta_m); // mxFree(theta_0_m); // return; }
int main(int argc, char **argv){ if(argc!=3){ printf("USAGE: %s\n", USAGE); exit(1); } int n_iterations=atoi(argv[1]); int n_burn=atoi(argv[2]); int iterMCMC; int numT; iterMCMC=n_iterations+n_burn; double *x,*t; double *a,*b,*c,*d,*chi; t=reserva(3000); x=reserva(3000);//Se usa mucho mas espacio del necesario para no tener problemas con el numero de datos a=reserva(iterMCMC); b=reserva(iterMCMC); c=reserva(iterMCMC); d=reserva(iterMCMC); chi=reserva(iterMCMC); a[0]=0; b[0]=0; c[0]=0; d[0]=1; numT=importarDatos(t,x,"monthrg.dat"); mcmc(chi,a,b,c,d,x,t,numT,iterMCMC); imprimirResultados("a",a,n_burn,n_iterations); imprimirResultados("b",b,n_burn,n_iterations); imprimirResultados("c",c,n_burn,n_iterations); imprimirResultados("d",d,n_burn,n_iterations); guardar(chi,a,b,c,d,n_burn,n_iterations); guardarLectura(x,t,numT); }
void R_mcmc(int *numIterations, int *n, double *theta, double *lambda, int *k, double *b1, double *b2, double *Y) { mcmc(numIterations[0], n[0], theta, lambda, k, b1, b2, Y); }
int main(int argc, char** argv) { try { long seed_from_command_line = 1L; string params_file; bool error; po::options_description options("EEMS options from command line"); po::variables_map vm; options.add_options() ("help", "Produce this help message") ("seed", po::value<long>(&seed_from_command_line)->default_value(time(NULL)), "Set the random seed") ("params", po::value<string>(¶ms_file)->required(), "Specify input parameter file") ; po::store(po::parse_command_line(argc, argv, options), vm); po::notify(vm); if(vm.count("help")) { cerr << options << endl; return(EXIT_FAILURE); } Params params(params_file,seed_from_command_line); error = params.check_input_params( ); if (error) { cerr << "[RunEEMS] Error parametrizing EEMS." << endl; return(EXIT_FAILURE); } // Specify the distance metric in the params.ini file dist_metric = params.distance; EEMS eems(params); MCMC mcmc(params); boost::filesystem::path dir(eems.prevpath().c_str()); if (exists(dir)) { cerr << "Load final EEMS state from " << eems.prevpath() << endl << endl; eems.load_final_state(); } else { cerr << "Initialize EEMS random state" << endl << endl; eems.initialize_state(); } error = eems.start_eems(mcmc); if (error) { cerr << "[RunEEMS] Error starting EEMS." << endl; return(EXIT_FAILURE); } Proposal proposal; while (!mcmc.finished) { switch ( eems.choose_move_type( ) ) { case Q_VORONOI_BIRTH_DEATH: eems.propose_birthdeath_qVoronoi(proposal); break; case M_VORONOI_BIRTH_DEATH: eems.propose_birthdeath_mVoronoi(proposal); break; case Q_VORONOI_POINT_MOVE: eems.propose_move_one_qtile(proposal); break; case M_VORONOI_POINT_MOVE: eems.propose_move_one_mtile(proposal); break; case Q_VORONOI_RATE_UPDATE: eems.propose_rate_one_qtile(proposal); break; case M_VORONOI_RATE_UPDATE: eems.propose_rate_one_mtile(proposal); break; case M_MEAN_RATE_UPDATE: eems.propose_overall_mrate(proposal); break; case DF_UPDATE: eems.propose_df(proposal,mcmc); break; default: cerr << "[RunEEMS] Unknown move type" << endl; return(EXIT_FAILURE); } mcmc.add_to_total_moves(proposal.move); if (eems.accept_proposal(proposal)) { mcmc.add_to_okay_moves(proposal.move); } if (params.testing) { eems.check_ll_computation( ); } //eems.update_sigma2( ); eems.update_hyperparams( ); mcmc.end_iteration( ); // Check whether to save the current parameter state, // as the thinned out iterations are not saved int iter = mcmc.to_save_iteration( ); if (iter>=0) { eems.print_iteration(mcmc); eems.save_iteration(mcmc); } } error = eems.output_results(mcmc); if (error) { cerr << "[RunEEMS] Error saving eems results to " << eems.mcmcpath() << endl; } } catch(exception& e) { cerr << e.what() << endl; return(EXIT_FAILURE); } return(0); }