SelectFormat::SelectFormat(const UnicodeString& pat, UErrorCode& status) : parsedValuesHash(NULL) { if (U_FAILURE(status)) { return; } initHashTable(status); applyPattern(pat, status); }
void SelectFormat::copyHashtable(Hashtable *other, UErrorCode& status) { if (U_FAILURE(status)) { return; } if (other == NULL) { cleanHashTable(); return; } if (parsedValuesHash == NULL) { initHashTable(status); if (U_FAILURE(status)) { return; } } parsedValuesHash->removeAll(); parsedValuesHash->setValueDeleter(uhash_deleteUnicodeString); int32_t pos = -1; const UHashElement* elem = NULL; // walk through the hash table and create a deep clone while ((elem = other->nextElement(pos)) != NULL){ const UHashTok otherKeyTok = elem->key; UnicodeString* otherKey = (UnicodeString*)otherKeyTok.pointer; const UHashTok otherKeyToVal = elem->value; UnicodeString* otherValue = (UnicodeString*)otherKeyToVal.pointer; parsedValuesHash->put(*otherKey, new UnicodeString(*otherValue), status); if (U_FAILURE(status)){ cleanHashTable(); return; } } }
void initialiseString() { FieldBlock *count = NULL, *value, *offset; string_class = findSystemClass0(SYMBOL(java_lang_String)); registerStaticClassRef(&string_class); if(string_class != NULL) { count = findField(string_class, SYMBOL(count), SYMBOL(I)); value = findField(string_class, SYMBOL(value), SYMBOL(array_C)); offset = findField(string_class, SYMBOL(offset), SYMBOL(I)); } /* findField doesn't throw an exception... */ if((count == NULL) || (value == NULL) || (offset == NULL)) { jam_fprintf(stderr, "Error initialising VM (initialiseString)\n"); exitVM(1); } count_offset = count->offset; value_offset = value->offset; offset_offset = offset->offset; /* Init hash table and create lock */ initHashTable(hash_table, HASHTABSZE, TRUE); }
int main() { int N = _5000; char ** content = readFromFile(N); //printContentToConsole(content,N); initHashTable(N); int i, aux; int maxColl = 0; nrOfResize = 0; float avgColl= 1; for (i=0; i<N; i++) { if ((i % 20) ==0) printf("\nElement Collisions FillFactor\n\n"); aux = insertElement(*(content+i)); printf("%7d %10d", i, aux); if (maxColl < aux) maxColl = aux; printf(" %8.2f%% \n", 100*getFillFactor()); avgColl=(float)((((float)(avgColl)*i)+(float)aux)/(float)(i+1)); } printf("\nNumber of resizes: %d\n", nrOfResize); printf("\nMaximal number of collisions: %d\n", maxColl); printf("\nAverage number of collisions: %f\n", avgColl); return 0; }
SharedData::SharedData(DWORD processorCount, char* wikiFileName, char* keywordFileName, ResultFile* resultFile) { itemCount = processorCount << 1; keywordFile = new KeywordFile(keywordFileName); currentTotal = 0; activeThreads = 0; currentProcessed = 0; runningThreads = processorCount + 1; initThreadSafeProtocols(); // initialize Producer Consumer full = PC<MyBuf>(eventQuit, itemCount); empty = PC<SlotID>(eventQuit, itemCount); full.setup(fullCS, myBufCount); empty.setup(emptyCS, slotIDCount); // initialize all the files if (!this->keywordFile->openFile()) { // open keyword file printf("SharedData Openfile Error\n"); exit(-1); } int maxKeywordLen = keywordFile->getMaxKeywordLength(); wikiFile = new WikiFile(wikiFileName, maxKeywordLen, itemCount); //keywordFreq = new DWORD[keywordFile->lineCount]; //ZeroMemory(keywordFreq, sizeof(DWORD) * keywordFile->lineCount); this->resultFile = resultFile; resultFile->setKeywordCount(keywordFile->lineCount); resultFile->openFile(); initHashTable(); }
static void initBadShiftTable(UTHashTable *jumpTable, MMBitmapRef needle) { const MMPoint lastPoint = MMPointMake(needle->width - 1, needle->height - 1); const size_t maxColors = needle->width * needle->height; MMPoint scan; printf("lastpoint=%d,%d, maxColors=%d\n", lastPoint.x, lastPoint.y, maxColors); /* Allocate max size initially to avoid a million calls to malloc(). */ initHashTable(jumpTable, maxColors, sizeof(struct shiftNode)); printf("init table finished!\n"); int i = 0; /* Populate jumpTable with analysis of |needle|. */ for (scan.y = lastPoint.y; ; --scan.y) { for (scan.x = lastPoint.x; ; --scan.x) { MMRGBHex color = MMRGBHexAtPoint(needle, scan.x, scan.y); if (!tableHasKey(jumpTable, color)) { i++; addNodeToTable(jumpTable, color, MMPointMake(needle->width - scan.x, needle->height - scan.y)); } if (scan.x == 0) break; /* Avoid infinite loop from unsigned type. */ } if (scan.y == 0) break; } printf("i = %d\n", i); //printf("init func finished!\n"); }
int main() { int N = _100000; char ** content = readFromFile(N); printContentToConsole(content,N); initHashTable(N); return 0; }
HashTable *classlibCreateLoaderTable(Object *class_loader) { HashTable *table = sysMalloc(sizeof(HashTable)); initHashTable((*table), CLASS_INITSZE, TRUE); INST_DATA(class_loader, HashTable*, ldr_classes_offset) = table; return table; }
int initandparserfile(char *stringPath) { FILE *fp= NULL; char *pk = NULL; char stream[MAX_STREAM] = {0}; char str_key[MAX_KEY] = {0}; char str_type[4] = {0}; uint offset = 0; HASH s_hash; SParser s_parse_tmp; printf("STRING_PATH=%s\n",stringPath); fp=fopen(stringPath,"r"); if(fp == NULL) { printf("open STRING_PATH failed!\n"); return FAILURE; } if (FAILURE == initHashTable(&s_parse_tmp)) { printf("initHashTable failed!\n"); fclose(fp); return FAILURE; } ResetHashTable(&s_parse);//free memory at first s_parse = s_parse_tmp; fseek(fp, 0, SEEK_SET); while(fgets(stream, MAX_STREAM, fp) != NULL) { int len = strlen(stream); pk = strstr(stream,"="); if ((stream[0] == ';') || (NULL == pk)) { offset += len; continue; } *pk = '\0'; strncpy(str_key, stream, strlen(stream)); s_hash.key = getkey(str_key); s_hash.ioffset = offset; offset += len; strcpy(str_attrname, str_key); insertToHash(&s_parse, s_hash); memset(stream, 0, MAX_STREAM); memset(str_key, 0, MAX_KEY); } fclose(fp); return SUCCESS; }
int msInitFontSet(fontSetObj *fontset) { fontset->filename = NULL; /* fontset->fonts = NULL; */ initHashTable(&(fontset->fonts)); fontset->numfonts = 0; fontset->map = NULL; return( 0 ); }
int initialiseUtf8(InitArgs *args) { if(args->testmode == TRUE){ testing_mode = TRUE; } if(args->persistence == TRUE){ is_persistent = TRUE; } /* Init hash table, and create lock */ /* XXX NVM CHANGE 005.001.009 - UTF8 HT - Y*/ initHashTable(hash_table, HASHTABSZE, TRUE, utf8_name, TRUE); initHashTable(native_hash_table,HASHTABSZE, TRUE, native_name, TRUE); /* XXX DOC CHANGE */ if(is_persistent){ OPC *ph_value = get_opc_ptr(); hash_table.hash_count = ph_value->utf8_hash_count; native_hash_table.hash_count = ph_value->utf8_native_hash_count; //printf("hashcount:%d\n",hash_table.hash_count); } return TRUE; }
int main() { (void)setHashFunc(modeFunc); initHashTable(); test1(); test2(); test3(); destroyHashTable(); system("pause"); }
//-------hash table---------- //hashTable HT createHashTable(char *dictName, int (*hashFun)(ElemType *word, int size)){ HT hashTable = malloc(sizeof(HT)); hashTable->tableSize = TSIZE; hashTable->numEntry = 0; hashTable->nonEmpBucket = 0; hashTable->maxListLeng = 0; hashTable->avgListLeng = 0; //allocate table array and initialize the table initHashTable(hashTable, dictName, hashFun); return hashTable; }
void initWicBasics(int argc, char *argv[], float dummy) { dummy = dummy; /* Dummy argument to include floating point routines */ initMemory(); initWicResources(argv[0]); initDebug(); g_commentList = createSLList(); g_dirList = createSLList(); g_logList = createSLList(); g_currPos = NULL; getCmdLineOptions(argc, argv); initHashTable(); initOutputSystem(); }
int main() { int N = _1000; char ** content = readFromFile(N); initHashTable(N); int i = 0; while (i < N) { insertElement(content[i]); i++; } computeDistributionsPerBucket(); printf("Standard deviation: %.3f\n", standardDeviation()); return 0; }
void resizeHashTable(int N) { //! reconstruct the hash table by (usually) doubling its size //! only call this when the current fill factor of your hash table > MAX_FILL_FACTOR //! careful, when resizing, the 'size' variable should be changed as well such that the 'hashFunction's distribution will work //! be double careful! all the elements which are already in the hash table have to be RE-hashed! (explanation @ lab) nrmax=0; int i; for(i=0; i<size; i++) free(hashTable[i]); int doublesize=N*2; res++; initHashTable(doublesize); }
SasMasterLock::SasMasterLock(unsigned int size) { #ifdef __SOMDebugPrint__ fprintf (stderr, "%s\n", __FUNCTION__); #endif if (size != 256) fprintf (stderr, "%s: only size of 256 is currently supported\n", __FUNCTION__); //eyecatcher = 0x6D6C636B; tableSize = size; //eyecatcher2 = 0x6B636C6D; initHashTable(); }
int initialiseInlining(InitArgs *args) { enabled = args->codemem > 0 ? checkRelocatability() : FALSE; if(enabled) { initVMLock(rewrite_lock); initHashTable(code_hash_table, HASHTABSZE, TRUE); sys_page_size = getpagesize(); max_code_size = ROUND(args->codemem, sys_page_size); code_increment = ROUND(CODE_INCREMENT, sys_page_size); replication_threshold = args->replication; } inlining_inited = TRUE; return enabled; }
void initialiseThreadStage1(InitArgs *args) { size_t size; /* Set the default size of the Java stack for each _new_ thread */ dflt_stack_size = args->java_stack; /* Initialise internal locks and pthread state */ pthread_key_create(&threadKey, NULL); pthread_mutex_init(&lock, NULL); pthread_cond_init(&cv, NULL); pthread_mutex_init(&exit_lock, NULL); pthread_cond_init(&exit_cv, NULL); pthread_attr_init(&attributes); pthread_attr_setdetachstate(&attributes, PTHREAD_CREATE_DETACHED); /* Ensure the thread stacks are at least 1 megabyte in size */ pthread_attr_getstacksize(&attributes, &size); if(size < 1*MB) pthread_attr_setstacksize(&attributes, 1*MB); monitorInit(&sleep_mon); initHashTable(thread_id_map, HASHTABSZE, TRUE); /* We need to cache field and method offsets to create and initialise threads. However, the class loading component requires a valid thread and ExecEnv. To get round this we initialise the main thread in two parts. First part is sufficient to _load_ classes, but it is still not fully setup so we don't allow initialisers to run */ main_thread.stack_base = args->main_stack_base; main_thread.tid = pthread_self(); main_thread.id = genThreadID(); main_thread.state = RUNNING; //main_thread.ee = &main_ee; //initialiseJavaStack(&main_ee); initialiseJavaStack(&main_thread); setThreadSelf(&main_thread); // create the nonspec group //RopeVM::instance()->new_group_for(0, threadSelf()->get_certain_core()); }
int main() { int N = _100; char ** content = readFromFile(N); //printContentToConsole(content,N) initHashTable(N); int i = 0; while (i < N) { insertElement(content[i]); i++; } computeDistributionsPerBucket();; return 0; }
int main() { int N = _100; char ** content = readFromFile(N); //printContentToConsole(content,N); initHashTable(N); int maxCol = 0, r, nrCol; for (r=0; r<N; r++){ nrCol = insertElement(content[r]); if (nrCol > maxCol){ maxCol = nrCol; } } printf("%d is the maximum number of collisions that occurred.\n", maxCol); printf("The hash table has been resized %d times.\n", (int)log2(size/(N*INITIAL_HT_SIZE_FACTOR))); return 0; }
int main() { //init int N = _100000; char** hashTable; int size; char** content = readFromFile(N); //printContentToConsole(content, N); printf("ISF: %f; MFF: %f; N = %d\n", INITIAL_HT_SIZE_FACTOR, MAX_FILL_FACTOR, N); initHashTable(&hashTable, &size, N); printf("Initial Size: %d\n", size); //solution insertAllElements(&hashTable, &size, N, content); printf("terminal size: %d\n", size); destroyHashTable(&hashTable, size); return 0; }
int main() { HashTable H = initHashTable(13); int Key = 5; Position Pos = Find(H, Key); Position newPos; assert(H->TheCells[Pos].Info == EMPTY); // test insert and find Insert(H, Key); assert(H->TheCells[Pos].Info == OCCUPY); InsertValue(H, Key, 90); newPos = Find(H, Key); assert(Pos == newPos); assert(H->TheCells[newPos].Info == OCCUPY); assert(H->TheCells[newPos].Value == 90); printf("pass!\n"); return 0; }
int main(void) { HashTable t; initHashTable(&t); char a1[5] = "X"; char a2[5] = "xy"; char a3[5] = "xx"; char a4[5] = "a"; char a5[5] = "b"; char a6[5] = "A"; char a7[5] = "Z"; char a8[5] = "inc"; char a9[5] = "lsj"; char a10[5] = "sdf"; char a11[5] = "grx"; char a12[5] = "yfg"; char a13[5] = "dsf"; char a14[5] = "inc"; // notice a variable already exits with this name, // the variable with this name in the list will have the // newest value, i.e. old values are overwritten addToHash(&t, a1, 5.0); addToHash(&t, a2, 6.0); addToHash(&t, a3, 7.0); addToHash(&t, a4, 8.0); addToHash(&t, a5, 9.0); addToHash(&t, a6, 10.0); addToHash(&t, a7, 11.0); addToHash(&t, a8, 12.0); addToHash(&t, a9, 13.0); addToHash(&t, a10, 14.0); addToHash(&t, a11, 15.0); addToHash(&t, a12, 16.0); addToHash(&t, a13, 17.0); addToHash(&t, a14, 18.0); printf("HashTable:\n%s", tableToString(&t)); return 0; }
void addToHashTable(int N) { char **content = readFromFile(N); collisions = (int*) malloc (sizeof(int) *N); initHashTable(N); int nr=0; int k; float fill_factor; for(k=0; k<N; k++) { fill_factor = getFillFactor(); if(fill_factor >MAX_FILL_FACTOR) resizeHashTable(); collisions[k] += insertElement(content[k], size, hashTable); nr+=1; //printContentToConsole(hashTable, size); } //printf("\n%d end", nr); }
int main() { int N = _1000; char ** content = readFromFile(N); //printContentToConsole(content,N); initHashTable(N); int collisions=0; int resizes=0; int i; float Fillfactor; for(i=0; i<N; i++) { collisions = collisions+insertElement(content[i]); Fillfactor= getFillFactor(); if(Fillfactor>MAX_FILL_FACTOR && size<N) { resizes++; resizeHashTable(N); i=0; } } printf("Total number of collisions: %d \nTimes the has table was resized: %d \n", collisions, resizes); }
int main() { int N = _100; int i; char ** content = readFromFile(N); initHashTable(N); for(i=0; i<N; i++) { insertElement(*(content + i)); } computeDistributionsPerBucket(); //compute de standard deviation float d=0; for(i=0; i<size; i++) { d=d+hashTable[i].size*i; } d=d/N; printf("\nstandard deviaton is:%g",d); //printContentToConsole(content,N); return 0; }
int main() { int N = 100; char ** content = readFromFile(N); printContentToConsole(content,N); initHashTable(N); int MAX=0; int i=0,resizeTable=0; while(i<N) { int x=hashFunction(*content,i); i++; if (insertElement(content[i],x)==-1) { i=0; resizeTable++; } } totalNrOfCollisions=0; for(i=0;i<N;i++) { totalNrOfCollisions+=nrOfCollisions[i]; printf("\nelement %d : %d collisions",i,nrOfCollisions[i]); if (MAX<nrOfCollisions[i]) MAX=nrOfCollisions[i]; } printf("\nthe maximum nr of collisions is %d", MAX); printf("\nthe total number of collisions is %d", totalNrOfCollisions); printf("\nthe number of resizes is %d",resizeTable); return 0; }
int main() { int N = _1000; initHashTable(N); return 0; }
void doAllInOne(tree *tr, analdef *adef) { int i, n, bestIndex, bootstrapsPerformed; #ifdef _WAYNE_MPI int bootStopTests = 1, j, bootStrapsPerProcess = 0; #endif double loopTime; int *originalRateCategories; int *originalInvariant; #ifdef _WAYNE_MPI int slowSearches, fastEvery; #else int slowSearches, fastEvery = 5; #endif int treeVectorLength = -1; topolRELL_LIST *rl; double bestLH, mlTime, overallTime; long radiusSeed = adef->rapidBoot; FILE *f; char bestTreeFileName[1024]; hashtable *h = (hashtable*)NULL; unsigned int **bitVectors = (unsigned int**)NULL; boolean bootStopIt = FALSE; double pearsonAverage = 0.0; pInfo *catParams = allocParams(tr); pInfo *gammaParams = allocParams(tr); unsigned int vLength; n = adef->multipleRuns; #ifdef _WAYNE_MPI if(n % processes != 0) n = processes * ((n / processes) + 1); #endif if(adef->bootStopping) { h = initHashTable(tr->mxtips * 100); treeVectorLength = adef->multipleRuns; bitVectors = initBitVector(tr, &vLength); } rl = (topolRELL_LIST *)rax_malloc(sizeof(topolRELL_LIST)); initTL(rl, tr, n); originalRateCategories = (int*)rax_malloc(tr->cdta->endsite * sizeof(int)); originalInvariant = (int*)rax_malloc(tr->cdta->endsite * sizeof(int)); initModel(tr, tr->rdta, tr->cdta, adef); if(adef->grouping) printBothOpen("\n\nThe topologies of all Bootstrap and ML trees will adhere to the constraint tree specified in %s\n", tree_file); if(adef->constraint) printBothOpen("\n\nThe topologies of all Bootstrap and ML trees will adhere to the bifurcating backbone constraint tree specified in %s\n", tree_file); #ifdef _WAYNE_MPI long parsimonySeed0 = adef->parsimonySeed; long replicateSeed0 = adef->rapidBoot; n = n / processes; #endif for(i = 0; i < n && !bootStopIt; i++) { #ifdef _WAYNE_MPI j = i + n * processID; tr->treeID = j; #else tr->treeID = i; #endif tr->checkPointCounter = 0; loopTime = gettime(); #ifdef _WAYNE_MPI if(i == 0) { if(parsimonySeed0 != 0) adef->parsimonySeed = parsimonySeed0 + 10000 * processID; adef->rapidBoot = replicateSeed0 + 10000 * processID; radiusSeed = adef->rapidBoot; } #endif if(i % 10 == 0) { if(i > 0) reductionCleanup(tr, originalRateCategories, originalInvariant); if(adef->grouping || adef->constraint) { FILE *f = myfopen(tree_file, "rb"); assert(adef->restart); if (! treeReadLenMULT(f, tr, adef)) exit(-1); fclose(f); } else makeParsimonyTree(tr, adef); tr->likelihood = unlikely; if(i == 0) { double t; onlyInitrav(tr, tr->start); treeEvaluate(tr, 1); t = gettime(); modOpt(tr, adef, FALSE, 5.0); #ifdef _WAYNE_MPI printBothOpen("\nTime for BS model parameter optimization on Process %d: %f seconds\n", processID, gettime() - t); #else printBothOpen("\nTime for BS model parameter optimization %f\n", gettime() - t); #endif memcpy(originalRateCategories, tr->cdta->rateCategory, sizeof(int) * tr->cdta->endsite); memcpy(originalInvariant, tr->invariant, sizeof(int) * tr->cdta->endsite); if(adef->bootstrapBranchLengths) { if(tr->rateHetModel == CAT) { copyParams(tr->NumberOfModels, catParams, tr->partitionData, tr); assert(tr->cdta->endsite == tr->originalCrunchedLength); catToGamma(tr, adef); modOpt(tr, adef, TRUE, adef->likelihoodEpsilon); copyParams(tr->NumberOfModels, gammaParams, tr->partitionData, tr); gammaToCat(tr); copyParams(tr->NumberOfModels, tr->partitionData, catParams, tr); } else { assert(tr->cdta->endsite == tr->originalCrunchedLength); } } } } computeNextReplicate(tr, &adef->rapidBoot, originalRateCategories, originalInvariant, TRUE, TRUE); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 1); computeBOOTRAPID(tr, adef, &radiusSeed); #ifdef _WAYNE_MPI saveTL(rl, tr, j); #else saveTL(rl, tr, i); #endif if(adef->bootstrapBranchLengths) { double lh = tr->likelihood; if(tr->rateHetModel == CAT) { copyParams(tr->NumberOfModels, tr->partitionData, gammaParams, tr); catToGamma(tr, adef); resetBranches(tr); onlyInitrav(tr, tr->start); treeEvaluate(tr, 2.0); gammaToCat(tr); copyParams(tr->NumberOfModels, tr->partitionData, catParams, tr); tr->likelihood = lh; } else { treeEvaluate(tr, 2.0); tr->likelihood = lh; } } printBootstrapResult(tr, adef, TRUE); loopTime = gettime() - loopTime; writeInfoFile(adef, tr, loopTime); if(adef->bootStopping) #ifdef _WAYNE_MPI { int nn = (i + 1) * processes; if((nn > START_BSTOP_TEST) && (i * processes < FC_SPACING * bootStopTests) && ((i + 1) * processes >= FC_SPACING * bootStopTests) ) { MPI_Barrier(MPI_COMM_WORLD); concatenateBSFiles(processes, bootstrapFileName); MPI_Barrier(MPI_COMM_WORLD); bootStopIt = computeBootStopMPI(tr, bootstrapFileName, adef, &pearsonAverage); bootStopTests++; } } #else bootStopIt = bootStop(tr, h, i, &pearsonAverage, bitVectors, treeVectorLength, vLength, adef); #endif } #ifdef _WAYNE_MPI MPI_Barrier(MPI_COMM_WORLD); bootstrapsPerformed = i * processes; bootStrapsPerProcess = i; concatenateBSFiles(processes, bootstrapFileName); removeBSFiles(processes, bootstrapFileName); MPI_Barrier(MPI_COMM_WORLD); #else bootstrapsPerformed = i; #endif rax_freeParams(tr->NumberOfModels, catParams); rax_free(catParams); rax_freeParams(tr->NumberOfModels, gammaParams); rax_free(gammaParams); if(adef->bootStopping) { freeBitVectors(bitVectors, 2 * tr->mxtips); rax_free(bitVectors); freeHashTable(h); rax_free(h); } { double t; printBothOpenMPI("\n\n"); if(adef->bootStopping) { if(bootStopIt) { switch(tr->bootStopCriterion) { case FREQUENCY_STOP: printBothOpenMPI("Stopped Rapid BS search after %d replicates with FC Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("Pearson Average of %d random splits: %f\n",BOOTSTOP_PERMUTATIONS , pearsonAverage); break; case MR_STOP: printBothOpenMPI("Stopped Rapid BS search after %d replicates with MR-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; case MRE_STOP: printBothOpenMPI("Stopped Rapid BS search after %d replicates with MRE-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; case MRE_IGN_STOP: printBothOpenMPI("Stopped Rapid BS search after %d replicates with MRE_IGN-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; default: assert(0); } } else { switch(tr->bootStopCriterion) { case FREQUENCY_STOP: printBothOpenMPI("Rapid BS search did not converge after %d replicates with FC Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("Pearson Average of %d random splits: %f\n",BOOTSTOP_PERMUTATIONS , pearsonAverage); break; case MR_STOP: printBothOpenMPI("Rapid BS search did not converge after %d replicates with MR-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; case MRE_STOP: printBothOpenMPI("Rapid BS search did not converge after %d replicates with MRE-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; case MRE_IGN_STOP: printBothOpenMPI("Rapid BS search did not converge after %d replicates with MR_IGN-based Bootstopping criterion\n", bootstrapsPerformed); printBothOpenMPI("WRF Average of %d random splits: %f\n", BOOTSTOP_PERMUTATIONS, pearsonAverage); break; default: assert(0); } } } t = gettime() - masterTime; printBothOpenMPI("Overall Time for %d Rapid Bootstraps %f seconds\n", bootstrapsPerformed, t); printBothOpenMPI("Average Time per Rapid Bootstrap %f seconds\n", (double)(t/((double)bootstrapsPerformed))); if(!adef->allInOne) { printBothOpenMPI("All %d bootstrapped trees written to: %s\n", bootstrapsPerformed, bootstrapFileName); #ifdef _WAYNE_MPI MPI_Finalize(); #endif exit(0); } } /* ML-search */ mlTime = gettime(); double t = mlTime; printBothOpenMPI("\nStarting ML Search ...\n\n"); /***CLEAN UP reduction stuff */ reductionCleanup(tr, originalRateCategories, originalInvariant); /****/ #ifdef _WAYNE_MPI restoreTL(rl, tr, n * processID); #else restoreTL(rl, tr, 0); #endif resetBranches(tr); evaluateGenericInitrav(tr, tr->start); modOpt(tr, adef, TRUE, adef->likelihoodEpsilon); #ifdef _WAYNE_MPI if(bootstrapsPerformed <= 100) fastEvery = 5; else fastEvery = bootstrapsPerformed / 20; for(i = 0; i < bootstrapsPerformed; i++) rl->t[i]->likelihood = unlikely; for(i = 0; i < bootStrapsPerProcess; i++) { j = i + n * processID; if(i % fastEvery == 0) { restoreTL(rl, tr, j); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 1); optimizeRAPID(tr, adef); saveTL(rl, tr, j); } } #else for(i = 0; i < bootstrapsPerformed; i++) { rl->t[i]->likelihood = unlikely; if(i % fastEvery == 0) { restoreTL(rl, tr, i); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 1); optimizeRAPID(tr, adef); saveTL(rl, tr, i); } } #endif printBothOpenMPI("Fast ML optimization finished\n\n"); t = gettime() - t; #ifdef _WAYNE_MPI printBothOpen("Fast ML search on Process %d: Time %f seconds\n\n", processID, t); j = n * processID; qsort(&(rl->t[j]), n, sizeof(topolRELL*), compareTopolRell); restoreTL(rl, tr, j); #else printBothOpen("Fast ML search Time: %f seconds\n\n", t); qsort(&(rl->t[0]), bootstrapsPerformed, sizeof(topolRELL*), compareTopolRell); restoreTL(rl, tr, 0); #endif t = gettime(); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); modOpt(tr, adef, TRUE, adef->likelihoodEpsilon); slowSearches = bootstrapsPerformed / 5; if(bootstrapsPerformed % 5 != 0) slowSearches++; slowSearches = MIN(slowSearches, 10); #ifdef _WAYNE_MPI if(processes > 1) { if(slowSearches % processes == 0) slowSearches = slowSearches / processes; else slowSearches = (slowSearches / processes) + 1; } for(i = 0; i < slowSearches; i++) { j = i + n * processID; restoreTL(rl, tr, j); rl->t[j]->likelihood = unlikely; evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 1.0); thoroughOptimization(tr, adef, rl, j); } #else for(i = 0; i < slowSearches; i++) { restoreTL(rl, tr, i); rl->t[i]->likelihood = unlikely; evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 1.0); thoroughOptimization(tr, adef, rl, i); } #endif /*************************************************************************************************************/ if(tr->rateHetModel == CAT) { catToGamma(tr, adef); modOpt(tr, adef, TRUE, adef->likelihoodEpsilon); } bestIndex = -1; bestLH = unlikely; #ifdef _WAYNE_MPI for(i = 0; i < slowSearches; i++) { j = i + n * processID; restoreTL(rl, tr, j); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 2); printBothOpen("Slow ML Search %d Likelihood: %f\n", j, tr->likelihood); if(tr->likelihood > bestLH) { bestLH = tr->likelihood; bestIndex = j; } } /*printf("processID = %d, bestIndex = %d; bestLH = %f\n", processID, bestIndex, bestLH);*/ #else for(i = 0; i < slowSearches; i++) { restoreTL(rl, tr, i); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 2); printBothOpen("Slow ML Search %d Likelihood: %f\n", i, tr->likelihood); if(tr->likelihood > bestLH) { bestLH = tr->likelihood; bestIndex = i; } } #endif printBothOpenMPI("Slow ML optimization finished\n\n"); t = gettime() - t; #ifdef _WAYNE_MPI printBothOpen("Slow ML search on Process %d: Time %f seconds\n", processID, t); #else printBothOpen("Slow ML search Time: %f seconds\n", t); #endif t = gettime(); restoreTL(rl, tr, bestIndex); resetBranches(tr); evaluateGenericInitrav(tr, tr->start); treeEvaluate(tr, 2); Thorough = 1; tr->doCutoff = FALSE; treeOptimizeThorough(tr, 1, 10); evaluateGenericInitrav(tr, tr->start); modOpt(tr, adef, TRUE, adef->likelihoodEpsilon); t = gettime() - t; #ifdef _WAYNE_MPI printBothOpen("Thorough ML search on Process %d: Time %f seconds\n", processID, t); #else printBothOpen("Thorough ML search Time: %f seconds\n", t); #endif #ifdef _WAYNE_MPI bestLH = tr->likelihood; printf("\nprocessID = %d, bestLH = %f\n", processID, bestLH); if(processes > 1) { double *buffer; int bestProcess; buffer = (double *)rax_malloc(sizeof(double) * processes); for(i = 0; i < processes; i++) buffer[i] = unlikely; buffer[processID] = bestLH; for(i = 0; i < processes; i++) MPI_Bcast(&buffer[i], 1, MPI_DOUBLE, i, MPI_COMM_WORLD); bestLH = buffer[0]; bestProcess = 0; for(i = 1; i < processes; i++) if(buffer[i] > bestLH) { bestLH = buffer[i]; bestProcess = i; } rax_free(buffer); if(processID != bestProcess) { MPI_Finalize(); exit(0); } } #endif printBothOpen("\nFinal ML Optimization Likelihood: %f\n", tr->likelihood); printBothOpen("\nModel Information:\n\n"); printModelParams(tr, adef); strcpy(bestTreeFileName, workdir); strcat(bestTreeFileName, "RAxML_bestTree."); strcat(bestTreeFileName, run_id); Tree2String(tr->tree_string, tr, tr->start->back, TRUE, TRUE, FALSE, FALSE, TRUE, adef, SUMMARIZE_LH, FALSE, FALSE, FALSE, FALSE); f = myfopen(bestTreeFileName, "wb"); fprintf(f, "%s", tr->tree_string); fclose(f); if(adef->perGeneBranchLengths) printTreePerGene(tr, adef, bestTreeFileName, "w"); overallTime = gettime() - masterTime; mlTime = gettime() - mlTime; printBothOpen("\nML search took %f secs or %f hours\n", mlTime, mlTime / 3600.0); printBothOpen("\nCombined Bootstrap and ML search took %f secs or %f hours\n", overallTime, overallTime / 3600.0); printBothOpen("\nDrawing Bootstrap Support Values on best-scoring ML tree ...\n\n"); freeTL(rl); rax_free(rl); calcBipartitions(tr, adef, bestTreeFileName, bootstrapFileName); overallTime = gettime() - masterTime; printBothOpen("Program execution info written to %s\n", infoFileName); printBothOpen("All %d bootstrapped trees written to: %s\n\n", bootstrapsPerformed, bootstrapFileName); printBothOpen("Best-scoring ML tree written to: %s\n\n", bestTreeFileName); if(adef->perGeneBranchLengths && tr->NumberOfModels > 1) printBothOpen("Per-Partition branch lengths of best-scoring ML tree written to %s.PARTITION.0 to %s.PARTITION.%d\n\n", bestTreeFileName, bestTreeFileName, tr->NumberOfModels - 1); printBothOpen("Best-scoring ML tree with support values written to: %s\n\n", bipartitionsFileName); printBothOpen("Best-scoring ML tree with support values as branch labels written to: %s\n\n", bipartitionsFileNameBranchLabels); printBothOpen("Overall execution time for full ML analysis: %f secs or %f hours or %f days\n\n", overallTime, overallTime/3600.0, overallTime/86400.0); #ifdef _WAYNE_MPI MPI_Finalize(); #endif exit(0); }