def model_setup(model): model.reset() model.Susceptible = 0 model.Infectious = 0 model.Recovered = 0 for person in range(100): model.add_agent(Person()) def model_step(model): for person in model.agents: person.step(model) model.update_plots() epidemic_model = Model("Epidemimodel", 100, 100) epidemic_model.add_button("Setup", model_setup) epidemic_model.add_button("Go", model_step, toggle=True) epidemic_model.line_chart(["Susceptible", "Infectious", "Recovered"], [(0, 200, 0), (200, 0, 0), (0, 0, 200)]) epidemic_model.add_checkbox("enable_groups") epidemic_model.add_controller_row() epidemic_model.add_slider("social_distance", 50, 0, 80) epidemic_model.add_controller_row() epidemic_model.add_slider("infection_distance", 15, 0, 40) run(epidemic_model)
def setup(model): model.reset() model.clear_plots() model.total_util = 0 model.BNP = 0 people = set([Person() for i in range(20)]) model.add_agents(people) def step(model): model.BNP = 0 for a in model.agents: a.step(model) model.BNP += a.utility() model.update_plots() model.remove_destroyed_agents() bnb_model = Model("Bread & butter economy during pandemic", 50, 50) bnb_model.add_button("Setup", setup) bnb_model.add_button("Step", step) bnb_model.add_button("Go", step, toggle=True) bnb_model.add_controller_row() bnb_model.add_slider("movespeed", 0.5, 0.1, 1) bnb_model.add_checkbox("Decay") bnb_model.line_chart(["BNP"], [(0, 0, 0)]) bnb_model.show_direction = False run(bnb_model)
file_handle.write( str(counter) + "," + str(model.Susceptible) + "," + str(model.Infectious) + "," + str(model.Recovered) + "," + str(model.Vaccinated) + "\n") file_handle.close() counter += 1 model.update_plots() epidemic_model = Model("Epidemimodel", 100, 100) epidemic_model.add_button("Setup", model_setup) epidemic_model.add_button("Go", model_step, toggle=True) epidemic_model.line_chart( ["Susceptible", "Infectious", "Recovered", "Vaccinated"], [(0, 200, 0), (200, 0, 0), (0, 0, 200), (100, 100, 200)]) epidemic_model.bar_chart( ["Susceptible", "Infectious", "Recovered", "Vaccinated"], (200, 200, 200)) epidemic_model.add_checkbox("enable_groups") epidemic_model.add_checkbox("Vaccine_exponential") epidemic_model.add_controller_row() epidemic_model.add_slider("Social_distance", 50, 0, 80) epidemic_model.add_controller_row() epidemic_model.add_slider("Infection_distance", 15, 0, 40) epidemic_model.add_controller_row() epidemic_model.add_slider("Vaccine_rate", 0.2, 0.1, 1.0) run(epidemic_model)