Some refactoring to include best practice JavaScript implementation. In the end I managed to avoid the issue of execution times varying depending on whether the solver was already used before or not. There is still some variation, but much smaller than before:
Benchmark on my machine, when running problems in batch:
The monster problem gets solved in 65 ms now, used to be 165ms.
The monster II problem gets solved in 28 seconds, used to be 108 seconds.
The monster II problem gets solved faster even when solved alone: 28 seconds instead of 42 seconds before.
It looks like batching problems now only have a minor impact (although still present) on execution time.
Note: I did refactor for readability, because I needed to understand what was going on. Let me know if the style bothers you.
Some refactoring to include best practice JavaScript implementation. In the end I managed to avoid the issue of execution times varying depending on whether the solver was already used before or not. There is still some variation, but much smaller than before:
It looks like batching problems now only have a minor impact (although still present) on execution time.
Note: I did refactor for readability, because I needed to understand what was going on. Let me know if the style bothers you.