Run Mesa as Web app

44 views
Skip to first unread message

Jeremy Foote

unread,
Dec 22, 2020, 11:53:42 AM12/22/20
to ProjectMesa
Hi all,

I would love to use some Mesa simulations as teaching tools in a course I'm developing. I have been looking through old forum posts and Googling but haven't found
any examples of folks running Mesa on a public-facing site that others can play with.

Is this more difficult than I think it will be? Does example code or a tutorial exist anywhere?

Thanks so much!,
Jeremy

Vincent Hess

unread,
Dec 22, 2020, 12:25:36 PM12/22/20
to Jeremy Foote, ProjectMesa

--
Project repos: github.com/projectmesa
---
You received this message because you are subscribed to the Google Groups "ProjectMesa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectmesa...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/projectmesa/5e856b44-1caa-4b90-9358-8784523b6629n%40googlegroups.com.

Jeremy Foote

unread,
Dec 22, 2020, 1:24:41 PM12/22/20
to Vincent Hess, ProjectMesa
This is perfect - thanks so much!

marcoscr...@gmail.com

unread,
Dec 22, 2020, 2:58:17 PM12/22/20
to ProjectMesa

Vincent Hess

unread,
Dec 22, 2020, 3:07:52 PM12/22/20
to Jeremy Foote, ProjectMesa
There is just one catch. Right now each connection *kind of* shares the same model. Some things will be the same, some will be very different. It's really very confusing.

But this PR should solve that: https://github.com/projectmesa/mesa/pull/934

It's a bit more involved to use a custom build on heroku based on this PR, but maybe we can push it into the next release of mesa. When is your course going to happen?

I am also currently thinking about how to further improve the visualization server so that model state logic is kept cleanly separated from the server itself. This could make it possible to have a custom front page before the actual model, which could be interesting for you. Would love to hear more about your use case (how you would like it to be)

Best
Vincent

Jeremy Foote

unread,
Dec 23, 2020, 10:20:25 AM12/23/20
to ProjectMesa
On Tue, Dec 22, 2020 at 3:07 PM Vincent Hess <vincent...@gmail.com> wrote:
There is just one catch. Right now each connection *kind of* shares the same model. Some things will be the same, some will be very different. It's really very confusing.

Ah! So if an entire class was playing around synchronously, there could be some odd and unexpected behavior?

But this PR should solve that: https://github.com/projectmesa/mesa/pull/934

It's a bit more involved to use a custom build on heroku based on this PR, but maybe we can push it into the next release of mesa. When is your course going to happen?

Course starts in mid-January, but I'm flexible as to when I would show these. I'll be teaching the course again, so maybe I'll build the models for this semester and just do a screenshare and then work on making a public-facing site for later.
 

I am also currently thinking about how to further improve the visualization server so that model state logic is kept cleanly separated from the server itself. This could make it possible to have a custom front page before the actual model, which could be interesting for you. Would love to hear more about your use case (how you would like it to be)

So, sort of like an explainer page or overlay? That seems like it could be nice. I'm not too worried about it for my use case - I have a course wiki where I can write a little bit about the model and link to it.

Thanks!,
Jeremy

Corvince

unread,
Jan 6, 2021, 3:13:22 PM1/6/21
to ProjectMesa
Ah! So if an entire class was playing around synchronously, there could be some odd and unexpected behavior?


Unexpected behavior would be your best bet ;)

I found a simple solution however. You can install packages directly from pull requests on GitHub. So you only need to put this line into your requirements file:   
instead of "Mesa". This should install the right version of mesa. You can also just test it yourself by opening the app from multiple tabs (which you should probably do before showing it to your class).

Hope this helps. Please come back to this thread if you have any more questions or just to tell us how it went ;)

Majd Al-shihabi

unread,
Jan 27, 2021, 1:32:17 PM1/27/21
to Corvince, ProjectMesa
Hi all - I thought it might be of interest to this group:

For my master's thesis, I've been working on a model of the financialization of the housing market in Beirut. The model explores the effect of imposing a vacancy tax on housing units, to see if it pushes investors to place their units on the market instead of holding them vacant.

I decided to put the model online for the thesis defence (which will happen in a couple of weeks). You can view it here:


There's a lot to explain about what the model is about and what it does, but unfortunately, the way that the web interface of Mesa is structured right now, it doesn't allow for a landing page with explanation. Maybe we can work on that next!

Let me know if you have any questions,

Majd

--
Project repos: github.com/projectmesa
---
You received this message because you are subscribed to the Google Groups "ProjectMesa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to projectmesa...@googlegroups.com.

Jacqueline Kazil

unread,
Feb 11, 2021, 2:17:26 AM2/11/21
to Majd Al-shihabi, Corvince, ProjectMesa
That is really cool! I am excited about this whole thread.
@Majd -- the model seems slow. Have you dug into why that is? 
@Majd -- Can you submit a ticket that requests a way to insert more information in the UI? 



Majd Al-shihabi

unread,
Feb 11, 2021, 11:55:18 AM2/11/21
to Jacqueline Kazil, Corvince, ProjectMesa
It's very exciting indeed!

Regarding slowness: on my laptop, it takes an average of 55 seconds to run the model for 20 steps. It's not surprising because there's a LOT of number crunching in the model, and since this was the first iteration of it, I was not prioritizing performance optimization while writing the code. I'm also deploying it on a free heroku instance, so the performance is bound to be very bad. The code is here in case you want to run it yourself.

Regarding the UI info, I think this existing ticket is a good starting point. The problem (which is not a problem) is that Mesa is a general purpose ABM library, so the effort to standardize its UI needs to stay abstract enough to accommodate for all the different permutations. I think the choice to depend on a plugin architecture was a wise one, so we can create different plugins for different modelling purposes. I'd be very interested in improving the geographic aspect of the interface, using modern mapping tools, and building on mesa-geo by Corvince. But I'm definitely into giving the web interface an overhaul to make it more coherent for general modelling!




Bahman Lahoorpoor

unread,
Feb 22, 2021, 11:06:51 PM2/22/21
to ProjectMesa
Majd, 

That's really interesting. Have you published your codes anywhere? 

Bahman
Reply all
Reply to author
Forward
0 new messages