fast
This commit is contained in:
parent
0552a81c72
commit
354a9e75d2
1 changed files with 21 additions and 14 deletions
37
rank.js
37
rank.js
|
@ -5,6 +5,7 @@ function rankCalc(result, iterations = 10) {
|
|||
let fng = {};
|
||||
let fnc = {};
|
||||
let frs = {};
|
||||
let frsEasy = {};
|
||||
let msum_old = 0.001;
|
||||
let pr = {};
|
||||
|
||||
|
@ -34,9 +35,8 @@ function rankCalc(result, iterations = 10) {
|
|||
|
||||
let mm = (process.env.matrixIterations || iterations);
|
||||
|
||||
let discarded = 0;
|
||||
let rl = Object.keys(result).length;
|
||||
|
||||
let thk = Object.keys(result).length;
|
||||
for (let i = 0; i < mm; i++) {
|
||||
let prold = pr;
|
||||
let matrixf = matrixe;
|
||||
|
@ -44,9 +44,8 @@ function rankCalc(result, iterations = 10) {
|
|||
pr = [];
|
||||
matrixe = [];
|
||||
let msum = 1;
|
||||
let intv = Math.pow(1/1000,Math.pow(0.25, i / Math.sqrt(mm)));
|
||||
console.log(`Completed ${i} iterations with ${intv} threshold and ${discarded * 100}% discard rate`)
|
||||
discarded = 0;
|
||||
let intv = Math.pow(0.35 / rl, Math.pow(0.1, i / mm));
|
||||
console.log(`Completed ${i} iterations with ${intv} threshold`)
|
||||
|
||||
let th = -1;
|
||||
for (let una in result) {
|
||||
|
@ -56,25 +55,33 @@ function rankCalc(result, iterations = 10) {
|
|||
if (frs[una].length == 0) {
|
||||
pr[una] = prold[una];
|
||||
matrixe[una] = matrixf[una];
|
||||
discarded += 1 / thk
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let unb in result) {
|
||||
let prb = prold[unb];
|
||||
matrixe[una][unb] = 0.03;
|
||||
let ar = Object.keys(result);
|
||||
let rf = pr[una];
|
||||
|
||||
if (prb < intv || fnc[unb] == 0) {
|
||||
pr[una] = prold[una];
|
||||
discarded += Math.pow(thk,-2) * 0.9;
|
||||
for (let unb of ar) {
|
||||
let prb = prold[unb];
|
||||
|
||||
matrixe[una][unb] = 0.03;
|
||||
msum += 0.03;
|
||||
|
||||
if (prb * matrixf[una][unb] < intv || fnc[unb] == 0) {
|
||||
let mfb = matrixf[una][unb];
|
||||
if (isNaN(mfb) || !mfb) continue;
|
||||
pr[una] += prb * mfb;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (let unc in result) {
|
||||
matrixe[una][unb] += matrixf[una][unc] * matrixf[unc][unb];
|
||||
let mfc = matrixf[una][unc];
|
||||
let mfb = matrixf[unc][unb];
|
||||
if (isNaN(mfc) || isNaN(mfb) || !mfc || !mfb) continue;
|
||||
matrixe[una][unb] += mfc * mfb;
|
||||
}
|
||||
|
||||
msum += matrixe[una][unb];
|
||||
msum += matrixe[una][unb] - 0.03;
|
||||
pr[una] += prb * matrixe[una][unb];
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +95,7 @@ function rankCalc(result, iterations = 10) {
|
|||
}
|
||||
}
|
||||
|
||||
let new_sum = Object.values(pr).reduce((a, b) => a + b, 0)
|
||||
let new_sum = Object.values(pr).filter(x => !isNaN(x)).reduce((a, b) => a + b, 0)
|
||||
|
||||
for (let unn in result) {
|
||||
pr[unn] /= new_sum;
|
||||
|
|
Loading…
Reference in a new issue