diff --git a/src/Balances.ts b/src/Balances.ts index 24152ae..da4bf03 100644 --- a/src/Balances.ts +++ b/src/Balances.ts @@ -99,9 +99,11 @@ export class Balances { const sent = this.sent[friend] || 0n; const received = this.received[friend] || 0n; if ((sent > 0) && (received > 0)) { + // console.log(`${name} has pos bilateral with ${friend}, min(${sent}, ${received}) = ${bigIntMin(sent, received)}`); num++; amount += bigIntMin(sent, received); } else if ((sent < 0) && (received < 0)) { + // console.log(`${name} has neg bilateral with ${friend}, max(${sent}, ${received}) = ${bigIntMax(sent, received)}`); num++; amount += bigIntMax(sent, received); } diff --git a/src/SingleThread.ts b/src/SingleThread.ts index 1cbfc8b..87766b1 100644 --- a/src/SingleThread.ts +++ b/src/SingleThread.ts @@ -82,8 +82,8 @@ export class SingleThread { stats.transfersReceived += workerStats.transfersReceived; stats.transfersSent += workerStats.transfersSent; stats.transferAmount += workerStats.transferAmount; - stats.bilateralNum += workerStats.bilateralNum; - stats.bilateralAmount += workerStats.bilateralAmount; + stats.bilateralNum += workerStats.bilateralNum / 2; + stats.bilateralAmount += workerStats.bilateralAmount / 2; stats.multilateralNum += workerStats.multilateralNum; stats.multilateralAmount += workerStats.multilateralAmount; stats.numNodes += workerStats.numNodes; diff --git a/src/Worker.ts b/src/Worker.ts index e14b7de..af70678 100644 --- a/src/Worker.ts +++ b/src/Worker.ts @@ -169,7 +169,7 @@ export class Worker { stats.multilateralAmount += this.ourNodes[name].multilateralAmount; stats.numNodes++; }); - console.log(`Worker ${this.workerNo} return stats`, stats); + // console.log(`Worker ${this.workerNo} return stats`, stats); return stats; } getNode(name: string): Jerboa { diff --git a/src/jerboaChallenge.ts b/src/jerboaChallenge.ts index 57b924d..0553269 100644 --- a/src/jerboaChallenge.ts +++ b/src/jerboaChallenge.ts @@ -19,9 +19,9 @@ async function runSingleThread(numWorkers: number): Promise { } console.log(`${stats.transfersSent} transfers between ${stats.numNodes} participants triggered an average of ${(stats.messagesSent / stats.transfersSent).toFixed(2)} messages each`); console.log(`Transfer amount ${Math.round(stats.transferAmount)}`); - console.log(`${Math.round((stats.bilateralAmount / stats.transferAmount)*100)}% netted bilaterally`); + console.log(`${Math.round((stats.bilateralAmount / stats.transferAmount)*100)}% netted in total`); console.log(`${Math.round((stats.multilateralAmount / stats.transferAmount)*100)}% netted multilaterally`); - console.log(`${Math.round((1 - (stats.bilateralAmount + stats.multilateralAmount) / stats.transferAmount)*100)}% not netted`); + console.log(`${Math.round((1 - (stats.bilateralAmount) / stats.transferAmount)*100)}% not netted`); console.log(stats); }