projectmesa / mesa-viz-tornado

Apache License 2.0
2 stars 8 forks source link

DataCollector carrying over information #27

Open nathawkins opened 6 years ago

nathawkins commented 6 years ago

We recently did an adaptation of the Wolf Sheep example to try and build a disease model (susceptible, infected, recovered) in mesa. When we plotted the population sizes, as is done in the wolf sheep model, the chart plots correctly the first time. However, when we reset the parameters and try and run a new model, the chart that shows up in the server first displays the data from the previous model's execution, and then it shows the data from the next iteration.

An example is shown below:

screen_shot 2018-04-17 at 4 27 27 pm

The sharp discontinuity in the graph is where the new data for the model starts being displayed. We then thought that it may have been our model (a bug), but revisiting the wold sheep model we saw the same thing

screen_shot 2018-04-17 at 4 27 34 pm

Is there a known issue where the DataCollector does not reset between runs? Closing the kernel and restarting it fixes the issue.

Our code can be found here.

jackiekazil commented 6 years ago

This is interesting. It doesn't seem like your code is available anymore though and I would like to look into this. Can you make it available again?

nathawkins commented 6 years ago

Hello. Yes, sorry. The repository was moved to a Private repository following its completion. I have made it Public again. Here is a link to the repository. The source code to pay attention to is found in agent_based_virus/. From there, execute python run.py to launch the simulation just as you would do with any of the other mesa tutorials.

Corvince commented 6 years ago

Hi there,

your model seems very nice, but are you sure the repository is up to date? I tried to run your model, but nothing happens. The visualisation shows up, but step has no effect. On further investigation your model.schedule.agents list is empty, meaning no agents are in the scheduler (and no agent is activated at a step). Since you use a heavily modified RandomActivation, I don't have the time to look into why your agents are not added to the scheduler properly (or perhaps are removed later on).

Regarding your original issue, however, my chart resets correctly when I click on reset. Are you on the latest version of mesa?

At this point I don't see an issue with mesa here, so I am closing this issue. Feel free to reopen, if there is reason to believe there is a problem with mesa itself and not your implementation.

And please note that while the issue is closed you can continue to post questions or comments regarding your model and people can help you with it. But in the future please use our mailing list/forum for questions about your specific model. 👍

nathawkins commented 6 years ago

Thank you for writing back on this issue. I apologize for any issue with the code not seeming up to date. I was able to run it without issue. The working code is found [here] (https://github.com/nathawkins/CMSE202--Semester-Project/tree/master/agent_based_virus). I am still getting the same issue with the visualization not reseting. We were able to work around this by just reseting the terminal window.

It may be an issue with my current version. As I said, this was for a class. I was just raising the issue in the event that other were having a similar problem. Thank you for your time!

Corvince commented 6 years ago

I just ran into this issue myself. If the model is still running (and faster then the visualization) while pressing the reset button, the "unresetted" model still runs and plots onto the line chart. Only the grid chart resets correctly

nathawkins commented 6 years ago

Yes! That is the issue that I was running into. I would alter the model paratemers using input sliders and click "reset," and the grid itself would reset with my new parameters. However, the chart that mesa was generating had the, as you put it, contained the "unresetted" model's data first. After it caught up to where I clicked "reset", then it would show the new model data, but not in time with the grid's movement.

rht commented 12 months ago

This should not be a problem in the Solara frontend.