Auxiliary classes and functions¶
The Objects module¶
The objects module contains several small classes that help organize the various aspects of the simulation software as intuitively as possible.
Reference¶
-
class
objects.DemandLocation(location_id, building_probs)[source]¶ An area in which incidents occur.
Parameters: - location_id (int) – Identifier of the demand location.
- building_probs (dictionary) – Specifies probabilities of an incident happening in a certain type of building. Dictonary must be defined like {‘incident type’: {‘building function’: prob}.
-
class
objects.FireStation(name, coords, base_vehicles, crew_dict)[source]¶ A fire station where vehicles and crews are positioned when not dispatched.
Parameters: - name (str,) – The name of the station.
- coords (tuple(float, float),) – Longitude and latitude of the station.
- base_vehicles (array-like,) – The fdsim.object.Vehicle objects that have this station as their base.
- crew_dict (dict,) – The crews that are available at this station. Dictionary like {‘vehicle type’ -> [fulltime crews, parttime crews]}.
-
dispatch_crew(vtype)[source]¶ Assign a crew to a dispatched vehicle for deployment or relocation. The crew is no longer available at the station after it is dispatched.
-
update_crew_status(day, hour)[source]¶ Update the available crews according to the current status of the station.
Stations can have cycles of statuses: 0: closed, no vehicles or crew available 1: station operating in part time mode (i.e., normal full time crew is now part time) 2: normal
This method checks what the current status is given the day of the week and hour of day and updates the available crews accordingly.
Parameters: - day (int in [0, 6]) – The day number in zero-indexed integers (Monday = 0, Sunday = 6).
- hour (int in [0, 23]) – The hour of day (rounded down / ignoring minutes) in zero-indexed integers.
-
class
objects.IncidentType(prio_probs, vehicle_probs, location_probs)[source]¶ A type of incident.
Parameters: - prio_probs (list) – list of probabilities that this type of incident is of priority [1, 2, 3] respectively.
- vehicle_probs (dictionary) – Combinations of vehicles are the keys and the values are the probabilities that this combination is required.
- location_probs (dictionary) – Keys are the location identifiers and values are the probability of the incident happening in that location.
-
class
objects.Vehicle(id_, vehicle_type, base_station_name, coords=None)[source]¶ A vehicle of the fire department.
Parameters: - id (int or str) – Identifier for this vehicle instance.
- vehicle_type (str) – The type of vehicle, one of ‘TS’, ‘RV’, ‘HV’, ‘WO’.
- base_station (str) – The name of the station this vehicle belongs to.
- coords (Tuple(float, float), optional) – The decimal longitude and latitude showing the current location of the vehicle.
-
available_for_deployment()[source]¶ Check whether the vehicle is available for deployment.
If the vehicles is at its base location, we need to check if there is a crew available at that station. If the vehicle is at another location, it already has a crew with it, so it is available if it is not already in deployment (i.e., when it is relocated).
The Helpers module¶
The helpers module contains some helper functions that take care of general tasks that are to be performed in different places throughout the software.
Reference¶
-
helpers.create_service_area_dict(kvt_path, veh_col='vehicle_type', station_col='kazerne_naam', loc_col='vak_nr', station_filter=None)[source]¶ Create a dictionary of service areas based on KVT data.
Parameters: - kvt_path (str) – The path to the KVT data.
- station_col, loc_col (veh_col,) – Column names that refer to the vehicle type, station name, and location id respectively.
- station_filter (array-like of strings, default=None) – Stations to use. If None, use all. Will be converted to upper case.
Returns: service_areas – A dictionary like {‘vehicle type’ -> {‘station name’ -> [loc1, loc2, …]}}.
Return type: dict
-
helpers.lonlat_to_xy(lon, lat)[source]¶ Convert (longitude, latitude) coordinates to (x, y).
Requires pyproj to be installed.
-
helpers.pre_process_station_name(x)[source]¶ Standarizes the station names. This step is necesary to merge different data sets later.
-
helpers.quick_load_simulator(path='data/simulator.pickle')[source]¶ Load a pickled Simulator object so that initialization can be skipped.
Notes
Also re-initializes the response time and incident time generator objects, since they cannot be pickled and were therefore deleted before saving.
Parameters: path (str) – The path to the pickled Simulator object. Optional, defaults to ‘data/simulator.pickle’, which is also the default of the Simulator.save_simulator() method. Returns: Return type: The loaded Simulator object.