-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Add a method to get the current state of Random\Engine\PcgOneseq128XslRr64
engine
#17937
Comments
E.g. Python has a method to do this: https://docs.python.org/3/library/random.html#random.getstate |
All the engines (except Secure) support serialization:
results in:
|
Thanks @TimWolla. In other words if the engine needs to be restored later, you think it's more reliable to store the serialized engine and retrieve it later using deserialization than storing the state property? The only drawback I can see is that it would be less interoperable with other systems if only the state (with its seed in certain cases too) is needed to rebuild the engine. |
Serialization is the intended solution to serialize the engine state, yes. Interoperability is not really a thing either way, since the functions to turn the engine output into, say, an integer ( |
Okay, the result won't be the same if the implementation isn't exactly the same from what I understand. That makes sense now thanks for your help. |
Description
Actually a
jump
method is available to moves the algorithm’s state ahead by the number of steps given by advance. However, there are no built-in method to retrieve the current state of the algorithm.This force to keep a class that decorates this engine to save the state of the algorithm although the state is known internally (I imagine) if we want to restore the state later (e.g. when creating a new engine).
It would be a good improvement to have a
getState()
method that returns the number of steps the algorithm has already advanced.The text was updated successfully, but these errors were encountered: