#define TRUE 1 #define FALSE 0 #define MAX_CARS 150 #define MAX_HOSP 20 #define MAX_BASE 20 #define MAX_REG 20 #define MAX_X 50 #define MAX_Y 50 int debug_level = 0; struct region{ int x_botleft; int y_botleft; int x_topright; int y_topright; }; // // A car has a home base, where it always tries to return to after it has // completed the assignment. // // The time any coordinates of the start of the trip is recorded in // struct car{ int x_start; // The starting point of the trip int y_start; int time_start; // Time at which the trip started int x_inc; // Loc of the incident int y_inc; int time_arr_inc; // ReportArrival here int time_leave_inc; // ReportReady(Inc) here if doesn't go hosp int x_hosp; // Loc of Hospital int y_hosp; int time_arr_hosp; // Arrive at hosp (no exoation here) int time_leave_hosp; // ReportReady(Hosp) here int x_base; // Home base - Constant int y_base; // Home base - Never change int time_arr_base; // ReportReady(base) here int consec_trip_count; int ready; }; struct hospital{ int x; int y; }; struct base{ int x; int y; }; #define RQT 0 #define ARR 1 #define BCK 2 #define RDY 3 struct event{ int car; int type; int time; int x; int y; struct event *next; }; struct request{ int x; int y; int count; struct request *next; }; struct coord{ int x; int y; }; const gsl_rng_type * T; gsl_rng *r; // // Environment descriptions // double hosp_rate; // Hospitalize rate int request_rate; // Request rate int diag_time; // Onsite diagnosis time int unload_time; // Time to unload the patient int markup_time; // Extra time required per cosecutive trip int crew_recovery_time; // Time needed by the crew to fully recover after a trip double comm_fail_rate; // Communication failure rate int spb_emerg; // sec per block: emergency speed in home region int spb_norm; int spb_emerg_foreign; int spb_norm_foreign; /////////////////////////////////////////////////////////// // // // BIG NOTE: ARRAY INDEX O ARE NEVER USED // // // /////////////////////////////////////////////////////////// struct region regions[MAX_REG + 1]; int region_count; struct car cars[MAX_CARS + 1]; int car_count; struct hospital hosps[MAX_HOSP + 1]; int hosp_count; struct base bases[MAX_BASE + 1]; int base_count; // // Simulation data structures // int curr_time = 0; int next_request; int request_x; int request_y; int pending_request_count[MAX_X][MAX_Y]; struct event *due_events = NULL; // // Statistics // int request_count = 0; int late08_delay_count = 0; int late08_travel_count = 0; int late08_both_count = 0; int late11_delay_count = 0; int late11_travel_count = 0; int late11_both_count = 0; int sim_reset(); int distance(int x1, int y1, int x2, int y2); int next_event(); void insert_event(struct event *e); void simu_drive(int x1, int y1, int x2, int y2, int t, int v, int *x, int *y); int a_step_closer(int source, int dest); int valid_coord(int x, int y); double rand_gaussian_duration(int mean); int in_home_region(int c, int x, int y); int is_a_base(int x, int y); int is_a_hosp(int x, int y); void gen_next_request(); int comm_fail_poss(int car, int time); int max_blocks_to_border(int car, struct coord src, struct coord dst); int simu_drive_full(int car, struct coord src, struct coord dst, int spb_home, int spd_foreign); struct coord simu_drive_partial(int car, struct coord src, struct coord dst, int spb_home, int spb_foreign, int t); struct coord local_hosp(struct coord inc); int containing_region(struct coord loc);