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
| def war_model_draw(agent): """ Portrayal Method for canvas """
portrayal = {} if isinstance(agent, regionAgent): if agent.atype == "in_war": portrayal["color"] = "Red" else: portrayal["color"] = "green" return portrayal
model_params = { "int_war_rate": { "type": "SliderFloat", "value": 0.2, "label": "Population Size", "min": 0, "max": 0.6, "step": 0.05, }, "threshold_war_infection": { "type": "SliderFloat", "value": 1.5, "label": "Population Size", "min": 1.2, "max": 2, "step": 0.1, }, "exposure_distance": { "type": "SliderInt", "value": 1000, "label": "Population Size", "min": 500, "max": 2000, "step": 100, }, "war_revovery_rate": { "type": "SliderFloat", "value": 0.6, "label": "Maximum Number of Steps to Recover", "min": 0.1, "max": 1, "step": 0.1, }}
page = mgv.GeoJupyterViz( war_model, model_params, measures= [ ["in_war", "no_war"]], name="war spread", agent_portrayal=war_model_draw, zoom=12, scroll_wheel_zoom=False )
|