3f11aa2bf2b75edfef8247f88dc591eaaa17d6a5 kent Thu Apr 4 10:16:19 2013 -0700 Fixing a place where needed a cast to double to avoid 0.82 going to 0. Rearranging debugging output. diff --git src/kehayden/alphaAsm/alphaAsm.c src/kehayden/alphaAsm/alphaAsm.c index 5c1b7c1..9ce4ab6 100644 --- src/kehayden/alphaAsm/alphaAsm.c +++ src/kehayden/alphaAsm/alphaAsm.c @@ -485,30 +485,31 @@ } } return picked; } int totUseZeroCount = 0; struct monomer *pickRandomFromType(struct monomerType *type) /* Pick a random word, weighted by outTarget, from all available of given type */ { /* Figure out total on list */ int total = 0; struct monomerRef *ref; for (ref = type->list; ref != NULL; ref = ref->next) total += ref->val->outTarget; +verbose(3, "pickRandomFromType %s total of outTarget=%d\n", type->name, total); /* Loop through list returning selection corresponding to random threshold. */ if (total > 0) { int threshold = rand() % total; int binStart = 0; for (ref = type->list; ref != NULL; ref = ref->next) { struct monomer *monomer = ref->val; int size = monomer->outTarget; int binEnd = binStart + size; if (threshold < binEnd) return monomer; binStart = binEnd; } @@ -916,31 +917,31 @@ maxWord = hel->name; } } *retWord = maxWord; *retCount = maxCount; hashFree(&countHash); } boolean subCommonCenter(struct alphaStore *store, struct monomer *center, struct monomerRef *neighborhood, struct dlList *ll) /* Scan list for places where have all items in neighborhood (except for center) matching. * Substitute in center at one of these places chosen at random and return TRUE if possible. */ { struct slRef *centerRefList = refsToPossibleCenters(center, neighborhood, ll); verbose(4, "sub %s in neighborhood: ", center->word); -if (verboseLevel() >= 3) +if (verboseLevel() >= 4) printMonomerRefList(neighborhood, stderr); verbose(4, "Got %d possible centers\n", slCount(centerRefList)); if (centerRefList == NULL) return FALSE; int commonCount = 0; char *commonWord = NULL; mostCommonMonomerWord(centerRefList, &commonWord, &commonCount); struct monomer *commonMonomer = hashFindVal(store->monomerHash, commonWord); verbose(4, "Commonest word to displace with %s is %s which occurs %d times in context and %d overall\n", center->word, commonWord, commonCount, commonMonomer->subbedOutCount); if (commonMonomer->subbedOutCount < 2) { verbose(3, "Want to substitute %s for %s, but %s only occurs %d time.\n", center->word, commonWord, commonWord, commonMonomer->subbedOutCount); return FALSE; @@ -1551,31 +1552,31 @@ { char *word = mon->word; if (startsWith(orderedPrefix, word) && !hashLookup(orderHash, word)) { errAbort("%s is in %s but not %s", word, readFile, typeFile); } } hashFree(&orderHash); } void monomerListNormalise(struct monomer *list, int totalCount, int outputSize) /* Set outTarget field in all of list to be normalized to outputSize */ { struct monomer *monomer; -double scale = outputSize/totalCount; +double scale = (double)outputSize/totalCount; for (monomer = list; monomer != NULL; monomer = monomer->next) { monomer->outCount = 0; monomer->outTarget = round(scale * monomer->useCount); } } void alphaStoreNormalize(struct alphaStore *store, int outputSize) /* Set up output counts on each word to make sure it gets it's share of output size */ { struct wordTree *wt = store->markovChains; wordTreeNormalize(wt, outputSize, 1.0); monomerListNormalise(store->monomerList, wt->useCount, outputSize); }