-
Notifications
You must be signed in to change notification settings - Fork 1
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
fast map-based example #35
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some perhaps useful comments...
|
||
**code:** [minimal_high_density.slim](minimal_high_density.slim); on [github](https://github.com/kr-colab/spatial_sims_standard/blob/main/minimal_high_density.slim) | ||
|
||
This code implements the same model as [`minimal.slim`](minimal.html), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is "minimal.html" here? I don't see that file in the repo...
(i.e., quadratic in the parameter `K`): local density computation, and mate choice. | ||
The two methods can be used independently - for instance, maybe your simulation | ||
has small interaction neighborhood size but large mating neighborhood size, | ||
so you'd use these methods for mating but not density computations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little vague what "these methods" refers to. Maybe it would be helpful to actually give the method shown in this example a name, so you can refer to it? Otherwise, "the alternative method shown here" instead of "these methods", I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just plop down the method/function names here to clarify the important differences? smooth
and sampleNearbyPoint
, maybe others?
Something like "The main changes from the minimal.slim
example are use of the SpatialMap
methods smooth
and sampleNearbyPoint
, which are described in more detail below."
has small interaction neighborhood size but large mating neighborhood size, | ||
so you'd use these methods for mating but not density computations. | ||
|
||
Both methods are linear because they rely on a pre-computed map of local density. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now "both methods" is also vague/confusing here. I thought at first that it referred to both the "standard" method and the "alternative" method, but that didn't make sense, so I guess the "alternative" method is actually two methods? Anyhow, the usage of this vague term "method" needs to be cleaned up.
Well, we'd like these to be as big as is reasonable, | ||
because computation will scale with the number of these squares. | ||
But, this grid is the source of any discretization artifacts: | ||
the smaller the grid squares are, the closer this model is to `minimal.slim`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even worse, potentially! could be much worse if you make them really small!
with a certain characteristic scale: `SX` for local density (for "interactions") and `SM` for mating. | ||
So, as long as our grid squares are sufficiently smaller than these, | ||
any discretization will be smoothed out by those operations. | ||
So, we set the size of the grid cells to be approximately `min(SX,SM)/2`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps i will be obvious to most readers but of course if you're only using the method for one or the other purpose, you could customize the grid to either SX or SM; and you could conceivably make two different grids, too, if SX and SM are very different, right?
``` | ||
initializeInteractionType(2, "xy", reciprocal=T, maxDistance=5/sqrt(K)); | ||
``` | ||
to have maximum interaction distance `5/sqrt(K)`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This last sentence, "Since...", is a sentence fragment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it needs explanation why the max distance is "5/sqrt(K)" – where does that come from?
If the density is roughly $K$, this means there should be around 25 individuals in each circle of that radius; | ||
however, if density is sufficiently nonuniform, or if you are simulating some nonequilibrium situation, | ||
then this may fail. | ||
The code is robust to this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "The code in this example handles this issue, by doing:". I misread "The code is robust to this:" as saying "The code in the model is robust to the following two lines of code:" which had me scratching my head for a good thirty seconds! As usual, "this" creates ambiguity and confusion. :->
``` | ||
means that if an individual has no neighbors, they will not reproduce, | ||
but this is over a much smaller distance than our nominal mating distance, `SM`, | ||
so we don't want this to happen very much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a bit of rewriting. "means that..." seems like it starts a sentence in the middle, and "this is over" and "we don't want this" both use "this" in an ambiguous way that I am honestly unable to puzzle out.
but this is over a much smaller distance than our nominal mating distance, `SM`, | ||
so we don't want this to happen very much. | ||
(Indeed, if `SM` was not much larger than `5/sqrt(K)` then we wouldn't be saving any computation at all.) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ends rather abruptly; some kind of closing sentence, a conclusion, a take-home point?
@@ -0,0 +1,130 @@ | |||
initialize() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't try actually running the model, but I don't see any problems. :->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runs fine on my end!
This is great! The grid set up at the beginning is a nice way to make the grid computation behind the scenes more explicit. Definitely a very helpful addition to the repo. |
|
||
**code:** [minimal_high_density.slim](minimal_high_density.slim); on [github](https://github.com/kr-colab/spatial_sims_standard/blob/main/minimal_high_density.slim) | ||
|
||
This code implements the same model as [`minimal.slim`](minimal.html), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code implements the same model as [`minimal.slim`](minimal.html), | |
This code implements the same model as [`minimal.slim`](https://github.com/kr-colab/spatial_sims_standard/blob/main/minimal.slim), |
(i.e., quadratic in the parameter `K`): local density computation, and mate choice. | ||
The two methods can be used independently - for instance, maybe your simulation | ||
has small interaction neighborhood size but large mating neighborhood size, | ||
so you'd use these methods for mating but not density computations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just plop down the method/function names here to clarify the important differences? smooth
and sampleNearbyPoint
, maybe others?
Something like "The main changes from the minimal.slim
example are use of the SpatialMap
methods smooth
and sampleNearbyPoint
, which are described in more detail below."
@@ -0,0 +1,130 @@ | |||
initialize() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Runs fine on my end!
I realized I never put this in!