Nth-iteration-labs/streamingbandit

Adding a seed to simulation handler

Closed this issue · 1 comments

We would like to add a parameter to set a seed for the numpy random generator when using experiments in the simulation handler. This would be useful since we could replicate the simulations.

I've been trying to implement this directly in the simulation handler, but the problem is that the "import numpy as np" import does not exist in the scope of the code that is being executed. I think this is due to the fact that we run the simulation code inside the Experiment class (i.e., we do EXP.run_action_code(context), which in itself runs the exec() function).

If anyone has an idea as a workaround for this, please let me know.

Apparently setting a seed for the generator makes it so that the seed is usable on different places. So now we set a seed at the beginning of the simulation (if provided) and set a new random seed when the simulation is done.