Skip to content

Commit bbe0636

Browse files
committed
merge experimental schelling into schelling example
1 parent a106204 commit bbe0636

File tree

12 files changed

+18
-714
lines changed

12 files changed

+18
-714
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ Boltzmann Wealth model with the experimental Juptyer notebook visualization feat
122122

123123
A modified version of the [Bank Reserves](https://github.com/projectmesa/mesa-examples/tree/main/examples/bank_reserves) example made to provide examples of Mesa's charting tools.
124124

125-
### [Schelling Segregation Model (Experimental)](https://github.com/projectmesa/mesa-examples/tree/main/examples/schelling_experimental)
126-
127-
Schelling segregation model with the experimental Juptyer notebook visualization feature.
128-
129125
### [Shape Example](https://github.com/projectmesa/mesa-examples/tree/main/examples/shape_example)
130126

131127
Example of grid display and direction showing agents in the form of arrow-head shape.

examples/schelling/README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,13 @@ To install the dependencies use pip and the requirements.txt in this directory.
1616

1717
## How to Run
1818

19-
To run the model interactively, run ``mesa runserver`` in this directory. e.g.
19+
To run the model interactively, in this directory, run the following command
2020

2121
```
22-
$ mesa runserver
22+
$ solara run app.py
2323
```
2424

25-
or
26-
27-
Directly run the file ``run.py`` in the terminal. e.g.
28-
29-
```
30-
$ python run.py
31-
```
32-
33-
Then open your browser to [http://127.0.0.1:8521/](http://127.0.0.1:8521/) and press Reset, then Run.
25+
Then open your browser to [http://127.0.0.1:8765/](http://127.0.0.1:8765/) and click the Play button.
3426

3527
To view and run some example model analyses, launch the IPython Notebook and open ``analysis.ipynb``. Visualizing the analysis also requires [matplotlib](http://matplotlib.org/).
3628

@@ -40,10 +32,9 @@ To run the model with the grid displayed as an ASCII text, run `python run_ascii
4032

4133
## Files
4234

43-
* ``run.py``: Launches a model visualization server.
35+
* ``app.py``: Code for the interactive visualization.
4436
* ``run_ascii.py``: Run the model in text mode.
4537
* ``schelling.py``: Contains the agent class, and the overall model class.
46-
* ``server.py``: Defines classes for visualizing the model in the browser via Mesa's modular server, and instantiates a visualization server.
4738
* ``analysis.ipynb``: Notebook demonstrating how to run experiments and parameter sweeps on the model.
4839

4940
## Further Reading

examples/schelling_experimental/app.py renamed to examples/schelling/app.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
from mesa.visualization import Slider, SolaraViz, make_plot_measure
1+
import solara
2+
from mesa.visualization import (
3+
Slider,
4+
SolaraViz,
5+
make_plot_measure,
6+
make_space_matplotlib,
7+
)
28
from model import Schelling
39

410

511
def get_happy_agents(model):
612
"""
713
Display a text count of how many happy agents there are.
814
"""
9-
return f"Happy agents: {model.happy}"
15+
return solara.Markdown(f"**Happy agents: {model.happy}**")
1016

1117

1218
def agent_portrayal(agent):
@@ -27,7 +33,11 @@ def agent_portrayal(agent):
2733

2834
page = SolaraViz(
2935
model1,
30-
components=[HappyPlot, get_happy_agents],
36+
components=[
37+
make_space_matplotlib(agent_portrayal),
38+
make_plot_measure("happy"),
39+
get_happy_agents,
40+
],
3141
model_params=model_params,
3242
)
3343
page # noqa

examples/schelling/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
jupyter
22
matplotlib
3-
mesa~=2.0
3+
mesa[viz]>=3.0.0b0

examples/schelling/run.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/schelling/server.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

examples/schelling_experimental/README.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

examples/schelling_experimental/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)