-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.py
More file actions
65 lines (55 loc) · 2.27 KB
/
server.py
File metadata and controls
65 lines (55 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from mesa_geo.visualization.ModularVisualization import ModularServer
from mesa.visualization.modules import ChartModule, TextElement
from mesa.visualization.UserParam import UserSettableParameter
from model import RegionModel
from mesa_geo.visualization.MapModule import MapModule
import numpy as np
model_params = {
"international_trade" : UserSettableParameter(
"checkbox", "International_Trade", value=True
),
"efficiency_stdev": UserSettableParameter(
"slider", "STDev of efficiency (mean = 1)", 0.1, 0, 2, 0.01
),
"eu_tax": UserSettableParameter(
"slider", "EU Tax (percentage of wealth)", 0.1, 0, 1, 0.001
),
"neighbor_influence": UserSettableParameter(
"slider", "Neighbor Influence (step size)", 0, 0., 0.2, 0.01
),
"tax_influence": UserSettableParameter(
"slider", "Tax/Benefit influence (step size)", 0.1, 0, 0.2, 0.01
),
"member_trade_multiplier": UserSettableParameter(
"slider", "Member trade advantage (multiplier of wealth)", 1.1, 0.5, 3, 0.01
),
"benefit_distribution": UserSettableParameter(
"slider", "Benefit distribution (multiplier of tax payed)", 1, 0.8, 1.2, 0.001
),
}
def schelling_draw(agent):
portrayal = dict()
if agent.strategy == 1:
portrayal["color"] = "RoyalBlue"
else:
portrayal["color"] = "Tomato"
return portrayal
map_element = MapModule(schelling_draw, [57, 12], 3, 400, 800)
type_chart = ChartModule([{"Label": 'other_count', "Color": "Tomato"},
{"Label": 'member_count', "Color": "RoyalBlue"}], 200, 500)
payoff_chart = ChartModule([{"Label": 'average_cooperativeness', "Color": "Gold"}], 200, 500)
gini_chart = ChartModule([{"Label": 'gini_coefficient', "Color": "Green"}], 200, 500)
wealth_chart = ChartModule([
{"Label": 'other_wealth', "Color": "Tomato"},
{"Label": 'total_wealth', "Color": "Gold"},
{"Label": 'member_wealth', "Color": "RoyalBlue"},
], 200, 500)
eff_chart = ChartModule([
{"Label": 'other_eff', "Color": "Tomato"},
{"Label": 'total_eff', "Color": "Gold"},
{"Label": 'member_eff', "Color": "RoyalBlue"},
], 200, 500)
server = ModularServer(
RegionModel, [map_element, type_chart, gini_chart, wealth_chart,eff_chart, payoff_chart], "ABM", model_params
)
server.launch()