Mesa 3.2.0.dev0__py3-none-any.whl → 3.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Mesa might be problematic. Click here for more details.
- mesa/__init__.py +1 -1
- mesa/agent.py +9 -7
- mesa/datacollection.py +1 -1
- mesa/examples/README.md +1 -1
- mesa/examples/__init__.py +2 -0
- mesa/examples/advanced/alliance_formation/Readme.md +50 -0
- mesa/examples/advanced/alliance_formation/__init__ .py +0 -0
- mesa/examples/advanced/alliance_formation/agents.py +20 -0
- mesa/examples/advanced/alliance_formation/app.py +71 -0
- mesa/examples/advanced/alliance_formation/model.py +184 -0
- mesa/examples/advanced/epstein_civil_violence/app.py +11 -11
- mesa/examples/advanced/pd_grid/Readme.md +4 -6
- mesa/examples/advanced/pd_grid/app.py +10 -11
- mesa/examples/advanced/sugarscape_g1mt/Readme.md +4 -5
- mesa/examples/advanced/sugarscape_g1mt/app.py +34 -16
- mesa/examples/advanced/wolf_sheep/Readme.md +2 -17
- mesa/examples/advanced/wolf_sheep/app.py +21 -18
- mesa/examples/basic/boid_flockers/Readme.md +6 -1
- mesa/examples/basic/boid_flockers/app.py +15 -11
- mesa/examples/basic/boltzmann_wealth_model/Readme.md +2 -12
- mesa/examples/basic/boltzmann_wealth_model/app.py +39 -32
- mesa/examples/basic/conways_game_of_life/Readme.md +1 -9
- mesa/examples/basic/conways_game_of_life/app.py +13 -16
- mesa/examples/basic/schelling/Readme.md +2 -10
- mesa/examples/basic/schelling/agents.py +9 -3
- mesa/examples/basic/schelling/app.py +50 -3
- mesa/examples/basic/schelling/model.py +2 -0
- mesa/examples/basic/schelling/resources/blue_happy.png +0 -0
- mesa/examples/basic/schelling/resources/blue_unhappy.png +0 -0
- mesa/examples/basic/schelling/resources/orange_happy.png +0 -0
- mesa/examples/basic/schelling/resources/orange_unhappy.png +0 -0
- mesa/examples/basic/virus_on_network/Readme.md +0 -4
- mesa/examples/basic/virus_on_network/app.py +31 -14
- mesa/experimental/__init__.py +2 -2
- mesa/experimental/continuous_space/continuous_space.py +1 -1
- mesa/experimental/meta_agents/__init__.py +25 -0
- mesa/experimental/meta_agents/meta_agent.py +387 -0
- mesa/model.py +3 -3
- mesa/space.py +4 -1
- mesa/visualization/__init__.py +2 -0
- mesa/visualization/backends/__init__.py +23 -0
- mesa/visualization/backends/abstract_renderer.py +97 -0
- mesa/visualization/backends/altair_backend.py +440 -0
- mesa/visualization/backends/matplotlib_backend.py +419 -0
- mesa/visualization/components/__init__.py +28 -8
- mesa/visualization/components/altair_components.py +86 -0
- mesa/visualization/components/matplotlib_components.py +4 -2
- mesa/visualization/components/portrayal_components.py +120 -0
- mesa/visualization/mpl_space_drawing.py +292 -129
- mesa/visualization/solara_viz.py +274 -32
- mesa/visualization/space_drawers.py +797 -0
- mesa/visualization/space_renderer.py +399 -0
- {mesa-3.2.0.dev0.dist-info → mesa-3.3.0.dist-info}/METADATA +13 -4
- {mesa-3.2.0.dev0.dist-info → mesa-3.3.0.dist-info}/RECORD +57 -40
- mesa/examples/advanced/sugarscape_g1mt/tests.py +0 -69
- {mesa-3.2.0.dev0.dist-info → mesa-3.3.0.dist-info}/WHEEL +0 -0
- {mesa-3.2.0.dev0.dist-info → mesa-3.3.0.dist-info}/licenses/LICENSE +0 -0
- {mesa-3.2.0.dev0.dist-info → mesa-3.3.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
from scipy import stats
|
|
3
|
-
|
|
4
|
-
from .agents import Trader
|
|
5
|
-
from .model import SugarscapeG1mt, flatten
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def check_slope(y, increasing):
|
|
9
|
-
x = range(len(y))
|
|
10
|
-
slope, intercept, _, p_value, _ = stats.linregress(x, y)
|
|
11
|
-
result = (slope > 0) if increasing else (slope < 0)
|
|
12
|
-
# p_value for significance.
|
|
13
|
-
assert result and p_value < 0.05, (slope, p_value)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def test_decreasing_price_variance():
|
|
17
|
-
# The variance of the average trade price should decrease over time (figure IV-3)
|
|
18
|
-
# See Growing Artificial Societies p. 109.
|
|
19
|
-
model = SugarscapeG1mt(42)
|
|
20
|
-
model.datacollector._new_model_reporter(
|
|
21
|
-
"price_variance",
|
|
22
|
-
lambda m: np.var(
|
|
23
|
-
flatten([a.prices for a in m.agents_by_type[Trader].values()])
|
|
24
|
-
),
|
|
25
|
-
)
|
|
26
|
-
model.run_model(step_count=50)
|
|
27
|
-
|
|
28
|
-
df_model = model.datacollector.get_model_vars_dataframe()
|
|
29
|
-
|
|
30
|
-
check_slope(df_model.price_variance, increasing=False)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def test_carrying_capacity():
|
|
34
|
-
def calculate_carrying_capacities(enable_trade):
|
|
35
|
-
carrying_capacities = []
|
|
36
|
-
visions = range(1, 10)
|
|
37
|
-
for vision_max in visions:
|
|
38
|
-
model = SugarscapeG1mt(vision_max=vision_max, enable_trade=enable_trade)
|
|
39
|
-
model.run_model(step_count=50)
|
|
40
|
-
carrying_capacities.append(len(model.agents_by_type[Trader]))
|
|
41
|
-
return carrying_capacities
|
|
42
|
-
|
|
43
|
-
# Carrying capacity should increase over mean vision (figure IV-6).
|
|
44
|
-
# See Growing Artificial Societies p. 112.
|
|
45
|
-
carrying_capacities_with_trade = calculate_carrying_capacities(True)
|
|
46
|
-
check_slope(
|
|
47
|
-
carrying_capacities_with_trade,
|
|
48
|
-
increasing=True,
|
|
49
|
-
)
|
|
50
|
-
# Carrying capacity should be higher when trade is enabled (figure IV-6).
|
|
51
|
-
carrying_capacities_no_trade = calculate_carrying_capacities(False)
|
|
52
|
-
check_slope(
|
|
53
|
-
carrying_capacities_no_trade,
|
|
54
|
-
increasing=True,
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
t_statistic, p_value = stats.ttest_rel(
|
|
58
|
-
carrying_capacities_with_trade, carrying_capacities_no_trade
|
|
59
|
-
)
|
|
60
|
-
# t_statistic > 0 means carrying_capacities_with_trade has larger values
|
|
61
|
-
# than carrying_capacities_no_trade.
|
|
62
|
-
# p_value for significance.
|
|
63
|
-
assert t_statistic > 0 and p_value < 0.05
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# TODO:
|
|
67
|
-
# 1. Reproduce figure IV-12 that the log of average price should decrease over average agent age
|
|
68
|
-
# 2. Reproduce figure IV-13 that the gini coefficient on trade should decrease over mean vision, and should be higher with trade
|
|
69
|
-
# 3. a stricter test would be to ensure the amount of variance of the trade price matches figure IV-3
|
|
File without changes
|
|
File without changes
|
|
File without changes
|