Skip to content
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

Allow for Neighborhood to split into identical states #30

Open
teald opened this issue Nov 9, 2022 · 0 comments
Open

Allow for Neighborhood to split into identical states #30

teald opened this issue Nov 9, 2022 · 0 comments
Labels
enhancement New feature or request major change significant/breaking changes proposal Changes proposed, not planned.

Comments

@teald
Copy link
Owner

teald commented Nov 9, 2022

It would be useful to spawn new Neighborhoods (and corresponding data) on command.

Motivation and example

I have an extant Neighborhood object, nbr, that I want to stop at some point and then feed two different inputs. Currently, if I wanted to manage this I'd need two instances to get the job done. This is a hassle if any initializations are required that take appreciable time. It would be easier to initialize a single Neighborhood and then have it run the two cases in tandem.

Consider the following example:

# Assume `nbr` was previously initialized as a Neighborhood()
# Run 10 steps
for _ in range(10):
    nbr.run_step()

# Now take this instance and create a new Neighborhood using '.fork()',
# which returns a new Neighborhood object with the same state as nbr.
nbr_other = nbr.fork()

print(nbr_other == nbr)
# Out: "True"

# Now, could run these two as if they were independent neighborhoods.
for _ in range(100:
    nbr.run_step()
    nbr_other.run_step()

# At this point, nbr and nbr_other will have significantly diverged.
print(nbr_other == nbr)
# Out: "False"

With this, more efficient comparison of the two models can be perform as they each evolve.

Implementation specifics

The primary barrier to this being immediately possible is deciding how copying will be applied to the new neighborhood object.

@teald teald added enhancement New feature or request major change significant/breaking changes proposal Changes proposed, not planned. labels Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major change significant/breaking changes proposal Changes proposed, not planned.
Projects
None yet
Development

No branches or pull requests

1 participant