int main(int argc, char** argv) { ProgramOptions program_options(argc, argv); std::thread t[program_options._threads]; for (int i : range(program_options._threads)) { t[i] = std::thread(call_from_thread, i); } std::cout << "Printed from the main thread" << std::endl; for (auto& thread : t) { thread.join(); } /// BACKGROUND boost::filesystem::path background_dir(program_options._background_input_directory); boost::filesystem::directory_iterator bit(background_dir), beod; std::vector<boost::filesystem::path> background_input_files; BOOST_FOREACH(boost::filesystem::path const &p, std::make_pair(bit, beod)) { if(is_regular_file(p) && p.extension() == program_options._input_file_extension) { background_input_files.push_back(p); } } ColibriPLM plm = ColibriPLM(program_options); plm.create_background_model(background_input_files); /// FOREGROUND if(program_options._foreground_input_directory != "") { boost::filesystem::path foreground_dir(program_options._foreground_input_directory); boost::filesystem::directory_iterator fit(foreground_dir), feod; BOOST_FOREACH(boost::filesystem::path const &p, std::make_pair(fit, feod)) { if(is_regular_file(p) && p.extension() == program_options._input_file_extension) { std::vector<std::pair<Pattern, double>> document_word_probs = plm.create_document_model(p); boost::filesystem::path output_file_name = boost::filesystem::path(program_options._generated_output_directory + "/" + p.stem().string() + ".dwp"); write_probs_to_file(document_word_probs, plm.getDecoder(), output_file_name); } } }
int main(int argc, char** argv) { #ifdef LOGGING rlog::RLogInit(argc, argv); #endif std::string complex_fn, values_fn, output_prefix; bool skip_infinite_vines = false, explicit_events = false, save_vines = false; program_options(argc, argv, complex_fn, values_fn, output_prefix, skip_infinite_vines, save_vines, explicit_events); // Read in the complex PLVineyard::LSFiltration simplices; read_simplices(complex_fn, simplices); std::cout << "Complex read, size: " << simplices.size() << std::endl; // Read in vertex values VertexVectorVector vertices; read_vertices(values_fn, vertices); // Setup the vineyard VertexEvaluator veval(vertices[0]); PLVineyard::VertexComparison vcmp(veval); PLVineyard::SimplexComparison scmp(vcmp); simplices.sort(scmp); PLVineyard v(boost::counting_iterator<Vertex>(0), boost::counting_iterator<Vertex>(vertices[0].size()), simplices, veval); std::cout << "Pairing computed" << std::endl; // Compute vineyard for (size_t i = 1; i < vertices.size(); ++i) { veval = VertexEvaluator(vertices[i]); v.compute_vineyard(veval); std::cout << "Processed frame: " << i << std::endl; } std::cout << "Vineyard computed" << std::endl; if (save_vines) v.vineyard().save_vines(output_prefix, skip_infinite_vines); else v.vineyard().save_edges(output_prefix, skip_infinite_vines); }
int main(int argc, char* argv[]) { const char* program_name = "contact_profile"; bool optsOK = true; gmx::initForCommandLine(&argc,&argv); copyright(program_name); cout << " Computes the standard atomic contacts for structures in" << endl; cout << " the given xtc file. A topology PDB file and atom index file" << endl; cout << " should be provided for determining the atoms to compare." << endl; cout << " The resulting sparse contact distance profiles are" << endl; cout << " in sparse vector format (index-file and data-file)." << endl; cout << endl; cout << " Use -h or --help to see the complete list of options." << endl; cout << endl; // Option vars... int nthreads = 0; double sigma; double eps; string top_filename; string xtc_filename; string ndx_filename; const char* ndx_filename_ptr = NULL; string index_filename; string data_filename; // Declare the supported options. po::options_description cmdline_options; po::options_description program_options("Program options"); program_options.add_options() ("help,h", "show this help message and exit") ("threads,t", po::value<int>(&nthreads)->default_value(omp_get_max_threads()>omp_get_num_procs()?omp_get_num_procs():omp_get_max_threads()), "Input: Number of threads to start (int)") ("epsilon,e", po::value<double>(&eps)->default_value(9.0), "Input: Contact cutoff (real)") // ("sigma,q", po::value<double>(&sigma)->default_value(1), "Input: Standard deviation of gaussian kernel (real)") ("topology-file,p", po::value<string>(&top_filename)->default_value("topology.pdb"), "Input: Topology file [.pdb,.gro,.tpr] (string:filename)") ("xtc-file,x", po::value<string>(&xtc_filename)->default_value("traj.xtc"), "Input: Trajectory file (string:filename)") ("ndx-file,n", po::value<string>(&ndx_filename), "Input: K-nn distances file (string:filename)") ("index-file,i", po::value<string>(&index_filename)->default_value("reference.svi"), "Output: Sparse vector indices file (string:filename)") ("data-file,d", po::value<string>(&data_filename)->default_value("reference.svd"), "Output: Sparse vector data file (string:filename)") ; cmdline_options.add(program_options); po::variables_map vm; po::store(po::parse_command_line(argc, argv, cmdline_options), vm); po::notify(vm); if (vm.count("help")) { cout << "usage: " << program_name << " [options]" << endl; cout << cmdline_options << endl; return 1; } if (vm.count("ndx-file")) { ndx_filename_ptr = ndx_filename.c_str(); } if (!optsOK) { return -1; } cout << "Running with the following options:" << endl; cout << "threads = " << nthreads << endl; cout << "topology-file = " << top_filename << endl; cout << "xtc-file = " << xtc_filename << endl; cout << "ndx-file = " << ndx_filename << endl; cout << "index-file = " << index_filename << endl; cout << "data-file = " << data_filename << endl; cout << endl; // Local vars int step = 1; float time = 0.0; matrix box; float prec = 0.001; char buf[256]; t_topology top; int ePBC; int natoms = 0; int nframes= 0; int update_interval = 1; t_fileio *ref_file; rvec *mycoords = NULL; gmx_bool bOK = 1; double *contact = NULL; vector<coord_array> *ref_coords = NULL; ::real *weights = NULL; int gnx1,gnx2; atom_id *index1,*index2; char *grpname1,*grpname2; ofstream index; ofstream data; // Remove C stdout (silly GROMACS warnings going every which stream!) int myout = dup(1); dup2(2,1); // Setup threads omp_set_num_threads(nthreads); // Get number of atoms and check xtc cout << "Reading topology information from " << top_filename << " ... "; read_tps_conf(top_filename.c_str(), buf, &top, &ePBC, &mycoords, NULL, box, TRUE); cout << "done." << endl; delete [] mycoords; ref_file = open_xtc(xtc_filename.c_str(),"r"); read_first_xtc(ref_file,&natoms, &step, &time, box, &mycoords, &prec, &bOK); close_xtc(ref_file); if (natoms != top.atoms.nr) { cout << "*** ERROR ***" << endl; cout << "Number of atoms in topology file (" << top.atoms.nr << ") " << "does not match the number of atoms " << "in the XTC file (" << xtc_filename << " : " << natoms << ")." << endl; exit(4); } // Get atom selections cout << "Please select two (non-overlapping) groups for contact profiling..." << endl; get_index(&top.atoms,ndx_filename_ptr,1,&gnx1,&index1,&grpname1); cout << endl; get_index(&top.atoms,ndx_filename_ptr,1,&gnx2,&index2,&grpname2); cout << endl; cout << "Total grid size is " << gnx1 << " x " << gnx2 << " = " << (gnx1*gnx2) << endl; // Read coordinates and weight-center all structures cout << "Reading reference coordinates from file: " << xtc_filename << " ... "; ref_coords = new vector<coord_array>; ref_file = open_xtc(xtc_filename.c_str(),"r"); mycoords = new rvec[natoms]; while (read_next_xtc(ref_file, natoms, &step, &time, box, mycoords, &prec, &bOK)) { ref_coords->push_back(mycoords); mycoords = new rvec[natoms]; } close_xtc(ref_file); delete [] mycoords; mycoords = NULL; nframes = ref_coords->size(); cout << "done." << endl; // Allocate vectors for storing the distances for a structure contact = new double[gnx1*gnx2]; weights = new ::real[gnx1*gnx2]; for (int x = 0; x < natoms; x++) weights[x] = top.atoms.atom[x].m; #pragma omp parallel for for (int i = 0; i < gnx1; i++) for (int j = 0; j < gnx2; j++) { weights[(i*gnx2)+j] = top.atoms.atom[index1[i]].m * top.atoms.atom[index2[j]].m; } // Restore C stdout. dup2(myout,1); index.open(index_filename.c_str()); data.open(data_filename.c_str()); // Timer for ETA time_t start = std::time(0); time_t last = start; // Compute fits for (int frame = 0; frame < nframes; frame++) { // Update user of progress if (std::time(0) - last > update_interval) { last = std::time(0); time_t eta = start + ((last-start) * nframes / frame); cout << "\rFrame: " << frame << ", will finish " << string(std::ctime(&eta)).substr(0,20); cout.flush(); } // Do Work #pragma omp parallel for for (int i = 0; i < gnx1*gnx2; i++) contact[i] = 0.0; #pragma omp parallel for for (int i = 0; i < gnx1; i++) { int ii = index1[i]; for (int j = 0; j < gnx2; j++) { int jj = index2[j]; double d = 0.0; for (int k = 0; k < 3; k++) d += (((*ref_coords)[frame][ii][k] - (*ref_coords)[frame][jj][k]) * ((*ref_coords)[frame][ii][k] - (*ref_coords)[frame][jj][k])); d = sqrt(d) * 10.0; // d = exp(-(d*d) / (2.0 * weights[(i*gnx2)+j])); // if (d > eps) // contact[(i*gnx2)+j] = d; if (d < eps) contact[(i*gnx2)+j] = 1.0; } // j } // i double sum = 0.0; #pragma omp parallel for reduction(+:sum) for (int i = 0; i < gnx1*gnx2; i++) sum += contact[i]; sum = 1.0; // No normalization... int total = 0; #pragma omp parallel for reduction(+:total) for (int i = 0; i < gnx1*gnx2; i++) if (contact[i] > 0) { contact[i] /= sum; total++; } index.write((char*) &total, sizeof(int) / sizeof(char)); for (int i = 0; i < gnx1*gnx2; i++) if (contact[i] > 0.0) { index.write((char*) &i, sizeof(int) / sizeof(char)); data.write((char*) &contact[i], sizeof(double) / sizeof(char)); } // cout << frame << " " << total << endl; } // frame cout << endl << endl; index.close(); data.close(); // Clean coordinates for (vector<coord_array>::iterator itr = ref_coords->begin(); itr != ref_coords->end(); itr++) delete [] (*itr); delete ref_coords; delete [] contact; delete [] weights; return 0; }
int main(int argc, char* argv[]) { const char* program_name = "decomp_sparse_nystrom"; bool optsOK = true; copyright(program_name); cout << " Reads the symmetric CSC format sparse matrix from" << endl; cout << " input-file, and computes the number of requested" << endl; cout << " eigenvalues/vectors of the normalized laplacian" << endl; cout << " using ARPACK and a gaussian kernel of width sigma." << endl; cout << " The general CSC format sparse matrix is projected" << endl; cout << " onto the eigenvectors of the symmetric matrix for" << endl; cerr << " out-of-sample prediction." << endl; cout << endl; cout << " Use -h or --help to see the complete list of options." << endl; cout << endl; // Option vars... double sigma_a; int nev; string ssm_filename; string gsm_filename; string evals_filename; string evecs_filename; string residuals_filename; // Declare the supported options. po::options_description cmdline_options; po::options_description program_options("Program options"); program_options.add_options() ("help,h", "show this help message and exit") ("sigma,q", po::value<double>(&sigma_a), "Input: Standard deviation of gaussian kernel (real)") ("nevals,n", po::value<int>(&nev), "Input: Number of eigenvalues/vectors (int)") ("ssm-file,s", po::value<string>(&ssm_filename)->default_value("distances.ssm"), "Input: Symmetric sparse matrix file (string:filename)") ("gsm-file,g", po::value<string>(&gsm_filename)->default_value("distances.gsm"), "Input: General sparse matrix file (string:filename)") ("evals-file,v", po::value<string>(&evals_filename)->default_value("eigenvalues.dat"), "Output: Eigenvalues file (string:filename)") ("evecs-file,e", po::value<string>(&evecs_filename)->default_value("eigenvectors.dat"), "Output: Eigenvectors file (string:filename)") ("residuals-file,r", po::value<string>(&residuals_filename)->default_value("residuals.dat"), "Output: Residuals file (string:filename)") ; cmdline_options.add(program_options); po::variables_map vm; po::store(po::parse_command_line(argc, argv, cmdline_options), vm); po::notify(vm); if (vm.count("help")) { cout << "usage: " << program_name << " [options]" << endl; cout << cmdline_options << endl; return 1; } if (!vm.count("sigma")) { cout << "ERROR: --sigma not supplied." << endl; cout << endl; optsOK = false; } if (!vm.count("nevals")) { cout << "ERROR: --nevals not supplied." << endl; cout << endl; optsOK = false; } if (!optsOK) { return -1; } cout << "Running with the following options:" << endl; cout << "sigma = " << sigma_a << endl; cout << "nevals = " << nev << endl; cout << "ssm-file = " << ssm_filename << endl; cout << "gsm-file = " << gsm_filename << endl; cout << "evals-file = " << evals_filename << endl; cout << "evecs-file = " << evecs_filename << endl; cout << "residuals-file = " << residuals_filename << endl; cout << endl; // General int n; // Dimension of the problem. int m; // Outer dimension // Main affinity matrix int nnzA; int *irowA; int *pcolA; double *A; // Pointer to an array that stores the lower // triangular elements of A. // Expanded affinity matrix int nnzB; int *irowB; int *pcolB; double *B; // Pointer to an array that stores the // sparse elements of B. // File input streams ifstream ssm; ifstream gsm; // File output streams ofstream eigenvalues; ofstream eigenvectors; ofstream residuals; // EPS double eps = 1.0; do { eps /= 2.0; } while (1.0 + (eps / 2.0) != 1.0); eps = sqrt(eps); // Open files ssm.open(ssm_filename.c_str()); gsm.open(gsm_filename.c_str()); eigenvalues.open(evals_filename.c_str()); eigenvectors.open(evecs_filename.c_str()); residuals.open(residuals_filename.c_str()); // Read symmetric CSC matrix ssm.read((char*) &n, (sizeof(int) / sizeof(char))); pcolA = new int[n+1]; ssm.read((char*) pcolA, (sizeof(int) / sizeof(char)) * (n+1)); nnzA = pcolA[n]; A = new double[nnzA]; irowA = new int[nnzA]; ssm.read((char*) irowA, (sizeof(int) / sizeof(char)) * nnzA); ssm.read((char*) A, (sizeof(double) / sizeof(char)) * nnzA); ssm.close(); // Read general CSC matrix gsm.read((char*) &m, (sizeof(int) / sizeof(char))); pcolB = new int[m+1]; gsm.read((char*) pcolB, (sizeof(int) / sizeof(char)) * (m+1)); nnzB = pcolB[m]; B = new double[nnzB]; irowB = new int[nnzB]; gsm.read((char*) irowB, (sizeof(int) / sizeof(char)) * nnzB); gsm.read((char*) B, (sizeof(double) / sizeof(char)) * nnzB); gsm.close(); // Turn distances into normalized affinities... double *d_a = new double[n]; double *d_b = new double[m]; // Make affinity matrices... for (int x = 0; x < nnzA; x++) A[x] = exp(-(A[x] * A[x]) / (2.0 * sigma_a * sigma_a)); for (int x = 0; x < nnzB; x++) B[x] = exp(-(B[x] * B[x]) / (2.0 * sigma_a * sigma_a)); // Calculate D_A for (int x = 0; x < n; x++) d_a[x] = 0.0; for (int x = 0; x < n; x++) { for (int y = pcolA[x]; y < pcolA[x+1]; y++) { d_a[x] += A[y]; d_a[irowA[y]] += A[y]; } } for (int x = 0; x < n; x++) d_a[x] = 1.0 / sqrt(d_a[x]); // Calculate D_B for (int x = 0; x < m; x++) d_b[x] = 0.0; for (int x = 0; x < m; x++) { for (int y = pcolB[x]; y < pcolB[x+1]; y++) { d_b[x] += B[y]; } } for (int x = 0; x < m; x++) d_b[x] = 1.0 / sqrt(d_b[x]); // Normalize the affinity matrix... for (int x = 0; x < n; x++) { for (int y = pcolA[x]; y < pcolA[x+1]; y++) { A[y] *= d_a[irowA[y]] * d_a[x]; } } // Normalized B matrix... for (int x = 0; x < m; x++) { for (int y = pcolB[x]; y < pcolB[x+1]; y++) { B[y] *= d_a[irowB[y]] * d_b[x]; } } delete [] d_a; delete [] d_b; // Eigen decomposition of nomalized affinity matrix... // ARPACK setup... double *Ax = new double[n]; // Array for residual calculation double residual = 0.0; double max_residual = 0.0; int ido = 0; char bmat = 'I'; char which[2]; which[0] = 'L'; which[1] = 'A'; double tol = 0.0; double *resid = new double[n]; // NOTE: Need about one order of magnitude more arnoldi vectors to // converge for the normalized Laplacian (according to residuals...) int ncv = ((10*nev+1)>n)?n:(10*nev+1); double *V = new double[(ncv*n)+1]; int ldv = n; int *iparam = new int[12]; iparam[1] = 1; iparam[3] = 100 * nev; iparam[4] = 1; iparam[7] = 1; int *ipntr = new int[15]; double *workd = new double[(3*n)+1]; int lworkl = ncv*(ncv+9); double *workl = new double[lworkl+1]; int info = 0; int rvec = 1; char HowMny = 'A'; int *lselect = new int[ncv]; double *d = new double[nev]; double *Z = &V[1]; int ldz = n; double sigma = 0.0; double *extrap_evec = new double[m]; double *norm_evec = new double[n]; while (ido != 99) { dsaupd_(&ido, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[1], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info); if (ido == -1 || ido == 1) { // Matrix-vector multiplication sp_dsymv(n, irowA, pcolA, A, &workd[ipntr[1]], &workd[ipntr[2]]); } } dseupd_(&rvec, &HowMny, lselect, d, Z, &ldz, &sigma, &bmat, &n, which, &nev, &tol, resid, &ncv, &V[1], &ldv, &iparam[1], &ipntr[1], &workd[1], &workl[1], &lworkl, &info); cout << "Number of converged eigenvalues/vectors found: " << iparam[5] << endl; for (int x = nev-1; x >= 0; x--) { #ifdef DECOMP_WRITE_DOUBLE eigenvalues.write((char*) &d[x],(sizeof(double) / sizeof(char))); eigenvectors.write((char*) &Z[n*x],(sizeof(double) * n) / sizeof(char)); #else eigenvalues << d[x] << endl; for (int y = 0; y < n; y++) eigenvectors << Z[(n*x)+y] << " "; #endif // Extrapolate remaining points onto the vector space for (int y = 0; y < n; y++) norm_evec[y] = Z[(n*x)+y] / d[x]; sp_dgemv(m, irowB, pcolB, B, norm_evec, extrap_evec); #ifdef DECOMP_WRITE_DOUBLE eigenvectors.write((char*) extrap_evec,(sizeof(double) * m) / sizeof(char)); #else for (int y = 0; y < m; y++) eigenvectors << extrap_evec[y] << " "; eigenvectors << endl; #endif // Calculate residual... // Matrix-vector multiplication sp_dsymv(n, irowA, pcolA, A, &Z[n*x], Ax); double t = -d[x]; int i = 1; daxpy_(&n, &t, &Z[n*x], &i, Ax, &i); residual = dnrm2_(&n, Ax, &i)/fabs(d[x]); if (residual > max_residual) max_residual = residual; #ifdef DECOMP_WRITE_DOUBLE residuals.write((char*) &residual, sizeof(double) / sizeof(char)); #else residuals << residual << endl; #endif } cout << "Max residual: " << max_residual << " (eps: " << eps << ")" << endl; if (max_residual > eps) { cout << "*** Sum of residuals too high (max_r > eps)!" << endl; cout << "*** Please, check results manually..." << endl; } eigenvalues.close(); eigenvectors.close(); residuals.close(); delete [] irowA; delete [] pcolA; delete [] A; delete [] irowB; delete [] pcolB; delete [] B; // ARPACK delete [] lselect; delete [] d; delete [] resid; delete [] Ax; delete [] V; delete [] iparam; delete [] ipntr; delete [] workd; delete [] workl; delete [] norm_evec; delete [] extrap_evec; return 0; }
int main(int argc, char **argv) { bool exit_success = false; std::string authors_file; std::string gitattributes_path; std::string svn_path; int resume_from = 0; int max_rev = 0; bool dump_rules = false; std::string match_path; int match_rev = 0; try { namespace po = boost::program_options; po::options_description program_options("Allowed options"); program_options.add_options() ("help,h", "produce help message") ("git", po::value(&options.git_executable)->value_name("PATH"), "Path to a Git executable containing the fix described in http://article.gmane.org/gmane.comp.version-control.git/228736") ("version,v", "print version string") ("quiet,q", "be quiet") ("verbose,V", "be verbose") ("extra-verbose,X", "be even more verbose") ("exit-success", "exit with 0, even if errors occured") ("authors", po::value(&authors_file)->value_name("FILENAME"), "map between svn username and email") ("svnrepo", po::value(&svn_path)->value_name("PATH")->required(), "path to svn repository") ("rules", po::value(&options.rules_file)->value_name("FILENAME")->required(), "file with the conversion rules") ("gitattributes,a", po::value(&gitattributes_path)->value_name("PATH"), "A file whose contents to inject as .gitattributes in every Git repository") ("dry-run", "Write no Git repositories") ("coverage", "Dump an analysis of rule coverage") ("add-metadata", "if passed, each git commit will have svn commit info") ("add-metadata-notes", "if passed, each git commit will have notes with svn commit info") ("resume-from", po::value(&resume_from)->value_name("REVISION"), "start importing at svn revision number") ("max-rev", po::value(&max_rev)->value_name("REVISION"), "stop importing at svn revision number") ("debug-rules", "print what rule is being used for each file") ("commit-interval", po::value(&options.commit_interval)->value_name("NUMBER")->default_value(10000), "if passed the cache will be flushed to git every NUMBER of commits") ("svn-branches", "Use the contents of SVN when creating branches, Note: SVN tags are branches as well") ("dump-rules", "Dump the contents of the rule trie and exit") ("match-path", po::value(&match_path)->value_name("PATH"), "Path to match in a quick ruleset test") ("match-rev", po::value(&match_rev)->value_name("REVISION"), "Optional revision to match in a quick ruleset test") ; po::variables_map variables; store(po::command_line_parser(argc, argv) .options(program_options) .run(), variables); if (variables.count("help")) { std::cout << program_options << std::endl; return 0; } if (variables.count("version")) { std::cout << "Svn2Git 0.9" << std::endl; return 0; } if (variables.count("quiet")) { Log::set_level(Log::Warning); } if (variables.count("verbose")) { Log::set_level(Log::Debug); } if (variables.count("extra-verbose")) { Log::set_level(Log::Trace); } if (variables.count("exit-success")) { exit_success = true; } dump_rules = variables.count("dump-rules") > 0; options.add_metadata = variables.count("add-metadata"); options.add_metadata_notes = variables.count("add-metadata-notes"); options.dry_run = variables.count("dry-run"); options.coverage = variables.count("coverage"); options.debug_rules = variables.count("debug-rules"); options.svn_branches = variables.count("svn-branches"); notify(variables); // Load the configuration Log::info() << "reading ruleset..." << std::endl; Ruleset ruleset(options.rules_file); Log::info() << "done reading ruleset." << std::endl; if (dump_rules) { std::cout << ruleset.matcher(); exit(0); } if (match_path.size() > 0) { Rule const* r = ruleset.matcher().longest_match(match_path, match_rev); std::cout << "The path " << (r ? "was" : "wasn't") << " matched" << std::endl; exit(r ? 0 : 1); } Log::info() << "Opening SVN repository at " << svn_path << std::endl; svn svn_repo(svn_path, authors_file); if (!gitattributes_path.empty()) { std::ifstream ifs(gitattributes_path); if (ifs.fail()) throw std::runtime_error("Couldn't open .gitattributes file: " + gitattributes_path); ifs.exceptions( std::ifstream::badbit ); ifs.seekg(0, std::ios::end); options.gitattributes.resize(ifs.tellg()); ifs.seekg(0, std::ios::beg); ifs.read(&options.gitattributes[0], options.gitattributes.size()); } Log::info() << "preparing repositories and import processes..." << std::endl; importer imp(svn_repo, ruleset); Log::info() << "done preparing repositories and import processes." << std::endl; if (max_rev < 1) max_rev = svn_repo.latest_revision(); Log::info() << "Using git executable: " << git_executable() << std::endl; for (int i = std::max(resume_from, imp.last_valid_svn_revision()); ++i <= max_rev;) imp.import_revision(i); coverage::report(); } catch (std::exception const& error) { Log::error() << error.what() << "\n\n"; return EXIT_FAILURE; } int result = Log::result(); return exit_success ? EXIT_SUCCESS : result; }
int main(int argc, char *argv[]) { std::string machine; std::string sysname; std::vector<std::string> request_urls; try { namespace po = boost::program_options; po::options_description program_options("Allowed options"); program_options.add_options() ("help", "produce help message") ("version", "print version string") ("sysname", po::value(&sysname)->value_name("SYSNAME"), "the system name") ("machine", po::value(&machine)->value_name("MACHINE"), "the hardware name") ; po::options_description hidden_options; hidden_options.add_options() ("request-url", po::value(&request_urls)) ; po::options_description cmdline_options; cmdline_options .add(program_options) .add(hidden_options) ; po::positional_options_description positional_options; positional_options .add("request-url", -1) ; po::variables_map variables; store(po::command_line_parser(argc, argv) .options(cmdline_options) .positional(positional_options) .run(), variables); if (variables.count("help")) { std::cout << program_options << std::endl; return 0; } if (variables.count("version")) { std::cout << "Lemonade 0.1" << std::endl; return 0; } notify(variables); } catch (std::exception const& error) { std::cerr << error.what() << std::endl; return -1; } if (request_urls.empty()) { std::cout << "No project URL given." << std::endl; return -1; } try { run(request_urls); } catch (std::exception const& error) { std::cerr << error.what() << std::endl; return -1; } return 0; }
int main(int argc, char* argv[]) { const char* program_name = "auto_heir_decomp_sparse"; bool optsOK = true; gmx::initForCommandLine(&argc,&argv); copyright(program_name); cout << " Reads the symmetric CSC format sparse matrix from" << endl; cout << " input-file, and heirarchically decomposes the " << endl; cout << " Laplacian matrix until relaxation time convergence" << endl; cout << " criteria are met as the following reference:" << endl; cout << " [1] B. Nadler and M. Galun, \"Fundamental Limitations" << endl; cout << " of Spectral Clustering,\" in Advances in Neural Information" << endl; cout << " Processing Systems 19, 2007, pp. 1017–1024." << endl; cout << " eigenvalues/vectors of the normalized laplacian" << endl; cout << endl; cout << " Use -h or --help to see the complete list of options." << endl; cout << endl; // Option vars... int k_a; double sigma; int nev = 2; double c1 = 1.2; double c2 = 2.0; double K; bool pSet = false; string ssm_filename; string output_filename; string ndx_filename; string residuals_filename; // Declare the supported options. po::options_description cmdline_options; po::options_description program_options("Program options"); program_options.add_options() ("help,h", "show this help message and exit") ("sigma,s", po::value<double>(&sigma)->default_value(1.0), "Input: Kernel sigma (double)") ("relaxation,r", po::value<double>(&c1)->default_value(1.2), "Input: Relaxation cutoff parameter, c1 (double)") ("partition,p", po::value<double>(&c2)->default_value(2.0), "Input: Partition cutoff parameter, c2 (double)") ("ssm-file,f", po::value<string>(&ssm_filename)->default_value("distances.ssm"), "Input: Symmetric sparse matrix file (string:filename)") ("output,o", po::value<string>(&output_filename)->default_value("clusters.dat"), "Output: Cluster assignment file (string:filename)") ("ndx,n", po::value<string>(&ndx_filename)->default_value("clusters.ndx"), "Output: Cluster assignment index file (string:filename)") ; cmdline_options.add(program_options); po::variables_map vm; po::store(po::parse_command_line(argc, argv, cmdline_options), vm); po::notify(vm); if (vm.count("help")) { cout << "usage: " << program_name << " [options]" << endl; cout << cmdline_options << endl; return 1; } if (!optsOK) { return -1; } cout << "Running with the following options:" << endl; cout << "sigma = " << sigma << endl; cout << "ssm-file = " << ssm_filename << endl; cout << "output = " << output_filename << endl; cout << "ndx = " << ndx_filename << endl; cout << endl; // Stacks vector<vector<int> > work; vector<vector<int> > completed; // Defining variables; double *Ax; // Array for residual calculation double residual = 0.0; double max_residual = 0.0; // SSM Matrix CSC_matrix A(ssm_filename); Ax = new double[A.n]; // File output streams ofstream output; ofstream ndx; // EPS double eps = getEPS(); // Open files output.open(output_filename.c_str()); ndx.open(ndx_filename.c_str()); // Get affinities affinity(A,sigma); // Setup work work.resize(1); work[0].resize(A.n); for (int x = 0; x < A.n; x++) work[0][x] = x; while (work.size()) { vector<int> current = work[work.size()-1]; work.pop_back(); CSC_matrix current_A; A.syslice(current,current_A); normalize(current_A); double* d = NULL; // values double* Z = NULL; // vectors double nevm = runARPACK(nev,current_A,d,Z); cout << "Number of converged eigenvalues/vectors found: " << nevm << endl; int *labels = new int[current_A.n]; kmeans(current_A.n,nev,nev,Z,labels); // kmeans(current_A.n,1,nev,&Z[A.n],labels); // Get slice indices vector<int> islice1 = select(current,0,labels); vector<int> islice2 = select(current,1,labels); if (islice1.size() == 0 || islice2.size() == 0) { cout << "Defunct partition..." << endl; } // Get slices CSC_matrix slice1; A.syslice(islice1,slice1); normalize(slice1); CSC_matrix slice2; A.syslice(islice2,slice2); normalize(slice2); double *slice1_d = NULL; double *slice1_Z = NULL; int nev1 = runARPACK(nev,slice1,slice1_d,slice1_Z); cout << "Number of converged eigenvalues/vectors found: " << nev1 << endl; double *slice2_d = NULL; double *slice2_Z = NULL; int nev2 = runARPACK(nev,slice2,slice2_d,slice2_Z); cout << "Number of converged eigenvalues/vectors found: " << nev2 << endl; double current_t,slice1_t,slice2_t,ratio; current_t = (1.0/(1.0-d[0])); slice1_t = (1.0/(1.0-slice1_d[0])); slice2_t = (1.0/(1.0-slice2_d[0])); ratio = slice1_t / slice2_t; if (ratio < 1.0) ratio = slice2_t / slice1_t; cout << "Main: " << current_t << endl; cout << "Slice1: " << slice1_t << endl; cout << "Slice2: " << slice2_t << endl; cout << "Relaxation: " << c1*(slice1_t + slice2_t) << endl; cout << "Partition: " << ratio << endl; if (nev1+nev2+nevm!=6) { cout << "No convergence. Skipping decomposition..." << endl; completed.push_back(current); } else { if (current_t < c1*(slice1_t + slice2_t)) { completed.push_back(current); } else if (ratio > c2) { if (slice1_t > slice2_t) { work.push_back(islice1); completed.push_back(islice2); } else { work.push_back(islice2); completed.push_back(islice1); } } else { work.push_back(islice1); work.push_back(islice2); } } delete [] labels; delete [] slice1_d; delete [] slice1_Z; delete [] slice2_d; delete [] slice2_Z; delete [] d; delete [] Z; } int *clusters = new int[A.n]; cout << "Number of clusters: " << completed.size() << endl; cout << endl; for (int x = 0; x < completed.size(); x++) { int idx = 0; ndx << "[cluster_" << x+1 << "]" << endl; for (int y = 0; y < completed[x].size(); y++) { ndx << completed[x][y]+1 << " "; clusters[completed[x][y]] = x+1; if (++idx > 19) { ndx << endl; idx = 0; } } ndx << endl; ndx << endl; } for (int x = 0; x < A.n; x++) output << clusters[x] << endl; ndx.close(); output.close(); delete [] clusters; delete [] Ax; return 0; } // main.
Program_Options Program_Options_Creator::Create(int const argc, char** const argv){ Program_Options program_options(argc, argv); Program_Options_Checker::Check(program_options); return program_options; }