示例#1
0
int Router::Walk_to_Vehicle (Vehicle_Data *veh)
{
	int acc, best, imped;
	Trip_End_Data *des_ptr, lot;
	Parking_Data *park_ptr;
	List_Data *acc_ptr;
	Access_Data *access_ptr = 0;

	//---- identify the parking lot ----

	park_ptr = parking_data [veh->Location ()];

	if (park_ptr == NULL) {
		return (Set_Problem (ACCESS_PROBLEM));
	}
	lot.ID (park_ptr->ID ());
	lot.Link (park_ptr->Link ());
	lot.Offset (park_ptr->Offset ());
	lot.Type (PARKING_ID);

	//---- find the access link ----

	for (acc = parking_access [trip_org.Rec ()]->From_List (); acc; acc = acc_ptr->From_List ()) {
		acc_ptr = access_list [acc];
		access_ptr = access_data [acc];

		if (access_ptr->To_ID () == veh->Location ()) break;
	}

	if (acc > 0 || limit_access) {
		if (acc == 0) {
			return (Set_Problem (ACCESS_PROBLEM));
		}

		//---- save the access information ----

		imped = (access_ptr->Time () * value_walk + access_ptr->Cost () * value_cost + value_round) >> value_roll;

		lot.Prev (-acc);
		lot.Cum (trip_org.Cum () + imped);
		lot.TOD (trip_org.TOD () + access_ptr->Time ());
		lot.Time (trip_org.Time () + access_ptr->Time ());
		lot.Cost (trip_org.Cost () + access_ptr->Cost ());

	} else {
示例#2
0
int Router::Kiss_Ride_Return (Vehicle_Data *veh_ptr)
{
	int stat, acc;

	Trip_End_Data des;

	Location_Data *loc_ptr;
	Access_Data *access_ptr;

	des = trip_des;

	//---- transit to the vehicle ----

	if (veh_ptr->Location () == 0) return (Set_Problem (ACCESS_PROBLEM));

	acc = parking_egress [veh_ptr->Location ()]->To_List ();
	
	if (acc == 0) return (Set_Problem (ACCESS_PROBLEM));

	access_ptr = access_data [acc];

	loc_ptr = location_data [access_ptr->From_ID ()];

	trip_des.Cum (MAX_INTEGER);
	trip_des.Rec (access_ptr->From_ID ());
	trip_des.ID (loc_ptr->ID ());
	trip_des.Link (loc_ptr->Link ());
	trip_des.Offset (loc_ptr->Offset ());
	trip_des.Type (LOCATION_ID);

	stat = Transit_Plan ();

	if (stat) return (stat);

	//---- build the drive path ----

	trip_org = trip_des;
	trip_des = des;
	
	return (Drive_Plan ((Use_Type) veh_ptr->Type (), veh_ptr));
}
示例#3
0
void ActivityPattern::Activity_Problem (Problem_Type problem, Activity_Data *act_ptr)
{
	Location_Data *location_ptr;
	Vehicle_Data *vehicle_ptr;
	HHold_Data *household_ptr;

	if (act_ptr->Problem () > 0) return;

	if (problem == LOCATION_PROBLEM) {
		if (act_ptr->Mode () == ALL_WALK) {
			problem = WALK_LOC_PROBLEM;
		} else if (act_ptr->Mode () == BICYCLE) {
			problem = BIKE_LOC_PROBLEM;
		} else if (act_ptr->Mode () == TRANSIT || act_ptr->Mode () == RAIL_TRANSIT ||
			act_ptr->Mode () == PNR_OUT || act_ptr->Mode () == PNR_IN ||
			act_ptr->Mode () == KNR_OUT || act_ptr->Mode () == KNR_IN) {
			problem = TRANSIT_LOC_PROBLEM;
		}
	}
	Set_Problem (problem);
	act_ptr->Problem (problem);
	num_problem++;

	household_ptr = household_data.Get (act_ptr->Household ());

	if (household_ptr != NULL) {
		household_ptr->Problem_Flag (true);
	}
	if (problem_flag) {

		problem_file.Household (act_ptr->Household ());
		problem_file.Person (act_ptr->Person ());

		problem_file.Trip (act_ptr->Activity ());
		problem_file.Mode (act_ptr->Mode ());
		problem_file.Problem (problem);

		problem_file.Start (activity_time.Format_Step (act_ptr->Start_Time ()));
		problem_file.End (activity_time.Format_Step (act_ptr->End_Time ()));

		problem_file.Location (act_ptr->Location ());

		if (act_ptr->Location () > 0) {
			location_ptr = location_data [act_ptr->Location ()];
			if (location_ptr != NULL) {
				problem_file.Location (location_ptr->ID ());
			}
		}

		problem_file.Vehicle (act_ptr->Vehicle ());

		if (act_ptr->Vehicle () > 0) {
			vehicle_ptr = vehicle_data [act_ptr->Vehicle ()];
			if (vehicle_ptr != NULL) {
				problem_file.Vehicle (vehicle_ptr->ID ());
			}
		}
		problem_file.Survey (survey_hhold);

		problem_file.Write ();
	}
}
示例#4
0
bool PathSkim::Save_Skims (One_To_Many *skim_ptr)
{
	if (skim_ptr == 0) return (false);

	if (!skim_flag) {
		delete skim_ptr;
		return (true);
	}
	if (skim_ptr->Problem ()) {
		Set_Problem ((Problem_Type) skim_ptr->Problem ());
		delete skim_ptr;
		return (true);
	}
	int org, des, loc;
	Skim_Data *data_ptr;
	Many_Itr many_itr;
	Dtime time;

	org = des = 0;

	if (zone_skim_flag || district_flag) {
		if (forward_flag) {
			org = skim_file->Org_Index (skim_ptr->Zone ());
		} else {
			des = skim_file->Des_Index (skim_ptr->Zone ());
		}
	} else {
		loc = location_array [skim_ptr->Location ()].Location ();
		if (forward_flag) {
			org = skim_file->Org_Index (loc);
		} else {
			des = skim_file->Des_Index (loc);
		}
	}
	for (many_itr = skim_ptr->begin (); many_itr != skim_ptr->end (); many_itr++) {
		if (many_itr->Problem ()) {
			Set_Problem ((Problem_Type) many_itr->Problem ());
			continue;
		}
		if (many_itr->Impedance () == 0) continue;

		if (zone_skim_flag || district_flag) {
			if (forward_flag) {
				des = skim_file->Des_Index (many_itr->Zone ());
			} else {
				org = skim_file->Org_Index (many_itr->Zone ());
			}
		} else {
			loc = location_array [many_itr->Location ()].Location ();
			if (forward_flag) {
				des = skim_file->Des_Index (loc);
			} else {
				org = skim_file->Org_Index (loc);
			}
		}
		if (org < 0 || des < 0) continue;

		data_ptr = skim_file->Table (org, des);

		if (skim_file->Total_Time_Flag ()) {
			data_ptr->Add_Skim (many_itr->Drive (), many_itr->Length (), many_itr->Cost (), many_itr->Impedance ());
		} else {
			data_ptr->Add_Skim (many_itr->Walk (), many_itr->Drive (), many_itr->Transit (), many_itr->Wait (), 
						many_itr->Other (), many_itr->Length (), many_itr->Cost (), many_itr->Impedance ());
		}
	}
	delete skim_ptr;
	return (true);
}
示例#5
0
int Router::Kiss_Ride_Plan (Vehicle_Data *veh_ptr)
{
	int i, stat, acc, rec, imped, value_backup;
	unsigned cum_a, cum_b;
	int tod_a, tod_b, cost_a, cost_b, time_a, time_b;

	Trip_End_Data org, *des_ptr;
	Location_Data *loc_ptr;
	List_Data *acc_ptr;
	Access_Data *access_ptr;
	Path_Data *path_ptr, path_root;

	//---- walk to vehicle (parking) ----

	stat = Walk_to_Vehicle (veh_ptr);

	if (stat) return (stat);

	//---- identify the best kiss-&-ride lots ----

	if (!Kiss_Ride_Lots ()) return (Set_Problem (KISS_PROBLEM));

	//---- build the path between the origin and destination parking lots ----
	//---- adjust in-vehicle time value to account for driver's time ----

	value_backup = value_time;
	value_time = (value_time * kissride_factor + 50) / 100;

	Drive_Path (HOV2, false);

	value_time = value_backup;

	//---- initialize the path data ----

	for (i=0; i <= max_paths; i++) {
		loc_path [i].Zero_Fill ();
	}

	//---- add activity locations attached to parking lots to processing list ----

	first_ptr = &path_root;

	first_ptr->Next (0);
	first_ptr->Type (0);
	first_ptr->Xfer (0);
	first_ptr->Mode (NO_TRANSIT);

	last_ptr = first_ptr;

	org = *(org_array.First ());

	park_array.Reset ();

	for (des_ptr = des_array.First (); des_ptr != NULL; des_ptr = des_array.Next ()) {
		if (des_ptr->Cum () == MAX_INTEGER) continue;

		park_array.Add (des_ptr);

		cum_a = des_ptr->Cum ();
		tod_a = des_ptr->TOD ();
		cost_a = des_ptr->Cost ();
		time_a = des_ptr->Time ();

		//---- add the egress links to the processing queue ----

		for (acc = parking_egress [des_ptr->Rec ()]->From_List (); acc; acc = acc_ptr->From_List ()) {
			access_ptr = access_data [acc];
			acc_ptr = access_list [acc];

			loc_ptr = location_data [access_ptr->To_ID ()];

			path_ptr = loc_path [0] [access_ptr->To_ID ()];

			//---- check the time schedule ----

			tod_b = tod_a + access_ptr->Time ();

			if (tod_b > max_tod) {
				time_flag = true;
				continue;
			}

			//---- check walk distance ----

			time_b = time_a + access_ptr->Time ();

			if (walk_flag && time_b >= max_walk) {
				length_flag = true;
				continue;
			}
			cost_b = cost_a + access_ptr->Cost ();

			//---- check the cumulative impedance ----

			imped = (access_ptr->Time () * value_walk + access_ptr->Cost () * value_cost + value_round) >> value_roll;

			cum_b = cum_a + imped;

			if (cum_b >= path_ptr->Cum () && path_ptr->Cum () > 0) continue;

			if (path_ptr->Next () == 0 && last_ptr != path_ptr) {
				last_ptr->Next (access_ptr->To_ID ());
				last_ptr->Type (LOCATION_ID);
				last_ptr->Xfer (0);
				last_ptr->Mode (NO_TRANSIT);
				last_ptr = path_ptr;
			}
			path_ptr->Cum (cum_b);
			path_ptr->TOD (tod_b);
			path_ptr->Cost (cost_b);
			path_ptr->Time (time_b);
			path_ptr->Prev (-(park_array.Record_Index ()));
			path_ptr->Layer (PARKING_ID);
			path_ptr->Path (0);
		}
	}

	//---- set drive path error ----

	if (first_ptr->Next () == 0) {
		return (Set_Drive_Error ());
	}

	//---- initialize the transit path data ----

	for (i=0; i <= max_paths; i++) {
		node_path [i].Zero_Fill ();
		if (i < max_paths) {
			board_path [i].Zero_Fill ();
			alight_path [i].Zero_Fill ();
		}
	}

	//---- build the path ----

	stat = Build_Transit_Legs ();

	if (stat) return (stat);

	//---- find the best kiss-&-ride lot ----

	Set_Leg_Trip_Ends ();

	//---- save the drive plan ----

	des_ptr = org_array.Last ();

	if (des_ptr == NULL || des_ptr->Layer () != PARKING_ID) {
		return (Set_Transit_Error ());
	}

	rec = -des_ptr->Prev ();

	veh_ptr->Location (park_array [rec]->Rec ());

	stat = Save_Plan (&org, park_array [rec], Plan_File::AUTO_MODE, veh_ptr->Vehicle (), 1);

	if (stat) return (stat);

	//---- save the walk to the activity location ----

	stat = Save_Plan (park_array [rec], des_ptr);

	if (stat) return (stat);

	//---- save the plan record ----

	return (Save_Transit_Legs ());
}