Exemplo n.º 1
0
void ActivityPattern::Read_Scripts (void)
{
	Print (1);

	//---- read the household type script ----

	if (hhold_type_flag) {
		Write (1, "Compiling Household Type Script");

		if (Report_Flag (HOUSEHOLD_SCRIPT)) {
			Header_Number (HOUSEHOLD_SCRIPT);

			if (!Break_Check (10)) {
				Print (1);
				Page_Header ();
			}
		}
		hhold_type.Set_Files (1, Demand_Db_Base (HOUSEHOLD));

		if (!hhold_type.Compile (&hhold_type_file, Report_Flag (HOUSEHOLD_SCRIPT))) {
			Error ("Compiling Household Type Script");
		}
		if (Report_Flag (HOUSEHOLD_STACK)) {
			Header_Number (HOUSEHOLD_STACK);

			hhold_type.Print_Commands (false);
		}
	}

	//---- read the survey type script ----

	if (survey_type_flag) {
		Write (1, "Compiling Survey Type Script");

		if (Report_Flag (SURVEY_SCRIPT)) {
			Header_Number (SURVEY_SCRIPT);

			if (!Break_Check (10)) {
				Print (1);
				Page_Header ();
			}
		}
		survey_type.Set_Files (1, &survey_hh_file);

		if (!survey_type.Compile (&survey_type_file, Report_Flag (SURVEY_SCRIPT))) {
			Error ("Compiling Survey Type Script");
		}
		if (Report_Flag (SURVEY_STACK)) {
			Header_Number (SURVEY_STACK);

			survey_type.Print_Commands (false);
		}
	}
	Header_Number (0);
	Show_Message (1);
}
Exemplo n.º 2
0
void ModeChoice::Value_Summary (int segment)
{
	int i, j;
	double value, trips;
	Doubles *mode_ptr;

	header_value = segment;
	Header_Number (MODE_VALUES);

	if (!Break_Check (num_modes + 5)) {
		Print (1);
		Value_Header ();
	}

	//---- process each mode ----

	for (i=0; i < num_modes; i++) {
		mode_ptr = &value_sum [segment] [i];

		trips = mode_ptr->at (const_field);
		if (trips <= 0) continue;

		Print (1, String ("%-20s") % mode_names [i]);

		for (j=0; j < const_field; j++) {
			value = mode_ptr->at (j) / trips;

			Print (0, String ("  %7.2lf") % value);
		}
		Print (0, String ("  %8.0lf") % trips);
	}
	Header_Number (0);
}
Exemplo n.º 3
0
void ConvertTrips::Zone_Sum_Report (void)
{
	int z, zone, org_in_tot, des_in_tot, org_out_tot, des_out_tot;
	Int_Map_Itr map_itr;

	//---- print the report ----

	Header_Number (ZONE_TRIP_ENDS);

	if (!Break_Check ((int) zone_map.size () + 7)) {
		Print (1);
		Zone_Sum_Header ();
	}
	org_in_tot = des_in_tot = org_out_tot = des_out_tot = 0;

	for (map_itr = zone_map.begin (); map_itr != zone_map.end (); map_itr++) {
		zone = map_itr->first;
		z = map_itr->second;

		org_in_tot += org_in [z];
		des_in_tot += des_in [z];
		org_out_tot += org_out [z];
		des_out_tot += des_out [z];

		Print (1, String ("%6d   %8d   %8d     %8d   %8d     %8d   %8d") % zone % org_in [z] % des_in [z] % 
			org_out [z] % des_out [z] % (org_out [z] - org_in [z]) % (des_out [z] - des_in [z]));
	}
	Print (2, String (" Total   %8d   %8d     %8d   %8d     %8d   %8d") % org_in_tot % des_in_tot % 
		org_out_tot % des_out_tot % (org_out_tot - org_in_tot) % (des_out_tot - des_in_tot));
		
	Header_Number (0);
}
Exemplo n.º 4
0
void RandomSelect::Execute (void)
{
	int last_hhold, last_part, part;
	double share, total, prob;
	Select_Map_Itr map_itr;
	Trip_Index trip_index;
	Int_Itr int_itr;

	//---- read the network data ----

	Data_Service::Execute ();

	//---- select a partition ----

	last_hhold = last_part = 0;
	share = 1.0 / num_parts;

	for (map_itr = select_map.begin (); map_itr != select_map.end (); map_itr++) {
		trip_index = map_itr->first;

		if (last_hhold != trip_index.Household ()) {
			last_hhold = trip_index.Household ();

			prob = random.Probability ();
			total = share;

			for (part=0; part < num_parts; part++, total += share) {
				if (total > prob) break;
			}
			last_part = part;
		}
		map_itr->second.Partition (last_part);
		part_count [last_part]++;
	}

	//---- write the selection file ----

	Write_Selections ();

	//---- report the records per partition ----

	total = select_map.size () / 100.0;
	if (total == 0.0) total = 1.0;

	Break_Check (num_parts + 3);
	Write (2, "Partition Distribution");

	for (part=0, int_itr = part_count.begin (); int_itr != part_count.end (); int_itr++, part++) {
		Write (1, String ("%5d %10d (%5.1lf%%)") % part % *int_itr % (*int_itr / total) % FINISH);
	}
	Write (1, String ("Total %10d") % (int) select_map.size ());

	//---- end the program ----

	Exit_Stat (DONE);
}
Exemplo n.º 5
0
void PlanSum::Trip_Time (void)
{
	int i, start_total, mid_total, end_total;
	double start, mid, end;

	Show_Message ("Trip Time Report");

	//---- get the total number of trips ----

	start_total = mid_total = end_total = 0;

	for (i=1; i <= num_inc; i++) {
		start_total += start_time [i];
		mid_total += mid_time [i];
		end_total += end_time [i];
	}
	if (start_total == 0 && mid_total == 0 && end_total == 0) {
		Write (2, "Trip Time Data is Zero");
		return;
	}
	if (start_total == 0) {
		start = 1.0;
	} else {
		start = start_total;
	}
	if (mid_total == 0) {
		mid = 1.0;
	} else {
		mid = mid_total;
	}
	if (end_total == 0) {
		end = 1.0;
	} else {
		end = end_total;
	}

	//---- print the report ----

	Header_Number (TRIP_TIME);

	if (!Break_Check (num_inc + 7)) {
		Print (1);
		Trip_Time_Header ();
	}		

	for (i=1; i <= num_inc; i++) {
		Print (1, "%-12.12s   %10d   %6.2lf   %10d   %6.2lf   %10d   %6.2lf", 
			time_periods.Range_Format (i), 
			start_time [i], 100.0 * start_time [i] / start,
			mid_time [i], 100.0 * mid_time [i] / mid_total,
			end_time [i], 100.0 * end_time [i] / end_total);
	}
	Print (2, "Total          %10d   100.00   %10d   100.00   %10d   100.00", start_total, mid_total, end_total);
		
	Header_Number (0);
}
Exemplo n.º 6
0
void ModeChoice::Mode_Summary (int segment)
{
	int i;
	double total, percent;
	String text;
	Doubles *mode_ptr;
	Dbl_Itr tab_itr;

	header_value = segment;
	Header_Number (MODE_SUMMARY);

	if (!Break_Check (num_modes + 8)) {
		Print (1);
		Mode_Header ();
	}

	//---- get the total number of trips ----

	total = market_seg [segment] [num_modes] [num_tables];
	if (total == 0.0) return;

	//---- process each mode ----

	for (i=0; i <= num_modes; i++) {
		if (i == num_modes) {
			Print (1);
			text = "Total";
		} else {
			text = mode_names [i];
		}
		Print (1, String ("%-20s") % text);

		mode_ptr = &market_seg [segment] [i];

		for (tab_itr = mode_ptr->begin (); tab_itr != mode_ptr->end (); tab_itr++) {
			Print (0, String ("  %10.1lf") % *tab_itr);
		}
		percent = mode_ptr->at (num_tables) * 100.0 / total;

		Print (0, String ("  %6.2lf%%") % percent % FINISH);
	}

	//---- table percents ----

	text = "Percent";
	Print (1, String ("%-20s") % text);

	mode_ptr = &market_seg [segment] [num_modes];

	for (tab_itr = mode_ptr->begin (); tab_itr != mode_ptr->end (); tab_itr++) {
		percent = *tab_itr * 100.0 / total;
		Print (0, String ("     %6.2lf%%") % percent % FINISH);
	}
	Header_Number (0);
}
Exemplo n.º 7
0
void TripSum::Trip_Diurnal_Report (void)
{
	int p, start_total, mid_total, end_total, num_periods;
	double start, mid, end;

	//---- get the total number of trips ----

	num_periods = sum_periods.Num_Periods ();
	start_total = mid_total = end_total = 0;

	for (p=0; p < num_periods; p++) {
		start_total += start_time [p];
		mid_total += mid_time [p];
		end_total += end_time [p];
	}
	if (start_total == 0 && mid_total == 0 && end_total == 0) {
		Write (2, "Time Distribution Data is Zero");
		return;
	}
	if (start_total == 0) {
		start = 1.0;
	} else {
		start = start_total;
	}
	if (mid_total == 0) {
		mid = 1.0;
	} else {
		mid = mid_total;
	}
	if (end_total == 0) {
		end = 1.0;
	} else {
		end = end_total;
	}

	//---- print the report ----

	Header_Number (TRIP_DIURNAL);

	if (!Break_Check (num_periods + 7)) {
		Print (1);
		Trip_Time_Header ();
	}		

	for (p=0; p < num_periods; p++) {
		Print (1, String ("%-12.12s   %10d   %6.2lf   %10d   %6.2lf   %10d   %6.2lf") % 
			sum_periods.Range_Format (p) %
			start_time [p] % (100.0 * start_time [p] / start) %
			mid_time [p] % (100.0 * mid_time [p] / mid) %
			end_time [p] % (100.0 * end_time [p] / end));
	}
	Print (2, String ("Total          %10d   100.00   %10d   100.00   %10d   100.00") % start_total % mid_total % end_total);
		
	Header_Number (0);
}
Exemplo n.º 8
0
void DynusTPlan::Execute (void)
{
	int nfile;

	//---- read the network ----

	Demand_Service::Execute ();

	Set_Zone ();

	//---- write a temporary header record ----

	fprintf (veh_file.File (), "0000000000 1 # of vehicles, max # of stops, start_time=%s\n", time_range.Format_Step (start_time));
	fprintf (veh_file.File (), "      #   usec   dsec   stime usrcls vehtype ioc #ONode #IntDe info ribf   comp    OZ\n");

	//---- read the plan file ----

	for (nfile=0; ; nfile++) {
		if (!plan_file.Open (nfile)) break;

		//---- process the plan files ----

		Read_Plan ();
	}
	if (nfile == 0) {
		File_Error ("No Plan Files were Found", plan_file.Filename ());
	}

	//---- write summary statistics ----

	Break_Check (8);

	Write (2, "Number of Plan Files = %d", nfile);
	Write (1, "Number of Input Plans = %d", plan_file.Num_Plans ());
	Write (1, "Number of Input Records = %d", plan_file.Num_Records ());
	Write (1, "Number of Input Travelers = %d", plan_file.Num_Travelers ());
	Write (1, "Number of Input Trips = %d", plan_file.Num_Trips ());

	Write (2, "Number of Output Trips = %d", num_out);

	//---- update the header ----

	veh_file.Rewind ();

	fprintf (veh_file.File (), "%10d", num_out);

	veh_file.Close ();
	path_file.Close ();

	//---- end the program ----

	Exit_Stat (DONE);
}
Exemplo n.º 9
0
void TPPlusRoute::Execute (void)
{
	int old_routes, old_nodes;

	//---- read the network ----

	Network_Service::Execute ();

	//---- check the input route numbers ----

	if (input_flag) {
		Route_Data *route_ptr = route_data.Last_Key ();

		if (route_ptr != NULL) {
			if (route_id <= route_ptr->Route ()) {
				route_id = ((route_ptr->Route () / 100) + 1) * 100;
			}
		}
		old_routes = route_data.Num_Records ();
		old_nodes = route_data.Num_Nodes ();
	} else {
		old_routes = old_nodes = 0;
	}

	//---- read the tpplus node map file ----

	if (map_flag) {
		Read_Node_Map ();
	}

	//---- read the tpplus line files ----

	Read_Line ();

	//---- write the route header and nodes ----

	Write_Route ();

	//---- print the results ----

	Break_Check (4);
	Write (2, "Number of Route Header Records = %d", nroute);
	if (old_routes > 0) Write (0, " (%d new)", (nroute - old_routes));

	Write (1, "Number of Route Nodes Records = %d", nnodes);
	if (old_nodes > 0) Write (0, " (%d new)", (nnodes - old_nodes));

	if (num_match > 0) Write (1, "Number of Matched Routes = %d", num_match);

	Exit_Stat (DONE);
}
Exemplo n.º 10
0
void SmoothPlans::Change_Report (void)
{
	int hour, time;
	double average;
	char buffer [20];

	Period_Index *period_ptr;

	//---- print the report header ----

	if (!Break_Check (32)) {
		Print (1);
	}
	Print (1, "Time Change Summary Report");
	Print (1);
	Print (1, "            ------ Trips -------     Average     Minimum    Maximum");
	Print (1, "      Hour   Original   Smoothed      Change      Change     Change");
	Print (1);

	for (hour=1; hour < 24; hour++) {
		period_ptr = period_index [hour];

		Print (1, "%10.10s %10d %10d", time_step.Format_Step (hour * 3600),
			period_ptr->Original (), period_ptr->Smoothed ());

		average = period_ptr->Average_Change ();

		if (time_step.Format () == Time_Step::HOURS) {
			if (average >= 0) {
				time = (int) (average + 0.5);
			} else {
				time = -((int) (-average + 0.5));
			}
			Print (0, "  %11.11s", time_step.Format_Duration (time));
		} else {
			if (average >= 0) {
				time = (int) average;
				average = average - time;
			} else {
				time = -((int) (-average));
				average = time - average;
			}
			str_fmt (buffer, sizeof (buffer), "%.1lf", average);

			Print (0, " %10.10s%s", time_step.Format_Duration (time), buffer+1);
		}
		Print (0, " %10.10s", time_step.Format_Duration (period_ptr->Min_Change ()));
		Print (0, " %10.10s", time_step.Format_Duration (period_ptr->Max_Change ()));
	}
}
Exemplo n.º 11
0
void Converge_Service::Trip_Gap_Report (int report)
{
	int i;
	double gap, max, diff, total, std_dev, rmse, num;

	Gap_Sum_Itr gap_itr;

	Header_Number (report);

	if (!Break_Check ((int) trip_gap_array.size () + 7)) {
		Print (1);
		Trip_Gap_Header ();
	}

	for (i=1, gap_itr = trip_gap_array.begin (); gap_itr != trip_gap_array.end (); gap_itr++, i++) {
		if (gap_itr->count == 0) continue;

		num = gap_itr->count;
		total = gap_itr->current;
		diff = gap_itr->abs_diff;
		max = gap_itr->max_gap;

		if (total > 0.0) {
			gap = diff / total;
			rmse = 100.0 * sqrt (gap_itr->diff_sq / num) * num / total;

			if (num > 1) {		
				std_dev = (gap_itr->diff_sq - diff * diff / num) / (num - 1.0);
				std_dev = (std_dev > 0.0) ? sqrt (std_dev) : 0.0;
				std_dev = std_dev * num / total;
			} else {
				std_dev = 0.0;
			}
			total /= 100;
			diff /= 100;
		} else {
			gap = 1.0;
			std_dev = rmse = 0.0;
		}

		//---- print the data record ----

		Print (1, String ("%6d   %13.6lf %13.6lf %13.6lf %9.1lf %13.0lf %13.0lf") %
			i % gap % std_dev % max % rmse % diff % total);
	}
	Header_Number (0);
}
Exemplo n.º 12
0
void ExportTransit::Execute (void)
{

	//---- read the network ----

	Network_Service::Execute ();

	//---- write the transit routes ----

	Write_Route ();

	//---- print the results ----

	Break_Check (3);
	Write (2, "Number of Route Header Records = %d", nroute);
	Write (1, "Number of Route Nodes Records = %d", nnodes);

	Exit_Stat (DONE);
}
Exemplo n.º 13
0
void Relocate::Location_Map_Report (void)
{
	Location_Itr loc_itr;
	Location_Data *loc_ptr;
	Int_Map_Itr map_itr;

	Header_Number (LOCATION_MAP);

	if (!Break_Check ((int) location_map.size () + 8)) {
		Print (1);
		Location_Map_Header ();
	}

	for (loc_itr = location_array.begin (); loc_itr != location_array.end (); loc_itr++) {

		if (loc_itr->Zone () == 2) {
			if (loc_itr->Offset () == -1) continue;

			Print (1, String ("%10d  %10d  %s") % 0 % loc_itr->Location () % "Unused Target Location");

		} else if (loc_itr->Zone () == 0) {

			Print (1, String ("%10d  %10d  %s") % loc_itr->Location () % 0 % "Location Not Mapped");

		} else {
			map_itr = target_loc_map.find (loc_itr->Location ());

			if (map_itr != target_loc_map.end ()) {
				loc_ptr = &location_array [map_itr->second];
				loc_ptr->Offset (-1);

				if (loc_itr->Zone () == 1) {
					Print (1, String ("%10d  %10d  %s") % loc_itr->Location () % loc_ptr->Location () % "Location on the Same Link");
				} else {
					Print (1, String ("%10d  %10d  %s") % loc_itr->Location () % loc_ptr->Location () % "Location Near By");
				}
			}
		}
	}
	Header_Number (0);
}
Exemplo n.º 14
0
void GISNet::Execute (void)
{

	//---- read the conversion script ----

	if (convert_flag) {
		if (Report_Flag (SCRIPT_REPORT)) {
			Header_Number (SCRIPT_REPORT);

			if (!Break_Check (10)) {
				Print (1);
				Page_Header ();
			}
		}
		convert.Set_Files (2, &gis_file, Network_Db_Base (NEW_LINK));

		if (!convert.Compile (&script_file, Report_Flag (SCRIPT_REPORT))) {
			Error ("Compiling Conversion Script");
		}
		if (Report_Flag (STACK_REPORT)) {
			Header_Number (STACK_REPORT);

			convert.Print_Commands (false);
		}
		Header_Number (0);
	}

	//---- gis node file ----

	if (node_flag) {
		Read_Node ();
	}

	//---- gis link file ----

	Read_Link ();

	//---- end the program ----

	Exit_Stat (DONE);
}
Exemplo n.º 15
0
void ActivityPattern::Read_Survey (void)
{
	//---- read the survey household weights ----

	if (weight_flag) {
		Survey_Weights ();
	}

	//---- read the survey household data ----

	Survey_Households ();

	//---- survey type summary report ----

	if (Report_Flag (SURVEY_TYPE)) {
		Header_Number (SURVEY_TYPE);

		if (!Break_Check (type_data.Num_Records () + 4)) {
			Print (1);
			Page_Header ();
		}
		Type_Data *type_ptr;

		for (type_ptr = type_data.First_Key (); type_ptr; type_ptr = type_data.Next_Key ()) {
			Print (1, "%4d  %8d      %15.6lf  %14.6lf", 
				type_ptr->Type (), type_ptr->Num_Survey (), type_ptr->Cum_Weight (),
				type_ptr->Cum_Weight () / ((type_ptr->Num_Survey () > 0) ? type_ptr->Num_Survey () : 1));
		}
		Header_Number (0);
	}

	//---- read the survey popoulation data ----

	Survey_Population ();

	//---- read the survey activity data ----

	Survey_Activity ();
}
Exemplo n.º 16
0
void CoordMatch::Execute (void)
{
	//---- read the network ----

	Network_Service::Execute ();

	//---- read the reference node file ----

	if (ref_node_flag) {
		Read_Reference ();
	}

	//---- read the node map file ----

	if (node_map_flag) {
		Read_Node_Map ();
	} else {
		Make_Node_Map ();
	}

	//---- match other reference nodes ----

	if (new_map_flag || replace_flag) {
		Expand_Node_Map ();
	}

	//---- convert the nodes ----

	Adjust_Nodes ();

	//---- print the results ----

	Break_Check (4);
	Write (2, "Number of New Node Records = %d", num_new_nodes);
	Write (1, "Number of New Node Map Records = %d", num_new_maps);

	Exit_Stat (DONE);
}
Exemplo n.º 17
0
void EventSum::Traveler_Sum_Report (void)
{
	int i;

	Show_Message ("Traveler Summary Report");

	//---- print the report ----

	Header_Number (TRAVELER_SUM);

	if (!Break_Check (num_inc + 7)) {
		Print (1);
		Traveler_Sum_Header ();
	}		

	for (i=1; i <= time_periods.Num_Ranges (); i++) {
		Print (1, "%-12.12s   %10d   %6.2lf   %10d   %6.2lf   %10d   %6.2lf", 
			time_periods.Range_Format (i));
	}
	Print (2, "Total          %10d   100.00   %10d   100.00   %10d   100.00");
		
	Header_Number (0);
}
Exemplo n.º 18
0
void LocationData::Set_Files (void)
{
	int i, nfld, key;
	bool binary;

	Db_Field *fld;
	Db_Base *file;
	Db_Sort_Array *data;
	Data_Itr data_itr;
	Polygon_Itr poly_itr;

	//---- create the program data structure ----

	data_rec.push_back (input_file);
	data_rec.push_back (output_file);

	//---- convert each data file to binary ----

	for (data_itr = data_group.begin (); data_itr != data_group.end (); data_itr++) {
		file = data_itr->file;
		data = data_itr->data_db;

		data_rec.push_back ((Db_Base *) data);

		data->File_ID (file->File_ID ());
		data->File_Type (file->File_Type ());

		nfld = file->Num_Fields ();
		key = data_itr->join_field;
	
		binary = (file->Record_Format () == BINARY);

		fld = file->Field (key);

		data->Add_Field (fld->Name (), DB_INTEGER, 10);
		data->Add_Field ("AL_COUNT", DB_INTEGER, 10);

		for (i=0; i < nfld; i++) {
			if (i == key) continue;
			fld = file->Field (i);
			if (fld != 0) {
				data->Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary);
			}
		}
	}

	//---- read the arcview boundary file ----

	for (poly_itr = polygons.begin (); poly_itr != polygons.end (); poly_itr++) {
		file = poly_itr->file;
		data = poly_itr->data_db;

		data_rec.push_back ((Db_Base *) data);

		data->File_ID (file->File_ID ());
		data->File_Type (file->File_Type ());

		nfld = file->Num_Fields ();
		binary = (file->Record_Format () == BINARY);

		data->Add_Field ("INDEX", DB_INTEGER, 10);

		for (i=0; i < nfld; i++) {
			fld = file->Field (i);
			if (fld != 0) {
				data->Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary);
			}
		}
	}
	Write (1, "Compiling Conversion Script");

	if (Report_Flag (PRINT_SCRIPT)) {
		Header_Number (PRINT_SCRIPT);

		if (!Break_Check (10)) {
			Print (1);
			Page_Header ();
		}
	}
	program.Initialize (data_rec, random.Seed () + 1);

	if (!program.Compile (program_file, Report_Flag (PRINT_SCRIPT))) {
		Error ("Compiling Conversion Script");
	}
	if (Report_Flag (PRINT_STACK)) {
		Header_Number (PRINT_STACK);

		program.Print_Commands (false);
	}
	Header_Number (0);
} 
Exemplo n.º 19
0
void TPPlusNet::Execute (void)
{
	//---- read the conversion script ----

	if (convert_flag) {
		int num;
		Db_Base *files [3];

		if (Report_Flag (SCRIPT_REPORT)) {
			Header_Number (SCRIPT_REPORT);

			if (!Break_Check (10)) {
				Print (1);
				Page_Header ();
			}
		}
		if (link_shape_flag) {
			files [0] = &link_shape_file;
		} else {
			files [0] = &link_file;
		}
		files [1] = Network_Db_Base (NEW_LINK);
		if (detail_flag) {
			files [2] = &detail_file;
			num = 3;
		} else {
			num = 2;
		}
		convert.Set_Files (num, files);

		if (!convert.Compile (&script_file, Report_Flag (SCRIPT_REPORT))) {
			Error ("Compiling Conversion Script");
		}
		if (Report_Flag (STACK_REPORT)) {
			Header_Number (STACK_REPORT);

			convert.Print_Commands (false);
		}
		Header_Number (0);
	}

	//---- setup network data ----

	Network_Service::Execute ();

	//---- read the speed capacity file ----

	if (spdcap_flag) {
		Read_SpdCap ();
	}

	//---- read the node file ----

	Read_Node ();

	//---- read the link file ----

	Read_Link ();

	//---- write the link file ----

	Write_Link ();

	//---- end the program ----

	Exit_Stat (DONE);
}
Exemplo n.º 20
0
void RiderSum::Line_Sum_Report (void)
{
	int riders, max_load, board, alight, run, runs;

	Int_Map_Itr map_itr;
	Line_Data *line_ptr;
	Line_Stop_Itr stop_itr;
	Line_Run_Itr run_itr;

	Show_Message ("Line Summary Report -- Record");
	Set_Progress ();

	//---- print the report ----

	Header_Number (LINE_SUM);

	if (!Break_Check ((int) line_map.size () + 5)) {
		Print (1);
		Line_Sum_Header ();
	}

	//---- get the route data ----

	for (map_itr = line_map.begin (); map_itr != line_map.end (); map_itr++) {
		Show_Progress ();

		if (select_routes && !route_range.In_Range (map_itr->first)) continue;

		line_ptr = &line_array [map_itr->second];

		if (select_modes && !select_mode [line_ptr->Mode ()]) continue;

		//---- check the link criteria ----

		if (!Link_Selection (line_ptr)) continue;

		//---- set the run flags ----

		if (!Run_Selection (line_ptr)) continue;

		//---- save the route ridership data ----

		riders = board = alight = max_load = runs = 0;

		for (stop_itr = line_ptr->begin (); stop_itr != line_ptr->end (); stop_itr++) {
			for (run=0, run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++, run++) {
				if (run_flag [run] == 0) continue;
				if (run_period [run] < 0) continue;
				if (select_time_of_day && !time_range.In_Range (run_itr->Schedule ())) continue;

				if (run_itr->Board () > board) board = run_itr->Board ();
				if (run_itr->Alight () > alight) alight = run_itr->Alight ();
				if (run_itr->Load () > max_load)  max_load = run_itr->Load ();
				riders += run_itr->Board ();

				if (run_flag [run] == 1) {
					runs++;
					run_flag [run] = 2;
				}
			}
		}
		if (riders == 0) continue;
		
		Print (1, String ("%8d  %10.10s  %5d  %5d  %8d  %8d %8d %8d") % line_ptr->Route () %
			Transit_Code ((Transit_Type) line_ptr->Mode ()) % line_ptr->size () % runs %
			riders % max_load % board % alight);

		if (!line_ptr->Name ().empty ()) {
			Print (0, String ("  %s") % line_ptr->Name ());
		}
		if (Notes_Name_Flag ()) {
			if (!line_ptr->Notes ().empty ()) {
				Print (0, String ("  %s") % line_ptr->Notes ());
			}
		}
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 21
0
void ConvertTours::Program_Control (void)
{
	int i, j, num_file, lvalue;
	double dvalue;
	bool factor_flag;
	char *str_ptr, buffer [FIELD_BUFFER], *format_ptr;

	File_Group *group;

	char *time_control [] = {"ORIGIN", "DESTINATION", "MID-TRIP", NULL};

	factor_flag = false;

	//---- open demand and network files ----

	Demand_Service::Program_Control ();

	//---- set the file points ----

	zone_flag = Network_File_Flag (ZONE);

	trip_file = (Trip_File *) Demand_Db_Base (NEW_TRIP);
	household_file = (Household_File *) Demand_Db_Base (NEW_HOUSEHOLD);
	population_file = (Population_File *) Demand_Db_Base (NEW_POPULATION);
	vehicle_file = (Vehicle_File *) Demand_Db_Base (NEW_VEHICLE);

	//---- check for copy commands ----

	if (Demand_File_Flag (TRIP)) {
		trip_file->Clear_Fields ();
		trip_file->Replicate_Fields (Demand_Db_Base (TRIP));
		trip_file->Write_Header ();
	}
	if (Demand_File_Flag (HOUSEHOLD)) {
		household_file->Clear_Fields ();
		household_file->Replicate_Fields (Demand_Db_Base (HOUSEHOLD));
		household_file->Write_Header ();
	}
	if (Demand_File_Flag (POPULATION)) {
		population_file->Clear_Fields ();
		population_file->Replicate_Fields (Demand_Db_Base (POPULATION));
		population_file->Write_Header ();
	}
	if (Demand_File_Flag (VEHICLE)) {
		vehicle_file->Clear_Fields ();
		vehicle_file->Replicate_Fields (Demand_Db_Base (VEHICLE));
		vehicle_file->Write_Header ();
	}

	//---- get the tour data file ----

	str_ptr = Get_Control_String (TOUR_DATA_FILE);

	if (str_ptr == NULL) goto control_error;

	Print (1);
	format_ptr = Get_Control_String (TOUR_DATA_FORMAT);

	if (format_ptr != NULL) {
		tour_file.Dbase_Format (format_ptr);
	}
	tour_file.Open (Project_Filename (str_ptr));

	tour_file_db.Add_Field ("SORTKEY", INTEGER, 10);

	tour_file_db.Replicate_Fields (&tour_file, true);
	tour_file_db.File_ID ("Tour");

	//---- set tour field numbers ----

	Print (1);

	str_ptr = Get_Control_String (TOUR_HOUSEHOLD_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.HHold_Field (str_ptr);
	} else {
		lvalue = tour_file.HHold_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Household Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_PERSON_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Person_Field (str_ptr);
	} else {
		lvalue = tour_file.Person_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Person Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_NUMBER_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Tour_Field (str_ptr);
	} else {
		lvalue = tour_file.Tour_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Number Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_PURPOSE_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Purpose_Field (str_ptr);
	} else {
		lvalue = tour_file.Purpose_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Purpose Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_MODE_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Mode_Field (str_ptr);
	} else {
		lvalue = tour_file.Mode_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Mode Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_ORIGIN_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Origin_Field (str_ptr);
	} else {
		lvalue = tour_file.Origin_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Origin Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_DESTINATION_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Dest_Field (str_ptr);
	} else {
		lvalue = tour_file.Dest_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Destination Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_STOP_OUT_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Stop_Out_Field (str_ptr);
	} else {
		lvalue = tour_file.Stop_Out_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Stop Out Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_STOP_IN_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Stop_In_Field (str_ptr);
	} else {
		lvalue = tour_file.Stop_In_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Stop In Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_START_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Start_Field (str_ptr);
	} else {
		lvalue = tour_file.Start_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Start Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}	
	str_ptr = Get_Control_String (TOUR_RETURN_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Return_Field (str_ptr);
	} else {
		lvalue = tour_file.Return_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Return Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}
	str_ptr = Get_Control_String (TOUR_GROUP_FIELD);
	if (str_ptr != NULL) {
		lvalue = tour_file.Group_Field (str_ptr);
	} else {
		lvalue = tour_file.Group_Field ();
	}
	if (lvalue > 0) {
		Print (1, "Tour Group Field = %s, Number = %d", tour_file.Field (lvalue)->Name (), lvalue);
	}

	//---- get the tour group script -----

	str_ptr = Get_Control_String (TOUR_GROUP_SCRIPT);

	if (str_ptr != NULL) {
		script_file.File_Type ("Tour Group Script");

		script_file.Open (Project_Filename (str_ptr));
		script_flag = true;
	}

	//---- get the household list file -----

	str_ptr = Get_Control_String (HOUSEHOLD_LIST);

	if (str_ptr != NULL) {
		hhlist_file.File_Type ("Household List File");

		hhlist_file.Open (Project_Filename (str_ptr));
		hhlist_flag = true;
	}

	//---- get the starting hhold id ----
	
	str_ptr = Get_Control_String (STARTING_HOUSEHOLD_ID);

	if (str_ptr != NULL) {
		Get_Integer (str_ptr, &hhold_id);
		if (hhold_id < 1) {
			Error ("Starting Household ID %d is Out of Range", hhold_id);
		}
	} else {
		hhold_id = 1;
	}
    Print (2, "Starting Household ID = %d", hhold_id);

	//---- get the starting vehicle id ----
	
	str_ptr = Get_Control_String (STARTING_VEHICLE_ID);

	if (str_ptr != NULL) {
		Get_Integer (str_ptr, &vehicle_id);
		if (vehicle_id < 1) {
			Error ("Starting Vehicle ID %d is Out of Range", vehicle_id);
		}
	} else {
		vehicle_id = 1;
	}
	Print (1, "Starting Vehicle ID = %d", vehicle_id);

	//---- get the time of day format ----
	
	str_ptr = Get_Control_String (TIME_OF_DAY_FORMAT);

	if (str_ptr == NULL) {
		str_ptr = "24_HOUR_CLOCK";
	}
	if (!trip_time.Format (str_ptr)) {
		Error ("Time of Day Format %s was Unrecognized", str_ptr);
	}
	Print (2, "Time of Day Format = %s", str_ptr);

	//---- get the additional travel time ----
	
	str_ptr = Get_Control_String (ADDITIONAL_TRAVEL_TIME);

	if (str_ptr != NULL) {
		Get_Integer (str_ptr, &additional_time);

		if (additional_time < 0) {
			Error ("Additional Travel Time %d is Out of Range", additional_time);
		}
	}
	Print (2, "Additional Travel Time = %d seconds", additional_time);

	//---- open the zone location map ----

	str_ptr = Get_Control_String (ZONE_LOCATION_MAP_FILE);

	if (str_ptr != NULL) {
		zone_loc_flag = true;
		Print (1);

		zone_loc_map.Open (Project_Filename (str_ptr));
	}

	//---- random number seed ----

	str_ptr = Get_Control_String (RANDOM_NUMBER_SEED);

	if (str_ptr != NULL) {
		random_org.Seed (atoi (str_ptr));
	}
	Print (2, "Random Number Seed = %d", random_org.Seed ());
	
	random_des.Seed (random_org.Seed () + 1);
	random_tod.Seed (random_org.Seed () + 2);
	random_stop.Seed (random_org.Seed () + 3);

	//---- open the zone equivalence ----

	str_ptr = Get_Control_String (ZONE_EQUIVALENCE_FILE);

	if (str_ptr != NULL) {
		equiv_flag = true;
		Print (1);

		zone_equiv.Open (Project_Filename (str_ptr));
	}

	//---- open the travel time skim ----

	str_ptr = Get_Control_String (TRAVEL_TIME_FILE);

	if (str_ptr != NULL) {
		skim_flag = true;
		Print (1);

		skim_file.Open (Project_Filename (str_ptr));
	}

	//---- open the diurnal allocation file ----

	str_ptr = Get_Control_String (NEW_DIURNAL_FILE);

	if (str_ptr != NULL) {
		diurnal_flag = true;
		diurnal_file.File_Type ("New Diurnal File");
		Print (1);

		diurnal_file.Create (Project_Filename (str_ptr));
	}

	//---- write the report names ----

	List_Reports ();

	//---- get the number of files ----

	num_file = Highest_Control_Group (TRIP_TIME_FILE_x, 0);

	if (num_file == 0) {
		Error ("No Trip Time Files were Found");
	}

	//---- allocate file space ----

	if (!file_group.Max_Records (num_file)) {
		Error ("Insufficient Memory for %d File Groups", num_file);
	}

	//---- process each file ----

	for (i=1; i <= num_file; i++) {

		//---- get the trip time file ----

		str_ptr = Get_Control_String (TRIP_TIME_FILE_x, i);

		if (!Break_Check (15)) {
			Print (1);
		}
		if (str_ptr == NULL) continue;

		group = file_group.New_Record (true);

		group->Group (i);

		group->Time_File (new Diurnal_File ());

		str_fmt (buffer, sizeof (buffer), "Trip Time File #%d", i);

		group->Time_File ()->File_Type (buffer);

		format_ptr = Get_Control_String (TRIP_TIME_FORMAT_x, i);

		if (format_ptr != NULL) {
			group->Time_File ()->Dbase_Format (format_ptr);
		}
		group->Time_File ()->Open (Project_Filename (str_ptr));

		//---- get the trip time field ----

		if (!script_flag) {
			str_ptr = Get_Control_String (TRIP_TIME_FIELD_x, i);

			if (str_ptr != NULL) {
				if (!group->Time_Field (str_ptr)) {
					Error ("Trip Time Field %s was Not Found", str_ptr);
				}
				Print (1, "Trip Time Field Name = %s, Number = %d", str_ptr, group->Time_Field ());
			}
		}

		//---- get the time period range ----

		str_ptr = Get_Control_String (TIME_PERIOD_RANGE_x, i);

		if (str_ptr != NULL) {
			Print (1, "Time Period Range = %s", str_ptr);

			if (!group->Time_Periods (str_ptr)) {
				Error ("Time Period Range %s is Illogical", str_ptr);
			}
		}

		//---- get the time control point ----

		str_ptr = Get_Control_String (TIME_CONTROL_POINT_x, i);

		if (str_ptr != NULL) {
			for (j=0; time_control [j] != NULL; j++) {
				if (str_cmp (str_ptr, time_control [j]) == 0) break;
			}
			if (time_control [j] == NULL) {
				Error ("Time Control Point %s was Unrecognized", str_ptr);
			}
			group->Method (j);
		} else {
			group->Method (0);
		}
		Print (1, "Time Control Point = %s", time_control [group->Method ()]);

		//---- get the origin weight ----

		str_ptr = Get_Control_String (ORIGIN_WEIGHT_FIELD_x, i);

		if (str_ptr != NULL) {
			group->Org_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr));

			if (group->Org_Wt () == 0) {
				Error ("Origin Weight Field %s was Not Found in the Activity Location File", str_ptr);
			}
			Print (1, "Origin Weight Field Name = %s, Number = %d", str_ptr, group->Org_Wt ());
		} else {
			group->Org_Wt (0);
			Print (1, "No Origin Weight Field --> Equal Weights");
		}

		//---- get the destination weight ----

		str_ptr = Get_Control_String (DESTINATION_WEIGHT_FIELD_x, i);

		if (str_ptr != NULL) {
			group->Des_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr));

			if (group->Des_Wt () == 0) {
				Error ("Destination Weight Field %s was Not Found in the Activity Location File", str_ptr);
			}
			Print (1, "Destination Weight Field Name = %s, Number = %d", str_ptr, group->Des_Wt ());
		} else {
			group->Des_Wt (0);
			Print (1, "No Destination Weight Field --> Equal Weights");
		}

		//---- get the distance weight ----

		str_ptr = Get_Control_String (DISTANCE_WEIGHT_FLAG_x, i);

		if (str_ptr != NULL) {
			group->Dist_Wt (Get_Control_Flag (DISTANCE_WEIGHT_FLAG_x, i));

			Print (1, "Distance Weight Flag = %s", str_ptr);
		} else {
			group->Dist_Wt (true);
		}

		//---- get the stop weight ----

		str_ptr = Get_Control_String (STOP_WEIGHT_FIELD_x, i);

		if (str_ptr != NULL) {
			group->Stop_Wt (Network_Db_Base (ACTIVITY_LOCATION)->Field_Number (str_ptr));

			if (group->Stop_Wt () == 0) {
				Error ("Stop Weight Field %s was Not Found in the Activity Location File", str_ptr);
			}
			Print (1, "Stop Weight Field Name = %s, Number = %d", str_ptr, group->Stop_Wt ());
		} else {
			group->Stop_Wt (0);
			Print (1, "No Stop Weight Field --> Equal Weights");
		}

		//---- get the trip purpose ----

		str_ptr = Get_Control_String (TRIP_PURPOSE_CODE_x, i);

		if (str_ptr != NULL) {
			Get_Integer (str_ptr, &lvalue);
			
			if (lvalue < 0 || lvalue > 100) {
				Error ("Trip Purpose %d is Out of Range (0..100)", lvalue);
			}
			group->Purpose (lvalue);
		} else {
			group->Purpose (1);
		}
		Print (1, "Trip Purpose Code = %d", group->Purpose ());

		//---- get the travel mode ----

		str_ptr = Get_Control_String (TRAVEL_MODE_CODE_x, i);

		if (str_ptr != NULL) {
			Get_Integer (str_ptr, &lvalue);

			if (lvalue < 0 || lvalue >= MAX_MODE) {
				Error ("Travel Mode %d is Out of Range (0..%d)", lvalue, MAX_MODE);
			}
			group->Mode (lvalue);
		} else {
			group->Mode (DRIVE_ALONE);
		}
		Print (1, "Travel Mode Code = %d", group->Mode ());

		//---- stop duration ----

		str_ptr = Get_Control_String (TRIP_STOP_DURATION_x, i);

		if (str_ptr != NULL) {
			Get_Integer (str_ptr, &lvalue);

			if (lvalue < 1 || lvalue > 4 * 60) {
				Error ("Trip Stop Duration %d is Out of Range (1..240)", lvalue);
			}
		} else {
			lvalue = 5;
		}
		group->Duration (lvalue * 60);

		//---- average speed ----

		str_ptr = Get_Control_String (AVERAGE_TRAVEL_SPEED_x, i);

		if (str_ptr != NULL) {
			Get_Double (str_ptr, &dvalue);

			if (dvalue < 1.0 || dvalue > 50.0) {
				Error ("Average Travel Speed %.1lf is Out of Range (1..50)", dvalue);
			}
		} else {
			dvalue = 10.0;
		}
		group->Speed (Round (dvalue));

		Print (1, "Average Travel Speed = %.1lf (meters/second)", UnRound (group->Speed ()));

		//---- get the vehicle type ----

		str_ptr = Get_Control_String (VEHICLE_TYPE_x, i);

		if (str_ptr != NULL) {
			Get_Integer (str_ptr, &lvalue);

			if (lvalue < 1 || lvalue > 20) {
				Error ("Vehicle Type %d is Out of Range (1..20)", lvalue);
			}
			group->Type (lvalue);
		} else {
			group->Type (1);
		}

		//---- get the vehicle subtype ----

		str_ptr = Get_Control_String (VEHICLE_SUBTYPE_x, i);

		if (str_ptr != NULL) {
			Get_Integer (str_ptr, &lvalue);

			if (lvalue < 0 || lvalue > 20) {
				Error ("Vehicle Subtype %d is Out of Range (0..20)", lvalue);
			}
			group->SubType (lvalue);
		} else {
			group->SubType (0);
		}
		Print (1, "Vehicle Type = %d, Subtype = %d", group->Type (), group->SubType ());

		//---- get the trip scaling factor ----

		str_ptr = Get_Control_String (TRIP_SCALING_FACTOR_x, i);

		if (str_ptr != NULL) {
			Get_Double (str_ptr, &dvalue);
			
			if (dvalue < 0.001 || dvalue > 100.0) {
				Error ("Trip Scaling Factor %.2lf is Out of Range (0.001..100.0)", dvalue);
			}
			group->Scaling_Factor (dvalue);
			Print (1, "Trip Scaling Factor = %.3lf", dvalue);
		} else {
			group->Scaling_Factor (1.0);
		}

		//---- get the trip adjustment factors ----

		str_ptr = Get_Control_String (TRIP_ADJUSTMENT_FACTORS_x, i);

		if (str_ptr != NULL) {
			group->Trip_Factor (new Factor_File ());

			str_fmt (buffer, sizeof (buffer), "Trip Adjustment Factors #%d", i);

			group->Trip_Factor ()->File_Type (buffer);

			format_ptr = Get_Control_String (TRIP_ADJUSTMENT_FORMAT_x, i);

			if (format_ptr != NULL) {
				group->Trip_Factor ()->Dbase_Format (format_ptr);
			}
			if (!group->Trip_Factor ()->Open (Project_Filename (str_ptr))) {
				Error ("Opening Trip Adjustment Factors #%d", i);
			}
			factor_flag = true;
		}

		//---- time period equivalence ----

		//if (factor_flag || group->Trip_File ()->Period_Flag ()) {

		//	str_ptr = Get_Control_String (TIME_PERIOD_EQUIVALENCE_x, i);

		//	if (str_ptr != NULL) {
		//		if (!group->Time_Equiv_File (Project_Filename (str_ptr))) {
		//			Error ("Opening Time Period Equivalence #%d", i);
		//		}
		//	} else if (group->Trip_File ()->Period_Flag ()) {
		//		Warning ("Trip Table Time Periods will be Ignored");
		//	}
		//}

		//---- set the field map ----

		if (group->Org_Wt () != 0) {
			j = field_map.Get_Index (group->Org_Wt ());

			if (j == 0) {
				field_map.Add (group->Org_Wt ());

				group->Org_Wt (field_map.Record_Index ());
			} else {
				group->Org_Wt (j);
			}
		}
		if (group->Des_Wt () != 0) {
			j = field_map.Get_Index (group->Des_Wt ());

			if (j == 0) {
				field_map.Add (group->Des_Wt ());

				group->Des_Wt (field_map.Record_Index ());
			} else {
				group->Des_Wt (j);
			}
		}

		//---- add the group record to the list ----

		file_group.Add ();
	}
	Write (2, "Highest Trip Group Number = %d", num_file);
	Write (1, "Number of Trip Table Groups = %d", file_group.Num_Records ());

	if (field_map.Num_Records () > 0) {
		Print (2, "Number of Unique Activity Location Weight Fields = %d", field_map.Num_Records ());

		Convert_Location *loc_ptr = (Convert_Location *) location_data.New_Record ();

		loc_ptr->Num_Weight (field_map.Num_Records ());
	}
	Show_Message (1);

	//---- read the zone equiv ----

	if (factor_flag) {
		if (equiv_flag) {
			zone_equiv.Read (Report_Flag (ZONE_EQUIV));
		} else {
			Write (2, "Trip Adjustment Factors are Zone-Based");
		}
	}

	//---- read the zone location map ----

	if (zone_loc_flag) {
		zone_loc_map.Read (false);
	}
	return;

	//---- error message ----

