#include #include #include #include #include #include #include using namespace std; using namespace stdext; using namespace boost; map tokens; map tags; vector tags2int; int nowtokenID = 1; int nowtagID = 0; const int maxsufflen = 2; // Tillståndet EFTER anrop med viss input är fullständigt deterministiskt // Delta-tillstånd mellan före och efter anrop är det däremot inte. // const innebär det första, men brukar ibland implicera även det andra const int tokenCode(string token) { map::iterator i; if ((i = tokens.find(token)) == tokens.end()) { tokens[token] = nowtokenID; return nowtokenID++; } return i->second; } const int tagCode(string tag) { map::iterator i; if ((i = tags.find(tag)) == tags.end()) { tags[tag] = nowtagID; tags2int.push_back(tag); printf("%d\n", nowtagID); return nowtagID++; } return i->second; } const int masklistan[4] = {0, 1048575, (1 << 30) - 1048575, (1 << 30) - 1}; typedef pair wordpair; class word_sequence { public: int data[4]; word_sequence() { for (int x = 0; x < 4; x++) { data[x] = -1; } } inline operator wordpair() const { return make_pair( (((long long) data[0]) << 32) + data[1], (((long long) data[2]) << 32) + data[3]); } inline operator size_t() const { size_t result = 0; for (int x = 0; x < 4; x++) { result = (result << 1) + ((result & (1 << 31)) > 0); result ^= data[x]; } return result; } void push_back(int word, int tag) { for (int x = 1; x < 4; x++) { data[x - 1] = data[x]; } data[3] = word + (tag << 20); } void mask(int mask, word_sequence& dest) { for (int x = 0; x < 4; x++) { dest.data[x] = (data[x] & masklistan[(mask & 3)]); mask >>= 2; } } bool inline operator <(const word_sequence& seq2) const { const word_sequence& seq1 = *this; for (int x = 0; x < 4; x++) { int diff = seq1.data[x] - seq2.data[x]; if (diff == 0) continue; return diff < 0; } return false; } bool operator ==(const word_sequence& seq2) const { const word_sequence& seq1 = *this; for (int x = 0; x < 4; x++) { int diff = seq1.data[x] - seq2.data[x]; if (diff == 0) continue; return false; } return true; } }; typedef double Cdouble; typedef vector, pool_allocator, default_user_allocator_new_delete, details::pool::null_mutex, 131072> > partvector; typedef map, less, fast_pool_allocator >, default_user_allocator_new_delete, details::pool::null_mutex, 131072> > DATATYPE; const int end = 192; DATATYPE data[end * (maxsufflen + 1)]; bool goodlist[256]; void makegood() { for (int x = 0; x < 256; x++) { int count = 0; int count2 = 0; int y = x; for (int z = 0; z < 4; z++) { if (y & 1) { count++; } if (y & 2) { count2++; } if ((y & 1) && (((y & 3) == 3) ^ z < 2)) { goto end; } y >>= 2; } printf("%d %d\n", count, count2); if (x & 32) count += 5; // Värde under fem i stället hjälper inte så mycket. // En gång 6519, 993 mot 6516, 990, repade sig snabbt mot 6518, 993 goodlist[x] = (count + count2 < 5); // 3 är dock lite lågt. end:; } } const inline int countindex(Cdouble count) { if (count < 4) { return 0; } if (count < 10) { return 1; } if (count < 50) { return 2; } return 3; } const inline int countprob(Cdouble prob) { if (prob > 0.98) return 0; if (prob > 0.82) return 1; if (prob > 0.50) return 2; return 3; /*if (prob > 0.99) return 0; if (prob > 0.93) return 1; if (prob > 0.70) return 2; return 3;*/ } int wl = 0; Cdouble matrix[(maxsufflen + 1) * end][4][4][2]; bool anyatall[(maxsufflen + 1) * end][4][4]; Cdouble laststep[(maxsufflen + 1) * end][4][4][2]; int gsuccu, gsucck, gknown; inline int likelyTac(int toc) { int x = 16; // Hehe, kopiera mera! word_sequence mainseq, refseq, refseq2; mainseq.push_back(toc, 0); mainseq.push_back(0, 0); mainseq.mask(x, refseq); DATATYPE::iterator i; if ((i = data[x].find(refseq)) == data[x].end()) { // printf("BLÄÄÄ!\n"); return -2; } Cdouble sum = i->second.first; int maxtag = -1; double maxvalue = 0; for (partvector::iterator j = i->second.second.begin(); j != i->second.second.end(); j++) { if (maxvalue < j->second) { maxvalue = j->second; maxtag = j->first; } } return maxtag; } const int maxlen = 14000; const int BC = 2; // beforecount int prevals[maxlen][3]; char tokenlist[maxlen][256]; vector gamla[BC * BC]; Cdouble gamlascores[maxlen][BC * BC][148][2]; int maxbearer[maxlen][BC]; int maxindex[maxlen][BC]; pair tag(Cdouble* require, int xchange, Cdouble* value) { FILE* fil = fopen("eval.txt", "r"); char tlf[2048]; word_sequence mainseq[BC * BC], refseq[BC * BC], refseq2[BC * BC], mainseq2[BC * BC]; Cdouble factor[BC * BC]; for (int n = 0; n < BC * BC; n++) factor[n] = 1; int toC = -1; int taC = 0; int lasttaC = -1; int lasttoC = 0; int succk = 0; int succu = 0; int tot = 0; int known = 0; Cdouble corrsum = 0; char* oldtoken = ""; LARGE_INTEGER tick, tick2; int size = gamla[0].size(); Cdouble scores[2] = {0, 0}; while (/*QueryPerformanceCounter(&tick) && */((tot < size) || (size == 0 && !feof(fil) && fgets(tlf, 2048, fil)))) { char* token = tokenlist[tot]; char tag[256]; lasttoC = toC; lasttaC = taC; for (int subindex = 0; subindex < BC * BC; subindex++) { mainseq[subindex] = mainseq2[subindex]; mainseq[subindex].push_back(lasttoC, (lasttaC == -1) ? -1 : -2); } if (tot >= gamla[0].size()) { if (sscanf(tlf, "%256s %256s", token, tag) == 2) { prevals[tot][0] = tokenCode(token); prevals[tot][1] = taC = tagCode(tag); } else { prevals[tot][0] = 0; prevals[tot][1] = -1; } prevals[tot][2] = (taC == -1) ? -1 : likelyTac(prevals[tot][0]); } toC = prevals[tot][0]; taC = prevals[tot][1]; bool thisknown = (lasttoC < wl) && (lasttoC > 0); known += thisknown; int len = strlen(oldtoken); for (int subindex = 0; subindex < BC * BC; subindex++) { mainseq[subindex].push_back(toC, prevals[tot][2]); if (!lasttoC) continue; int lastnotfound = 0xff; bool matching = tot < gamla[0].size() && (gamla[subindex][tot] == mainseq[subindex]) && (xchange <= end * (maxsufflen + 1)); if (!matching) { for (int x = 0; x < nowtagID; x++) { gamlascores[tot][subindex][x][0] = 0.0; gamlascores[tot][subindex][x][1] = 1.0; } } if ((!matching || (thisknown ^ (xchange >= end)))) for (int x = 1 + matching * ((xchange % end) - 1); x < end + (-end + 1 + (xchange % end)) * matching; x++) { if (!goodlist[x]) continue; /*if ((x & 16) && !thisknown) { continue; }*/ /*if ((x & lastnotfound) == lastnotfound) { continue; }*/ bool suffix = (x & 16) && (!thisknown); if (suffix) { mainseq[subindex].mask(x - 16, refseq[subindex]); } else { mainseq[subindex].mask(x, refseq[subindex]); } int snum = 1; for (int suff = suffix; suff < 1 + maxsufflen * suffix; suff++) { if (suffix) { if (len - suff <= 0) break; refseq[subindex].data[2] += ((((int) oldtoken[len - suff]) + 256) % 32) * snum; snum *= 32; } DATATYPE::iterator i; int dataindex = x + end * (suff * suffix); if ((i = data[dataindex].find(refseq[subindex])) == data[dataindex].end()) { if (data[dataindex].size() && suff <= 1) lastnotfound = x; break; } int index = x + end * ((!thisknown) + (suff - 1) * suffix); if (matching && index != xchange) continue; Cdouble sum = i->second.first; for (partvector::iterator j = i->second.second.begin(); j != i->second.second.end(); j++) { int i = countprob(j->second / sum) * 4 + countindex(j->second); anyatall[index][0][i] = true; for (int i2 = 0; i2 < 2; i2++) { Cdouble addition = j->second * (matching ? value[i * 2 + i2] : matrix[index][0][i][i2]); gamlascores[tot][subindex][j->first][i2] += addition; } } } } } oldtoken = token; if (!size) { for (int subindex = 0; subindex < BC * BC; subindex++) gamla[subindex].resize(tot + 1); } for (int subindex = 0; subindex < BC * BC; subindex++) gamla[subindex][tot] = mainseq[subindex]; Cdouble max[BC]; int oldmaxbearer[BC]; for (int q = 0; q < BC; q++) { max[q] = 0; oldmaxbearer[q] = maxbearer[tot][q]; maxbearer[tot][q] = -1; maxindex[tot][q] = 0; } if (lasttoC != 0) { Cdouble sums[BC][BC]; Cdouble sum = 0; for (int y = -BC; y < nowtagID; y++) { int x = y; if (x < 0) { x = oldmaxbearer[-x - 1]; if (x < 0) continue; } //if (!allow[x] && thisknown) continue; Cdouble vals[BC * BC]; Cdouble val = 0; for (int subindex = 0; subindex < BC * BC; subindex++) { val += (vals[subindex] = gamlascores[tot][subindex][x][0] * gamlascores[tot][subindex][x][1] * factor[subindex]); } val *= matrix[(end * (!thisknown + 1)) - 1][0][0][31 - x]; bool alreadydone = val < max[BC - 1]; for (int index = 0; index < BC; index++) { if (x == maxbearer[tot][index] || (y >= 0 && x == oldmaxbearer[index])) goto endloop2; if (!alreadydone && val > max[index]) { if (maxbearer[tot][index] != -1) { for (int index2 = BC - 1; index2 > index; index2--) { max[index2] = max[index2 - 1]; maxbearer[tot][index2] = maxbearer[tot][index2 - 1]; maxindex[tot][index2] = maxindex[tot][index2 - 1]; for (int subindex = 0; subindex < BC; subindex++) { sums[index2][subindex] = sums[index2 - 1][subindex]; } } } max[index] = val; maxbearer[tot][index] = x; for (int pindex = 0; pindex < BC; pindex++) { sums[index][pindex] = 0; for (int index2 = 0; index2 < BC; index2++) sums[index][pindex] += vals[pindex * BC + index2]; sums[index][pindex] *= matrix[(end * (!thisknown + 1)) - 1][0][0][31 - x]; } maxindex[tot][index] = 0; for (int pindex = 1; pindex < BC; pindex++) { if (sums[index][pindex] > sums[index][maxindex[tot][index]]) { maxindex[tot][index] = pindex * BC; } } break; } } sum += val; endloop2:; } word_sequence mainseq3[BC * BC]; Cdouble factorsum = 0; // Det kan finnas vissa dubbletter, egentligen. /*for (int pindex = 0; pindex < BC; pindex++) { for (int pindex2 = pindex + 1; pindex2 < BC; pindex2++) { if (maxbearer[pindex] == maxbearer[pindex2]) { printf("%d %d %d %d\n", tot, pindex, pindex2, maxbearer[pindex2]); } } }*/ bool found = false; for (int pindex = 0; pindex < BC; pindex++) // TODO { // succk += (maxbearer[tot][pindex] == lasttaC) * (/*BC - pindex*/1) * thisknown/* * (!pindex)*/; // succu += (maxbearer[tot][pindex] == lasttaC) * (/*BC - pindex*/1) * (!thisknown)/* * (!pindex)*/; for (int subindex = 0; subindex < BC; subindex++) { //mainseq3[pindex * BC + subindex] = mainseq2[maxindex[tot][pindex] + subindex]; mainseq3[pindex * BC + subindex] = mainseq2[subindex * BC]; // TODO mainseq3[pindex * BC + subindex].push_back(lasttoC, maxbearer[tot][pindex]); /*if (subindex && mainseq3[pindex * BC + subindex] == mainseq3[pindex * BC + subindex - 1]) { printf("%d %d %d\n", pindex, subindex, tot); }*/ factorsum += (factor[pindex * BC + subindex] = sums[pindex][subindex]); } found |= (maxbearer[tot][pindex] == lasttaC); } if (factorsum == 0) { for (int index = 0; index < BC * BC; index++) { factor[index] = 1; } factorsum = BC * BC; } if (maxindex[tot][0]) // Maxfaktorn först { swap(factor[maxindex[tot][0] / BC], factor[0]); swap(mainseq3[maxindex[tot][0] / BC], mainseq3[0]); } for (int pindex = 0; pindex < BC * BC; pindex++) // TODO { factor[pindex] /= factorsum; scores[tot & 1] += (-1 + 2 * (maxbearer[tot][pindex / BC] == lasttaC)) * factor[pindex] * (1/* + (pindex == 0)*/); mainseq2[pindex] = mainseq3[pindex]; } if (!found) scores[tot & 1] -= 3 * factorsum / sum; /*if (factor[0] < factor[1]) { printf("%d\n", tot); } if (factor[0] + factor[1] + factor[2] < factor[3] + factor[4] + factor[5]) { printf("Q: %d\n", tot); }*/ //corrsum += (lasttaC == maxbearer) * (max / sum); if (sum == 0) sum = 1; // corrsum += (gamlascores[tot][lasttaC][0] * gamlascores[tot][lasttaC][1] + (-1 + 1 * (lasttaC == maxbearer)) * max) / sum; /* if (lasttoC >= wl) { succu += lasttaC == maxbearer; } else { succk += lasttaC == maxbearer; }*/ } else { for (int subindex = 0; subindex < BC * BC; subindex++) { mainseq2[subindex].push_back(0, -1); mainseq2[subindex].push_back(0, -1); mainseq2[subindex].push_back(0, -1); mainseq2[subindex].push_back(0, -1); factor[subindex] = 1.0 / BC * BC; } } tot++; /*QueryPerformanceCounter(&tick2); tick2.QuadPart -= tick.QuadPart; if (xchange > 5) printf("%lld\n", tick2.QuadPart);*/ //printf("%s (%d) ", token, toC); } lasttaC = -1; // corrsum += ((double) (succk + succu)) / 16 ; succk = 0; succu = 0; for (int x = 0; x < 2; x++) { scores[x] /= 128; //scores[x] += succk + succu; } int* succs[2] = {&succk, &succu}; for (tot--; tot > 0; tot--) { for (int i = 0; i < BC; i++) { if (lasttaC == -1 || maxbearer[tot][i] == lasttaC) { lasttaC = maxbearer[tot][i]; bool thisknown = (prevals[tot - 1][0] && prevals[tot - 1][0] <= wl); if (prevals[tot - 1][0]) { (*succs[thisknown]) += (lasttaC == prevals[tot - 1][1]); scores[tot & 1] += (lasttaC == prevals[tot - 1][1]); } lasttaC = gamla[maxindex[tot][i]][tot].data[1] >> 20; int toc = gamla[maxindex[tot][i]][tot].data[1] & 1048575; if (toc == 0) lasttaC = -1; break; } } } // printf("%d\t%d\n", known, cnt); /*printf("%d + %d / %d + %d, %lf\n", succu, succk, known, tot - known, ((Cdouble) succk + succu) / tot);*/ fclose(fil); gsuccu = succu; gsucck = succk; gknown = known; return make_pair(scores[0], scores[1]); } int main(int argc, char** argv) { makegood(); FILE* fil = fopen("train.txt", "r"); char tlf[2048]; word_sequence mainseq, refseq; int line = 0; char oldtoken[256] = {0}; int tt = 0; while (!feof(fil) && fgets(tlf, 2048, fil)) { line++; char token[256]; char tag[256]; int toC; int taC; if (sscanf(tlf, "%256s %256s", token, tag) == 2) { toC = tokenCode(token); taC = tagCode(tag); } else { toC = 0; taC = -1; } int len = strlen(oldtoken); mainseq.push_back(toC, taC); for (int x = 1; x < end; x++) { if (!goodlist[x]) continue; mainseq.mask(x, refseq); int snum = 1; for (int suff = 0; suff <= maxsufflen; suff++) { int count = (bool) (x & 1); count += (bool) (x & 4); count += (bool) (x & 64); int count2 = (bool) (x & 2); count2 += (bool) (x & 8); count2 += (bool) (x & 128); //if (suff >= 1 && count * 2 + count2 >= 4) break; if (suff >= 1 && !(x & 16)) { break; } else { if (suff == 1) { mainseq.mask(x - 16, refseq); } if (suff >= 1) { if (len - suff <= 0) break; refseq.data[2] += ((((int) oldtoken[len - suff]) + 256) % 32) * snum; snum *= 32; } //if (suff == 1) continue; } DATATYPE::iterator i; if ((i = data[x + end * suff].find(refseq)) == data[x + end * suff].end()) { i = data[x + end * suff].insert(make_pair(refseq, make_pair(0, 0))).first; } int newtaC = mainseq.data[2] >> 20; for (partvector::iterator j = i->second.second.begin(); j != i->second.second.end(); j++) { if (j->first == newtaC && j->second < 65535) { i->second.first++; j->second++; if (j->second == 65535) printf("Hej!\n"); goto dontadd; } } if (newtaC >= 0) { i->second.second.push_back(make_pair(newtaC, 1)); } /*if (i->second.second.size() > 8) { printf("%d %d %d\n", x + end * suff, i->second.second.size(), i->second.second.capacity()); }*/ else { dontadd:; /*if (suff == 0) { break; }*/ } } } strcpy(oldtoken, token); /*if (tokens.size() % 2048 == 0) { printf("%s ", token); break; }*/ if (toC == 0) { mainseq.push_back(0, -1); mainseq.push_back(0, -1); mainseq.push_back(0, -1); mainseq.push_back(0, -1); } } for (int x = 0; x < 256; x++) if (goodlist[x]) printf("%d %d %d\n", tokens.size(), x, data[x].size()); for (int x = 0; x < (maxsufflen + 1) * end; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { for (int i2 = 0; i2 < 2; i2++) { matrix[x][y][z][i2] = 1 / (1.0 + 16383.0 * (i2 && (x % end) < end - 5)); laststep[x][y][z][i2] = -1.9; } } } } /*for (int x = 0; x < 16; x++) { matrix[21][0][x] = 10000; matrix[20][0][x] = 1000; matrix[16][0][x] = 100; }*/ if (argc > 1) { for (int x = 0; x < (maxsufflen + 1) * end; x++) { for (int y = 0; y < 4; y++) { for (int z = 0; z < 4; z++) { for (int i2 = 0; i2 < 2; i2++) { laststep[x][y][z][i2] = -1.05; } } } } FILE* ut = fopen(argv[1], "rb"); printf("VAL: %d\n", fread(matrix, sizeof(Cdouble)*((maxsufflen + 1) * end)*16*2, 1, ut)); fclose(ut); /*for (int x = 1; x < 96; x++) for (int i = 0; i < 16; i++) matrix[x + 96][0][i] = matrix[x][0][i];*/ } wl = nowtokenID; int pass = /*496*/0; Cdouble setback = 1.0001f; Cdouble maxlimit = 4096; double div = 1; Cdouble require[2]; srand(time(0)); Cdouble lim = 1024*1024*1024.0f*262144; /*for (int x = 1; x < 2 * end + 1; x++) for (int i = 0; i < 16; i++) { matrix[x][0][i] = max(matrix[x][0][i], 1.0f/lim); matrix[x][0][i] = min(matrix[x][0][i], lim); }*/ while (true) { /*for (int x = 0; x < 512; x++) for (int y = 0; y < 4; y++) for (int z = 0; z < 4; z++) { matrix[x][y][z] = 0/* + (x & 16)*/; /* } Cdouble last = tag(require, end * 2 + 1, 0, 0); for (int x = 0; x < 385; x++) if ((goodlist[x % end] || x == 2 * end) && x != end && (x < end || (!((x % end) & 16)))) for (int y = 0; y < 4; y++) for (int z = 0; z < 4; z++) { matrix[x][y][z] = 0.1/* + (x & 16)*/; /* last = tag(require, x, y * 4 + z, 0.1); pass++; printf("Entering: %d, %d, %lf, %d, %d, %d\n", 0, pass, last, gsuccu, gsucck, gknown); } for (int x = 384; x >= 0; x--) if ((goodlist[x % end] || x == 2 * end) && x != end && (x < end || (!((x % end) & 16)))) for (int y = 0; y < 4; y++) for (int z = 0; z < 4; z++) { matrix[x][y][z] = 1/* + (x & 16)*/; /* last = tag(require, x, y * 4 + z, 0.9); pass++; printf("Entering: %d, %d, %lf, %d, %d, %d\n", 0, pass, last, gsuccu, gsucck, gknown); }*/ Cdouble value[32]; for (int x = 0; x < 32; x++) value[x] = 0; pair last = tag(require, end * (maxsufflen + 1) + 1, value); last = tag(require, end * (maxsufflen + 1) + 1, value); pass++; printf("Entering: %d, %d, %lf, %d, %d, %d\n", 0, pass, last.first + last.second, gsuccu, gsucck, gknown); double sum = 0; double sum2 = 0; int c = 0; int bc = 0; __int64 minval = 1048576; for (int x = 1; x < end * (maxsufflen + 1); x++) // TODO { //if ((goodlist[x % end]) && x != end && (x < 2 * end || (x & 16)) && data[x].size() || () if ((goodlist[x % end] || (x < end * 2 && (x % end >= end - 5))) && ((x < end * 2 && (x % end >= end - 5)) || data[x].size() || (x / end == 1 && data[x - end].size()))) { for (int i = 0; i < 16; i++) { if (!anyatall[x][0][i] && (x % end < end - 5)) { continue; } for (int i2 = 0; i2 < 2; i2++) { Cdouble abs = fabs(laststep[x][0][i][i2]) / maxlimit; if (abs > 32) { abs = 0; laststep[x][0][i][i2] = setback * ((rand() / (RAND_MAX / 2)) ? 1 : -1); maxlimit *= 1.00001f; } Cdouble oldstep = laststep[x][0][i][i2]; if (abs > 1.0/64.0) { laststep[x][0][i][i2] *= -7.0f; } else if (abs > 1.0/256.0) { laststep[x][0][i][i2] *= -5.0f; } else if (abs > 1.0/1024.0) { laststep[x][0][i][i2] *= -4.0f; } else if (abs > 1.0/3072.0) { laststep[x][0][i][i2] *= -2.5f; } else if (abs > 1.0/4000.0) { laststep[x][0][i][i2] *= -1.18f; } else { laststep[x][0][i][i2] *= -1.04f; } //printf("%f ",laststep[x][0][i]); laststep[x][0][i][i2] = (((laststep[x][0][i][i2] + oldstep) / 2) / RAND_MAX * rand()) - oldstep; sum2 += fabs(laststep[x][0][i][i2]); if (fabs(laststep[x][0][i][i2]) < 1.3) c++; //printf("%f %f\n", oldstep, laststep[x][0][i]); Cdouble old = matrix[x][0][i][i2]; /* Cdouble add = 0.001f * pass; if (laststep[x][0][i] < 0) { laststep[x][0][i] = -1 - add; } else { laststep[x][0][i] = 1 + add; }*/ if (laststep[x][0][i][i2] < 0) { /*if (require[1] < laststep[x][0][i]) { printf("Hej!"); continue; }*/ matrix[x][0][i][i2] /= -laststep[x][0][i][i2]; } else { /*if (require[0] > laststep[x][0][i]) { printf("HEj!"); continue; }*/ matrix[x][0][i][i2] *= laststep[x][0][i][i2]; } matrix[x][0][i][i2] = max(matrix[x][0][i][i2], 1.0f/lim); matrix[x][0][i][i2] = min(matrix[x][0][i][i2], lim); /*LARGE_INTEGER tick, tick2; QueryPerformanceCounter(&tick);*/ value[i * 2 + i2] = matrix[x][0][i][i2] - old; pair next = tag(require, x, value); for (int x = 0; x < 32; x++) { value[x] = 0; } if ((next.first < last.first/* + 0.00000001*/ || next.second < last.second /*+ 0.00000001*/) || (next.first <= last.first && next.second <= last.second)) //if (next.first + next.second < last.first + last.second) { Cdouble temp = matrix[x][0][i][i2]; matrix[x][0][i][i2] = old; value[i * 2 + i2] = old - temp; } else { if (bc != (int) (next.first + next.second)) { bc = (int) (next.first + next.second); char tlf[255]; sprintf(tlf, "%lf", last); FILE* ut = fopen("utfil.tbl", "wb"); fwrite(matrix, sizeof(Cdouble) * ((maxsufflen + 1) * end) * 16 * 2, 1, ut); fclose(ut); printf("%d\t%d\t%d\t%lf\t%lf\t%lf\t%d\t%d\n", x, i, i2, matrix[x][0][i][i2], laststep[x][0][i][i2], next.first + next.second, gsucck, gsuccu); fflush(stdout); } last = next; //laststep[x][0][i][i2] = oldstep; // This was good, let's do it again! if (fabs(laststep[x][0][i][i2]) > 1.18) laststep[x][0][i][i2] = setback * ((rand() / (RAND_MAX / 2)) ? 1 : -1); } /*QueryPerformanceCounter(&tick2); tick2.QuadPart -= tick.QuadPart; minval = min(tick2.QuadPart, minval);*/ //printf("%lld\n", minval); sum += matrix[x][0][i][i2]; } } bool run = false; for (int x = 0; x < 32; x++) { run |= (value[x] != 0); } if (run) last = tag(require, x, value); for (int x = 0; x < 32; x++) { value[x] = 0; } } } printf("Vikt!\t%lf\t%lf\t%d\t%lf\n", sum, sum2, c, maxlimit); if (pass == 59) ExitProcess(0); } } // 736