local void newrun(void) { eps = getdparam("eps"); // get input parameters dtime = getdparam("dtime"); nstatic = getiparam("nstatic"); #if !defined(QUICKSCAN) theta = getdparam("theta"); #endif usequad = getbparam("usequad"); tstop = getdparam("tstop"); dtout = getdparam("dtout"); options = getparam("options"); outputs = getparam("outputs"); if (! strnull(infile)) // if data file was given inputdata(); // then read inital data else { // else make initial data nbody = getiparam("nbody"); // get number of bodies // I added this timesteps = getiparam("timesteps"); // get number of timesteps init_random(getiparam("seed")); // set random number gen. testdata(); // and make plummer model } rsize = 1.0; // start root w/ unit cube nstep = 0; // begin counting steps tout = tnow; // schedule first output }
void getinput() { /* reads the input data */ getalleles(); inputdata(); if (!contchars) { transformgfs(); } } /* getinput */
void getinput() { /* reads the input data */ inputoptions(); if ((!freqsfrom) && !logdet && !similarity) { if (kimura || jukes) { freqa = 0.25; freqc = 0.25; freqg = 0.25; freqt = 0.25; } getbasefreqs(freqa, freqc, freqg, freqt, &freqr, &freqy, &freqar, &freqcy, &freqgr, &freqty, &ttratio, &xi, &xv, &fracchange, freqsfrom, printdata); if (freqa < 0.00000001) { freqa = 0.000001; freqc = 0.999999*freqc; freqg = 0.999999*freqg; freqt = 0.999999*freqt; } if (freqc < 0.00000001) { freqa = 0.999999*freqa; freqc = 0.000001; freqg = 0.999999*freqg; freqt = 0.999999*freqt; } if (freqg < 0.00000001) { freqa = 0.999999*freqa; freqc = 0.999999*freqc; freqg = 0.000001; freqt = 0.999999*freqt; } if (freqt < 0.00000001) { freqa = 0.999999*freqa; freqc = 0.999999*freqc; freqg = 0.999999*freqg; freqt = 0.000001; } } if (!justwts || firstset) inputdata(sites); makeweights(); dnadist_makevalues(); if (freqsfrom) { dnadist_empiricalfreqs(); getbasefreqs(freqa, freqc, freqg, freqt, &freqr, &freqy, &freqar, &freqcy, &freqgr, &freqty, &ttratio, &xi, &xv, &fracchange, freqsfrom, printdata); } } /* getinput */
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); inforWin = new QTextEdit(this); debugWin = new QPlainTextEdit(); debugWin2 = new QPlainTextEdit(); debugWin->setWindowTitle("receive window"); debugWin2->setWindowTitle("post window"); //inforWin->setDisabled(true); //debugWin->setDisabled(true); setCentralWidget(inforWin); QMenu *testMenu = menuBar()->addMenu(tr("&Tools")); QMenu *test2Menu = menuBar()->addMenu(tr("&Tools2")); test2Menu->addAction(myTr("set timeout"), this, SLOT(setTimeout())); test2Menu->addAction(tr("settings"), this, SLOT(inputdata())); testMenu->addAction(myTr("登陆"), this, SLOT(loginsis())); testMenu->addAction(myTr("load thread from internet"), this, SLOT(loadthreadfromeinternet())); testMenu->addAction(myTr("working"), this, SLOT(working())); testMenu->addAction(myTr("catalog"), this, SLOT(generateCatalog())); #define DEBUG_MODE #ifdef DEBUG_MODE testMenu->addAction(myTr("load thread from file and checking"), this, SLOT(loadthreadfromfileandchecking())); testMenu->addAction(myTr("fixPoster"), this, SLOT(fixPoster())); testMenu->addAction(myTr("test"), this, SLOT(test4())); testMenu->addAction(myTr("fanye"), this, SLOT(fanye())); testMenu->addAction(myTr("robfloor"), this, SLOT(robfloor())); testMenu->addAction(myTr("clear cookie"), this, SLOT(clearCookie())); testMenu->addAction(myTr("签到"), this, SLOT(registersis())); //connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); test2Menu->addAction(myTr("toggle internet mode"), this, SLOT(togglenet())); #endif }
void maketree() { /* construct the tree */ long i ; inputdata(replicates, printdata, lower, upper, x, reps); /* if (njoin && (spp < 3)) { mexPrintf("\nERROR: Neighbor-Joining runs must have at least 3 species\n\n"); exxit(-1); } */ if (progress) putchar('\n'); if (ith == 1) setuptree(&curtree, nonodes2 + 1); for (i = 1; i <= spp; i++) enterorder[i - 1] = i; if (jumble) randumize(seed, enterorder); for (i = 0; i < spp; i++) cluster[i] = curtree.nodep[i]; jointree(); if (njoin) curtree.start = curtree.nodep[outgrno - 1]->back; printree(curtree.start, treeprint, njoin, (boolean)(!njoin)); if (treeprint) summarize(); if (trout) { col = 0; if (njoin) treeout(curtree.start, &col, 0.43429448222, njoin, curtree.start); else curtree.root = curtree.start, treeoutr(curtree.start,&col,&curtree); } if (progress) { mexPrintf("\nOutput written on file \"%s\"\n\n", outfilename); if (trout) mexPrintf("Tree written on file \"%s\"\n\n", outtreename); } } /* maketree */
void doinput() { /* reads the input data */ inputnumbers(&spp, &chars, &nonodes, 1); words = chars / bits + 1; printf("%2ld species, %3ld characters\n", spp, chars); printf("\nReading input file ...\n\n"); getoptions(); if (weights) openfile(&weightfile,WEIGHTFILE,"weights file","r",progname,weightfilename); if(ancvar) openfile(&ancfile,ANCFILE,"ancestors file", "r",progname,ancfilename); if(factors) openfile(&factfile,FACTFILE,"factors file", "r",progname,factfilename); alloctree(&treenode); setuptree(treenode); allocrest(); inputoptions(); inputdata(treenode, dollo, false, stdout); } /* doinput */
void maketree() { /* construct the tree */ long i ; inputdata(replicates, printdata, lower, upper, x, reps); if (progress) putchar('\n'); if (ith == 1) setuptree(&curtree, nonodes2 + 1); for (i = 1; i <= spp; i++) enterorder[i - 1] = i; if (jumble) randumize(seed, enterorder); for (i = 0; i < spp; i++) cluster[i] = curtree.nodep[i]; jointree(); if (outgropt) curtree.start = curtree.nodep[outgrno - 1]->back; printree(&curtree, curtree.start->next, treeprint, njoin, !njoin); if (treeprint) summarize(); if (trout) { col = 0; if (njoin) treeout(curtree.start, &col, 0.43429448222, njoin, curtree.start); else curtree.root = curtree.start, treeoutr(curtree.start,&col,&curtree); } if (progress) { printf("\nOutput written on output file\n\n"); if (trout) printf("Tree written on tree file\n\n"); } } /* maketree */
startrun() { string restfile, contfile; bool scanopt(); proc get_potential(); infile = getparam("in"); /* set I/O file names */ outfile = getparam("out"); restfile = getparam("restart"); contfile = getparam("continue"); savefile = getparam("save"); options = getparam("options"); /* set control options */ debug = getbparam("hdebug"); if (debug) dprintf(0,"hdebug is turned on"); nrigid = getiparam("nrigid"); if (*contfile) /* resume interrupted run */ restorestate(contfile); else if (*restfile) { /* resume w/ new parameters */ restorestate(restfile); /* NOTE: someday, I will have a way to tell which, if any, of these * * parameters are actually input from the command line, and only * * change them. ANY NON-DEFAULT ARGS MUST BE SPECIFIED AT RESTART. */ eps = getdparam("eps"); /* get modified params */ tol = getdparam("tol"); options = getparam("options"); /* restorestate overwrite */ fcells = getdparam("fcells"); tstop = getdparam("tstop"); freqout = getdparam("freqout"); minor_freqout = getdparam("minor_freqout"); if (scanopt(options, "new_tout")) { /* reset output times? */ tout = tnow + 1 / freqout; /* offset from present */ minor_tout = tnow + 1 / minor_freqout; } } else { /* start new calculation */ if (*infile) /* was data file given? */ inputdata(infile); /* read inital data */ else { /* make initial conds? */ nbody = getiparam("nbody"); /* get nbody parameter */ if (nbody < 1) /* is value absurd? */ error("startrun: absurd nbody\n"); init_xrandom(getparam("seed")); /* set random generator */ testdata(getbparam("cencon")); /* make test model */ } freq = getdparam("freq"); /* get various parameters */ eps = getdparam("eps"); tol = getdparam("tol"); fcells = getdparam("fcells"); tstop = getdparam("tstop"); freqout = getdparam("freqout"); minor_freqout = getdparam("minor_freqout"); nstep = 0; /* start counting steps */ minor_tout = tout = tnow; /* schedule first output */ SETVS(rmin, -2.0); /* init box scaling */ rsize = -2.0 * rmin[0]; } contfile = getparam("potname"); if (*contfile) { extpot = get_potential(contfile, getparam("potpars"),getparam("potfile")); } }
void DataHandler::DataAdapter(vector<vector<double>> dataMatrix) { //Import the .csv file using the fstream class vector<vector<double>> inputdata(dataMatrix.size()+1,vector<double>(dataMatrix[0].size())); ifstream file(_filepath); string line; int col = 0; int row = 0; while (getline(file, line)) { istringstream iss(line); string result; while (getline(iss, result, ';')) //The delimiter of the csv file is ";" { istringstream convertor(result); //Convert the string into a float number convertor >> inputdata[row][col]; //Fill the inputdata matrix with the values of the .csv col = col + 1; } row = row + 1; col = 0; } //Delete the first row of the matrix (headers) for (int i = 1; i < inputdata.size(); i++) //Start from the second line of inputdata { for (int j = 0; j < inputdata[0].size(); j++) { dataMatrix[i - 1][j] = inputdata[i][j]; } } //Normalization of the matrix (except the last column) for (int j = 0; j<dataMatrix[0].size() - 1; j++) { vector<double> v(dataMatrix.size()); vector<double> w(dataMatrix.size()); for (int i = 0; i < dataMatrix.size(); i++) { w[i] = dataMatrix[i][j]; } double a = *max_element(w.begin(),w.end()); double b = *min_element(w.begin(), w.end()); for (int i = 0; i < inputdata.size() - 1; i++) { v[i] = (w[i] - b) / (a - b); dataMatrix[i][j] = v[i]; } } //Shuffle the matrix random_device rd; mt19937 g(rd()); shuffle(dataMatrix.begin(), dataMatrix.end(), g); //Save the adapted data into 3 .csv's ofstream myfile1; myfile1.open("..\\..\\Results\\training_dataset.csv"); for (int i = 0; i<floor((0.666)*dataMatrix.size()); i++) //select the first 2/3 elements of the database { for (int j = 0; j < dataMatrix[0].size(); j++) { myfile1 << dataMatrix[i][j] << ";"; } myfile1 << endl; } myfile1.close(); ofstream myfile2; myfile2.open("..\\..\\Results\\testing_dataset.csv"); for (int i = floor((0.666)*dataMatrix.size()); i< floor((0.666)*dataMatrix.size()) + floor((0.166)*dataMatrix.size()); i++) //Select the next 1/6 samples { for (int j = 0; j < dataMatrix[0].size(); j++) { myfile2 << dataMatrix[i][j] << ";"; } myfile2 << endl; } myfile2.close(); ofstream myfile3; myfile3.open("..\\..\\Results\\predict_dataset.csv"); for (int i = floor((0.666)*dataMatrix.size()) + floor((0.166)*dataMatrix.size()); i< dataMatrix.size(); i++) //Select the last samples { for (int j = 0; j < dataMatrix[0].size(); j++) { myfile3 << dataMatrix[i][j] << ";"; } myfile3 << endl; } myfile3.close(); }
void maketree() { /* contruct the tree */ long nextsp,numtrees; boolean succeeded=false; long i, j, which; if (usertree) { inputdata(replicates, printdata, lower, upper, x, reps); setuptree(&curtree, nonodes2); for (which = 1; which <= spp; which++) setuptipf(which, &curtree); if (eoln(infile)) { fscanf(infile, "%*[^\n]"); getc(infile); } openfile(&intree,INTREE,"input tree file","r",progname,intreename); fscanf(intree, "%ld%*[^\n]", &numtrees); getc(intree); if (numtrees > MAXNUMTREES) { printf("\nERROR: number of input trees is read incorrectly from %s\n", intreename); exxit(-1); } if (treeprint) { fprintf(outfile, "User-defined tree"); if (numtrees > 1) putc('s', outfile); fprintf(outfile, ":\n\n"); } first = true; which = 1; while (which <= numtrees) { treeread2 (intree, &curtree.start, curtree.nodep, lengths, &trweight, &goteof, intreename, "Fitch", &haslengths, &spp); nums = spp; curtree.start = curtree.nodep[outgrno - 1]->back; treevaluate(); printree(&curtree, curtree.start, treeprint, false, false); summarize(numtrees); which++; } FClose(intree); } else { if (jumb == 1) { inputdata(replicates, printdata, lower, upper, x, reps); setuptree(&curtree, nonodes2); setuptree(&priortree, nonodes2); setuptree(&bestree, nonodes2); if (njumble > 1) setuptree(&bestree2, nonodes2); } for (i = 1; i <= spp; i++) enterorder[i - 1] = i; if (jumble) randumize(seed, enterorder); nextsp = 3; buildsimpletree(&curtree, nextsp); curtree.start = curtree.nodep[enterorder[0] - 1]->back; if (jumb == 1) numtrees = 1; nextsp = 4; if (progress) { printf("Adding species:\n"); writename(0, 3, enterorder); #ifdef WIN32 phyFillScreenColor(); #endif } while (nextsp <= spp) { nums = nextsp; buildnewtip(enterorder[nextsp - 1], &curtree, nextsp); copy_(&curtree, &priortree); bestree.likelihood = -99999.0; addtraverse(curtree.nodep[enterorder[nextsp - 1] - 1]->back, curtree.start, true, &numtrees,&succeeded); copy_(&bestree, &curtree); if (progress) { writename(nextsp - 1, 1, enterorder); #ifdef WIN32 phyFillScreenColor(); #endif } if (global && nextsp == spp) { if (progress) { printf("Doing global rearrangements\n"); printf(" !"); for (j = 1; j <= (spp - 2); j++) putchar('-'); printf("!\n"); printf(" "); } } succeeded = true; while (succeeded) { succeeded = false; rearrange(curtree.start, &numtrees,&nextsp,&succeeded); if (global && ((nextsp) == spp) && progress) printf("\n "); } if (global && nextsp == spp) { putc('\n', outfile); if (progress) putchar('\n'); } if (njumble > 1) { if (jumb == 1 && nextsp == spp) copy_(&bestree, &bestree2); else if (nextsp == spp) { if (bestree2.likelihood < bestree.likelihood) copy_(&bestree, &bestree2); } } if (nextsp == spp && jumb == njumble) { if (njumble > 1) copy_(&bestree2, &curtree); curtree.start = curtree.nodep[outgrno - 1]->back; printree(&curtree, curtree.start, treeprint, true, false); summarize(numtrees); } nextsp++; } } if (jumb == njumble && progress) { printf("\nOutput written to output file\n\n"); if (trout) { printf("Tree also written onto file\n"); putchar('\n'); } } } /* maketree */
int main(int argc, char *argv[]) { std::cout << "Started"; // set up MPI MPI_Init(&argc, &argv); // get communicator size and my rank MPI_Comm comm = MPI_COMM_WORLD; int p, rank; MPI_Comm_size(comm, &p); MPI_Comm_rank(comm, &rank); /* code */ //testrandom(10, 32, 9); bits_t* input;// = getrandom(10, 32, 9); if (rank == 0) { // read input file if (argc < 2) { printUsage(); exit(EXIT_FAILURE); } // get the master depth, (i.e. the number of bits till which the // master process solves the problem) std::string depthstr = argv[1]; std::istringstream ssargv(depthstr); unsigned int master_depth; ssargv >> master_depth; // open input file (if given, else default to stdin) std::istream* instream_ptr = &std::cin; std::ifstream infile; if (argc >= 3) { //std::string infilename(argv[2]); infile.open(argv[2]); if (!(infile.good() && infile.is_open())) { printUsage(); exit(EXIT_FAILURE); } instream_ptr = &infile; } std::istream& instream = *instream_ptr; // open output file (if given, else use stdout) std::ostream* outstream_ptr = &std::cout; std::ofstream outfile; if (argc == 4) { //std::string outfilename(argv[3]); outfile.open(argv[3]); if (!(outfile.good() && outfile.is_open())) { printUsage(); exit(EXIT_FAILURE); } outstream_ptr = &outfile; } std::ostream& outstream = *outstream_ptr; // read input from file unsigned int n, l, d; instream >> n >> l >> d; std::vector<bits_t> inputdata(n); for (unsigned int i = 0; i < n; ++i) { instream >> inputdata[i]; } // get data as pointer (for more C-like interface) input = &inputdata[0]; // prepare results std::vector<bits_t> results; // start timer // we omit the file loading and argument parsing from the runtime // timings, we measure the time needed by the master process struct timespec t_start, t_end; // clock_gettime(CLOCK_MONOTONIC, &t_start); if (p == 1) { std::cerr << "[WARNING]: Running the sequential solver. Start with mpirun to execute the parallel version." << std::endl; // call the sequential solver results = findmotifs(n, l, d, input); } else { // call the parallel solver function results = master_main(n, l, d, input, master_depth); } // end timer // clock_gettime(CLOCK_MONOTONIC, &t_end); // time in seconds double time_secs = (t_end.tv_sec - t_start.tv_sec) + (double) (t_end.tv_nsec - t_start.tv_nsec) * 1e-9; // output time std::cerr << time_secs << std::endl; // write output file in ascending order std::sort(results.begin(), results.end()); for (std::size_t i = 0; i < results.size(); ++i) { outstream << results[i] << std::endl; } } else {