void RandomSelect::Program_Control (void) { String key; //---- create the network files ---- Data_Service::Program_Control (); Read_Select_Keys (); trip_flag = System_File_Flag (TRIP); if (trip_flag) System_File_False (HOUSEHOLD); Print (2, String ("%s Control Keys:") % Program ()); //---- get the number of partitions ---- num_parts = Get_Control_Integer (NUMBER_OF_PARTITIONS); part_count.assign (num_parts, 0); //---- check the selection file ---- if (num_parts > 1) { Selection_File *file = (Selection_File *) System_File_Handle (NEW_SELECTION); if (!file->Part_Flag ()) { file->Clear_Fields (); file->Partition_Flag (true); file->Create_Fields (); file->Write_Header (); } } }
bool Data_Service::Get_Event_Data (Event_File &file, Event_Data &event_rec) { int hhold, lvalue, link, dir, offset, dir_index; hhold = file.Household (); if (hhold < 1) return (false); event_rec.Household (hhold); event_rec.Person (file.Person ()); event_rec.Tour (MAX (file.Tour (), 1)); event_rec.Trip (file.Trip ()); event_rec.Event (file.Event ()); if (file.Version () <= 40) { event_rec.Mode (Trip_Mode_Map (file.Mode ())); } else { event_rec.Mode (file.Mode ()); } event_rec.Schedule (file.Schedule ()); event_rec.Actual (file.Actual ()); //---- check/convert the link number and direction ---- link = file.Link (); if (link > 0) { dir = file.Dir (); offset = Round (file.Offset ()); Link_Data *link_ptr = Set_Link_Direction (file, link, dir, offset); if (link_ptr == 0) return (false); if (dir) { dir_index = link_ptr->BA_Dir (); } else { dir_index = link_ptr->AB_Dir (); } if (dir_index < 0) { Warning (String ("Event %d Link %d Direction %s was Not Found") % Progress_Count () % link_ptr->Link () % ((dir) ? "BA" : "AB")); } event_rec.Dir_Index (dir_index); event_rec.Offset (offset); event_rec.Lane (file.Lane ()); } lvalue = file.Route (); if (lvalue > 0) { if (System_File_Flag (TRANSIT_ROUTE)) { Int_Map_Itr map_itr = line_map.find (lvalue); if (map_itr == line_map.end ()) { Warning (String ("Event %d Route %d was Not Found") % Progress_Count () % lvalue); return (false); } event_rec.Route (map_itr->second); } else { event_rec.Route (lvalue); } } return (true); }
void PlanSum::Program_Control (void) { String key; bool link_flag, report_flag; link_flag = report_flag = false; if (!Set_Control_Flag (UPDATE_FLOW_RATES) && !Set_Control_Flag (UPDATE_TRAVEL_TIMES)) { System_File_False (NEW_LINK_DELAY); } //---- initialize the MPI thread range ---- MPI_Setup (); //---- set equivalence flags --- if (Report_Flag (LINK_GROUP) || Report_Flag (RIDER_GROUP)) { Link_Equiv_Flag (true); link_flag = true; } if (skim_flag || trip_flag) { Zone_Equiv_Flag (true); zone_flag = true; } Stop_Equiv_Flag (Report_Flag (STOP_GROUP)); //---- create the network files ---- Data_Service::Program_Control (); Read_Select_Keys (); Read_Flow_Time_Keys (); plan_file = (Plan_File *) System_File_Handle (PLAN); if (!plan_file->Part_Flag ()) Num_Threads (1); select_flag = System_File_Flag (SELECTION); new_delay_flag = System_File_Flag (NEW_LINK_DELAY); if (System_File_Flag (LINK_DELAY)) { link_flag = true; Link_Delay_File *file = (Link_Delay_File *) System_File_Handle (LINK_DELAY); turn_flag = file->Turn_Flag (); } if (new_delay_flag) { link_flag = true; Link_Delay_File *file = (Link_Delay_File *) System_File_Handle (NEW_LINK_DELAY); turn_flag = file->Turn_Flag (); } else { turn_flag = System_File_Flag (CONNECTION); } Print (2, String ("%s Control Keys:") % Program ()); //---- new trip time file ---- key = Get_Control_String (NEW_TRIP_TIME_FILE); if (!key.empty ()) { time_file.File_Type ("New Trip Time File"); time_file.File_ID ("Time"); if (Master ()) { time_file.Create (Project_Filename (key)); } time_flag = true; } //---- new link volume file ---- key = Get_Control_String (NEW_LINK_VOLUME_FILE); if (!key.empty ()) { volume_file.File_Type ("New Link Volume File"); volume_file.File_ID ("Volume"); if (Master ()) { volume_file.Create (Project_Filename (key)); volume_file.Num_Decimals (1); volume_file.Data_Units (Performance_Units_Map (FLOW_DATA)); volume_file.Copy_Periods (sum_periods); volume_file.Create_Fields (); volume_file.Write_Header (); } volume_flag = new_delay_flag = link_flag = true; } //---- read report types ---- List_Reports (); if (Report_Flag (TOP_100) || Report_Flag (VC_RATIO) || Report_Flag (LINK_GROUP)) { new_delay_flag = link_flag = report_flag = true; cap_factor = (double) sum_periods.Range_Length () / (Dtime (1, HOURS) * sum_periods.Num_Periods ()); } if (link_flag && (!System_File_Flag (LINK) || !System_File_Flag (NODE))) { Error ("Link and Node Files are Required for Link-Based Output"); } if (System_File_Flag (LANE_USE) && !System_File_Flag (LINK)) { Error ("A Link File is Required for Lane-Use Processing"); } travel_flag = Report_Flag (SUM_TRAVEL); //---- ridership summary ---- passenger_flag = Report_Flag (SUM_PASSENGERS); transfer_flag = (Report_Flag (SUM_STOPS) || Report_Flag (STOP_GROUP)); rider_flag = (System_File_Flag (NEW_RIDERSHIP) || Report_Flag (SUM_RIDERS) || Report_Flag (RIDER_GROUP)); xfer_flag = Report_Flag (SUM_TRANSFERS); xfer_detail = Report_Flag (XFER_DETAILS); if (passenger_flag || transfer_flag || rider_flag || xfer_flag || xfer_detail) { if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) || !System_File_Flag (TRANSIT_SCHEDULE)) { Error ("Transit Network Files are Required for Ridership Output"); } if ((passenger_flag || rider_flag) && !System_File_Flag (TRANSIT_DRIVER)) { Error ("A Transit Driver File is needed for Passengers Summaries"); } } else { System_File_False (TRANSIT_STOP); System_File_False (TRANSIT_ROUTE); System_File_False (TRANSIT_SCHEDULE); System_File_False (TRANSIT_DRIVER); } //---- process support data ---- if (Link_Equiv_Flag ()) { link_equiv.Read (Report_Flag (LINK_EQUIV)); } if (Zone_Equiv_Flag ()) { zone_equiv.Read (Report_Flag (ZONE_EQUIV)); } if (Stop_Equiv_Flag ()) { stop_equiv.Read (Report_Flag (STOP_EQUIV)); } //---- allocate work space ---- if (time_flag || Report_Flag (TRIP_TIME)) { time_flag = true; int periods = sum_periods.Num_Periods (); start_time.assign (periods, 0); mid_time.assign (periods, 0); end_time.assign (periods, 0); } //---- transfer arrays ---- if (xfer_flag || xfer_detail) { Integers rail; rail.assign (10, 0); total_on_array.assign (10, rail); if (xfer_detail) { int num = sum_periods.Num_Periods (); if (num < 1) num = 1; walk_on_array.assign (num, total_on_array); drive_on_array.assign (num, total_on_array); } } //---- initialize the trip summary data ---- if (travel_flag) { trip_sum_data.Copy_Periods (sum_periods); } //---- initialize the passenger summary data ---- if (passenger_flag) { pass_sum_data.Copy_Periods (sum_periods); } }
bool ArcPlan::Get_Problem_Data (Problem_File &file, Problem_Data &problem_rec, int partition) { Location_Data *loc_ptr; Trip_Index trip_index; if (Data_Service::Get_Problem_Data (file, problem_rec, partition)) { if (select_problems && !problem_range.In_Range (problem_rec.Problem ())) return (false); if (select_households && !hhold_range.In_Range (problem_rec.Household ())) return (false); if (problem_rec.Mode () < MAX_MODE && !select_mode [problem_rec.Mode ()]) return (false); if (select_purposes && !purpose_range.In_Range (problem_rec.Purpose ())) return (false); if (select_start_times && !start_range.In_Range (problem_rec.Start ())) return (false); if (select_end_times && !end_range.In_Range (problem_rec.End ())) return (false); if (select_origins && !org_range.In_Range (file.Origin ())) return (false); if (select_destinations && !des_range.In_Range (file.Destination ())) return (false); if (select_org_zones) { loc_ptr = &location_array [problem_rec.Origin ()]; if (!org_zone_range.In_Range (loc_ptr->Zone ())) return (false); } if (select_des_zones) { loc_ptr = &location_array [problem_rec.Destination ()]; if (!des_zone_range.In_Range (loc_ptr->Zone ())) return (false); } if (select_travelers && !traveler_range.In_Range (problem_rec.Type ())) return (false); //---- check the selection records ---- if (System_File_Flag (SELECTION)) { Select_Map_Itr sel_itr; sel_itr = select_map.Best (problem_rec.Household (), problem_rec.Person (), problem_rec.Tour (), problem_rec.Trip ()); if (sel_itr == select_map.end ()) return (false); } //---- draw the problem record ---- if (problem_out) { XYZ_Point point; arcview_problem.clear (); arcview_problem.Copy_Fields (file); if (problem_method == 3) { if (file.Link () > 0 && problem_rec.Dir_Index () >= 0) { int lane, center; double side; Dir_Data *dir_ptr = &dir_array [problem_rec.Dir_Index ()]; Link_Data *link_ptr = &link_array [dir_ptr->Link ()]; lane = problem_rec.Lane () + 1; if (center_flag) { if (link_ptr->BA_Dir () < 0) { center = dir_ptr->Left () + dir_ptr->Lanes () + dir_ptr->Right () + 1; } else if (link_ptr->AB_Dir () < 0) { center = dir_ptr->Left () + dir_ptr->Lanes () + dir_ptr->Right () + 1; } else { center = 1; } } else { center = 1; } side = (2 * lane - center) * lane_width / 2.0; Link_Shape (link_ptr, dir_ptr->Dir (), points, UnRound (problem_rec.Offset ()), 0.0, side); arcview_problem.assign (1, points [0]); } else { loc_ptr = &location_array [problem_rec.Origin ()]; point.x = UnRound (loc_ptr->X ()); point.y = UnRound (loc_ptr->Y ()); arcview_problem.push_back (point); } } else if (problem_method < 2) { loc_ptr = &location_array [problem_rec.Origin ()]; point.x = UnRound (loc_ptr->X ()); point.y = UnRound (loc_ptr->Y ()); arcview_problem.push_back (point); } if (problem_method != 1) { loc_ptr = &location_array [problem_rec.Destination ()]; point.x = UnRound (loc_ptr->X ()); point.y = UnRound (loc_ptr->Y ()); arcview_problem.push_back (point); } if (!arcview_problem.Write_Record ()) { Error (String ("Writing %s") % arcview_problem.File_Type ()); } num_problem++; } //---- save the problem index ---- if (plan_flag) { trip_index.Set (problem_rec.Household (), problem_rec.Person (), problem_rec.Tour (), problem_rec.Trip ()); problem_map.insert (Trip_Map_Data (trip_index, problem_rec.Problem ())); } } return (false); }
void LinkSum::Program_Control (void) { int i, field, ngroup, num; bool binary; String key, token; Location_File *location_file; Db_Field *fld; Doubles dbl; Doubles_Itr itr; //---- set the equivalence flags ---- Zone_Equiv_Flag (Check_Control_Key (NEW_GROUP_TRAVEL_FILE)); group_select = Set_Control_Flag (SELECT_BY_LINK_GROUP); Link_Equiv_Flag (group_select || Report_Flag (LINK_GROUP) || Report_Flag (TRAVEL_TIME) || Report_Flag (GROUP_REPORT) || Report_Flag (GROUP_SUMMARY) || Check_Control_Key (NEW_GROUP_SUMMARY_FILE)); //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); turn_flag = System_File_Flag (TURN_DELAY); Print (2, String ("%s Control Keys:") % Program ()); //---- open the compare performance file ---- key = Get_Control_String (COMPARE_PERFORMANCE_FILE); if (!key.empty ()) { compare_file.File_Type ("Compare Performance File"); Print (1); if (Check_Control_Key (COMPARE_PERFORMANCE_FORMAT)) { compare_file.Dbase_Format (Get_Control_String (COMPARE_PERFORMANCE_FORMAT)); } compare_file.Open (Project_Filename (key)); compare_flag = true; } num_inc = sum_periods.Num_Periods (); if (num_inc < 1) num_inc = 1; cap_factor = (double) sum_periods.Range_Length () / (Dtime (1, HOURS) * num_inc); if (cap_factor <= 0.0) cap_factor = 1.0; //---- open the compare link map file ---- key = Get_Control_String (COMPARE_LINK_MAP_FILE); if (!key.empty ()) { link_map_file.File_Type ("Compare Link Map File"); Print (1); if (Check_Control_Key (COMPARE_LINK_MAP_FORMAT)) { link_map_file.Dbase_Format (Get_Control_String (COMPARE_LINK_MAP_FORMAT)); } link_map_file.Open (Project_Filename (key)); link_map_flag = true; } //---- get minimum volume ---- minimum_volume = Get_Control_Double (MINIMUM_LINK_VOLUME); //---- person-based statistics ---- person_flag = Get_Control_Flag (PERSON_BASED_STATISTICS); //---- get the select by link group flag ---- group_select = Get_Control_Flag (SELECT_BY_LINK_GROUP); if (group_select || select_subareas || select_polygon || select_facilities) select_flag = true; //---- turning movement data ---- if (turn_flag) { //---- open the compare turn delays file ---- key = Get_Control_String (COMPARE_TURN_DELAY_FILE); if (!key.empty ()) { turn_compare_file.File_Type ("Compare Turn Delay File"); Print (1); if (Check_Control_Key (COMPARE_TURN_DELAY_FORMAT)) { turn_compare_file.Dbase_Format (Get_Control_String (COMPARE_TURN_DELAY_FORMAT)); } turn_compare_file.Open (Project_Filename (key)); turn_compare_flag = true; } //---- select turn nodes---- key = exe->Get_Control_Text (TURN_NODE_RANGE); if (!key.empty () && !key.Equals ("ALL")) { if (!turn_range.Add_Ranges (key)) { exe->Error ("Adding Turn Node Ranges"); } } } //---- create link activity file ---- key = Get_Control_String (NEW_LINK_ACTIVITY_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Link Activity File"); } location_file = System_Location_File (); binary = (location_file->Record_Format () == BINARY); Print (1); activity_file.File_Type ("New Link Activity File"); if (Check_Control_Key (NEW_LINK_ACTIVITY_FORMAT)) { activity_file.Dbase_Format (Get_Control_String (NEW_LINK_ACTIVITY_FORMAT)); } activity_file.Create (Project_Filename (key)); //---- copy location field name ---- key = Get_Control_Text (COPY_LOCATION_FIELDS); if (key.empty ()) { Error ("Location Field Names are Required for Link Activity File"); } link_db.File_Type ("Link Location Database"); //---- set required fields ---- link_db.Add_Field ("LINK", DB_INTEGER, 10); activity_file.Add_Field ("LINK", DB_INTEGER, 10); //---- copy selected fields ---- while (!key.Split (token)) { field = location_file->Field_Number (token); if (field < 0) { Error (String ("Field %s was Not Found in the Location File") % token); } field_list.push_back (field); fld = location_file->Field (field); link_db.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); activity_file.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary); } activity_file.Write_Header (); activity_flag = true; } //---- create zone travel file ---- key = Get_Control_String (NEW_ZONE_TRAVEL_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Zone Travel File"); } Print (1); zone_file.File_Type ("New Zone Travel File"); if (Check_Control_Key (NEW_ZONE_TRAVEL_FORMAT)) { zone_file.Dbase_Format (Get_Control_String (NEW_ZONE_TRAVEL_FORMAT)); } zone_file.Create (Project_Filename (key)); zone_flag = true; } //---- create zone group travel file ---- key = Get_Control_String (NEW_GROUP_TRAVEL_FILE); if (!key.empty ()) { if (!System_File_Flag (LOCATION)) { Error ("A Location File is needed for the Group Travel File"); } Print (1); group_file.File_Type ("New Group Travel File"); if (Check_Control_Key (NEW_GROUP_TRAVEL_FORMAT)) { group_file.Dbase_Format (Get_Control_String (NEW_GROUP_TRAVEL_FORMAT)); } group_file.Create (Project_Filename (key)); group_flag = true; } if (!activity_flag && !zone_flag && !group_flag) { System_File_False (LOCATION); } //---- get the number of direction groups ---- ngroup = Highest_Control_Group (NEW_LINK_DIRECTION_FILE, 0); if (ngroup > 0) { Dir_Group group, *group_ptr; //---- process each group ---- for (i=1; i <= ngroup; i++) { key = Get_Control_String (NEW_LINK_DIRECTION_FILE, i); if (key.empty ()) continue; Print (1); dir_group.push_back (group); group_ptr = &dir_group.back (); group_ptr->group = i; group_ptr->file = new Link_Direction_File (); group_ptr->file->File_Type (String ("New Link Direction File #%d") % i); if (Check_Control_Key (NEW_LINK_DIRECTION_FORMAT, i)) { group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DIRECTION_FORMAT, i)); } group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ()); group_ptr->file->Create (Project_Filename (key)); //---- get the field name ---- key = Get_Control_Text (NEW_LINK_DIRECTION_FIELD, i); if (key.empty ()) { Error (String ("New Link Direction Field #%d is Missing") % i); } group_ptr->field = Performance_Code (key); group_ptr->index = Get_Control_Flag (NEW_LINK_DIRECTION_INDEX, i); group_ptr->flip = Get_Control_Flag (NEW_LINK_DIRECTION_FLIP, i); if (group_ptr->flip && !compare_flag) { Warning ("Link Direction Flipping requires Comparison Data"); group_ptr->flip = false; } Set_Link_Dir (group_ptr); } } //---- get the number of groups ---- ngroup = Highest_Control_Group (NEW_LINK_DATA_FILE, 0); if (ngroup > 0) { Data_Group group, *group_ptr; //---- process each group ---- for (i=1; i <= ngroup; i++) { key = Get_Control_String (NEW_LINK_DATA_FILE, i); if (key.empty ()) continue; Print (1); data_group.push_back (group); group_ptr = &data_group.back (); group_ptr->group = i; group_ptr->file = new Link_Data_File (); group_ptr->file->File_Type (String ("New Link Data File #%d") % i); if (Check_Control_Key (NEW_LINK_DATA_FORMAT, i)) { group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DATA_FORMAT, i)); } group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ()); group_ptr->file->Create (Project_Filename (key)); //---- get the field name ---- key = Get_Control_Text (NEW_LINK_DATA_FIELD, i); if (key.empty ()) { Error (String ("New Link Data Field #%d is Missing") % i); } group_ptr->field = Performance_Code (key); Set_Link_Data (group_ptr); } } //---- data summary file ---- key = Get_Control_String (NEW_DATA_SUMMARY_FILE); if (!key.empty ()) { Print (1); summary_file.File_Type ("New Data Summary File"); if (Check_Control_Key (NEW_DATA_SUMMARY_FORMAT)) { summary_file.Dbase_Format (Get_Control_String (NEW_DATA_SUMMARY_FORMAT)); } summary_file.Add_Field ("MEASURE", DB_STRING, 40); summary_file.Add_Field ("VALUE", DB_DOUBLE, 12.2); if (compare_flag) summary_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2); summary_file.Create (Project_Filename (key)); summary_flag = true; //---- data summary periods ---- if (!Control_Key_Empty (NEW_DATA_SUMMARY_PERIODS)) { periods_flag = data_periods.Add_Ranges (Get_Control_Text (NEW_DATA_SUMMARY_PERIODS)); } //---- data summary ratios ---- if (Check_Control_Key (NEW_DATA_SUMMARY_RATIOS)) { Double_List list; Dbl_Itr itr; Get_Control_List (NEW_DATA_SUMMARY_RATIOS, list); for (i=0, itr = list.begin (); itr != list.end (); itr++, i++) { if (i > 0 && *itr >= 1.0) { data_ratios.push_back (Round (*itr * 100.0)); ratios_flag = true; } } } } //---- group summary file ---- key = Get_Control_String (NEW_GROUP_SUMMARY_FILE); if (!key.empty ()) { Print (1); group_sum_file.File_Type ("New Group Summary File"); if (Check_Control_Key (NEW_GROUP_SUMMARY_FORMAT)) { group_sum_file.Dbase_Format (Get_Control_String (NEW_GROUP_SUMMARY_FORMAT)); } group_sum_file.Add_Field ("MEASURE", DB_STRING, 40); group_sum_file.Add_Field ("VALUE", DB_DOUBLE, 12.2); if (compare_flag) group_sum_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2); group_sum_file.Create (Project_Filename (key)); group_sum_flag = true; } //---- read report types ---- List_Reports (); if (!compare_flag && (Report_Flag (TIME_CHANGE) || Report_Flag (VOLUME_CHANGE) || Report_Flag (TOP_TIME_CHANGE) || Report_Flag (TOP_VOL_CHANGE) || Report_Flag (RELATIVE_GAP))) { Error ("A Compare Performance File is Required for Change Reports"); } //---- process support data ---- if (Link_Equiv_Flag ()) { link_equiv.Read (Report_Flag (LINK_EQUIV)); } if (group_flag) { zone_equiv.Read (Report_Flag (ZONE_EQUIV)); } //---- allocate work space ---- if (periods_flag || ratios_flag) { num = (periods_flag) ? (int) data_periods.size () : 1; num += (ratios_flag) ? (int) data_ratios.size () : 1; if (num_inc + 1 > num) { num = num_inc + 1; } } else { num = num_inc + 1; } sum_bin.assign (num, dbl); for (itr = sum_bin.begin (); itr != sum_bin.end (); itr++) { itr->assign (NUM_SUM_BINS, 0.0); } }
void ExportPlans::Read_Plans (void) { int part, num, first, part_num, org, des, period, link, dir, veh_type; bool start_flag, vehicle_flag; Dtime start; Plan_File *file = (Plan_File *) System_File_Handle (PLAN); Int_Map_Itr map_itr; Plan_Data plan_rec; Plan_Leg_Itr leg_itr; Location_Data *loc_ptr; Link_Data *link_ptr; Node_Data *node_ptr; Vehicle_Map_Itr vehicle_itr; Vehicle_Index veh_index; Vehicle_Data *vehicle_ptr; Veh_Type_Data *veh_type_ptr; Trip_Table_Map_Stat trip_map_stat; Trip_Table trip_table, *table_ptr; Matrix_Index trip_index; Trip_Table_Stat trip_stat; Integers volumes; num = sum_periods.Num_Periods (); volumes.assign (MAX (num, 1), 0); //---- check the partition number ---- period = first = 0; if (file->Part_Flag () && First_Partition () != file->Part_Number ()) { file->Open (0); } else if (First_Partition () >= 0) { first = First_Partition (); } veh_type = 1; vehicle_flag = System_File_Flag (VEHICLE); //---- process each partition ---- for (part=0; ; part++) { if (part > 0) { if (!file->Open (part)) break; } //---- store the plan data ---- if (file->Part_Flag ()) { part_num = file->Part_Number (); Show_Message (String ("Reading %s %d -- Record") % file->File_Type () % part_num); } else { part_num = part + first; Show_Message (String ("Reading %s -- Record") % file->File_Type ()); } Set_Progress (); while (file->Read_Plan (plan_rec)) { Show_Progress (); if (vehicle_flag) { if (plan_rec.Vehicle () <= 0) continue; veh_index.Household (plan_rec.Household ()); veh_index.Vehicle (plan_rec.Vehicle ()); vehicle_itr = vehicle_map.find (veh_index); if (vehicle_itr == vehicle_map.end ()) continue; vehicle_ptr = &vehicle_array [vehicle_itr->second]; veh_type_ptr = &veh_type_array [vehicle_ptr->Type ()]; veh_type = veh_type_ptr->Type (); } if (select_vehicles && !vehicle_range.In_Range (veh_type)) continue; start = plan_rec.Depart (); org = plan_rec.Origin (); des = plan_rec.Destination (); if (select_flag) { map_itr = location_map.find (org); if (map_itr != location_map.end ()) { loc_ptr = &location_array [map_itr->second]; start_flag = (loc_ptr->Zone () > 0); } else { start_flag = false; } //---- trace the path ---- for (leg_itr = plan_rec.begin (); leg_itr != plan_rec.end (); leg_itr++) { if (leg_itr->Mode () == DRIVE_MODE && leg_itr->Link_Type ()) { link = leg_itr->Link_ID (); dir = leg_itr->Link_Dir (); map_itr = link_map.find (link); if (map_itr != link_map.end ()) { link_ptr = &link_array [map_itr->second]; if (link_ptr->Divided () != 0) { if (dir == 0) { if (link_ptr->Divided () == 1) { node_ptr = &node_array [link_ptr->Bnode ()]; des = node_ptr->Control (); break; } else if (!start_flag) { node_ptr = &node_array [link_ptr->Anode ()]; org = node_ptr->Control (); } } else { if (link_ptr->Divided () == 2) { node_ptr = &node_array [link_ptr->Anode ()]; des = node_ptr->Control (); break; } else if (!start_flag) { node_ptr = &node_array [link_ptr->Bnode ()]; org = node_ptr->Control (); } } start_flag = true; } } } if (!start_flag) start += leg_itr->Time (); } if (!start_flag) continue; } if (map_flag) { map_itr = loc_zone_map.find (org); if (map_itr != loc_zone_map.end ()) { org = map_itr->second; } map_itr = loc_zone_map.find (des); if (map_itr != loc_zone_map.end ()) { des = map_itr->second; } } trip_index.Origin (org); trip_index.Destination (des); if (num > 0) { period = sum_periods.Period (start); if (period < 0) continue; } trip_map_stat = trip_tables.insert (Trip_Table_Map_Data (veh_type, trip_table)); table_ptr = &trip_map_stat.first->second; trip_stat = table_ptr->insert (Trip_Table_Data (trip_index, volumes)); trip_stat.first->second [period]++; } End_Progress (); } file->Close (); }
int Data_Service::Put_Ridership_Data (Ridership_File &file, Line_Data &data) { int i, runs, count; double capacity, cap; bool type_flag = false; Int_Map_Itr itr; Line_Stop_Itr stop_itr; Line_Run *run_ptr; Stop_Data *stop_ptr; Veh_Type_Data *veh_type_ptr; count = 0; if (System_File_Flag (VEHICLE_TYPE)) { veh_type_ptr = &veh_type_array [data.Type ()]; capacity = veh_type_ptr->Capacity () / 100.0; //---- ratio type_flag = ((int) data.run_types.size () > 0); } else { capacity = 100.0; } file.Route (data.Route ()); stop_itr = data.begin (); runs = (int) stop_itr->size (); file.Mode (data.Mode ()); file.Route (data.Route ()); for (i=0; i < runs; i++) { file.Run (i+1); for (stop_itr = data.begin (); stop_itr != data.end (); stop_itr++) { run_ptr = &(stop_itr->at (i)); if (run_ptr->Schedule () == run_ptr->Time () && run_ptr->Board () == 0 && run_ptr->Alight () == 0 && run_ptr->Load () == 0) continue; stop_ptr = &stop_array [stop_itr->Stop ()]; file.Stop (stop_ptr->Stop ()); file.Schedule (run_ptr->Schedule ()); if (run_ptr->Time () == 0 && run_ptr->Schedule () > 0) { file.Time (run_ptr->Schedule ()); } else { file.Time (run_ptr->Time ()); } file.Board (run_ptr->Board ()); file.Alight (run_ptr->Alight ()); file.Load (run_ptr->Load ()); if (run_ptr->Factor () == 0 && run_ptr->Load () > 0) { if (type_flag) { veh_type_ptr = &veh_type_array [data.Run_Type (i)]; cap = veh_type_ptr->Capacity () / 100.0; } else { cap = capacity; } if (cap > 0) { file.Factor (run_ptr->Load () / cap); } else { file.Factor (100); } } else { file.Factor (run_ptr->Factor ()); } if (!file.Write ()) { Error (String ("Writing %s") % file.File_Type ()); } count++; } } return (count); }
void EventSum::Program_Control (void) { String key; //---- create the network files ---- Data_Service::Program_Control (); Read_Select_Keys (); select_flag = System_File_Flag (SELECTION); trip_file_flag = System_File_Flag (TRIP); new_select_flag = System_File_Flag (NEW_SELECTION); update_flag = System_File_Flag (PLAN) || System_File_Flag (NEW_PLAN); if (update_flag && (!System_File_Flag (PLAN) || !System_File_Flag (NEW_PLAN))) { Error ("Input and Output Plan Files are Required for Plan Updates"); } num_inc = sum_periods.Num_Periods (); Print (2, String ("%s Control Keys:") % Program ()); //---- get the compare travel time file ---- key = Get_Control_String (TRAVEL_TIME_FILE); if (!key.empty ()) { if (Check_Control_Key (TRAVEL_TIME_FORMAT)) { time_in_file.Dbase_Format (Get_Control_String (TRAVEL_TIME_FORMAT)); } time_in_file.Open (Project_Filename (key)); time_in_flag = true; } //---- get the travel time file ---- key = Get_Control_String (NEW_TRAVEL_TIME_FILE); if (!key.empty ()) { if (Check_Control_Key (NEW_TRAVEL_TIME_FORMAT)) { travel_time_file.Dbase_Format (Get_Control_String (NEW_TRAVEL_TIME_FORMAT)); } travel_time_file.Create (Project_Filename (key)); time_file_flag = true; } //---- get the time summary file ---- key = Get_Control_String (NEW_TIME_SUMMARY_FILE); if (!key.empty ()) { time_sum_file.File_Type ("New Time Summary File"); if (Check_Control_Key (NEW_TIME_SUMMARY_FORMAT)) { time_sum_file.Dbase_Format (Get_Control_String (NEW_TIME_SUMMARY_FORMAT)); } time_sum_file.Create (Project_Filename (key)); time_sum_flag = true; //---- get the minimum schedule variance ---- min_variance = Get_Control_Time (MINIMUM_SCHEDULE_VARIANCE); } //---- get the link event file ---- key = Get_Control_String (NEW_LINK_EVENT_FILE); if (!key.empty ()) { link_event_file.File_Type ("New Link Event File"); if (Check_Control_Key (NEW_LINK_EVENT_FORMAT)) { link_event_file.Dbase_Format (Get_Control_String (NEW_LINK_EVENT_FORMAT)); } link_event_file.Create (Project_Filename (key)); link_event_flag = true; } //---- new time distribution file ---- time_diff.Open_Distribution (Get_Control_String (NEW_TIME_DISTRIBUTION_FILE)); //---- new trip time gap file ---- time_gap.Open_Trip_Gap_File (Get_Control_String (NEW_TRIP_TIME_GAP_FILE)); //---- read report types ---- List_Reports (); //---- set report flags ---- time_flag = time_diff.Report_Flags (Report_Flag (TOTAL_TIME), Report_Flag (PERIOD_TIME), Report_Flag (TOT_TIME_SUM), Report_Flag (PER_TIME_SUM)); if (time_diff.Output_Flag () || Report_Flag (PERIOD_TIME) || Report_Flag (PER_TIME_SUM)) { time_diff.Set_Periods (sum_periods); time_flag = time_diff_flag = true; } if (time_gap.Output_Flag () || Report_Flag (TRP_TIME_GAP)) { time_gap.Report_Flags (Report_Flag (TRP_TIME_GAP)); time_gap.Set_Periods (sum_periods); time_gap_flag = true; } //---- set the compare flag ---- compare_flag = (time_in_flag || trip_file_flag); }
void NewFormat::Program_Control (void) { bool type_flag, flat_flag, time_flag; String key; //---- open the support files ---- Data_Service::Program_Control (); if (Check_Control_Key (VERSION4_PLAN_FILE) && Check_Control_Key (TRIP_SORT_TYPE)) { Warning ("Plan Sorting is Limited to Version 5 Plan files"); Show_Message (1); } Print (2, String ("%s Control Keys:") % Program ()); //---- copy existing fields ---- copy_flag = Get_Control_Flag (COPY_EXISTING_FIELDS); if (copy_flag) { if (System_File_Flag (LOCATION) && System_File_Flag (NEW_LOCATION)) { Location_File *file = (Location_File *) System_File_Handle (LOCATION); new_loc_file = (Location_File *) System_File_Handle (NEW_LOCATION); new_loc_file->Add_User_Fields (file); } if (System_File_Flag (ZONE) && System_File_Flag (NEW_ZONE)) { Zone_File *file = (Zone_File *) System_File_Handle (ZONE); new_zone_file = (Zone_File *) System_File_Handle (NEW_ZONE); new_zone_file->Add_User_Fields (file); } } //---- copy existing configuration ---- if (System_File_Flag (LINK_DELAY) && System_File_Flag (NEW_LINK_DELAY)) { Link_Delay_File *file = (Link_Delay_File *) System_File_Header (LINK_DELAY); if (file->Turn_Flag ()) { file = (Link_Delay_File *) System_File_Header (NEW_LINK_DELAY); file->Clear_Fields (); file->Turn_Flag (true); file->Set_Nesting (true); file->Create_Fields (); file->Write_Header (); } } if (System_File_Flag (PERFORMANCE) && System_File_Flag (NEW_PERFORMANCE)) { Performance_File *file = (Performance_File *) System_File_Header (PERFORMANCE); if (file->Turn_Flag ()) { file = (Performance_File *) System_File_Header (NEW_PERFORMANCE); file->Clear_Fields (); file->Turn_Flag (true); file->Set_Nesting (true); file->Create_Fields (); file->Write_Header (); } } //---- flatten output flag ---- flat_flag = Get_Control_Flag (FLATTEN_OUTPUT_FLAG); if (flat_flag) { if (System_File_Flag (NEW_SHAPE)) { System_File_Header (NEW_SHAPE)->Flatten_File (); } if (System_File_Flag (NEW_PARKING)) { System_File_Header (NEW_PARKING)->Flatten_File (); } if (System_File_Flag (NEW_SIGNAL)) { System_File_Header (NEW_SIGNAL)->Flatten_File (); } if (System_File_Flag (NEW_TIMING_PLAN)) { System_File_Header (NEW_TIMING_PLAN)->Flatten_File (); } if (System_File_Flag (NEW_PHASING_PLAN)) { System_File_Header (NEW_PHASING_PLAN)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_ROUTE)) { System_File_Header (NEW_TRANSIT_ROUTE)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_SCHEDULE)) { System_File_Header (NEW_TRANSIT_SCHEDULE)->Flatten_File (); } if (System_File_Flag (NEW_TRANSIT_DRIVER)) { System_File_Header (NEW_TRANSIT_DRIVER)->Flatten_File (); } if (System_File_Flag (NEW_ROUTE_NODES)) { System_File_Header (NEW_ROUTE_NODES)->Flatten_File (); } if (System_File_Flag (NEW_HOUSEHOLD)) { System_File_Header (NEW_HOUSEHOLD)->Flatten_File (); } if (System_File_Flag (NEW_LINK_DELAY)) { System_File_Header (NEW_LINK_DELAY)->Flatten_File (); } if (System_File_Flag (NEW_PERFORMANCE)) { System_File_Header (NEW_PERFORMANCE)->Flatten_File (); } if (System_File_Flag (NEW_PLAN)) { System_File_Header (NEW_PLAN)->Flatten_File (); } } //---- toll file ---- key = Get_Control_String (TOLL_FILE); if (!key.empty ()) { toll_file.Open (Project_Filename (key)); toll_flag = true; } //---- activity file ---- key = Get_Control_String (ACTIVITY_FILE); if (!key.empty ()) { activity_file.Open (Project_Filename (key)); activity_flag = true; if (!System_File_Flag (NEW_TRIP)) { Error ("A New Trip file is required to convert an Activity File"); } if (!System_File_Flag (VEHICLE)) { Error ("A Vehicle file is required to convert an Activity File"); } } //---- person file ---- key = Get_Control_String (PERSON_FILE); if (!key.empty ()) { person_file.Open (Project_Filename (key)); person_flag = true; } //---- snapshot file ---- key = Get_Control_String (SNAPSHOT_FILE); if (!key.empty ()) { Print (1); snap_file.Open (Project_Filename (key)); snap_flag = true; } //---- new snapshot file ---- key = Get_Control_String (NEW_SNAPSHOT_FILE); if (!key.empty ()) { new_snap_file.Compress_Flag (Set_Control_Flag (NEW_SNAPSHOT_COMPRESSION)); if (new_snap_file.Compress_Flag ()) { new_snap_file.Dbase_Format (BINARY); } else { if (Check_Control_Key (NEW_SNAPSHOT_FORMAT)) { new_snap_file.Dbase_Format (Get_Control_String (NEW_SNAPSHOT_FORMAT)); } new_snap_file.Location_Flag (snap_file.Location_Flag ()); new_snap_file.Cell_Flag (snap_file.Cell_Flag ()); new_snap_file.Status_Flag (snap_file.Status_Flag ()); } new_snap_file.Create (Project_Filename (key)); Get_Control_Flag (NEW_SNAPSHOT_COMPRESSION); } else if (snap_flag) { Error ("A New Snapshot File is required for Output"); } //---- version 4 time format ---- time_units = Units_Code (Get_Control_Text (VERSION4_TIME_FORMAT)); time_flag = Check_Control_Key (VERSION4_TIME_FORMAT); if (time_flag) { int num; Field_Ptr fld_ptr; if (System_File_Flag (TRIP)) { Trip_File *file = (Trip_File *) System_File_Base (TRIP); if (file->Version () <= 40) { num = file->Optional_Field (START_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } num = file->Optional_Field (END_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } num = file->Optional_Field (DURATION_FIELD_NAMES); if (num >= 0) { fld_ptr = file->Field (num); fld_ptr->Units (time_units); } } } if (activity_flag) { num = activity_file.Optional_Field ("START_MIN", "START", "START_TIME", "STARTTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("START_MAX", "START", "START_TIME", "STARTTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("END_MIN", "END", "END_TIME", "ENDTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("END_MAX", "END", "END_TIME", "ENDTIME"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("TIME_MIN", "DURATION"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } num = activity_file.Optional_Field ("TIME_MAX", "DURATION"); if (num >= 0) { fld_ptr = activity_file.Field (num); fld_ptr->Units (time_units); } } } //---- plan file ---- if (Check_Control_Key (VERSION4_PLAN_FILE)) { if (System_File_Flag (PLAN)) { Error ("A plan file and Version 4 plan file must be processed separateley"); } if (!System_File_Flag (NEW_PLAN)) { Error ("A new plan file is required to convert a Version 4 plan file"); } Print (1); plan_flag = true; old_plan.File_Type ("Version4 Plan File"); //---- get the list type ---- key = Get_Control_String (NODE_LIST_PATHS); if (!key.empty ()) { type_flag = key.Bool (); } else { type_flag = true; } old_plan.Node_Based_Flag (type_flag); //---- get the traveler scale ---- key = Get_Control_String (TRAVELER_SCALING_FACTOR); if (!key.empty ()) { scale = key.Integer (); if (scale < 2 || scale > 100) { Control_Key_Error (TRAVELER_SCALING_FACTOR, "(2..100)"); } old_plan.Traveler_Scale (scale); } //---- get the file format ---- if (Check_Control_Key (VERSION4_PLAN_FORMAT)) { old_plan.File_Format (Get_Control_String (VERSION4_PLAN_FORMAT)); } //---- open the file and print the parameters ---- if (!old_plan.Open (Project_Filename (Get_Control_String (VERSION4_PLAN_FILE)))) { File_Error ("Opening Version4 Plan File", old_plan.Filename ()); } Get_Control_Text (VERSION4_PLAN_FORMAT); type_flag = old_plan.Node_Based_Flag (); if (type_flag) { Print (1, "Plan File contains Node List Paths"); if (!System_File_Flag (NODE) || !System_File_Flag (LINK) || !System_File_Flag (PARKING)) { Error ("A Node, Link and Parking Files are Required for Node-Based Plan Files"); } AB_Map_Flag (true); } else { Print (1, "Plan File contains Link List Paths"); } Get_Control_Integer (TRAVELER_SCALING_FACTOR); } else if (snap_flag && snap_file.Version () <= 40) { //---- get the traveler scale ---- scale= Get_Control_Integer (TRAVELER_SCALING_FACTOR); if (scale < 2 || scale > 100) { Control_Key_Error (TRAVELER_SCALING_FACTOR, "(2..100)"); } } //---- Version 4 Route Header and Node files ---- if (Check_Control_Key (VERSION4_ROUTE_HEADER)) { if (!System_File_Flag (NEW_ROUTE_NODES)) { Error ("A New Route Nodes File is Required"); } int i, num; String field; Field_Ptr fld_ptr; if (!time_flag) time_units = MINUTES; Print (1); route_flag = true; Route_Nodes_File *file = (Route_Nodes_File *) System_File_Base (NEW_ROUTE_NODES); key = Get_Control_String (VERSION4_ROUTE_HEADER); route_header.File_Type ("Version4 Route Header"); route_header.File_ID ("Header"); route_header.Open (Project_Filename (key)); for (i=1; i <= 24; i++) { field ("HEADWAY_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num < 0) break; fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); field ("OFFSET_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num >= 0) { fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); } field ("TTIME_%d") % i; num = route_header.Optional_Field (field.c_str ()); if (num >= 0) { fld_ptr = route_header.Field (num); fld_ptr->Units (time_units); } } route_periods = i - 1; if (route_periods != file->Num_Periods ()) { file->Num_Periods (route_periods); file->Clear_Fields (); file->Create_Fields (); file->Write_Header (); } key = Get_Control_String (VERSION4_ROUTE_NODES); if (key.empty ()) { Error ("A Version4 Route Nodes file is Required"); } route_nodes.File_Type ("Version4 Route Nodes"); route_nodes.File_ID ("Nodes"); route_nodes.Open (Project_Filename (key)); } }
void PerfPrep::Program_Control (void) { String key; Strings list; Str_Itr str_itr; //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); Read_Flow_Time_Keys (); Print (2, String ("%s Control Keys:") % Program ()); new_file_flag = System_File_Flag (NEW_PERFORMANCE); //---- open the merge performance ---- key = Get_Control_String (MERGE_PERFORMANCE_FILE); if (!key.empty ()) { merge_file.File_Type ("Merge Performance File"); Print (1); if (Check_Control_Key (MERGE_PERFORMANCE_FORMAT)) { merge_file.Dbase_Format (Get_Control_String (MERGE_PERFORMANCE_FORMAT)); } merge_file.Open (Project_Filename (key)); merge_flag = true; if (!new_file_flag) { Error ("A New Performance File is required for Merge Processing"); } } //---- open the base performance ---- key = Get_Control_String (BASE_PERFORMANCE_FILE); if (!key.empty ()) { base_file.File_Type ("Base Performance File"); Print (1); if (Check_Control_Key (BASE_PERFORMANCE_FORMAT)) { base_file.Dbase_Format (Get_Control_String (BASE_PERFORMANCE_FORMAT)); } base_file.Open (Project_Filename (key)); base_flag = true; if (!new_file_flag) { Error ("A New Performance File is required for Base Processing"); } } //---- open the merge turn delay ---- turn_flag = System_File_Flag (TURN_DELAY); if (turn_flag) { key = Get_Control_String (MERGE_TURN_DELAY_FILE); if (!key.empty ()) { turn_file.File_Type ("Merge Turn Delay File"); Print (1); if (Check_Control_Key (MERGE_TURN_DELAY_FORMAT)) { turn_file.Dbase_Format (Get_Control_String (MERGE_TURN_DELAY_FORMAT)); } turn_file.Open (Project_Filename (key)); turn_merge_flag = true; if (!System_File_Flag (NEW_TURN_DELAY)) { Error ("A New Turn Delay File is required for Merge Processing"); } } } //---- processing method ---- Print (1); key = Get_Control_Text (PROCESSING_METHOD); if (!key.empty ()) { method = Combine_Code (key); if (method != UPDATE_TIMES) { if (merge_flag || turn_merge_flag) { if (method == WEIGHTED_LINK_AVG || method == REPLACE_AVERAGE) { //---- merge weighting factor ---- factor = Get_Control_Double (MERGE_WEIGHTING_FACTOR); } } else { //Error (String ("Processing Method %s requires Merge Files") % key); } } } //---- read the smoothing parameters ---- smooth_flag = smooth_data.Read_Control (); if (smooth_flag) { if (!smooth_data.Num_Input (time_periods.Num_Periods ())) { Error ("Smooth Parameters are Illogical"); } if (!new_file_flag) { Error ("A New Performance File is required for Data Smoothing"); } } //---- set min travel time ---- min_time_flag = Get_Control_Flag (SET_MIN_TRAVEL_TIME); if (min_time_flag && !new_file_flag) { Error ("A New Performance File is required for Minimum Travel Times"); } //---- set merge transit data ---- key = Get_Control_Text (MERGE_TRANSIT_DATA); if (!key.empty ()) { transit_flag = true; if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) || !System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER)) { Error ("Transit Network Files are Required for Transit Loading"); } if (!new_file_flag) { Error ("A New Performance File is required to Merge Transit Data"); } key.Parse (list); for (str_itr = list.begin (); str_itr != list.end (); str_itr++) { if (str_itr->Starts_With ("VEH")) { transit_veh_flag = true; } else if (str_itr->Starts_With ("PER")) { transit_person_flag = true; } else if (str_itr->Starts_With ("PCE") || str_itr->Starts_With ("CAR_EQ")) { transit_pce_flag = true; } } if (!System_File_Flag (VEHICLE_TYPE) && transit_pce_flag) { Warning ("Vehicle Type File is Required for Transit PCE Loading"); } if (!System_File_Flag (RIDERSHIP) && transit_person_flag) { Warning ("Ridership File is Required for Transit Person Loading"); } if (!merge_flag) { method = Combine_Code (Get_Control_Text (PROCESSING_METHOD)); } } //---- open the time constraint file ---- key = Get_Control_String (TIME_CONSTRAINT_FILE); if (!key.empty ()) { constraint_file.File_Type ("Time Constraint File"); Print (1); if (Check_Control_Key (TIME_CONSTRAINT_FORMAT)) { constraint_file.Dbase_Format (Get_Control_String (TIME_CONSTRAINT_FORMAT)); } constraint_file.Open (Project_Filename (key)); constraint_flag = true; } //---- open the time ratio file ---- key = Get_Control_String (NEW_TIME_RATIO_FILE); if (!key.empty ()) { time_ratio_file.File_Type ("New Time Ratio File"); time_ratio_file.Create (Project_Filename (key)); time_ratio_flag = true; } //---- open the deleted record file ---- key = Get_Control_String (NEW_DELETED_RECORD_FILE); if (!key.empty ()) { deleted_file.File_Type ("New Deleted Record File"); Print (1); if (Check_Control_Key (NEW_DELETED_RECORD_FORMAT)) { deleted_file.Dbase_Format (Get_Control_String (NEW_DELETED_RECORD_FORMAT)); } deleted_file.Create (Project_Filename (key)); del_file_flag = true; } List_Reports (); first_delete = deleted_flag = (Report_Flag (DELETED_RECORDS) || del_file_flag); }
void TransimsNet::Execute (void) { Int_Map_Itr map_itr; //---- read the update and delete files ---- if (update_link_flag || update_node_flag || delete_link_flag || delete_node_flag) { //Read_Files (); } //---- read the network ---- Data_Service::Execute (); //---- set the record numbers ---- location_base = (int) location_array.size (); if (location_base > 0) { map_itr = --location_map.end (); location_id = ((map_itr->first / 100) + 1) * 100 - 1; } parking_base = (int) parking_array.size (); if (parking_base > 0) { map_itr = --parking_map.end (); parking_id = ((map_itr->first / 100) + 1) * 100 - 1; } //---- read the link detail file ---- if (link_detail_flag) { Read_Details (); } //---- read the zone boundary file ---- if (boundary_flag) { Read_Boundary (); } //---- add link access points ---- Link_Access (); Write_Locations (); Write_Parking_Lots (); //---- build the link connection list ---- Connections (); //---- create traffic controls ---- Traffic_Controls (); Write_Signs (); Write_Signals (); //---- create pocket lanes ---- Pocket_Lanes (); Write_Pockets (); //---- create lane ranges ---- Lane_Ranges (); Write_Connections (); //---- write the network ---- nnode = (int) node_array.size (); nlink = (int) link_array.size (); nshapes = (int) shape_array.size (); Write_Nodes (); if (zout_flag) { nzout = (int) zone_array.size (); Write_Zones (); } if (shape_flag) { nshape = Write_Shapes (); } Write_Links (); //---- link detail lane use ---- if (link_detail_flag && System_File_Flag (NEW_LANE_USE)) { Lane_Use (); nuse = (int) lane_use_array.size (); Write_Lane_Uses (); } //---- write the turn penalties ---- if (turn_flag && Network_File_Flag (NEW_TURN_PENALTY)) { Write_Turn_Pens (); } //---- write summary statistics ---- Break_Check (6); Write (2, "Number of Input Node Records = ") << node_array.size (); Write (1, "Number of Input Link Records = ") << link_array.size (); Write (1, "Number of Input Zone Records = ") << zone_array.size (); Write (2, "Highest Zone Number = ") << Max_Zone_Number (); if (update_flag || delete_flag) { Break_Check (10); Write (1); if (xlink) Write (1, "Number of Deleted Link Records = ") << xlink; if (xnode) Write (1, "Number of Deleted Node Records = ") << xnode; if (xactivity) Write (1, "Number of Deleted Location Records = ") << xactivity; if (xparking) Write (1, "Number of Deleted Parking Lot Records = ") << xparking; if (xprocess) Write (1, "Number of Deleted Access Link Records = ") << xprocess; if (xpocket) Write (1, "Number of Deleted Pocket Lane Records = ") << xpocket; if (xconnect) Write (1, "Number of Deleted Connection Records = ") << xconnect; if (xuse) Write (1, " Number of Deleted Lane Use Records = ") << xuse; if (xsign) Write (1, "Number of Deleted Sign Records = ") << xsign; if (xsignal) Write (1, "Number of Deleted Signal Records = ") << xsignal; } Break_Check (15); Write (2, "Number of New Node Records = ") << nnode; if (zout_flag) { Write (1, "Number of New Zone Records = ") << nzout; } Write (1, "Number of New Link Records = ") << nlink; if (shape_flag) { Write (1, "Number of New Link Shapes = ") << nshapes; Write (1, "Number of New Shape_Records = ") << nshape; } Write (1, "Number of New Location Records = ") << ((int) location_array.size () - location_base); Write (1, "Number of New Parking Lot Records = ") << ((int) parking_array.size () - parking_base); Write (1, "Number of New Access Link Records = ") << nprocess; Write (1, "Number of New Pocket Lane Records = ") << npocket; Write (1, "Number of New Connection Records = ") << nconnect; if (nturn > 0) Write (1, "Number of New Turn Penalty Records = ") << nturn; if (nuse > 0) Write (1, "Number of New Lane Use Records = ") << nuse; Write (1, "Number of New Sign Records = ") << nsign; Write (1, "Number of New Signal Records = ") << nsignal; if (nexternal) { Write (2, "Number of External Connections = ") << nexternal; } if (nshort) { Print (2, "Number of Short Links Increased in Length = ") << nshort; } if (nlength) { Print (2, "Number of Coordinate-Based Length Adjustments = ") << nlength; } if (nsign > 0) { Break_Check (2); Print (1); if (nstop > 0) { Print (1, "Number of Stop Signs = ") << nstop; } if (nyield > 0) { Print (1, "Number of Yield Signs = ") << nyield; } } if (nsignal > 0) { Break_Check (5); Print (1); if (nfixed1 > 0) { Print (1, "Number of Fixed Timed Single Ring Signals = ") << nfixed1; } if (nfixed2 > 0) { Print (1, "Number of Fixed Timed Dual Ring Signals = ") << nfixed2; } if (nfixed3 > 0) { Print (1, "Number of Fixed Timed Triple Ring Signals = ") << nfixed3; } if (nactuated1 > 0) { Print (1, "Number of Demand Actuated Single Ring Signals = ") << nactuated1; } if (nactuated2 > 0) { Print (1, "Number of Demand Actuated Dual Ring Signals = ") << nactuated2; } if (nactuated3 > 0) { Print (1, "Number of Demand Actuated Triple Ring Signals = ") << nactuated3; } } Exit_Stat (DONE); }
void Validate::Program_Control (void) { int i, num; String key, record; Dtime low, high; Db_File label_file; Str_Map_Stat map_stat; //---- set equivalence flags ---- line_flag = Report_Flag (LINE_GROUP); stop_flag = (Report_Flag (STOP_GROUP) || Report_Flag (BOARD_GROUP) || Report_Flag (ALIGHT_GROUP)); Link_Equiv_Flag (Report_Flag (LINK_GROUP) || Report_Flag (GROUP_DETAILS)); Zone_Equiv_Flag (Report_Flag (ZONE_GROUP)); Stop_Equiv_Flag (stop_flag); Line_Equiv_Flag (line_flag); //---- open network files ---- Data_Service::Program_Control (); Print (2, String ("%s Control Keys:") % Program ()); //---- check for traffic counts ---- if (Check_Control_Key (TRAFFIC_COUNT_FILE)) { link_flag = true; if (Report_Flag (ZONE_GROUP)) { if (!System_File_Flag (ZONE)) { Error ("Zone File is Required for Zone Group Reports"); } zone_flag = true; } else if (Report_Flag (AREA_TYPE)) { zone_flag = System_File_Flag (ZONE); } } else { if (Report_Flag (VOLUME_LEVEL) || Report_Flag (FACILITY_TYPE) || Report_Flag (AREA_TYPE) || Report_Flag (ZONE_GROUP) || Report_Flag (LINK_GROUP) || Report_Flag (GROUP_DETAILS)) { Error ("Traffic Count file is Required for Link-Based Reports"); } } //---- check for turning movements ---- if (Check_Control_Key (TURN_COUNT_FILE)) { if ((Report_Flag (TURN_MOVEMENT) || Report_Flag (TURN_LOS)) && !System_File_Flag (CONNECTION)) { Error ("Connection File is Required for Turning Movement Reports"); } if (Report_Flag (TURN_LOS) && !(System_File_Flag (SIGNAL) && System_File_Flag (TIMING_PLAN) && System_File_Flag (PHASING_PLAN))) { Error ("Signal Data is Required for Turn Level of Service Analysis"); } turn_flag = true; } else { if (Report_Flag (TURN_MOVEMENT) || Report_Flag (TURN_LOS)) { Error ("Turn Count File is Required for Turning Movement Reports"); } System_File_False (POCKET); System_File_False (CONNECTION); System_File_False (SIGNAL); System_File_False (TIMING_PLAN); System_File_False (PHASING_PLAN); } //---- check for transit reports ---- if (line_flag || stop_flag) { if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) || !System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER) || !System_File_Flag (RIDERSHIP)) { Error ("Transit Network and Ridership are Required for Transit Reports"); } if (line_flag && !Check_Control_Key (LINE_EQUIVALENCE_FILE)) { Error ("Line Group Equivalance is Required for Line Group Reports"); } if (line_flag && !Check_Control_Key (LINE_GROUP_COUNT_FILE)) { Error ("Line Group Counts are Required for Line Group Reports"); } if (stop_flag && !Check_Control_Key (STOP_EQUIVALENCE_FILE)) { Error ("Stop Group Equivalance is Required for Stop Group Reports"); } if (stop_flag && !Check_Control_Key (STOP_GROUP_COUNT_FILE)) { Error ("Stop Group Counts are Required for Stop Group Reports"); } } else { System_File_False (TRANSIT_STOP); System_File_False (TRANSIT_ROUTE); System_File_False (TRANSIT_SCHEDULE); System_File_False (TRANSIT_DRIVER); System_File_False (RIDERSHIP); } //---- check for a link delay file ---- if (!System_File_Flag (LINK_DELAY)) { //---- open the link volume file ---- if (link_flag) { key = Get_Control_String (INPUT_VOLUME_FILE); if (key.empty ()) goto control_error; Print (1); volume_file.File_Type ("Input Volume File"); volume_file.Open (Project_Filename (key)); Print (1, "Number of Time Periods = ") << volume_file.Num_Periods (); } //---- open the turn movement file ---- if (turn_flag) { key = Get_Control_String (TURN_VOLUME_FILE); if (key.empty ()) goto control_error; Print (1); turn_volume.File_Type ("Turn Volume File"); turn_volume.Open (Project_Filename (key)); } } else { delay_flag = true; } //---- open the traffic count file ---- if (link_flag) { key = Get_Control_String (TRAFFIC_COUNT_FILE); Print (1); count_file.File_Type ("Traffic Count File"); count_file.Open (Project_Filename (key)); Print (1, "Number of Time Periods = ") << count_file.Num_Periods (); } //---- open the turn count file ---- if (turn_flag) { key = Get_Control_String (TURN_COUNT_FILE); Print (1); turn_count.File_Type ("Turn Count File"); turn_count.Open (Project_Filename (key)); } //---- open the transit line group count file ---- if (line_flag) { key = Get_Control_String (LINE_GROUP_COUNT_FILE); Print (1); line_count_file.File_Type ("Transit Line Group Count File"); line_count_file.Open (Project_Filename (key)); line_count_file.Required_Field ("GROUP", "LINE", "LINEGROUP", "LINEGRP", "ID"); line_count_file.Required_Field ("COUNT", "RIDERS", "PASSENGERS", "TOTAL", "VOLUME"); } //---- open the transit stop group count file ---- if (stop_flag) { key = Get_Control_String (STOP_GROUP_COUNT_FILE); Print (1); stop_count_file.File_Type ("Transit Stop Group Count File"); stop_count_file.Open (Project_Filename (key)); stop_count_file.Required_Field ("GROUP", "STOP", "STOPGROUP", "STOPGRP", "ID"); if (Report_Flag (STOP_GROUP)) { stop_count_file.Required_Field ("TOTAL", "ONOFF", "ON_OFF", "PASSENGERS", "COUNT"); } if (Report_Flag (BOARD_GROUP)) { stop_count_file.Required_Field ("BOARDINGS", "BOARD", "ON", "PASSENGERS", "COUNT"); } if (Report_Flag (ALIGHT_GROUP)) { stop_count_file.Required_Field ("ALIGHTINGS", "ALIGHT", "OFF", "PASSENGERS", "COUNT"); } } //---- create new volume file ---- key = Get_Control_String (NEW_VOLUME_FILE); if (!key.empty ()) { if (!delay_flag && !link_flag) { Error ("Link Delay or Volume File is Required to Output Volume Data"); } Print (1); output_file.File_Type ("New Volume File"); output_file.Create (Project_Filename (key)); output_flag = true; } //---- create new volume count file ---- key = Get_Control_String (NEW_VOLUME_COUNT_FILE); if (!key.empty ()) { if (!delay_flag && !link_flag) { Error ("Volume and Count Files are Required to Output Volume Count Data"); } Print (1); vol_cnt_file.File_Type ("New Volume Count File"); vol_cnt_file.Create (Project_Filename (key)); vc_flag = true; } //---- adjust the volume ranges ---- hours = 24.0 * sum_periods.Range_Length () / Dtime (MIDNIGHT, SECONDS); if (hours < 12.0) { double adjust = (hours <= 4.0) ? 0.1 : 0.5; for (i=0; volume_level [i] > 0; i++) { volume_level [i] = (int) (volume_level [i] * adjust + 0.5); } } hours = hours / sum_periods.Num_Periods (); //---- check the data fields ---- if (link_flag) { key = "Traffic Count"; num = sum_periods.Num_Periods (); if (count_file.Num_Periods () < num) goto field_error; for (i=0; i < num; i++) { sum_periods.Period_Range (i, low, high); if (!count_file.In_Range (low) || !count_file.In_Range ((low + high) / 2)) goto field_error; } if (!delay_flag) { key = "Input Volume"; if (volume_file.Num_Periods () < num) goto field_error; for (i=0; i < num; i++) { sum_periods.Period_Range (i, low, high); if (!volume_file.In_Range (low) || !volume_file.In_Range ((low + high) / 2)) goto field_error; } } } //---- read the analysis method ---- key = Get_Control_Text (ANALYSIS_METHOD); if (!key.empty ()) { if (key.Equals ("VOLUME")) { method = false; } else if (key.Equals ("VMT")) { method = true; } else { Error (String ("Analysis Method = %s was Unrecognized") % key); } } header1 = String ("\n%29cNum. ------%s------ ---Difference--- --Abs.Error-- Std. %% R ----V/C----") % BLANK % ((method) ? "--VMT-" : "Volume") % FINISH; header2 = String (" Obs. Estimate Observed %6.6s %% Avg. %% Dev. RMSE Sq. Avg. Max.\n") % ((method) ? "VMT" : "Volume") % FINISH; //---- read the adjustment factor ---- factor = Get_Control_Double (ADJUSTMENT_FACTOR); //---- open the facility type labels ---- if (Report_Flag (FACILITY_TYPE)) { key = Get_Control_String (FACILITY_TYPE_LABELS); if (!key.empty ()) { label_file.File_Type ("Facility Type Label File"); Print (1); label_file.Open (Project_Filename (key)); while (label_file.Read ()) { record = label_file.Record_String (); if (record.empty ()) continue; record.Split (key); i = key.Integer (); map_stat = facility_type.insert (Str_Map_Data (i, record)); if (!map_stat.second) { Error ("Duplicate Facility Type Label"); } } label_file.Close (); } } //---- open the area type labels ---- if (Report_Flag (AREA_TYPE)) { key = Get_Control_String (AREA_TYPE_LABELS); if (!key.empty ()) { label_file.File_Type ("Area Type Label File"); Print (1); label_file.Open (Project_Filename (key)); while (label_file.Read ()) { record = label_file.Record_String (); if (record.empty ()) continue; record.Split (key); i = key.Integer (); map_stat = area_type.insert (Str_Map_Data (i, record)); if (!map_stat.second) { Error ("Duplicate Area Type Label"); } } label_file.Close (); } } //---- write the report names ---- List_Reports (); //---- read the zone equiv ---- if (Zone_Equiv_Flag ()) { zone_equiv.Read (Report_Flag (ZONE_EQUIV)); } //---- process support data ---- if (Link_Equiv_Flag ()) { link_equiv.Read (Report_Flag (LINK_EQUIV)); } //---- read the line equiv ---- if (line_flag) { line_equiv.Read (Report_Flag (LINE_EQUIV)); } //---- read the stop equiv ---- if (stop_flag) { stop_equiv.Read (Report_Flag (STOP_EQUIV)); } return; //---- error message ---- field_error: Error (String ("The %s File has insufficient data for %d Time Increments") % key % num); control_error: Error (String ("Missing Control Key = %s") % Current_Key ()); }