{"id":42239794,"url":"https://github.com/luccabb/emergency_simulation","last_synced_at":"2026-01-27T04:05:04.413Z","repository":{"id":57426208,"uuid":"360914238","full_name":"luccabb/emergency_simulation","owner":"luccabb","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-23T15:23:11.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T09:27:35.300Z","etag":null,"topics":["emergency-response","networkx","networkx-graph","networkx-library","python3","simulation","simulation-modeling"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/emergency_simulation/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luccabb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-23T14:39:20.000Z","updated_at":"2021-04-23T15:31:39.000Z","dependencies_parsed_at":"2022-09-11T05:01:28.930Z","dependency_job_id":null,"html_url":"https://github.com/luccabb/emergency_simulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luccabb/emergency_simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccabb%2Femergency_simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccabb%2Femergency_simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccabb%2Femergency_simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccabb%2Femergency_simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luccabb","download_url":"https://codeload.github.com/luccabb/emergency_simulation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luccabb%2Femergency_simulation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28800974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T03:44:14.111Z","status":"ssl_error","status_checked_at":"2026-01-27T03:43:33.507Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emergency-response","networkx","networkx-graph","networkx-library","python3","simulation","simulation-modeling"],"created_at":"2026-01-27T04:05:03.702Z","updated_at":"2026-01-27T04:05:04.402Z","avatar_url":"https://github.com/luccabb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emergency Response Simulation\n\n## Installing \n\n`pip install emergency_simulation`\n\n## Introduction\n\nEmergency Response Simulation is a package that helps anyone to create a simulation where you can create a city as a Graph of neighborhoods with the networkx library, and simulate emergency responses in it. The idea is to easily allow anyone to explore what is the best configuration for ambulance allocations in a given city.\n\n## Creating a simulation. Getting started with Sample Code.\n\n### Part 1. Creating a Graph with networkx\n\n```\n# importing packages\nfrom emergency_simulation import *\nimport scipy.stats as sts\nimport networkx as nx\n\n## Creating Graph\nG = nx.Graph()\n\n# creating neighborhoods with their emergency rate\nG.add_node(\"Civic Center\", emergency_distribution = sts.expon(scale=29))\nG.add_node(\"Nob Hill\", emergency_distribution = sts.expon(scale=35))\nG.add_node(\"Downtown\", emergency_distribution = sts.expon(scale=30))\nG.add_node(\"Tenderloin\", emergency_distribution = sts.expon(scale=36))\nG.add_node(\"South of Market\", emergency_distribution = sts.expon(scale=30))\nG.add_node(\"Financial District\", emergency_distribution = sts.expon(scale=20))\nG.add_node(\"Yerba Buena\", emergency_distribution = sts.expon(scale=29))\nG.add_node(\"South Beach\", emergency_distribution = sts.expon(scale=25))\nG.add_node(\"Mission Bay\", emergency_distribution = sts.expon(scale=30))\nG.add_node(\"Potrero Hill\", emergency_distribution = sts.expon(scale=33))\nG.add_node(\"Inner Mission\", emergency_distribution = sts.expon(scale=38))\nG.add_node(\"Dogpatch\", emergency_distribution = sts.expon(scale=32))\n\n\n# creating edges with weight representing the distance in minutes between 2 neighborhoods\nG.add_edge(\"Civic Center\", \"Nob Hill\", weight=5)\nG.add_edge(\"Civic Center\", \"Downtown\", weight=5)\nG.add_edge(\"Civic Center\", \"Tenderloin\", weight=3)\nG.add_edge(\"Civic Center\", \"South of Market\", weight=5)\n\nG.add_edge(\"Nob Hill\", \"Downtown\", weight=5)\nG.add_edge(\"Nob Hill\", \"Financial District\", weight=4)\n\nG.add_edge(\"Downtown\", \"Financial District\", weight=7)\nG.add_edge(\"Downtown\", \"Yerba Buena\", weight=4)\nG.add_edge(\"Downtown\", \"Tenderloin\", weight=4)\n\nG.add_edge(\"Financial District\", \"Yerba Buena\", weight=5)\nG.add_edge(\"Financial District\", \"South Beach\", weight=5)\n\nG.add_edge(\"Yerba Buena\", \"South of Market\", weight=2)\nG.add_edge(\"Yerba Buena\", \"South Beach\", weight=3)\n\nG.add_edge(\"South of Market\", \"Mission Bay\", weight=5)\nG.add_edge(\"South of Market\", \"Potrero Hill\", weight=5)\nG.add_edge(\"South of Market\", \"Inner Mission\", weight=6)\nG.add_edge(\"South of Market\", \"Tenderloin\", weight=5)\n\nG.add_edge(\"Mission Bay\", \"South Beach\", weight=5)\nG.add_edge(\"Mission Bay\", \"Dogpatch\", weight=5)\nG.add_edge(\"Mission Bay\", \"Potrero Hill\", weight=5)\n\nG.add_edge(\"Dogpatch\", \"Potrero Hill\", weight=4)\n\nG.add_edge(\"Potrero Hill\", \"Inner Mission\", weight=5)\n```\n\n### Part 2. Running the simulation\n\n```\n## Running the simulation with a single configuration\n\n# neighborhoods that have ambulance stations\nneighborhoods = [\"Downtown\", \"Potrero Hill\", \"South Beach\"]\n# total ambulances available to be used\ntotal_ambulances = 13\n# ambulance stations per neighborhood\nneighborhood_ambulance_allocations = neighborhood_ambulance_combinations(neighborhoods, total_ambulances)\n# random value to account for ambulance time to get to the exact location and assist the person\nlocation_and_assitance_distribution = sts.norm(loc=15, scale=5)\n\n# running the simulation for the first \"neighborhood_ambulance_allocations\" and for 20 steps\nsimulation = run_simulation(G, neighborhood_ambulance_allocations[0], location_and_assitance_distribution, 20, log=True)\n```\n\n### Part 3. Exploring statistics/metrics\n\n```\n# getting simulation statistics\nwait_time = simulation.emergency_queue.wait_time_per_emergency\nambulance_stations = simulation.ambulance_stations\n\nprint(\"======================== RESULTS ========================\")\nprint(\"Average Wait Time:\", np.mean(wait_time))\nprint(\"Average Number of Ambulances left idle throughout the simulation\")\nfor station in ambulance_stations:\n    print(\"___________\")\n    mean_available_ambulances = np.mean(station.available_ambulances_evolution)\n    print(station.neighborhood)\n    print(\"Average Number of Ambulances left idle\")\n    print(mean_available_ambulances)\n    print(\"Ambulance Evolution\")\n    print(station.available_ambulances_evolution)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluccabb%2Femergency_simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluccabb%2Femergency_simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluccabb%2Femergency_simulation/lists"}