void Demand_Service::Program_Control (void) { int max_errors; char *str_ptr, *format_ptr; Format_Type default_format, file_format, demand_format; Access_Type access; //---- open network files ---- Network_Service::Program_Control (); demand_format = default_format = Demand_Format (); File_Data *file = demand_file; //---- get the default demand file format ---- format_ptr = Get_Control_String (DEMAND_FILE_FORMAT); if (format_ptr != NULL) { demand_format = Format_Code (format_ptr); if (demand_format != default_format) { Print (2, "Demand File Format = %s", format_ptr); } } else { demand_format = default_format; } Demand_Format (demand_format); //---- open the files ---- for (int i=0; i < END_DEMAND; i++, file++) { if (file->flag || file->option) { //---- initialize overlaid data classes ---- if (i == LINK_DELAY || i == NEW_LINK_DELAY) { if (dir_array == NULL) { dir_array = (Dir_Array *) new TTime_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == PERFORMANCE || i == NEW_PERFORMANCE) { if (dir_array == NULL) { dir_array = (Dir_Array *) new Performance_Array (); } if (connect_array == NULL) { connect_array = (Connect_Array *) new Connect_Time_Array (); } } else if (i == RIDERSHIP || i == NEW_RIDERSHIP) { if (line_array == NULL) { line_array = (Line_Array *) new Rider_Array (); } } //---- read the key ---- str_ptr = Get_Control_String (file->key); if (str_ptr == NULL) { if (file->flag) goto control_error; } else { Print (1); file->flag = true; format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { file_format = Format_Code (format_ptr); } else { file_format = demand_format; } access = file->access; switch (i) { case HOUSEHOLD: case NEW_HOUSEHOLD: file->file = new Household_File (Project_Filename (str_ptr), access, file_format); break; case POPULATION: case NEW_POPULATION: file->file = new Population_File (Project_Filename (str_ptr), access, file_format); break; case LINK_DELAY: case PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format); if (((Db_Base *) file->file)->Dbase_Format () == VERSION3) { if (i == LINK_DELAY) { ttime_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (ttime_data.Period_Size ()); } else { performance_data.Period_Size (((Delay_File *) file->file)->Increment ()); connect_time.Period_Size (performance_data.Period_Size ()); } } //---- max link delay errors ---- str_ptr = Get_Control_String (MAX_LINK_DELAY_ERRORS); if (str_ptr != NULL) { Get_Integer (str_ptr, &max_errors); if (max_delay_errors < 0) { Error ("Maximum Link Delay Errors %d is Out of Range", max_errors); } Print (1, "Maximum Number of Link Delay Errors = %d", max_errors); Max_Delay_Errors (max_errors); } break; case NEW_LINK_DELAY: case NEW_PERFORMANCE: file->file = new Delay_File (Project_Filename (str_ptr), access, file_format, Time_Increment ()); break; case RIDERSHIP: case NEW_RIDERSHIP: file->file = new Ridership_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE_TYPE: case NEW_VEHICLE_TYPE: file->file = new Veh_Type_File (Project_Filename (str_ptr), access, file_format); break; case VEHICLE: case NEW_VEHICLE: file->file = new Vehicle_File (Project_Filename (str_ptr), access, file_format); //---- sort vehicles ---- if (i == VEHICLE) { if (Get_Control_String (SORT_VEHICLES) != NULL) { sort_flag = Get_Control_Flag (SORT_VEHICLES); } if (sort_flag) { Print (1, "Vehicle File will be Sorted by Vehicle ID"); } else { Print (1, "Vehicle File is Sorted by Vehicle ID"); } } break; case ACTIVITY: case NEW_ACTIVITY: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Activity_File * act_file = new Activity_File (access, file_format); file->file = act_file; if (Partition ()) { act_file->Filename (str_ptr, Partition_Number ()); } else { act_file->Filename (str_ptr); } Print_Filename (1, act_file->File_Type (), act_file->Groupname ()); if (!act_file->Open (0)) { File_Error (act_file->File_Type (), act_file->Filename ()); } } else { file->file = new Activity_File (str_ptr, access, file_format); } break; case TRIP: case NEW_TRIP: str_ptr = Project_Filename (str_ptr); if (Enable_Partitions ()) { Trip_File * trip_file = new Trip_File (access, file_format); file->file = trip_file; if (Partition ()) { trip_file->Filename (str_ptr, Partition_Number ()); } else { trip_file->Filename (str_ptr); } Print_Filename (1, trip_file->File_Type (), trip_file->Groupname ()); if (!trip_file->Open (0)) { File_Error (trip_file->File_Type (), trip_file->Filename ()); } } else { file->file = new Trip_File (str_ptr, access, file_format); } break; case BOUNDARY_SPEED: case NEW_BOUNDARY_SPEED: file->file = new Boundary_File (Project_Filename (str_ptr), access, file_format); break; } } } } Demand_Format (default_format); control_flag = true; return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void ArcSnapshot::Program_Control (void) { int i; String key, text; bool z_flag, m_flag; string method_text [] = { "AT_INCREMENT", "TOTAL", "MAXIMUM", "" }; Set_Range_String (SUMMARY_TIME_INCREMENT, "0.0..1440.0"); //---- open network files ---- Data_Service::Program_Control (); Read_Select_Keys (); max_time = Model_End_Time (); //---- get the projection data ---- project_flag = projection.Read_Control (); //---- get the z coordinate flag ---- m_flag = projection.M_Flag (); z_flag = projection.Z_Flag (); //---- open the snapshot file ---- Print (2, String ("%s Control Keys:") % Program ()); key = Get_Control_String (SNAPSHOT_FILE); if (!key.empty ()) { if (Check_Control_Key (SNAPSHOT_FORMAT)) { snapshot_file.Dbase_Format (Get_Control_String (SNAPSHOT_FORMAT)); } snapshot_file.Open (Project_Filename (key)); } else { key = Get_Control_String (OCCUPANCY_FILE); if (key.empty ()) { Error ("A Snapshot or Occupancy file is Required"); } if (Check_Control_Key (OCCUPANCY_FORMAT)) { occupancy_file.Dbase_Format (Get_Control_String (OCCUPANCY_FORMAT)); } occupancy_file.Open (Project_Filename (key)); occupancy_flag = true; } //---- get the arcview snapshot file ---- key = Get_Control_String (NEW_ARC_SNAPSHOT_FILE); if (!key.empty ()) { if (key.Ends_With (".shp")) { key.Split_Last (text, "."); } shapename = Project_Filename (key); text = shapename + "_time_of_day.shp"; Print_Filename (2, "New Arc Snapshot File", text); snapshot_flag = true; } //---- new snapshot file ---- key = Get_Control_String (NEW_SNAPSHOT_FILE); if (!key.empty ()) { Print (1); if (Check_Control_Key (NEW_SNAPSHOT_FORMAT)) { new_snapshot_file.Dbase_Format (Get_Control_String (NEW_SNAPSHOT_FORMAT)); } new_snapshot_file.Location_Flag (true); new_snapshot_file.Create (Project_Filename (key)); output_flag = true; if (project_flag) { project_coord.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); } } //---- new link summary file ---- key = Get_Control_String (NEW_LINK_SUMMARY_FILE); if (!key.empty ()) { if (occupancy_flag) { Error ("New Link Summary File requires a Snapshot File"); } Print (1); summary_file.File_Type ("Link Summary File"); if (Check_Control_Key (NEW_LINK_SUMMARY_FORMAT)) { summary_file.Dbase_Format (Get_Control_String (NEW_LINK_SUMMARY_FORMAT)); } sum_flag = true; summary_file.Create (Project_Filename (key)); } if (!snapshot_flag && !output_flag && !sum_flag) { Error ("An Arcview Snapshot, New Snapshot, or New Link Summary File is Required"); } //---- cell size ---- cell_size = Get_Control_Double (CELL_SIZE); //---- lane width ---- Read_Draw_Keys (); //---- draw vehicle shapes ---- if (snapshot_flag && !shape_flag) { circle_flag = Get_Control_Flag (ADD_PASSENGER_CIRCLE_SIZE); square_flag = Get_Control_Flag (ADD_PASSENGER_SQUARE_SIZE); } //---- pad file time labels ---- pad_flag = Get_Control_Flag (PAD_FILE_TIME_LABEL); //---- get the time processing method ---- key = Get_Control_Text (TIME_PROCESSING_METHOD); if (!key.empty ()) { for (i=0; (int) method_text [i].size () > 0; i++) { if (key.Equals (method_text [i])) { method = i; break; } } if ((int) method_text [i].size () == 0) { Error (String ("Unrecognized Time Processing Method = %s") % key); } if (!occupancy_flag && method == TOTAL) { Error ("Snapshot Files cannot be Totaled"); } } //---- initialize the shape file ---- arcview_snapshot.File_Type ("New Arc Snapshot File"); arcview_snapshot.File_Access (CREATE); arcview_snapshot.Shape_Type ((shape_flag) ? POLYGON : DOT); arcview_snapshot.Z_Flag (z_flag); arcview_snapshot.M_Flag (m_flag); if (occupancy_flag) { arcview_snapshot.Replicate_Fields (&occupancy_file); arcview_snapshot.LinkDir_Type ((Direction_Type) occupancy_file.LinkDir_Type ()); link_field = occupancy_file.Link_Field (); dir_field = occupancy_file.Dir_Field (); start_field = occupancy_file.Start_Field (); end_field = occupancy_file.End_Field (); lane_field = occupancy_file.Lane_Field (); offset_field = occupancy_file.Offset_Field (); occ_field = occupancy_file.Occupancy_Field (); type_field = -1; } else { Snapshot_File *file = &snapshot_file; if (file->Compress_Flag ()) { dummy_snapshot.Status_Flag (); dummy_snapshot.Create_Fields (); file = &dummy_snapshot; } arcview_snapshot.Replicate_Fields (file); arcview_snapshot.LinkDir_Type ((Direction_Type) file->LinkDir_Type ()); link_field = file->Link_Field (); dir_field = file->Dir_Field (); lane_field = file->Lane_Field (); offset_field = file->Offset_Field (); type_field = file->Type_Field (); cell_field = file->Cell_Field (); occ_field = start_field = end_field = -1; if (circle_flag) { arcview_snapshot.Add_Field ("RADIUS", DB_DOUBLE, 14.2); circle_field = arcview_snapshot.Field_Number ("RADIUS"); } if (square_flag) { arcview_snapshot.Add_Field ("SQUARE", DB_DOUBLE, 14.2); square_field = arcview_snapshot.Field_Number ("SQUARE"); } } arcview_snapshot.Set_Projection (projection.Input_Projection (), projection.Output_Projection ()); }
void DynusTPlan::Program_Control (void) { int increment; char *str_ptr, buffer [STRING_BUFFER]; //---- open network files ---- Demand_Service::Program_Control (); if (Demand_File_Flag (VEHICLE) && !Demand_File_Flag (VEHICLE_TYPE)) { Error ("A Vehicle Type File is needed to Convert Vehicle IDs to Type Codes"); } if (!Demand_File_Flag (VEHICLE) && Demand_File_Flag (VEHICLE_TYPE)) { Error ("A Vehicle File is needed to Convert Vehicle IDs to Type Codes"); } //---- open the plan file ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (PLAN_FILE); if (str_ptr == NULL) goto control_error; str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, plan_file.File_Type (), str_ptr); plan_file.Filename (str_ptr); plan_file.Plan_Sort (TIME_SORT); str_ptr = Get_Control_String (PLAN_FORMAT); if (str_ptr != NULL) { plan_file.File_Format (str_ptr); Print (1, "%s Format = %s", plan_file.File_Type (), str_ptr); } plan_file.Node_Based_Flag (type_flag); if (!plan_file.Open (0)) { File_Error ("Opening Plan File", plan_file.Filename ()); } type_flag = plan_file.Node_Based_Flag (); //---- node list paths ---- if (type_flag) { Print (1, "Plan File contains Node List Paths"); } else { Print (1, "Plan File contains Link List Paths"); } //---- get output time increment ---- str_ptr = Get_Control_String (OUTPUT_TIME_INCREMENT); if (str_ptr != NULL) { increment = atol (str_ptr); if (increment < 0 || increment > 240) { Error ("Output Time Increment %d is Out of Range (0-240)", increment); } increment *= 60; } if (!increment == 0) { time_range.Period_Flag (true); } time_range.Increment (increment); //---- get the select time period ---- str_ptr = Get_Control_String (SELECT_TIME_PERIOD); time_range.Format (Time_Step::CLOCK24); if (str_ptr != NULL) { Print (2, "Select Time Period = %s", str_ptr); if (!time_range.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } } else { time_range.Add_Ranges ("0:00..24:00"); } if (increment > 0) { Print (1, "Output Time Increment = %d minutes", (increment / 60)); } start_time = time_range.First ()->Low (); //---- get the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } select_flag = (percent != 100.0); } Print (2, "Selection Percentage = %.1lf%%", percent); percent /= 100.0; //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } if (str_ptr != NULL || percent != 1.0) { Print (1, "Random Number Seed = %d", random.Seed ()); } //---- get the DynusT directory ---- str_ptr = Get_Control_String (DYNUST_PLAN_DIRECTORY); if (str_ptr == NULL) goto control_error; str_cpy (plan_dir, sizeof (plan_dir), Project_Filename (str_ptr)); Print (2, "DynusT Plan Directory = %s", plan_dir); //---- vehicle.dat ---- veh_file.File_Type ("DynusT Vehicle File"); str_fmt (buffer, sizeof (buffer), "%s/vehicle.dat", plan_dir); veh_file.Create (buffer); //---- path.dat ---- path_file.File_Type ("DynusT Path File"); str_fmt (buffer, sizeof (buffer), "%s/path.dat", plan_dir); path_file.Create (buffer); //---- DynusT user class ---- str_ptr = Get_Control_String (DYNUST_USER_CLASS); if (str_ptr != NULL) { user_class = atoi (str_ptr); Print (2, "DynusT User Class = %d", user_class); if (user_class < 1 || user_class > 5) { Error ("DynusT User Class %d is Out of Range (1..5)", user_class); } } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void Network_Service::Program_Control (void) { bool first, new_flag, notes_flag; char *str_ptr, *format_ptr; Format_Type default_format, file_format, network_format; Access_Type access; first = true; new_flag = false; network_format = default_format = Network_Format (); if (Get_Control_String (CREATE_NOTES_AND_NAME_FIELDS) != NULL) { Notes_Name_Flag (Get_Control_Flag (CREATE_NOTES_AND_NAME_FIELDS)); } notes_flag = Notes_Name_Flag (); File_Data *file = network_file; //---- open the files ---- for (int i=0; i < END_NETWORK; i++, file++) { if (file->flag || file->option) { if (i == DIRECTORY) { first = true; //---- get the network format ---- format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { network_format = Format_Code (format_ptr); if (network_format != default_format) { Print (2, "Default Network Format = %s", format_ptr); first = false; } } else { network_format = default_format; } Network_Format (network_format); } else if (i == NEW_DIRECTORY) { first = true; //---- get the new network format ---- format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { network_format = Format_Code (format_ptr); if (network_format != default_format) { Print (2, "Default New Network Format = %s", format_ptr); first = false; } } else { network_format = default_format; } Network_Format (network_format); } //---- get the filename ---- str_ptr = Get_Control_String (file->key); if (str_ptr == NULL) { if (file->flag) goto control_error; } else { if (first) { Print (1); first = false; } file->flag = true; if (i == DIRECTORY) { Print_Filename (1, "Network Directory", str_ptr); Network_Directory (str_ptr); } else if (i == NEW_DIRECTORY) { Print_Filename (1, "New Network Directory", str_ptr); New_Directory (str_ptr); } else { format_ptr = Get_Control_String (file->format); if (format_ptr != NULL) { file_format = Format_Code (format_ptr); //if (file_format != network_format) Print (1); } else { file_format = network_format; } access = file->access; if (i > NEW_DIRECTORY) { new_flag = true; str_ptr = New_Filename (str_ptr); } else { str_ptr = Network_Filename (str_ptr); } switch (i) { case NODE: case NEW_NODE: file->file = new Node_File (str_ptr, access, file_format, notes_flag); break; case ZONE: case NEW_ZONE: file->file = new Zone_File (str_ptr, access, file_format, notes_flag); break; case SHAPE: case NEW_SHAPE: file->file = new Shape_File (str_ptr, access, file_format, notes_flag); break; case LINK: case NEW_LINK: file->file = new Link_File (str_ptr, access, file_format, notes_flag); break; case POCKET_LANE: case NEW_POCKET_LANE: file->file = new Pocket_File (str_ptr, access, file_format, notes_flag); break; case LANE_USE: case NEW_LANE_USE: file->file = new Lane_Use_File (str_ptr, access, file_format, notes_flag); break; case TOLL: case NEW_TOLL: file->file = new Toll_File (str_ptr, access, file_format, notes_flag); break; case LANE_CONNECTIVITY: case NEW_LANE_CONNECTIVITY: file->file = new Connect_File (str_ptr, access, file_format, notes_flag); break; case TURN_PROHIBITION: case NEW_TURN_PROHIBITION: file->file = new Turn_File (str_ptr, access, file_format, notes_flag); if (((Turn_File *) (file->file))->Node_Based ()) AB_Key_Flag (true); break; case PARKING: case NEW_PARKING: file->file = new Parking_File (str_ptr, access, file_format, notes_flag); break; case ACTIVITY_LOCATION: case NEW_ACTIVITY_LOCATION: file->file = new Location_File (str_ptr, access, file_format, notes_flag); break; case PROCESS_LINK: case NEW_PROCESS_LINK: file->file = new Access_File (str_ptr, access, file_format, notes_flag); break; case UNSIGNALIZED_NODE: case NEW_UNSIGNALIZED_NODE: file->file = new Sign_File (str_ptr, access, file_format, notes_flag); break; case SIGNALIZED_NODE: case NEW_SIGNALIZED_NODE: file->file = new Signal_File (str_ptr, access, file_format, notes_flag); break; case TIMING_PLAN: case NEW_TIMING_PLAN: file->file = new Timing_File (str_ptr, access, file_format, notes_flag); break; case PHASING_PLAN: case NEW_PHASING_PLAN: file->file = new Phasing_File (str_ptr, access, file_format, notes_flag); break; case DETECTOR: case NEW_DETECTOR: file->file = new Detector_File (str_ptr, access, file_format, notes_flag); break; case SIGNAL_COORDINATOR: case NEW_SIGNAL_COORDINATOR: file->file = new Coordinator_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_STOP: case NEW_TRANSIT_STOP: file->file = new Stop_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_FARE: case NEW_TRANSIT_FARE: file->file = new Fare_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_ROUTE: case NEW_TRANSIT_ROUTE: file->file = new Line_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_SCHEDULE: case NEW_TRANSIT_SCHEDULE: file->file = new Schedule_File (str_ptr, access, file_format, notes_flag); break; case TRANSIT_DRIVER: case NEW_TRANSIT_DRIVER: file->file = new Driver_File (str_ptr, access, file_format, notes_flag); break; case ROUTE_HEADER: case NEW_ROUTE_HEADER: file->file = new Route_Header_File (str_ptr, access, file_format, notes_flag); break; case ROUTE_NODES: case NEW_ROUTE_NODES: file->file = new Route_Nodes_File (str_ptr, access, file_format, notes_flag); break; default: file->file = new Db_Header (Project_Filename (str_ptr)); break; } } } } } if (new_flag && notes_flag) { Print (2, "Notes and Name Fields will be Created"); } Network_Format (default_format); control_flag = true; return; control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void PlanSelect::Program_Control (void) { int i, nsel, lvalue; char *str_ptr, buffer [FIELD_BUFFER]; double dvalue; Box box; //---- open network files ---- Demand_Service::Program_Control (); //---- open the plan file ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (PLAN_FILE); if (str_ptr == NULL) goto control_error; str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, plan_file.File_Type (), str_ptr); plan_file.Filename (str_ptr); str_ptr = Get_Control_String (PLAN_FORMAT); if (str_ptr != NULL) { plan_file.File_Format (str_ptr); Print (1, "%s Format = %s", plan_file.File_Type (), str_ptr); } plan_file.Node_Based_Flag (type_flag); if (!plan_file.Open (0)) { File_Error ("Opening Plan File", plan_file.Filename ()); } type_flag = plan_file.Node_Based_Flag (); //---- node list paths ---- if (type_flag) { Print (1, "Plan File contains Node List Paths"); } else { Print (1, "Plan File contains Link List Paths"); } //---- check for a link delay file ---- if (Demand_File_Flag (LINK_DELAY)) { Delay_File *file = (Delay_File *) Demand_Db_File (LINK_DELAY); if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) { Error ("Link and Node files are Required for Link Delay Processing"); } if (file->Dbase_Format () == VERSION3) { turn_flag = false; Network_File_False (LANE_CONNECTIVITY); } else if (!Network_File_Flag (LANE_CONNECTIVITY)) { Warning ("Lane Connectivity is required for Turning Delays"); Show_Message (1); turn_flag = false; } else { turn_flag = true; } delay_flag = true; } else { Network_File_False (LANE_CONNECTIVITY); } //---- open the population file ---- str_ptr = Get_Control_String (POPULATION_FILE); if (str_ptr != NULL) { pop_file.File_Type ("Population File"); Print (1); pop_file.Open (str_ptr); pop_flag = true; } //---- get the household list ---- str_ptr = Get_Control_String (NEW_HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("New Household List"); hhlist_file.File_Access (CREATE); str_ptr = Project_Filename (str_ptr, Extension ()); hhlist_file.Filename (str_ptr); Print_Filename (2, hhlist_file.File_Type (), str_ptr); if (!hhlist_file.Open (0)) { File_Error ("Opening Household List File", hhlist_file.Filename ()); } if (hhlist_file.Extend () == 0 && plan_file.Extend () != 0) { Warning ("Household List File is Not Partitioned"); } } else { str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FILE); if (str_ptr == NULL) { Error ("A New Household List or Household Record File is Required"); } hhrec_flag = true; hhrec_file.File_Access (CREATE); str_ptr = Project_Filename (str_ptr, Extension ()); hhrec_file.Filename (str_ptr); Print_Filename (2, hhrec_file.File_Type (), str_ptr); str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FORMAT); if (str_ptr != NULL) { hhrec_file.Dbase_Format (str_ptr); Print (1, "%s Format = %s", hhrec_file.File_Type (), str_ptr); } if (!hhrec_file.Open (0)) { File_Error ("Opening Household Record file", hhrec_file.Filename ()); } if (hhrec_file.Extend () == 0 && plan_file.Extend () != 0) { Warning ("Household Record File is Not Partitioned"); } } //---- get the select travelers ---- str_ptr = Get_Control_String (SELECT_TRAVELERS); if (str_ptr != NULL) { Print (2, "Select Traveler IDs = %s", str_ptr); if (!travelers.Add_Ranges (str_ptr)) { File_Error ("Traveler ID Range", str_ptr); } } //---- get the select nodes ---- nsel = Highest_Control_Group (SELECT_NODES_x, 0); if (nsel > 0) { nodes.Max_Records (nsel); for (i=1; i <= nsel; i++) { str_ptr = Get_Control_String (SELECT_NODES_x, i); if (str_ptr == NULL) continue; Print (2, "Select Nodes for Group #%d = %s", i, str_ptr); Data_Range *ptr = new Data_Range (); if (!ptr->Add_Ranges (str_ptr)) { File_Error ("Path Node Numbers", str_ptr); } if (!nodes.Add (ptr)) { Error ("Adding Node Ranges to the List"); } } } //---- get the select links ---- nsel = Highest_Control_Group (SELECT_LINKS_x, 0); if (nsel > 0) { links.Max_Records (nsel); for (i=1; i <= nsel; i++) { str_ptr = Get_Control_String (SELECT_LINKS_x, i); if (str_ptr == NULL) continue; Print (2, "Select Links for Group #%d = %s", i, str_ptr); Data_Range *ptr = new Data_Range (1, -MAX_INTEGER, MAX_INTEGER, 0); if (!ptr->Add_Ranges (str_ptr)) { File_Error ("Path Link Numbers", str_ptr); } if (!links.Add (ptr)) { Error ("Adding Link Ranges to the List"); } } } //---- get the select time periods ---- str_ptr = Get_Control_String (SELECT_TIME_PERIODS); if (str_ptr != NULL) { Print (2, "Select Time Periods = %s", str_ptr); times.Format (Time_Step::HOURS); if (!times.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } } //---- get the select travel modes ---- str_ptr = Get_Control_String (SELECT_TRAVEL_MODES); if (str_ptr != NULL) { Print (2, "Select Travel Modes = %s", str_ptr); memset (mode_flag, '\0', sizeof (mode_flag)); nsel = 0; while (str_ptr != NULL) { char *old_ptr = str_ptr; str_ptr = Get_Integer (str_ptr, &i); if (i < 0 || i > DRIVER_MODE || (i == 0 && *old_ptr != '0')) { Error ("Selected Travel Mode %s is Out of Range (0..%d)", old_ptr, DRIVER_MODE); } mode_flag [i] = true; nsel++; } if (nsel == 0) { Error ("No Modes were Selected for Processing"); } } else { for (i=0; i <= DRIVER_MODE; i++) { mode_flag [i] = true; } } //---- get the select facility types ---- str_ptr = Get_Control_String (SELECT_FACILITY_TYPES); if (str_ptr != NULL) { Print (2, "Select Facility Types = %s", str_ptr); factype_flag = true; memset (facility_flag, '\0', sizeof (facility_flag)); nsel = 0; while (str_ptr != NULL) { str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer)); if (buffer [0] == '\0') break; i = Facility_Code (buffer); facility_flag [i] = true; nsel++; } if (nsel == 0) { Error ("No Facility Types were Selected for Processing"); } } //---- get the select locations ---- str_ptr = Get_Control_String (SELECT_LOCATIONS); if (str_ptr != NULL) { Print (2, "Select Activity Locations = %s", str_ptr); if (!locations.Add_Ranges (str_ptr)) { File_Error ("Activity Location Range", str_ptr); } } //---- get the select parking lots ---- str_ptr = Get_Control_String (SELECT_PARKING_LOTS); if (str_ptr != NULL) { Print (2, "Select Parking Lots = %s", str_ptr); if (!parking_lots.Add_Ranges (str_ptr)) { File_Error ("Parking Lot Range", str_ptr); } } //---- get the select transit stops ---- str_ptr = Get_Control_String (SELECT_TRANSIT_STOPS); if (str_ptr != NULL) { Print (2, "Select Transit Stops = %s", str_ptr); if (!transit_stops.Add_Ranges (str_ptr)) { File_Error ("Transit Stop Range", str_ptr); } } //---- get the select transit routes ---- str_ptr = Get_Control_String (SELECT_TRANSIT_ROUTES); if (str_ptr != NULL) { Print (2, "Select Transit Routes = %s", str_ptr); if (!transit_routes.Add_Ranges (str_ptr)) { File_Error ("Transit Route Range", str_ptr); } } //---- get the select vc ratio ---- str_ptr = Get_Control_String (SELECT_VC_RATIOS); if (str_ptr != NULL) { if (!delay_flag) { Error ("Select V/C Ratios requires a Link Delay file"); } vc_flag = true; Get_Double (str_ptr, &vc_ratio); if (vc_ratio < 1.0) { Error ("Select V/C Ratios %.2lf is Out of Range (>= 1.0)", vc_ratio); } Print (2, "Select V/C Ratios >= %.2lf", vc_ratio); } //---- get the select time ratio ---- str_ptr = Get_Control_String (SELECT_TIME_RATIOS); if (str_ptr != NULL) { if (!delay_flag) { Error ("Select Travel Time Ratios requires a Link Delay file"); } ratio_flag = true; Get_Double (str_ptr, &time_ratio); if (time_ratio < 1.0) { Error ("Select Time Ratios %.2lf is Out of Range (>= 1.0)", time_ratio); } Print (2, "Select Time Ratios >= %.2lf", time_ratio); } //---- get the select coordinates ---- nsel = Highest_Control_Group (SELECT_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (SELECT_COORDINATES); } else { str_ptr = Get_Control_String (SELECT_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Select Coordinates requires a Node file"); } coord_flag = true; if (i == 0) { Print (2, "Select Coordinates = %s", str_ptr); } else { if (coord_box.Num_Records () == 0) Print (1); Print (1, "Select Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!coord_box.Add (&box)) goto mem_error; } //---- get the select od coordinates ---- nsel = Highest_Control_Group (SELECT_OD_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (SELECT_OD_COORDINATES); } else { str_ptr = Get_Control_String (SELECT_OD_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Select OD Coordinates requires a Node file"); } in_flag = true; if (i == 0) { Print (2, "Select OD Coordinates = %s", str_ptr); } else { if (od_box.Num_Records () == 0) Print (1); Print (1, "Select OD Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!od_box.Add (&box)) goto mem_error; } //---- get the exclude od coordinates ---- nsel = Highest_Control_Group (EXCLUDE_OD_COORDINATES_x, 0); for (i=0; i <= nsel; i++) { if (i == 0) { str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES); } else { str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES_x, i); } if (str_ptr == NULL) continue; if (!Network_File_Flag (NODE)) { Error ("Excludet OD Coordinates requires a Node file"); } out_flag = true; if (i == 0) { Print (2, "Exclude OD Coordinates = %s", str_ptr); } else { if (exclude_box.Num_Records () == 0) Print (1); Print (1, "Excludet OD Coordinates #%d = %s", i, str_ptr); } str_ptr = Get_Double (str_ptr, &dvalue); box.x1 = Round (dvalue); if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y1 = Round (dvalue); if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.x2 = Round (dvalue); if (box.x2 < box.x1) { lvalue = box.x2; box.x2 = box.x1; box.x1 = lvalue; } if (str_ptr == NULL) goto od_coord_error; str_ptr = Get_Double (str_ptr, &dvalue); box.y2 = Round (dvalue); if (box.y2 < box.y1) { lvalue = box.y2; box.y2 = box.y1; box.y1 = lvalue; } if (!exclude_box.Add (&box)) goto mem_error; } //---- get the select subarea polygon ---- str_ptr = Get_Control_String (SELECT_SUBAREA_POLYGON); if (str_ptr != NULL) { if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) { Error ("Link and Node files are Required for Subarea Polygon Selection"); } Print (1); select_subarea.File_Type ("Select Subarea Polygon"); select_subarea.Open (Project_Filename (str_ptr)); if (!select_subarea.Read_Record ()) { Error ("Reading %s", select_subarea.File_Type ()); } subarea_flag = true; } //---- get the select vehicle types ---- str_ptr = Get_Control_String (SELECT_VEHICLE_TYPES); if (str_ptr != NULL) { Print (2, "Select Vehicle Types = %s", str_ptr); if (!vehicle_types.Add_Ranges (str_ptr)) { File_Error ("Vehicle Type Range", str_ptr); } vehicle_flag = true; if (!Demand_File_Flag (VEHICLE)) { Error ("A Vehicle File is Required for Vehicle Type Selection"); } } else { Demand_File_False (VEHICLE); } //---- get the percent time difference ---- str_ptr = Get_Control_String (PERCENT_TIME_DIFFERENCE); if (str_ptr != NULL) { if (!delay_flag) { Error ("Percent Time Difference requires a Link Delay file"); } diff_flag = true; Get_Double (str_ptr, &percent_diff); if (percent_diff < 0.1 || percent_diff > 100.0) { Error ("Percent Time Difference %.2lf is Out of Range (0.1-100.0)", percent_diff); } Print (2, "Percent Time Difference = %.1lf%%", percent_diff); percent_diff /= 100.0; //---- get the minimum time difference ---- str_ptr = Get_Control_String (MINIMUM_TIME_DIFFERENCE); if (str_ptr != NULL) { Get_Integer (str_ptr, &min_time); if (min_time < 0 || min_time > 120) { Error ("Minimum Time Difference %d is Out of Range (0-120)", min_time); } } Print (1, "Minimum Time Difference = %d minute%s", min_time, ((min_time != 1) ? "s" : " ")); //---- get the maximum time difference ---- str_ptr = Get_Control_String (MAXIMUM_TIME_DIFFERENCE); if (str_ptr != NULL) { Get_Integer (str_ptr, &max_time); if (max_time < min_time || max_time > 1440) { Error ("Maximum Time Difference %d is Out of Range (%d-1440)", max_time, min_time); } } Print (1, "Maximum Time Difference = %d minutes", max_time); min_time *= 60; max_time *= 60; } //---- get the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } select_flag = (percent != 100.0); } Print (2, "Selection Percentage = %.1lf%%", percent); percent /= 100.0; //---- get the max percent selected ---- str_ptr = Get_Control_String (MAXIMUM_PERCENT_SELECTED); if (str_ptr != NULL) { Get_Double (str_ptr, &max_percent); if (max_percent < 1.0 || max_percent > 100.0) { Error ("Maximum Percent Selected %.1lf is Out of Range (1.0-100.0)", max_percent); } } Print (1, "Maximum Percent Selected = %.1lf%%", max_percent); max_percent /= 100.0; //---- random number seed ---- str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } if (str_ptr != NULL || percent != 1.0 || max_percent != 1.0) { Print (1, "Random Number Seed = %d", random.Seed ()); } //---- reset the network flags ---- if (!vc_flag && !diff_flag && !ratio_flag) { delay_flag = parking_flag = turn_flag = false; Demand_File_False (LINK_DELAY); Network_File_False (LANE_USE); Network_File_False (PARKING); Network_File_False (LANE_CONNECTIVITY); if (!coord_flag && !out_flag && !in_flag && !subarea_flag && !factype_flag && nodes.Num_Records () == 0 && links.Num_Records () == 0) { Network_File_False (LINK); Network_File_False (NODE); Network_File_False (TRANSIT_STOP); Network_File_False (TRANSIT_DRIVER); } else if (!factype_flag && type_flag && links.Num_Records () == 0) { Network_File_False (LINK); } } else { parking_flag = Network_File_Flag (PARKING); if (!diff_flag) { turn_flag = false; Network_File_False (LANE_CONNECTIVITY); } } transit_flag = (Network_File_Flag (TRANSIT_STOP) && Network_File_Flag (TRANSIT_DRIVER)); return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); coord_error: Error ("Select Coordinates are Incomplete"); od_coord_error: Error ("Exclude OD Coordinates are Incomplete"); mem_error: Error ("Insufficient Memory for Coordinate Groups"); }
void PlanPrep::Program_Control (void) { int i, dump; char *str_ptr; Sort_Type input_sort; //---- open network files ---- Demand_Service::Program_Control (); //---- open the input plans ---- if (Get_Control_String (NODE_LIST_PATHS) != NULL) { type_flag = Get_Control_Flag (NODE_LIST_PATHS); } str_ptr = Get_Control_String (INPUT_PLAN_FILE); if (str_ptr == NULL) goto control_error; input_plans.File_Type ("Input Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, input_plans.File_Type (), str_ptr); input_plans.Filename (str_ptr); str_ptr = Get_Control_String (INPUT_PLAN_FORMAT); if (str_ptr != NULL) { input_plans.File_Format (str_ptr); Print (1, "%s Format = %s", input_plans.File_Type (), str_ptr); } input_plans.Node_Based_Flag (type_flag); if (!input_plans.Open (0)) { File_Error ("Opening Input Plan File", input_plans.Filename ()); } type_flag = input_plans.Node_Based_Flag (); parts_flag = (input_plans.Extend () > 0); //---- input plan sort ---- str_ptr = Get_Control_String (INPUT_PLAN_SORT); if (str_ptr != NULL) { Print (1, "Input Plan Sort = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { input_sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { input_sort = TIME_SORT; } else { Error ("Unrecognized Input Plan Sort = %s", str_ptr); } input_plans.Plan_Sort (input_sort); input_sort_flag = true; } else { input_sort = input_plans.Plan_Sort (); } //---- open the merge plans ---- str_ptr = Get_Control_String (MERGE_PLAN_FILE); if (str_ptr != NULL) { merge_plans.File_Type ("Merge Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, merge_plans.File_Type (), str_ptr); merge_plans.Filename (str_ptr); merge_plans.Extend (input_plans.Extend ()); str_ptr = Get_Control_String (MERGE_PLAN_FORMAT); if (str_ptr != NULL) { merge_plans.File_Format (str_ptr); Print (1, "%s Format = %s", merge_plans.File_Type (), str_ptr); } merge_plans.Node_Based_Flag (type_flag); if (!merge_plans.Open (0)) { File_Error ("Opening Merge Plan File", merge_plans.Filename ()); } merge_flag = true; if (merge_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the subarea plans ---- str_ptr = Get_Control_String (SUBAREA_PLAN_FILE); if (str_ptr != NULL) { if (merge_flag) { Error ("Merge and Subarea Plans are Incompatible"); } subarea_plans.File_Type ("Subarea Plan File"); str_ptr = Project_Filename (str_ptr); subarea_plans.Filename (str_ptr); if (subarea_plans.Extend () > 0) { if (parts_flag) { subpart_flag = true; } else { str_ptr = subarea_plans.Pathname (); str_ptr = Project_Filename (str_ptr, Extension ()); subarea_plans.Filename (str_ptr); subarea_plans.Extend (0); } } Print_Filename (2, subarea_plans.File_Type (), str_ptr); str_ptr = Get_Control_String (SUBAREA_PLAN_FORMAT); if (str_ptr != NULL) { subarea_plans.File_Format (str_ptr); Print (1, "%s Format = %s", subarea_plans.File_Type (), str_ptr); } subarea_plans.Node_Based_Flag (type_flag); if (!subarea_plans.Open (0)) { File_Error ("Opening Subarea Plan File", subarea_plans.Filename ()); } subarea_flag = true; if (subarea_plans.Node_Based_Flag () != type_flag) { Error ("Incompatible Plan Formats"); } } //---- open the output plans ---- str_ptr = Get_Control_String (OUTPUT_PLAN_FILE); if (str_ptr != NULL) { output_plans.File_Type ("Output Plan File"); str_ptr = Project_Filename (str_ptr, Extension ()); Print_Filename (2, output_plans.File_Type (), str_ptr); output_plans.Filename (str_ptr); output_plans.File_Access (CREATE); str_cpy (output_name, sizeof (output_name), output_plans.Pathname ()); extend = output_plans.Extend (); output_flag = true; str_ptr = Get_Control_String (OUTPUT_PLAN_FORMAT); if (str_ptr != NULL) { output_plans.File_Format (str_ptr); Print (1, "%s Format = %s", output_plans.File_Type (), str_ptr); binary_flag = (output_plans.File_Format () == BINARY); } output_plans.Node_Based_Flag (type_flag); } else if (merge_flag) { Error ("Plan Merging Requires an Output File"); } else if (subarea_flag) { Error ("Subarea Merging Requires an Output File"); } //---- plan sort option ---- str_ptr = Get_Control_String (PLAN_SORT_OPTION); if (str_ptr != NULL && output_flag) { Print (2, "Plan Sort Option = %s", str_ptr); if (str_cmp (str_ptr, "TRAVELER") == 0) { sort = TRAVELER_SORT; } else if (str_cmp (str_ptr, "TIME") == 0) { if (merge_flag) { Error ("Plan Merging must be performed in TRAVELER Sort"); } sort = TIME_SORT; } else { Error ("Unrecognized Plan Sort Option = %s", str_ptr); } if (!input_sort_flag || input_sort != sort) { input_plans.Plan_Memory (ALLOCATE_MEMORY); input_plans.Plan_Sort (sort); sort_flag = true; } if (sort_flag && subarea_flag) { Error ("Sorting and Subarea Merging are Incompatible"); } } //---- plan combine option ---- str_ptr = Get_Control_String (PLAN_COMBINE_OPTION); if (str_ptr != NULL && parts_flag && output_flag) { Print (2, "Plan Combine Option = %s", str_ptr); if (!input_sort_flag && !sort_flag) { Error ("The Input Sort or Sort Option are needed for Plan Combining"); } if (str_cmp (str_ptr, "FILE") == 0) { combine = FILE_COMBINE; } else if (str_cmp (str_ptr, "MEMORY") == 0) { if (merge_flag) { Error ("Plan Merging and Memory Combining are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Memory Combining are Incompatible"); } if (sort_flag) { combine = MEMORY_COMBINE; } else { combine = FILE_COMBINE; } } else { Error ("Unrecognized Plan Combine Option = %s", str_ptr); } combine_flag = true; } //---- max plan size ---- str_ptr = Get_Control_String (MAX_OUTPUT_PLAN_SIZE); if (str_ptr != NULL && (combine_flag || (!parts_flag && output_flag))) { Print (2, "Maximum Output Plan Size = %s megabytes", str_ptr); max_size = atol (str_ptr); if (max_size < 1 || max_size > 2048) { Error ("Maximum Output Plan Size %d is Out of Range (1-2048)", max_size); } max_size *= 1024 * 1024; max_size_flag = true; } //---- get the select traveler range ---- str_ptr = Get_Control_String (SELECT_TRAVELER_RANGE); if (str_ptr != NULL) { Print (2, "Select Traveler Range = %s", str_ptr); if (!hhold_range.Add_Ranges (str_ptr)) { Error ("Select Traveler Range", str_ptr); } hhold_flag = true; } //---- get the select time periods ---- str_ptr = Get_Control_String (SELECT_TIME_PERIODS); if (str_ptr != NULL) { Print (2, "Select Time Periods = %s", str_ptr); time_period.Format (Time_Step::HOURS); if (!time_period.Add_Ranges (str_ptr)) { File_Error ("Time Period Range", str_ptr); } time_flag = true; } //---- read the selection percentage ---- str_ptr = Get_Control_String (SELECTION_PERCENTAGE); if (str_ptr != NULL) { if (input_sort != TRAVELER_SORT) { Error ("The Input Plans must be in Traveler order for Plan Selection"); } Get_Double (str_ptr, &percent); if (percent < 0.1 || percent > 100.0) { Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent); } Print (2, "Selection Percentage = %.2lf", percent); percent /= 100.0; select_flag = (percent != 1.0); } if ((time_flag || select_flag || hhold_flag) && subarea_flag) { Error ("Subarea Merging and Plan Selections are Incompatible"); } //---- check plan partitions ---- str_ptr = Get_Control_String (CHECK_PLAN_PARTITIONS); if (str_ptr != NULL) { check_flag = Get_Control_Flag (CHECK_PLAN_PARTITIONS); Print (2, "Check Plan Partitions = %s", str_ptr); if (check_flag) { partition.Initialize (sizeof (Partition)); } } //---- update plan partitions ---- str_ptr = Get_Control_String (UPDATE_PLAN_PARTITIONS); if (str_ptr != NULL) { partition_flag = Get_Control_Flag (UPDATE_PLAN_PARTITIONS); Print (2, "Update Plan Partitions = %s", str_ptr); } //---- get the household list file ---- str_ptr = Get_Control_String (HOUSEHOLD_LIST); if (str_ptr != NULL) { hhlist_file.File_Type ("Household List"); hhlist_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, hhlist_file.File_Type (), str_ptr); if (!hhlist_file.Open (0)) { File_Error ("Opening Household List File", hhlist_file.Filename ()); } hhlist_flag = true; } else if (partition_flag) { Error ("Household Lists are required for Partition Updates"); } if (hhlist_flag) { combine_flag = false; if (sort_flag) { Error ("Plan Sorting and Household Lists are Incompatible"); } if (merge_flag) { Error ("Plan Merging and Household Lists are Incompatible"); } else if (subarea_flag) { Error ("Subarea Merging and Household Lists are Incompatible"); } if (check_flag) { Error ("Checking and Updating Plan Partitions are Incompatible"); } if (!output_flag) { Error ("Output Plans are Required for Household Lists"); } partition.Initialize (sizeof (Partition)); } //---- get the delete household list file ---- str_ptr = Get_Control_String (DELETE_HOUSEHOLD_LIST); if (str_ptr != NULL) { delete_file.File_Type ("Delete Household List"); delete_file.Filename (Project_Filename (str_ptr)); Print_Filename (2, delete_file.File_Type (), str_ptr); if (!delete_file.Open (0)) { File_Error ("Opening Delete Household List File", delete_file.Filename ()); } delete_flag = true; } //---- get the delete one leg plans flag ---- str_ptr = Get_Control_String (DELETE_ONE_LEG_PLANS); if (str_ptr != NULL) { one_leg_flag = Get_Control_Flag (DELETE_ONE_LEG_PLANS); Print (1, "Delete One Leg Plans = %s", str_ptr); } //---- get the fix plan file ---- str_ptr = Get_Control_String (FIX_PLAN_FILE); if (str_ptr != NULL) { fix_file.File_Type ("Fix Plan File"); if (!fix_file.Open (Project_Filename (str_ptr))) { File_Error ("Opening Fix Plan File", fix_file.Filename ()); } fix_flag = true; } //---- merge by trip ---- str_ptr = Get_Control_String (MERGE_BY_TRIP); if (str_ptr != NULL) { trip_flag = Get_Control_Flag (MERGE_BY_TRIP); Print (2, "Merge by Trip = %s", str_ptr); } //---- random number seed ---- if (select_flag || fix_flag) { str_ptr = Get_Control_String (RANDOM_NUMBER_SEED); if (str_ptr != NULL) { random.Seed (atoi (str_ptr)); } Print (2, "Random Number Seed = %d", random.Seed ()); } //---- check output file name ---- if (output_flag) { output_plans.Plan_Sort (input_plans.Plan_Sort ()); if (max_size_flag || !combine_flag) { extend = output_plans.Extend (input_plans.Extend ()); if (extend == 0 && max_size_flag) { extend = output_plans.Extend (1); } } if (!hhlist_flag || !delete_flag) { if (!output_plans.Open (0)) { File_Error ("Creating Output Plan File", output_plans.Filename ()); } } if (combine_flag && combine == FILE_COMBINE && (sort_flag || merge_flag || subarea_flag)) { //---- set the temporary output filename ---- output_plans.Filename (Filename (output_name, TEMP_LABEL)); output_plans.Extend (input_plans.Extend ()); output_plans.File_Format (BINARY); } } //---- read report types ---- compare_flag = path_flag = false; dump_path = dump_time = MAX_INTEGER; for (i=First_Report (); i != 0; i=Next_Report ()) { if (i != FIX_PLAN) compare_flag = true; if (i == PATH_CHANGE || i == DUMP_PATH_CHANGES) { path_flag = true; if (i == DUMP_PATH_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_path) { dump_path = dump; } } } else if (i == DUMP_TIME_CHANGES) { dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5); if (dump < dump_time) { dump_time = dump; } } } if (compare_flag) { if (!merge_flag) { Write (1); Warning ("Change Reports require a Merge Plan File"); compare_flag = false; } memset (time_changes, '\0', sizeof (time_changes)); memset (path_changes, '\0', sizeof (path_changes)); increment = MIDNIGHT / TOTAL_TIME_PERIOD; } return; //---- error message ---- control_error: Error ("Missing Control Key = %s", Current_Key ()); }
void NetMerge::Program_Control (void) { String key, merge_dir; //---- open network and demand files ---- Data_Service::Program_Control (); Print (2, String ("%s Control Keys:") % Program ()); Print (1); //---- merge directory ---- merge_dir = Get_Control_String (MERGE_DIRECTORY); if (!merge_dir.empty ()) { Print_Filename (1, "Merge Directory", merge_dir); Fix_Directory (merge_dir); } //---- open merge node file ---- key = Get_Control_String (MERGE_NODE_FILE); if (!key.empty ()) { node_file.File_Type ("Merge Node File"); node_file.Open (merge_dir + key); } //---- open merge link file ---- key = Get_Control_String (MERGE_LINK_FILE); if (!key.empty ()) { link_file.File_Type ("Merge Link File"); link_file.Open (merge_dir + key); } //---- open merge shape file ---- key = Get_Control_String (MERGE_SHAPE_FILE); if (!key.empty ()) { shape_file.File_Type ("Merge Shape File"); shape_file.Open (merge_dir + key); shape_flag = true; } //---- open merge pocket file ---- key = Get_Control_String (MERGE_POCKET_FILE); if (!key.empty ()) { pocket_file.File_Type ("Merge Pocket File"); pocket_file.Open (merge_dir + key); pocket_flag = true; } //---- open merge lane use file ---- key = Get_Control_String (MERGE_LANE_USE_FILE); if (!key.empty ()) { lane_use_file.File_Type ("Merge Lane Use File"); lane_use_file.Open (merge_dir + key); lane_use_flag = true; } //---- open merge location file ---- key = Get_Control_String (MERGE_LOCATION_FILE); if (!key.empty ()) { location_file.File_Type ("Merge Location File"); location_file.Open (merge_dir + key); location_flag = true; } //---- open merge connection file ---- key = Get_Control_String (MERGE_CONNECTION_FILE); if (!key.empty ()) { connect_file.File_Type ("Merge Connection File"); connect_file.Open (merge_dir + key); connect_flag = true; } //---- open merge parking file ---- key = Get_Control_String (MERGE_PARKING_FILE); if (!key.empty ()) { parking_file.File_Type ("Merge Parking File"); parking_file.Open (merge_dir + key); parking_flag = true; } //---- open merge access file ---- key = Get_Control_String (MERGE_ACCESS_FILE); if (!key.empty ()) { access_file.File_Type ("Merge Access File"); access_file.Open (merge_dir + key); access_flag = true; } //---- open merge stop file ---- key = Get_Control_String (MERGE_STOP_FILE); if (!key.empty ()) { stop_file.File_Type ("Merge Stop File"); stop_file.Open (merge_dir + key); stop_flag = true; } //---- open merge sign file ---- key = Get_Control_String (MERGE_SIGN_FILE); if (!key.empty ()) { sign_file.File_Type ("Merge Sign File"); sign_file.Open (merge_dir + key); sign_flag = true; } //---- open merge signal file ---- key = Get_Control_String (MERGE_SIGNAL_FILE); if (!key.empty ()) { signal_file.File_Type ("Merge Signal File"); signal_file.Open (merge_dir + key); signal_flag = true; } //---- open merge timing file ---- key = Get_Control_String (MERGE_TIMING_PLAN_FILE); if (!key.empty ()) { timing_file.File_Type ("Merge Timing Plan File"); timing_file.Open (merge_dir + key); timing_flag = true; } //---- open merge phasing file ---- key = Get_Control_String (MERGE_PHASING_PLAN_FILE); if (!key.empty ()) { phasing_file.File_Type ("Merge Phasing Plan File"); phasing_file.Open (merge_dir + key); phasing_flag = true; } //---- open merge detector file ---- key = Get_Control_String (MERGE_DETECTOR_FILE); if (!key.empty ()) { detector_file.File_Type ("Merge Detector File"); detector_file.Open (merge_dir + key); detector_flag = true; } //---- open merge zone file ---- key = Get_Control_String (MERGE_ZONE_FILE); if (!key.empty ()) { zone_file.File_Type ("Merge Zone File"); zone_file.Open (merge_dir + key); zone_flag = true; } //---- open merge performance file ---- key = Get_Control_String (MERGE_PERFORMANCE_FILE); if (!key.empty ()) { performance_file.File_Type ("Merge Performance File"); performance_file.Open (merge_dir + key); performance_flag = true; } //---- open merge turn_delay file ---- key = Get_Control_String (MERGE_TURN_DELAY_FILE); if (!key.empty ()) { turn_delay_file.File_Type ("Merge Turn Delay File"); turn_delay_file.Open (merge_dir + key); turn_delay_flag = true; } }