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

Barebone examples without using the tornado server #693

Open
rht opened this issue May 23, 2019 · 7 comments
Open

Barebone examples without using the tornado server #693

rht opened this issue May 23, 2019 · 7 comments

Comments

@rht
Copy link
Contributor

rht commented May 23, 2019

What's the problem this feature will solve?

Currently, even the simplest example requires a web server to be run.
However, not every model needs to be visualized, especially the ones that don't need the 2D grid structure.

Describe the solution you'd like

Several simple examples of models that are concise enough to fit in one file, to showcase the modularity of the library, and also that it can be experimented live on a repl.it instance.

@Corvince
Copy link
Contributor

Corvince commented May 23, 2019

I think the examples are really more to (literally) show off models.

How to run a model without visualization is also already covered in the beginning of the introductory tutorial. Given that is boils down to model = Model(); model.step() I don't think we need to point that out more often. If you mean something like that the mesa runserver command always opens some kind of visualization, we would have to think about different output to the console. What would someone expect as an output from a model run? Exit code 0 ?

Please also take a look at the bank reserves example. It showcases a batch run (without any visualization involved). We also have several examples that include jupyter notebooks, which run without the tornado server.

But maybe you can elaborate a bit more on the following points, I am not sure I get them correctly:

Several simple examples of models that are concise enough to fit in one file, to showcase the modularity of the library, and also that it can be experimented live on a repl.it instance.

How does putting everything into one file (again, see intro tutorial for that) showcase modularity? And I have no experience with repl.it, but it seems to support multiple files?

All that said I think most (probably all) mesa developers are always happy to include more examples, so please feel free to submit.

@rht
Copy link
Contributor Author

rht commented May 23, 2019

I wasn't aware of the introductory tutorial.

Please also take a look at the bank reserves example. It showcases a batch run (without any visualization involved).

Since it is a new example, it is not in the list at https://github.com/projectmesa/mesa/blob/master/examples/Readme.md. And the batch_runner description comes after I have assumed that the example requires a server to run.

We also have several examples that include jupyter notebooks, which run without the tornado server.

To run a .ipynb would still require a server to be run. Although some people might find jupyter notebooks more intuitive to run than a .py on IDLE.

What I meant by 'modularity' is that the library can be used piecemeal without the visualization server, and that it can be concise enough to be described fully in 1 file.
The result can be in the form of numbers or a plot, definitely not just exit 0.

@Corvince
Copy link
Contributor

I wasn't aware of the introductory tutorial.

Ah, that probably explains your confusion.

Please also take a look at the bank reserves example. It showcases a batch run (without any visualization involved).

Since it is a new example, it is not in the list

Oh good catch, nice to know!

We also have several examples that include jupyter notebooks, which run without the tornado server.

To run a .ipynb would still require a server to be run. Although some people might find jupyter notebooks more intuitive to run than a .py on IDLE.

Sorry, I wrote that a bit confusing. What I meant was that inside the notebooks (which can easily be viewed on e.g. GitHub) users can see how to run the models without a server.

What I meant by 'modularity' is that the library can be used piecemeal without the visualization server, and that it can be concise enough to be described fully in 1 file.

I disagree that this needs to be mentioned explicitly since this is true for everything written in Python. But lets hear what others think about this

@jackiekazil
Copy link
Member

I understand what @rht is getting at and see the value. I just don't know how to do this organizations in docs or examples to demonstrate this without making it super confusing on top of the basic model and the advanced models we already have.

thoughts?

@dmasad
Copy link
Member

dmasad commented Jul 5, 2019

One easy way to do this would be to simply add a __main__ to Schelling and some of the other simple models, and have it instantiate a model, run it, and print some summary statistics. @rht Do you think that would address what you have in mind?

@rht
Copy link
Contributor Author

rht commented Jul 5, 2019

to Schelling and some of the other simple models

Though, virtually all the existing example models require a grid representation. One option is to find a classic example that doesn't require grid.

and print some summary statistics.

The other option is to somehow print an ASCII grid (possibly with colors and custom unicode to represent an agent in a cell) as another visualization mode.

@rht
Copy link
Contributor Author

rht commented Jul 6, 2019

The other option is to somehow print an ASCII grid (possibly with colors and custom unicode to represent an agent in a cell) as another visualization mode.

I saw there is an unused class SchellingTextVisualization at examples/Schelling/server.py. I assume this concern (of running a model without a viz server) has been considered in the past.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants