ALNS
ALNS copied to clipboard
Replace `RandomState` with `Generator`
Is your feature request related to a problem? Please describe
The ALNS library currently uses numpy.random
's RandomState
for random number generation. But this object is considered legacy and no longer receives updates from Numpy 1.16 onwards.
The main problem happens when users pass their own rng
to ALNS. The current default RNG from numpy is Generator
, but it has a different interface than RandomState
(e.g., integers
vs. randint
). Since we implement some acceptance criteria/operator selection schemes assuming that the RNG is a RandomState
object, users that use Generator
object will run into problems.
Describe the solution you'd like
We should replace RandomState
with Generator
.
Describe alternatives you have considered
N/A
Additional context
N/A
I think I worked around this a few years ago in SimulatedAnnealing
(but might've been somewhere else). Back then the generator interface was quite new, so I hadn't wanted to move over yet. By now I think we can just port.
Yup, here: https://github.com/N-Wouda/ALNS/blob/04991b6b2d21437992da2da415a3f98958ec9e2c/alns/accept/SimulatedAnnealing.py#L113-L118
I initially thought of supporting both RandomState and Generator like this, but since RandomState is legacy we should just replace it entirely.