aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolden Rohrer <hr@hrhr.dev>2020-01-29 23:21:05 -0500
committerHolden Rohrer <hr@hrhr.dev>2020-01-29 23:32:36 -0500
commitdf56e8a4c6b05e9f2f5c98c14af3f95a7bc6926c (patch)
tree2428ba929dc33cade13908b61251ca8796bcd959
parenta9e6a234abd6f04c76c0005aa9306db6da1b68d8 (diff)
fixed mathematical model in tools/sched
Used to keep `num` the same and decrease the sum of weight, which created an error because the value of `num` was used in dequeuing job components. This patch prevents `dequeue()` from pushing more objects than it's actually able to.
-rw-r--r--tools/schedule.js1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/schedule.js b/tools/schedule.js
index 80a6bc3..3254a24 100644
--- a/tools/schedule.js
+++ b/tools/schedule.js
@@ -87,6 +87,7 @@ exports.Queue = function(delayms, maxExport, call){
// Step 2: Start at lowest, and pop all until job.data.length>job.normweight*num (decreasing num as popping and recalc job.normweight). Delete the job.
let weightsum = jobq.map(job => job.wt).reduce((acc, cur)=>acc+cur);
while (jobq[0] && jobq[0].data.length<(jobq[0].wacc+jobq[0].wt*num/weightsum)){
+ num -= jobq[0].data.length;
weightsum -= jobq[0].wt;
dequeued.push(...jobq.shift().data);
}