-
Notifications
You must be signed in to change notification settings - Fork 154
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
Cholera Voronoi #118
base: main
Are you sure you want to change the base?
Cholera Voronoi #118
Conversation
Thanks for the PR! I will try to review it later this week. |
Hi Vítor! I'm really sorry, we really dropped the ball here. The example looks great, and is really useful. I would like to have it in, there are two points that would be nice to have:
Are you interested in picking one or both up? Otherwise I could do it. Sorry again, it's really appreciated! |
Hello Ewout. This semester was crazy and I got very busy. I'm finally at vacation and expect to implement both tasks. |
No worries, I know how it goes 😅. Thanks, looking forward to it! If I can help let me know. |
Looks great! I will review in the morning. (I think the import should still be |
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.
Okay, a few small comments already. In the morning I will fire it up for a more thorough review.
@quaquel you might also be interested in reviewing this, since it’s one of the first external implementations of the experimental cell space.
|
||
The model has two agents: people and pumps. Pumps can infect people and neighbor pumps. People start as susceptible, can be infected by pumps and recover or die, according to a simple SIR model. Each cell has only one pump and is connected to neighbor cells according to Voronoi's diagram. The model aims to investigate how fast actions oriented by Voronoi diagrams can prevent disease spread. | ||
|
||
## How to Run |
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.
Thanks for writing a Readme! Don’t forget to update this section
examples/cholera_voronoi/agents.py
Outdated
self.recovery_chance = recovery_chance | ||
|
||
def step(self): | ||
if self.state == REMOVED: |
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 have a hunch this whole section could be simpler. Let me check tomorrow.
examples/cholera_voronoi/agents.py
Outdated
people = [ | ||
obj | ||
for obj in self.cell.agents | ||
if isinstance(obj, Person) and obj.state is not REMOVED |
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.
Shouldn’t agents be just removed from cell.agents instead of having a state “removed”?
examples/cholera_voronoi/agents.py
Outdated
self.model.infected_pumps += 1 | ||
|
||
# If cases in total is too high, fix pump | ||
cases = sum(1 for a in people if a.state is INFECTIOUS) |
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.
Can you do len() instead of sum()?
@rht @Corvince (and maybe even @maartenbreddels) do you think we can display the cell space easily in Solara? And in this case the actual Vonoroi space? With some color scale depending on the number of infected agents per cell? |
Short answer, yes: https://py.cafe/maartenbreddels/solara-ipyreact-voronoi :) I guess you want to customize it a bit, but that's just some fiddling with js examples. |
@vitorfrois could you resolve the comments above if you have already answered them? Then we keep a nice overview what's done and not. |
|
||
cell_population = [400] * 8 | ||
|
||
points = [ |
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.
Shouldn't this be called pump_locations
for clarity?
To run the model interactively, run ``mesa runserver`` in this directory. e.g. | ||
|
||
``` | ||
$ mesa runserver |
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.
Documentation is outdated.
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 is for the old visualization, whereas it should have bin solara run run.py
.
Other than the comments, everything else LGTM. The Voronoi visualization can be deferred to a separate PR, since this PR has been hanging in limbo for a while. @maartenbreddels's demo uses D3, but maybe for now we could use Matplotlib, and still be pure Python? There is https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.voronoi_plot_2d.html. There is also a way to do it for Altair. |
I will update this example with the visualization for voronoi space included in projectmesa/mesa#1895. |
Awesome, looking forward to it! Note that we just updated the visualisation tutorial to the new API.
No, I don't think it's needed here. It's mostly useful if you want to do things outside discrete timesteps. 90% of models don't need DEVS. For the 10% that do it's a total game changer. |
Implements agents, model and server graph visualization according to #112 issue.
This example uses the
VoronoiGrid
, which inherits from theDiscreteSpace
, as proposed in projectmesa/mesa#2084.