-
Notifications
You must be signed in to change notification settings - Fork 1
Make library SPEC-7 compliant #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@eliotwrobson technically, this looks good. An issue that I have is that I don't really know how to treat sequences of RNG/seed instances. For example, you can now define something as follows: model, _ = networkx_to_ic_model(graph, activation_prob=0.2, rng=[1, 42]) What does it mean to have multiple RNG seeds? Should the model be run for each seed? e.g. rather than running: n_sim = 1_000
total = 0.0
for _ in range(n_sim):
# Resetting the model doesn't change the initial seed set used.
model.reset_model()
model.advance_until_completion()
total += model.get_num_activated_nodes()
avg = total / n_sim Should I now run something like the following: # Note this code could be wrong, I haven't tested it, but it gets the idea across (hopefully)
rng_seeds = [x for x in range(n_sims)]
models, _ = networkx_to_ic_model(graph, activation_prob=0.2, rng=rng_seeds)
nodes = (model.get_num_activated_nodes() for model in models)
avg = sum(nodes) / n_sims This is a domain question, and I can't answer it for you. But you should probably have a think about it. |
@Kai-Striega thanks for the feedback! I see what you mean, I'll make a couple of small changes and get back to you. |
Following up on the previous comment, the goal of the rng seeding should be to guarantee deterministic output from model execution, even after multiple runs (you want to seed once and run 1000 times). I don't think there's a use case for wanting to equip the model with a separate random seed each run, as this would make 1000 consecutive runs very slow because of rng reseeding. However, the way the models are written means that the desired behavior is already the current behavior after multiple runs (i.e., the third run after having the first initial seed is always the same, not just the first). To assert this behavior, I've added a test case that runs the model multiple times after a reseeding and asserts that each run after reseeding activates the same set of nodes. See the code below: Since @Kai-Striega had no other issues, will go ahead and merge this PR, and we can call this feature completed! |
See title, resolves #21