mdabros / SharpLearning

Machine learning for C# .Net
MIT License
383 stars 84 forks source link

Order of results from RandomSearch is not deterministic with different iteration counts. #130

Closed mdabros closed 4 years ago

mdabros commented 4 years ago

Running the RandomSearchOptimizer with runPrallel=false, so not multithreading, with 100 iterations and 120 iterations seem to provide different order of results. Expectation would be that the fist 100 iteration would be the same, and this is not currently the case. This is most likely caused by the use of ConcurrentBag to collect the results, which does not guarantee order.

This might also affect other Optimizers supporting parallel execution,

nietras commented 4 years ago

@mdabros you need to use ConcurrentQueue this is FIFO. :) Bag is as you say unordered and should only be used in those cases where that is ok. Otherwise, ConcurrentQueue FIFO, or ConcurrentStack FILO, haven't checked your code though.