control_error:
	Error ("Missing Control Key = %s", Current_Key ());
}
Exemplo n.º 22
0
void RiderSum::Line_Rider_Report (void)
{
	int riders, board, alight, run, runs, num, length, tot_len, period, num_periods;
	int max_riders, max_board, max_alight, max_runs, total, capacity, max_cap;
	double factor, max_fac, sum_time, tot_time, time, capfac, max_capfac;
	double vmt, vht, pmt, pht;
	Dtime low, high;

	Int_Map_Itr map_itr;
	Line_Data *line_ptr;
	Stop_Data *stop_ptr;
	Line_Stop_Itr stop_itr, next_itr;
	Line_Run_Itr run_itr;
	Veh_Type_Data *veh_type_ptr, *run_type_ptr;

	Show_Message ("Line Rider Profile -- Record");
	Set_Progress ();

	//---- print the report ----

	Header_Number (LINE_RIDERS);

	num_periods = sum_periods.Num_Periods ();
	if (num_periods == 0) num_periods = 1;

	num = (int) (line_map.size () * stop_map.size ());

	if (!Break_Check (num + 5)) {
		Print (1);
		Line_Rider_Header ();
	}

	//---- process each route ----

	for (map_itr = line_map.begin (); map_itr != line_map.end (); map_itr++) {
		Show_Progress ();

		if (select_routes && !route_range.In_Range (map_itr->first)) continue;

		line_ptr = &line_array [map_itr->second];

		if (select_modes && !select_mode [line_ptr->Mode ()]) continue;

		//---- check the link criteria ----

		if (!Link_Selection (line_ptr)) continue;

		//---- set the run flags ----

		if (!Run_Selection (line_ptr)) continue;

		//---- save the route ridership data ----
		
		veh_type_ptr = &veh_type_array [line_ptr->Type ()];

		for (period = 0; period < num_periods; period++) {
			if (period_flag [period] == 0) continue;

			if (!Break_Check ((int) line_ptr->size () + 15)) {
				Print (1);
				Line_Rider_Header ();
			}
			veh_type_ptr = &veh_type_array [line_ptr->Type ()];

			Print (1, "   Route    Mode     Type   Time Period  Name");

			Print (2, String ("%8d  %10.10s %4d  %12.12s") % line_ptr->Route () %
				Transit_Code ((Transit_Type) line_ptr->Mode ()) % veh_type_ptr->Type () % 
				sum_periods.Range_Format (period));

			if (!line_ptr->Name ().empty ()) {
				Print (0, String ("  %s") % line_ptr->Name ());
			}
			if (Notes_Name_Flag ()) {
				if (!line_ptr->Notes ().empty ()) {
					Print (0, String (" -- %s") % line_ptr->Notes ());
				}
			}
			Print (2, "    Stop  Length   TTime   Alight    Board   Riders  Runs  LoadFac Capacity CapFac");
			Print (1);

			time = tot_time = 0.0;
			max_alight = max_board = max_riders = max_runs = total = length = tot_len = max_cap = 0;
			max_fac = vmt = vht = pmt = pht = max_capfac = 0.0;

			sum_periods.Period_Range (period, low, high);

			for (stop_itr = line_ptr->begin (); stop_itr != line_ptr->end (); stop_itr++) {
				riders = board = alight = runs = capacity = 0;

				stop_ptr = &stop_array [stop_itr->Stop ()];

				next_itr = stop_itr + 1;

				if (next_itr != line_ptr->end ()) {
					length = next_itr->Length () - stop_itr->Length ();
				} else {
					length = 0;
				}
				sum_time = 0.0;
				num = 0;

				for (run=0, run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++, run++) {
					if (run_flag [run] == 0) continue;
					if (run_period [run] != period) continue;

					board += run_itr->Board ();
					alight += run_itr->Alight ();
					riders += run_itr->Load ();
					runs++;

					if (line_ptr->run_types.size () > 0) {
						run_type_ptr = &veh_type_array [line_ptr->Run_Type (run)];
						capacity += run_type_ptr->Capacity ();
					} else {
						capacity += veh_type_ptr->Capacity ();
					}
					if (next_itr != line_ptr->end ()) {
						time = next_itr->at (run).Schedule ().Seconds () - run_itr->Schedule ().Seconds ();

						vmt += length;
						vht += time;
						pmt += length * run_itr->Load ();
						pht += time * run_itr->Load ();

						sum_time += time;
						num++;
					}
				}
				if (runs == 0) continue;
				if (capacity == 0) capacity = runs;

				factor = (double) riders / runs;
				capfac = DTOI (riders * 10.0 / capacity) / 10.0;

				if (next_itr == line_ptr->end ()) runs = 0;

				if (num > 0) {
					time = sum_time / num;
				} else {
					time = 0;
				}
				Print (1, String ("%8d %7.0lf %7.0lf %8d %8d %8d %5d %8.1lf %6d %8.1lf") % stop_ptr->Stop () % 
					UnRound (length) % time % alight % board % riders % runs % factor % capacity % capfac);

				if (Notes_Name_Flag ()) {
					if (!stop_ptr->Name ().empty ()) {
						Print (0, String ("  %s") % stop_ptr->Name ());
					}
					if (!stop_ptr->Notes ().empty ()) {
						Print (0, " -- ") << stop_ptr->Notes ();
					}
				}
				if (alight > max_alight) max_alight = alight;
				if (board > max_board) max_board = board;
				if (riders > max_riders) max_riders = riders;
				if (runs > max_runs) max_runs = runs;
				if (factor > max_fac) max_fac = factor;
				if (capacity > max_cap) max_cap = capacity;
				if (capfac > max_capfac) max_capfac = capfac;

				tot_len += length;
				tot_time += time;
				total += board;
			}
			if (max_runs == 0) continue;

			Print (2, String (" Maximum                 %8ld %8ld %8ld %5ld %8.1lf %6lf %8.1lf") %
				max_alight % max_board % max_riders % max_runs % max_fac % max_cap % max_capfac);

			Print (2, "Total Boardings = ") << total;

			if (total == 0 || tot_time == 0) continue;

			factor = UnRound (tot_len);
			vmt = UnRound (vmt) / 5280.0;
			vht = vht / 3600.0;
			pmt = UnRound (pmt) / 5280.0;
			pht = pht / 3600.0;


			Print (1, String ("Route Length = %.1lf miles, %.1lf minutes  Average Speed = %.1lf mph") %
				External_Units (factor, MILES) % (tot_time / 60.0) % External_Units ((factor / tot_time), MPH));
			Print (1, String ("Vehicle Miles = %.1lf  Vehicle Hours = %.1lf") % vmt % vht);
			Print (1, String ("Passenger Miles = %.1lf  Passenger Hours = %.1lf") %	pmt % pht);
			Print (1, String ("Passengers per Vehicle Mile = %.1lf  Passengers per Vehicle Hour = %.1lf") %	
				(pmt / vht) % (pht / vht));

			vmt = pmt / total;
			vht = pht * 60.0 / total;

			Print (1, String ("Average Trip Length = %.1lf miles, %.1lf minutes") % vmt % vht);
		}
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 23
0
void SubareaNet::Execute (void)
{

	//---- read the network ----

	Network_Service::Execute ();

	//---- save the node file ----

	Write_Node ();

	//---- save the shape file ----

	if (Network_File_Flag (NEW_SHAPE)) {
		Write_Shape ();
	}

	//---- save the timing plan file ----

	if (Network_File_Flag (NEW_TIMING_PLAN)) {
		Write_Timing ();
	}

	//---- save the signal coordinator file ----

	if (Network_File_Flag (NEW_SIGNAL_COORDINATOR)) {
		Write_Coordinator ();
	}

	//---- write the boundary records ----

	Write_Boundary ();

	//---- save the transit files ----

	if (transit_flag) {
		Write_Route ();
	}

	//---- summary statistics ----

	Break_Check (8);
	Print (1);
	Write (1, "Number of Subarea Node Records = %d", nnode);
	Write (1, "Number of Subarea Link Records = %d", nlink);
	Write (1, "Number of Subarea Pocket Lane Records = %d", npocket);
	Write (1, "Number of Subarea Lane Connectivity Records = %d", nconnect);
	Write (1, "Number of Subarea Activity Locations = %d", nlocation);
	Write (1, "Number of Subarea Parking Lots = %d", nparking);
	Write (1, "Number of Subarea Process Links = %d", naccess);

	Break_Check (11);
	if (Network_File_Flag (NEW_ZONE)) {
		Write (1, "Number of Subarea Zone Records = %d", nzone);
	}
	if (Network_File_Flag (NEW_SHAPE)) {
		Write (1, "Number of Subarea Shape Records = %d", nshape);
	}
	if (Network_File_Flag (NEW_LANE_USE)) {
		Write (1, "Number of Subarea Lane Use Records = %d", nlane_use);
	}
	if (Network_File_Flag (NEW_TURN_PROHIBITION)) {
		Write (1, "Number of Subarea Turn Prohibition Records = %d", nturn);
	}
	if (Network_File_Flag (NEW_TOLL)) {
		Write (1, "Number of Subarea Toll Records = %d", ntoll);
	}
	if (Network_File_Flag (NEW_UNSIGNALIZED_NODE)) {
		Write (1, "Number of Subarea Unsignalized Node Records = %d", nsign);
	}
	if (Network_File_Flag (NEW_SIGNALIZED_NODE)) {
		Write (1, "Number of Subarea Signalized Node Records = %d", nsignal);
	}
	if (Network_File_Flag (NEW_TIMING_PLAN)) {
		Write (1, "Number of Subarea Timing Plan Records = %d", ntiming);
	}
	if (Network_File_Flag (NEW_PHASING_PLAN)) {
		Write (1, "Number of Subarea Phasing Plan Records = %d", nphasing);
	}
	if (Network_File_Flag (NEW_DETECTOR)) {
		Write (1, "Number of Subarea Detector Records = %d", ndetector);
	}
	if (Network_File_Flag (NEW_SIGNAL_COORDINATOR)) {
		Write (1, "Number of Subarea Signal Coordinator Records = %d", ncoord);
	}
	if (transit_flag) {
		Write (1, "Number of Subarea Transit Stop Records = %d", nstop);
		Write (1, "Number of Subarea Transit Route Records = %d", nroute);
		Write (1, "Number of Subarea Transit Schedule Records = %d", nschedule);
		Write (1, "Number of Subarea Transit Driver Records = %d", ndriver);
	}

	Break_Check (7);
	Write (2, "Number of Boundary Links = %d", nboundary);
	Write (1, "Number of Short Links Skipped = %d", nshort);
	Write (1, "Number of New Activity Locations = %d", new_location);
	Write (1, "Number of New Parking Lots = %d", new_parking);
	Write (1, "Number of New Process Links = %d", new_access);
	if (transit_flag) {
		Write (1, "Number of New Transit Stops = %d", new_stop);
		Write (1, "Number of New Transit Routes = %d", new_route);
	}
	Show_Message (1);

	Exit_Stat (DONE);
}
Exemplo n.º 24
0
void RiderSum::Group_Rider_Report (void)
{
	int n, run, runs, num, length, tot_len, period, num_periods, routes, index, stop, to, link;
	int max_riders, max_board, max_alight, max_runs, total;
	double factor, max_fac, sum_time, tot_time, time;
	double vmt, vht, pmt, pht;
	Dtime low, high;
	String label;
	bool flag;

	Int_Set *group;
	Int_Set_Itr itr;
	Int_Map_Itr map_itr, to_itr;
	Line_Data *line_ptr;
	Stop_Data *stop_ptr;
	Line_Stop_Itr stop_itr, next_itr;
	Line_Run_Itr run_itr;
	Int_Map stop_index;
	Int2_Map link_index;
	Int2_Map_Itr map2_itr;
	Int2_Key int2_key;
	Int2_Map_Stat map2_stat;
	Int_Map_Stat map_stat;
	Stop_Group_Data data, *data_ptr, *link_ptr;
	Stop_Group_Itr data_itr;

	Show_Message ("Line Group Profile -- Record");
	Set_Progress ();

	//---- print the report ----

	Header_Number (GROUP_RIDERS);

	num_periods = sum_periods.Num_Periods ();
	if (num_periods == 0) num_periods = 1;

	num = (int) (line_map.size () * stop_map.size ());

	if (!Break_Check (num + 5)) {
		Print (1);
		Group_Rider_Header ();
	}

	routes = 0;
	memset (&data, '\0', sizeof (data));
	
	for (n = line_equiv.First_Group (); n > 0; n = line_equiv.Next_Group ()) {

		group = line_equiv.Group_List (n);
		if (group == 0) continue;

		label = line_equiv.Group_Label (n);

		//---- process each time period ----

		for (period = 0; period < num_periods; period++) {

			//---- initialize stop data ----

			stop_index.clear ();
			link_index.clear ();
			stop_group_array.clear ();
			routes = 0;
			vmt = vht = pmt = pht = 0.0;

			//---- process each line in the line group ----

			for (itr = group->begin (); itr != group->end (); itr++) {

				map_itr = line_map.find (*itr);
				if (map_itr == line_map.end ()) continue;

				Show_Progress ();

				line_ptr = &line_array [map_itr->second];

				//---- set the run flags ----

				if (!Run_Selection (line_ptr)) continue;

				if (period_flag [period] == 0) continue;

				time = 0.0;
				total = length = 0;
				flag = false;

				sum_periods.Period_Range (period, low, high);

				for (stop_itr = line_ptr->begin (); stop_itr != line_ptr->end (); stop_itr++) {

					stop_ptr = &stop_array [stop_itr->Stop ()];
					stop = stop_ptr->Stop ();

					map_itr = stop_index.find (stop);

					next_itr = stop_itr + 1;

					if (next_itr != line_ptr->end ()) {
						stop_ptr = &stop_array [next_itr->Stop ()];

						to = stop_ptr->Stop ();
					} else {
						to = 0;
					}

					//---- create the link ----

					int2_key = Int2_Key (stop, to);

					map2_itr = link_index.find (int2_key);

					if (map2_itr == link_index.end ()) {
						if (to == 0 && map_itr != stop_index.end ()) {
							link = map_itr->second;
						} else {
							link = (int) stop_group_array.size ();

							link_index.insert (Int2_Map_Data (int2_key, link));

							data.stop = stop;
							data.to = to;
							stop_group_array.push_back (data);

							//---- check for a merge ----

							if (to != 0) {
								to_itr = stop_index.find (to);

								if (to_itr != stop_index.end ()) {
									index = (int) stop_group_array.size ();

									int2_key = Int2_Key (to, 0);

									map2_stat = link_index.insert (Int2_Map_Data (int2_key, index));

									if (map2_stat.second) {
										data.stop = to;
										data.to = 0;
										stop_group_array.push_back (data);
									}
								}
							}
						}
					} else {
						link = map2_itr->second;
					}
					link_ptr = &stop_group_array [link];

					//---- crete the stop index ----

					if (map_itr == stop_index.end ()) {
						map_stat = stop_index.insert (Int_Map_Data (stop, link));
						index = link;
					} else {
						index = map_itr->second;
					}
					data_ptr = &stop_group_array [index];

					if (next_itr != line_ptr->end ()) {
						length = next_itr->Length () - stop_itr->Length ();
					} else {
						length = 0;
					}
					sum_time = 0.0;
					num = runs = 0;

					for (run=0, run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++, run++) {
						if (run_flag [run] == 0) continue;
						if (run_period [run] != period) continue;

						data_ptr->board += run_itr->Board ();
						data_ptr->alight += run_itr->Alight ();
						link_ptr->riders += run_itr->Load ();
						runs++;
						flag = true;

						if (next_itr != line_ptr->end ()) {
							link_ptr->runs++;
							time = next_itr->at (run).Schedule ().Seconds () - run_itr->Schedule ().Seconds ();
							sum_time += time;
							num++;

							vmt += length;
							vht += time;
							pmt += length * run_itr->Load ();
							pht += time * run_itr->Load ();
						}
					}
					if (runs == 0) continue;

					if (link_ptr->length == 0.0) {
						link_ptr->length = length;
					}
					if (num > 0) {
						time = sum_time / num;
					} else {
						time = 0;
					}
					if (link_ptr->time > 0) {
						link_ptr->time = (link_ptr->time + time) / 2.0;
					} else {
						link_ptr->time = time;
					}
				}
				if (flag) routes++;
			}

			//---- print the report ----

			if (!Break_Check ((int) stop_index.size () + 15)) {
				Print (1);
				Group_Rider_Header ();
			}
			Print (1, "Group   Time Period  Routes  Description");

			Print (2, String ("%5d  %12.12s  %6d  %s") % n %	sum_periods.Range_Format (period) %
				routes % label);

			Print (2, "    Stop  Length   TTime   Alight    Board   Riders  Runs  LoadFac");
			Print (1);

			tot_time = 0.0;
			max_alight = max_board = max_riders = max_runs = total = tot_len = 0;
			max_fac = 0.0;

			for (data_itr = stop_group_array.begin (); data_itr != stop_group_array.end (); data_itr++) {

				map_itr = stop_map.find (data_itr->stop);
					
				stop_ptr = &stop_array [map_itr->second];
				
				if (data_itr->runs > 0) {
					factor = DTOI (data_itr->riders * 10.0 / data_itr->runs) / 10.0;
				} else {
					factor = 0.0;
				}
				Print (1, String ("%8d %7.0lf %7.0lf %8d %8d %8d %5d %8.1lf") % data_itr->stop  % 
					UnRound (data_itr->length) % data_itr->time % data_itr->alight % data_itr->board % 
					data_itr->riders % data_itr->runs % factor);

				if (Notes_Name_Flag ()) {
					if (!stop_ptr->Name ().empty ()) {
						Print (0, String ("  %s") % stop_ptr->Name ());
					}
					if (!stop_ptr->Notes ().empty ()) {
						Print (0, " -- ") << stop_ptr->Notes ();
					}
				}
				if (data_itr->alight > max_alight) max_alight = data_itr->alight;
				if (data_itr->board > max_board) max_board = data_itr->board;
				if (data_itr->riders > max_riders) max_riders = data_itr->riders;
				if (data_itr->runs > max_runs) max_runs = data_itr->runs;
				if (factor > max_fac) max_fac = factor;

				tot_len += data_itr->length;
				tot_time += data_itr->time;
				total += data_itr->board;
			}
			if (max_runs == 0) continue;

			Print (2, String (" Maximum                 %8ld %8ld %8ld %5ld %8.1lf") %
				max_alight % max_board % max_riders % max_runs % max_fac);

			Print (2, "Total Boardings = ") << total;

			if (total == 0 || tot_time == 0) continue;

			factor = UnRound (tot_len);
			vmt = UnRound (vmt) / 5280.0;
			vht = vht / 3600.0;
			pmt = UnRound (pmt) / 5280.0;
			pht = pht / 3600.0;


			Print (1, String ("Route Length = %.1lf miles, %.1lf minutes  Average Speed = %.1lf mph") %
				External_Units (factor, MILES) % (tot_time / 60.0) % External_Units ((factor / tot_time), MPH));
			Print (1, String ("Vehicle Miles = %.1lf  Vehicle Hours = %.1lf") % vmt % vht);
			Print (1, String ("Passenger Miles = %.1lf  Passenger Hours = %.1lf") %	pmt % pht);
			Print (1, String ("Passengers per Vehicle Mile = %.1lf  Passengers per Vehicle Hour = %.1lf") %	
				(pmt / vht) % (pht / vht));

			vmt = pmt / total;
			vht = pht * 60.0 / total;

			Print (1, String ("Average Trip Length = %.1lf miles, %.1lf minutes") % vmt % vht);
		}
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 25
0
void Validate::Facility_Stats (void)
{
	int i, n;
	String label;

	Group_Data *data;
	Group_Map_Itr map_itr;
	Statistics stats;
	Link_Itr link_itr;
	Str_Map_Itr str_itr;

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		if (link_itr->AB_Dir () >= 0) {
			Sum_Group (link_itr->Type (), &(*link_itr), link_itr->AB_Dir ());
		}
		if (link_itr->BA_Dir () >= 0) {
			Sum_Group (link_itr->Type (), &(*link_itr), link_itr->BA_Dir ());
		}
	}

	//---- print the page header ----

	Header_Number (FACILITY_TYPE);

	if (!Break_Check ((int) group_data.size () + 9)) {
		Print (1);
		Facility_Header ();
	}

	//---- print each functional class ----

	for (map_itr = group_data.begin (); map_itr != group_data.end (); map_itr++) {
		data = &map_itr->second;
		n = data->number;
		if (n == 0) continue;
	
		Calc_Stats (data, stats);
		
		i = data->index;

		str_itr = facility_type.find (i);
		if (str_itr == facility_type.end ()) {
			label = Facility_Code ((Facility_Type) i);
		} else {
			label = str_itr->second;
		}
		Page_Check (1);

		Print (0, String (stats_format) % label % n % data->volume % data->count % 
			(data->volume - data->count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % data->max_vc);
	}
		
	//---- calculate the total statistics ----
	
	n = total.number;
	if (n > 0) {
		Calc_Stats (&total, stats);
		
		Page_Check (3);
		Print (0, "\n");
		Print (0, String (stats_format) % "TOTAL" % n % total.volume % total.count % 
			(total.volume - total.count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % total.max_vc);
		Print (0, "\n");
	}
	Header_Number (0);
}
Exemplo n.º 26
0
void PlanSum::Link_Group (double min_vc)
{
	int i, num, dir, link, cap, tod_cap, tod_cap2, lns, lanes, period, periods, index, flow_index;
	Dtime low, high;
	double flow, vc;
    string label;
	bool flag;

	Flow_Time_Period_Itr array_itr;
	Dir_Data *dir_ptr;
	Link_Data *link_ptr;
	Lane_Use_Period *period_ptr;
	Int_Set *list;
	Int_Set_Itr list_itr;
	Int_Map_Itr int_itr;

	Group_Array group_array;
	Group_Data zero, *data_ptr;

	memset (&zero, '\0', sizeof (zero));
	periods = sum_periods.Num_Periods ();

	Show_Message ("Writing the Link Group Report -- Record");
	Set_Progress ();

	minimum_vc = min_vc;

	//---- find V/C ratios for each link group ----

	num = link_equiv.Num_Groups ();

	Header_Number (LINK_GROUP);

	if (!Break_Check (num + 7)) {
		Print (1);
		Link_Group_Header ();
	}
	num = link_equiv.Max_Group ();

	for (i=1; i <= num; i++) {

		list = link_equiv.Group_List (i);
		if (list == 0) continue;

		label = link_equiv.Group_Label (i);

		flag = false;
		group_array.assign (periods, zero);

		//---- process each link in the link group ----

		for (list_itr = list->begin (); list_itr != list->end (); list_itr++) {

			link = abs (*list_itr);
			
			int_itr = link_map.find (link);
			if (int_itr == link_map.end ()) continue;

			link_ptr = &link_array [int_itr->second];

			if (*list_itr < 0) {
				dir = link_ptr->BA_Dir ();
			} else {
				dir = link_ptr->AB_Dir ();
			}
			if (dir < 0) continue;
			
			//---- get the directional data ----

			dir_ptr = &dir_array [dir];

			cap = (int) (dir_ptr->Capacity () * cap_factor + 0.5);
			if (cap <= 0) continue;

			lanes = dir_ptr->Lanes ();
			if (lanes < 1) lanes = 1;

			flow_index = dir_ptr->Flow_Index ();

			//---- process each time period ----

			for (period=0, array_itr = link_delay_array.begin (); array_itr != link_delay_array.end (); array_itr++, period++) {
				flow = array_itr->Flow (dir);

				//---- time-of-day capacity ----

				tod_cap = tod_cap2 = cap;
				index = dir_ptr->First_Lane_Use ();

				if (index >= 0) {
					sum_periods.Period_Range (period, low, high);
					low = (low + high) / 2;

					for (period_ptr = &use_period_array [index]; ; period_ptr = &use_period_array [++index]) {
						if (period_ptr->Start () <= low && low < period_ptr->End ()) {
							lns = period_ptr->Lanes (0);
							tod_cap = (tod_cap * lns + lanes / 2) / lanes;
							if (tod_cap == 0) tod_cap = cap / 2;

							lns = period_ptr->Lanes (1);
							tod_cap2 = (tod_cap2 * lns + lanes / 2) / lanes;
							if (tod_cap2 == 0) tod_cap2 = cap / 2;
							break;
						}
						if (period_ptr->Periods () == 0) break;
					}
				}
				if (tod_cap > 0) {
					data_ptr = &group_array [period];

					flag = true;
					data_ptr->links++;
					data_ptr->volume += DTOI (flow);
					data_ptr->capacity += tod_cap;

					if (flow_index >= 0 && tod_cap2 > 0) {
						flow = array_itr->Flow (flow_index);

						data_ptr->volume += DTOI (flow);
						data_ptr->capacity += tod_cap2;
					}
				}
			}
		}
		if (!flag) continue;

		//---- print the link group data ----

		flag = true;

		for (period=0; period < periods; period++) {
			data_ptr = &group_array [period];

			if (data_ptr->capacity <= 0) continue;

			vc = (double) data_ptr->volume / data_ptr->capacity;

			if (vc > min_vc) {
				Show_Progress ();

				//---- print the data record ----

				if (flag) {
					flag = false;
					Print (1, label);
				}
				Print (1, String ("%20c%5d   %7d  %12.12s  %7d   %6.2lf") %
					BLANK % data_ptr->links % data_ptr->capacity % 
					sum_periods.Range_Format (period) % data_ptr->volume % vc);
			}
		}
	}
	End_Progress ();

	if (Progress_Count () > 0) {
		Print (2, "Number of Records in the Report = ") << Progress_Count ();
	}
	Header_Number (0);
}
Exemplo n.º 27
0
void PlanSum::Rider_Group (void)
{
	int i, j, num, dir, length, link, previous_period, period, dir_index, periods;
	String label;
	bool flag;

	Int_Set *group;
	Int_Set_Itr link_itr;
	Line_Itr line_itr;
	Line_Stop_Itr stop_itr;
	Line_Run_Itr run_itr;
	Driver_Array *driver_ptr;
	Driver_Itr driver_itr;
	Link_Data *link_ptr;
	Dir_Data *dir_ptr;

	Group_Data group_data, *group_ptr;
	Group_Array group_array;
	Group_Itr group_itr;

	memset (&group_data, '\0', sizeof (group_data));

	periods = sum_periods.Num_Periods ();
	if (periods < 1) periods= 1;

	Show_Message ("Writing Transit Link Groups -- Record");
	Set_Progress ();

	//---- find each link group ----

	num = link_equiv.Num_Groups ();

	Header_Number (RIDER_GROUP);

	if (!Break_Check (num + 7)) {
		Print (1);
		Rider_Header ();
	}
	num = link_equiv.Max_Group ();

	for (i=1; i <= num; i++) {

		group = link_equiv.Group_List (i);
		if (group == 0) continue;

		group_array.assign (periods, group_data);

		label = link_equiv.Group_Label (i);

		flag = false;
		memset (&group_data, '\0', sizeof (group_data));

		//---- write data for each line ----

		for (line_itr = line_array.begin (); line_itr != line_array.end (); line_itr++) {
			Show_Progress ();

			driver_ptr = &line_itr->driver_array;

			//---- process each link in the link group ----

			for (link_itr = group->begin (); link_itr != group->end (); link_itr++) {
				link = *link_itr;
				if (link < 0) {
					link = -link;
					dir = 1;
				} else {
					dir = 0;
				}
				link_ptr = &link_array [link];
				dir_index = (dir == 0) ? link_ptr->AB_Dir () : link_ptr->BA_Dir ();

				//---- search for the link on the route ----

				length = 0;

				for (driver_itr = driver_ptr->begin (); driver_itr != driver_ptr->end (); driver_itr++) {
					dir_ptr = &dir_array [*driver_itr];
					link_ptr = &link_array [dir_ptr->Link ()];

					if (*driver_itr == dir_index) {
						length += link_ptr->Length () / 2;
						break;
					}
					length += link_ptr->Length ();
				}

				for (stop_itr = line_itr->begin (); stop_itr != line_itr->end (); stop_itr++) {
					if (stop_itr->Length () > length) {
						if (stop_itr > line_itr->begin ()) {
							stop_itr--;
							previous_period = -1;

							for (run_itr = stop_itr->begin (); run_itr != stop_itr->end (); run_itr++) {
								period = sum_periods.Period (run_itr->Schedule ());
								if (period < 0) continue;

								group_ptr = &group_array [period];

								if (period != previous_period) {
									previous_period = period;
									group_ptr->lines++;
								}
								group_ptr->runs++;
								group_ptr->riders += run_itr->Load ();
							}
						}
						flag = true;
						break;
					}
				}
			}
		}
		if (!flag) continue;

		//---- print the link group data ----

		flag = true;

		for (j=0, group_itr = group_array.begin (); group_itr != group_array.end (); group_itr++, j++) {
			if (group_itr->lines == 0) continue;

			if (flag) {
				Print (1, String ("%3d %-40.40s") % i % label);
				flag = false;
			} else {
				Print (1, String ("%44c") % BLANK);
			}
			Print (0, String ("%5d %6d  %12.12s  %7d") %
				group_itr->lines % group_itr->runs %  
				sum_periods.Range_Format (j) % group_itr->riders);
		}
		if (j > 1) Print (1);
	}
	End_Progress ();

	Header_Number (0);
}
Exemplo n.º 28
0
void PathSkim::Flow_Skims (void)
{
	int mode, period, periods;
	size_t paths;
	Dtime low, high;

	One_To_Many *skim_ptr;
	Many_Data many_data;
	Many_Itr many_itr;

	Location_Itr loc_itr;
	Int_Itr org_itr, des_itr;
	
	Skim_Processor skim_processor;

	periods = route_periods.Num_Periods ();
	paths = org_loc.size () * des_loc.size () * periods;

	Break_Check (4);
	Print (1);
	Write (1, "Number of Selected Origin Locations = ") << org_loc.size ();
	Write (1, "Number of Selected Destinations     = ") << des_loc.size ();
	Write (1, "Number of Specified Time Periods    = ") << periods;
	Write (1, "Number of Potential Path Traces     = ") << paths;

	Show_Message (2, "Tracing Specified Paths -- Record");
	Set_Progress ();

	if (mode_flag) {
		mode = new_mode;
	} else {
		mode = DRIVE_MODE;
	}

	//---- initialize the skim processor ----

	skim_processor.Initialize (this, Num_Threads ());

	skim_processor.Start_Processing ();

	//---- loop through each time increment ----

	for (period = 0; period < periods; period++) {
		if (!route_periods.Period_Range (period, low, high)) continue;

		if (forward_flag) {

			//---- loop through each origin location ----

			for (org_itr = org_loc.begin (); org_itr != org_loc.end (); org_itr++) {
				skim_ptr = new One_To_Many ();

				skim_ptr->Location (*org_itr);
				skim_ptr->Time (low);
				skim_ptr->Mode (mode);
				skim_ptr->Use (use_type);
				skim_ptr->Veh_Type (veh_type);
				skim_ptr->Type (traveler_type);
				skim_ptr->Direction (constraint);

				//---- loop through each destination location ----

				for (des_itr = des_loc.begin (); des_itr != des_loc.end (); des_itr++) {
					if (*org_itr == *des_itr) continue;
					Show_Progress ();

					many_data.Clear ();
					many_data.Location (*des_itr);

					skim_ptr->push_back (many_data);
				}
				if (skim_ptr->size () > 0) {
					skim_processor.Skim_Build (skim_ptr);
				} else {
					delete skim_ptr;
				}
			}

		} else {

			//---- loop through each destination location ----

			for (des_itr = des_loc.begin (); des_itr != des_loc.end (); des_itr++) {
				skim_ptr = new One_To_Many ();

				skim_ptr->Location (*des_itr);
				skim_ptr->Time (high);
				skim_ptr->Mode (mode);
				skim_ptr->Use (use_type);
				skim_ptr->Veh_Type (veh_type);
				skim_ptr->Type (traveler_type);
				skim_ptr->Direction (constraint);

				//---- loop through each origin location ----

				for (org_itr = org_loc.begin (); org_itr != org_loc.end (); org_itr++) {
					if (*org_itr == *des_itr) continue;
					Show_Progress ();

					many_data.Clear ();
					many_data.Location (*org_itr);

					skim_ptr->push_back (many_data);
				}
				if (skim_ptr->size () > 0) {
					skim_processor.Skim_Build (skim_ptr);
				} else {
					delete skim_ptr;
				}
			}
		}
	}
	End_Progress ();
	skim_processor.Stop_Processing ();
}
Exemplo n.º 29
0
void LinkSum::Perf_Detail_Report (void)
{
	int i, j, k, k1, lanes, max_lanes, tod_list, index, flow_index;
	double base_time, loaded_time, length, len, base, diff, value, percent, flow, factor;
	Dtime low, high, tod;
	bool connect_flag;
	String units, vmt, lane_mi;

	Link_Itr link_itr;
	Dir_Data *dir_ptr;
	Link_Perf_Period_Itr period_itr;
	Link_Perf_Array *period_ptr;
	Link_Perf_Data perf_data;
	Flow_Time_Period_Itr turn_itr;
	Flow_Time_Array *compare_ptr;
	Flow_Time_Data *turn_ptr;
	Lane_Use_Period *use_ptr;
	Connect_Data *connect_ptr;
	Doubles_Itr itr;

	Show_Message ("Creating the Network Performance Details Report -- Record");
	Set_Progress ();

	//---- clear the summary bins -----

	for (j=0, itr = sum_bin.begin (); itr != sum_bin.end (); itr++, j++) {
		itr->assign (NUM_SUM_BINS, 0.0);
	}	
	connect_flag = System_Data_Flag (CONNECTION) && (turn_perf_array.size () > 0) && (compare_turn_array.size () > 0);

	//---- process each link ----

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		Show_Progress ();

		if (select_flag && link_itr->Use () == 0) continue;

		length = UnRound (link_itr->Length ());
		len = 0;

		for (i=0; i < 2; i++) {
			if (i) {
				if (link_itr->Use () == -1) continue;
				index = link_itr->BA_Dir ();
			} else {
				if (link_itr->Use () == -2) continue;
				index = link_itr->AB_Dir ();
			}
			if (index < 0) continue;
			dir_ptr = &dir_array [index];
			flow_index = dir_ptr->Flow_Index ();

			base_time = dir_ptr->Time0 ();
			if (base_time <= 0.0) continue;

			tod_list = dir_ptr->First_Lane_Use ();

			max_lanes = dir_ptr->Lanes ();
			if (max_lanes < 1) max_lanes = 1;
			lanes = max_lanes;

			if (len == 0) {
				len = length;
			} else {
				len = 0;
			}

			//---- process each time period ----

			for (j=0, period_itr = link_perf_array.begin (); period_itr != link_perf_array.end (); period_itr++, j++) {
				if (tod_list >= 0) {

					//---- get the time period ----

					sum_periods.Period_Range (j, low, high);
					tod = (low + high + 1) / 2;

					lanes = max_lanes;
					k = tod_list;

					for (use_ptr = &use_period_array [k]; ; use_ptr = &use_period_array [++k]) {
						if (use_ptr->Start () <= tod && tod < use_ptr->End ()) {
							lanes = use_ptr->Lanes0 () + use_ptr->Lanes1 ();
							break;
						}
						if (use_ptr->Periods () == 0) break;
					}
				}
				perf_data = period_itr->Total_Link_Perf (index, flow_index);

				loaded_time = perf_data.Time ();
				flow = perf_data.Flow ();

				sum_bin [j] [LINKS] += 1;
				sum_bin [j] [LENGTH] += len;
				sum_bin [j] [LANES] += lanes * length;
				sum_bin [j] [VMT] += flow * length;
				sum_bin [j] [VHT] += flow * loaded_time;
				sum_bin [j] [VHD] += flow * (loaded_time - base_time);
				sum_bin [j] [TIME_RATIO] += (double) loaded_time / base_time;
				sum_bin [j] [DENSITY] += perf_data.Density ();
				sum_bin [j] [MAX_DEN] = MAX (sum_bin [j] [MAX_DEN], perf_data.Max_Density ());
				sum_bin [j] [QUEUE] += perf_data.Queue ();
				sum_bin [j] [MAX_QUEUE] = MAX (sum_bin [j] [MAX_QUEUE], perf_data.Max_Queue ());
				sum_bin [j] [FAILURE] += perf_data.Failure ();

				if (Ratio_Flag ()) {
					sum_bin [j] [CONG_VMT] += perf_data.Ratio_VMT ();
					sum_bin [j] [CONG_VHT] += perf_data.Ratio_VHT ();
					sum_bin [j] [CONG_TIME] += perf_data.Ratio_Count ();
					sum_bin [j] [COUNT] += perf_data.Occupancy ();
				}

				if (compare_flag) {
					period_ptr = &compare_link_array [j];
					perf_data = period_ptr->Total_Link_Perf (index, flow_index);

					loaded_time = perf_data.Time ();
					flow = perf_data.Flow ();

					sum_bin [j] [VMT+PREV] += flow * length;
					sum_bin [j] [VHT+PREV] += flow * loaded_time;
					sum_bin [j] [VHD+PREV] += flow * (loaded_time - base_time);
					sum_bin [j] [TIME_RATIO+PREV] += (double) loaded_time / base_time;
					sum_bin [j] [DENSITY+PREV] += perf_data.Density ();
					sum_bin [j] [MAX_DEN+PREV] = MAX (sum_bin [j] [MAX_DEN+PREV], perf_data.Max_Density ());
					sum_bin [j] [QUEUE+PREV] += perf_data.Queue ();
					sum_bin [j] [MAX_QUEUE+PREV] = MAX (sum_bin [j] [MAX_QUEUE+PREV], perf_data.Max_Queue ());
					sum_bin [j] [FAILURE+PREV] += perf_data.Failure ();

					if (Ratio_Flag ()) {
						sum_bin [j] [CONG_VMT+PREV] += perf_data.Ratio_VMT ();
						sum_bin [j] [CONG_VHT+PREV] += perf_data.Ratio_VHT ();
						sum_bin [j] [CONG_TIME+PREV] += perf_data.Ratio_Count ();
						sum_bin [j] [COUNT+PREV] += perf_data.Occupancy ();
					}
				}
			}

			//---- get the turning movements ----

			if (connect_flag) {
				for (k=dir_ptr->First_Connect (); k >= 0; k = connect_ptr->Next_Index ()) {
					connect_ptr = &connect_array [k];

					if (connect_ptr->Type () != LEFT && connect_ptr->Type () != RIGHT &&
						connect_ptr->Type () != UTURN) continue;

					for (j=0, turn_itr = turn_perf_array.begin (); turn_itr != turn_perf_array.end (); turn_itr++, j++) {
						turn_ptr = &turn_itr->at (k);

						sum_bin [j] [TURNS] += turn_ptr->Flow ();

						if (compare_flag) {
							compare_ptr = &compare_turn_array [j];
							turn_ptr = &compare_ptr->at (k);

							sum_bin [j] [TURNS+PREV] += turn_ptr->Flow ();
						}
					}
				}
			}
		}
	}
	End_Progress ();

	//---- print the report ----

	Header_Number (PERF_DETAIL);

	if (!Break_Check (num_inc * 16)) {
		Print (1);
		Perf_Detail_Header ();
	}
	if (Metric_Flag ()) {
		factor = 1.0 / 1000.0;
		units = "Kilometers";
		vmt = "VKT";
		lane_mi = "km";
	} else {
		factor = 1.0 / MILETOFEET;
		units = "Miles";
		vmt = "VMT";
		lane_mi = "mi";
	}
	tod.Hours (1);

	for (i=0; i <= num_inc; i++) {
		len = sum_bin [i] [LINKS];
		if (len == 0.0) continue;

		if (i < num_inc) {
			for (k = 0; k <= COUNT; k++) {
				k1 = k + PREV;
				if (k < VMT) {
					sum_bin [num_inc] [k] = MAX (sum_bin [i] [k], sum_bin [num_inc] [k]);

					if (compare_flag) {
						sum_bin [num_inc] [k1] = MAX (sum_bin [i] [k1], sum_bin [num_inc] [k1]);
					}
				} else {
					sum_bin [num_inc] [k] += sum_bin [i] [k];

					if (compare_flag) {
						sum_bin [num_inc] [k1] += sum_bin [i] [k1];
					}
				}
			}
		}
		if (i < num_inc && sum_bin [i] [VHT] == 0.0 && (!compare_flag || sum_bin [i] [VHT+PREV] == 0.0)) continue;
		if (i) {
			if (!Break_Check ((Ratio_Flag () ? 19 : 16))) {
				Print (1);
			}
		}
		Print (1, String ("Time Period%22c") % BLANK);
		if (i == num_inc) {
			Print (0, "       Total");
			len *= num_inc;
		} else {
			Print (0, String ("%12.12s") % sum_periods.Range_Format (i));
		}
		Print (1, String ("Number of Links                 %13.2lf") % sum_bin [i] [LINKS]);
		Print (1, String ("Number of Roadway %-10.10s    %13.2lf") % units % (sum_bin [i] [LENGTH] * factor));
		Print (1, String ("Number of Lane %-10.10s       %13.2lf") % units % (sum_bin [i] [LANES] * factor));
		Print (1, String ("Vehicle %-20.20s    %13.2lf") % (units + " of Travel") % (sum_bin [i] [VMT] * factor));
		if (compare_flag) {
			base = sum_bin [i] [VMT+PREV] * factor;
			diff = sum_bin [i] [VMT] * factor - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Vehicle Hours of Travel         %13.2lf") % (sum_bin [i] [VHT] / tod));
		if (compare_flag) {
			base = sum_bin [i] [VHT+PREV] / tod;
			diff = sum_bin [i] [VHT] / tod - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}	
		Print (1, String ("Vehicle Hours of Delay          %13.2lf") % (sum_bin [i] [VHD] / tod));
		if (compare_flag) {
			base = sum_bin [i] [VHD+PREV] / tod;
			diff = sum_bin [i] [VHD] / tod - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Queued Vehicles       %13.2lf") % UnRound (sum_bin [i] [QUEUE]));
		if (compare_flag) {
			base = sum_bin [i] [QUEUE+PREV];
			diff = sum_bin [i] [QUEUE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Maximum Queued Vehicles         %13.2lf") % sum_bin [i] [MAX_QUEUE]);
		if (compare_flag) {
			base = sum_bin [i] [MAX_QUEUE+PREV];
			diff = sum_bin [i] [MAX_QUEUE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Cycle Failures        %13.2lf") % sum_bin [i] [FAILURE]);
		if (compare_flag) {
			base = sum_bin [i] [FAILURE+PREV];
			diff = sum_bin [i] [FAILURE] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Number of Turning Movements     %13.2lf") % sum_bin [i] [TURNS]);
		if (compare_flag) {
			base = sum_bin [i] [TURNS+PREV];
			diff = sum_bin [i] [TURNS] - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Average Link Time Ratio         %13.2lf") % (sum_bin [i] [TIME_RATIO] / len));
		if (compare_flag) {
			base = sum_bin [i] [TIME_RATIO+PREV] / len;
			diff = sum_bin [i] [TIME_RATIO] / len - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Average Link Density (/ln-%s)   %13.2lf") % lane_mi % UnRound (sum_bin [i] [DENSITY] / len));
		if (compare_flag) {
			base = UnRound (sum_bin [i] [DENSITY+PREV] / len);
			diff = UnRound (sum_bin [i] [DENSITY] / len) - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		Print (1, String ("Maximum Link Density (/ln-%s)   %13.2lf") % lane_mi % UnRound (sum_bin [i] [MAX_DEN]));
		if (compare_flag) {
			base = UnRound (sum_bin [i] [MAX_DEN+PREV]);
			diff = UnRound (sum_bin [i] [MAX_DEN]) - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}
		length = sum_bin [i] [VMT] * factor;
		loaded_time = sum_bin [i] [VHT] / tod;
		if (loaded_time == 0.0) {
			loaded_time = length;
		} else {
			loaded_time = length / loaded_time;
		}
		Print (1, String ("Average %-19.19s     %13.2lf") % (units + " per Hour") % loaded_time);
		if (compare_flag) {
			length = sum_bin [i] [VMT+PREV] * factor;
			base = sum_bin [i] [VHT+PREV] / tod;
			if (base == 0.0) {
				base = length;
			} else {
				base = length / base;
			}
			diff = loaded_time - base;

			Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
		}

		if (Ratio_Flag ()) {
			value = sum_bin [i] [VMT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_VMT] / value;

			Print (1, String ("Percent %s Congested           %13.2lf") % vmt % percent);
			if (compare_flag) {
				value = sum_bin [i] [VMT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_VMT+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
			value = sum_bin [i] [VHT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_VHT] / value;

			Print (1, String ("Percent VHT Congested           %13.2lf") % percent);
			if (compare_flag) {
				value = sum_bin [i] [VHT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_VHT+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
			value = sum_bin [i] [COUNT];
			if (value == 0.0) value = 1.0;
			percent = 100.0 * sum_bin [i] [CONG_TIME] / value;

			Print (1, String ("Percent Time Congested          %13.2lf") % percent);
			if (compare_flag) {
				value = sum_bin [i] [COUNT+PREV];
				if (value == 0.0) value = 1.0;
				base = 100.0 * sum_bin [i] [CONG_TIME+PREV] / value;
				diff = percent - base;

				Print (0, String (" %13.2lf %13.2lf  (%.2lf%%)") % base % diff % ((base > 0.0) ? (100.0 * diff / base) : 0.0) % FINISH);
			}
		}
	}
	Header_Number (0);
}
Exemplo n.º 30
0
void PlanSum::Transfer_Report (int num, int mode)
{
	int i, j, total, num_board, board;
	bool flag;

	Ints_Array *on_ptr;
	Ints_Itr on_itr;
	Int_Itr int_itr;
	Integers bus_total;

	if (num == 0) {
		on_ptr = &total_on_array;
		xfer_label.clear ();
	} else if (mode == 0) {
		on_ptr = &walk_on_array [num - 1];
		xfer_label ("Walk Access %s") % sum_periods.Range_Format (num - 1);
	} else {
		on_ptr = &drive_on_array [num - 1];
		xfer_label ("Drive Access %s") % sum_periods.Range_Format (num - 1);
	}

	//---- get the dimensions ----

	total = max_rail = num_board = 0;

	for (i=0, on_itr = on_ptr->begin (); on_itr != on_ptr->end (); on_itr++, i++) {
		flag = false;

		for (j=0, int_itr = on_itr->begin (); int_itr != on_itr->end (); int_itr++, j++) {
			if (*int_itr > 0) {
				num_board += *int_itr * (i + j);
				if (j > max_rail) max_rail = j;
				flag = true;
			}
		}
		if (flag) total++;
	}
	if (total == 0) return;

	if (num == 0) {
		Header_Number (SUM_TRANSFERS);
	} else {
		Header_Number (XFER_DETAILS);
	}
	if (!Break_Check (total + 10)) {
		Print (1);
		Transfer_Header ();
	}

	//---- print each row ----

	bus_total.assign (10, 0);

	for (i=0, on_itr = on_ptr->begin (); on_itr != on_ptr->end (); on_itr++, i++) {
		for (int_itr = on_itr->begin (); int_itr != on_itr->end (); int_itr++) {
			if (*int_itr > 0) break;
		}
		if (int_itr == on_itr->end ()) continue;
		
		Print (1, String ("%3d      ") % i);

		if (max_rail > 0) {
			total = 0;

			for (j=0; j <= max_rail; j++) {
				board = on_itr->at (j);
				Print (0, String (" %7d") % board);
				total += board;
				bus_total [j] += board;
			}
		} else {
			total = on_itr->at (0);
			bus_total [0] += total;
		}
		Print (0, String (" %7d") % total);
	}
	
	//---- bus totals ----

	Print (2, "Total    ");

	if (max_rail > 0) {
		total = 0;

		for (j=0; j <= max_rail; j++) {
			Print (0, String (" %7d") % bus_total [j]);
			total += bus_total [j];
		}
	} else {
		total = bus_total [0];
	}
	Print (0, String (" %7d") % total);

	Print (2, String ("Total Boardings = %d, Boardings per Trip = %.2lf") % num_board %
		((total > 0) ? (double) num_board / total : 0.0));

	Header_Number (0);
}