Exemple #1
0
void Simulator_Base::Check_Output (Travel_Step &step)
{
	if (step.Vehicle () < 0) return;

	//---- link delay processing ----

	if (link_delay_output.Output_Flag ()) {
		link_delay_output.Summarize (step);
	}

	//----- performance processing -----

	if (performance_output.Output_Flag ()) {
		performance_output.Summarize (step);
	}

	//----- turn volume processing -----

	if (turn_vol_output.Output_Flag ()) {
		turn_vol_output.Summarize (step);
	}

	//----- occupancy processing -----

	if (occupancy_output.Output_Flag ()) {
		occupancy_output.Summarize (step);
	}
}
Exemple #2
0
bool Sim_Method::Cell_Use (Sim_Lane_Data *lane_ptr, int lane, int cell, Travel_Step &step, bool use_flag)
{
	int i, index, num, seed;
	Lane_Use_Data *use_ptr;
	Lane_Use_Period *period_ptr;
	Link_Dir_Data *use_index;

	int type = step.sim_traveler_ptr->Type ();
	int veh_type = step.sim_veh_ptr->Type ();
	Use_Type use = step.veh_type_ptr->Use ();

	step.Delay (0);

	if (use_flag) {
		if (use != BUS && use != HOV2 && use != HOV3 && use != HOV4) return (false);
		if (Use_Permission (lane_ptr->Use (), SOV)) return (false);
	}
	if (!Use_Permission (lane_ptr->Use (), use)) return (false);

	if (veh_type >= 0 && lane_ptr->Min_Veh_Type () >= 0) {
		if (lane_ptr->Type () == PROHIBIT) {
			if (veh_type >= lane_ptr->Min_Veh_Type () && veh_type <= lane_ptr->Max_Veh_Type ()) return (false);
		} else {
			if (veh_type < lane_ptr->Min_Veh_Type () || veh_type > lane_ptr->Max_Veh_Type ()) return (false);
		}
	}
	if (type > 0 && lane_ptr->Min_Traveler () > 0) {
		if (lane_ptr->Type () == PROHIBIT) {
			if (type >= lane_ptr->Min_Traveler () && type <= lane_ptr->Max_Traveler ()) return (false);
		} else {
			if (type < lane_ptr->Min_Traveler () || type > lane_ptr->Max_Traveler ()) return (false);
		}
	}
	index = lane_ptr->First_Use ();
	if (index < 0) return (true);

	period_ptr = &exe->use_period_array [index];

	num = period_ptr->Records ();
	index = period_ptr->Index ();

	for (i=0; i < num; i++, index++) {
		use_index = &exe->use_period_index [index];
		use_ptr = &exe->lane_use_array [use_index->Link ()];

		if (use_ptr->Offset () > 0 || use_ptr->Length () > 0) {
			int offset = cell * param.cell_size;

			if (use_ptr->Offset () > offset || offset > (use_ptr->Offset () + use_ptr->Length ())) continue;
		}
		if (use_ptr->Type () == REQUIRE) {
			if (!Use_Permission (use_ptr->Use (), use)) continue;
			if (veh_type >= 0 && use_ptr->Min_Veh_Type () >= 0) {
				if (veh_type < use_ptr->Min_Veh_Type () || veh_type > use_ptr->Max_Veh_Type ()) continue;
			}
			if (type > 0 && use_ptr->Min_Traveler () > 0) {
				if (type < use_ptr->Min_Traveler () || type > use_ptr->Max_Traveler ()) continue;
			}
			return (lane >= use_ptr->Low_Lane () && lane <= use_ptr->High_Lane ());
		} else {
			if (lane < use_ptr->Low_Lane () || lane > use_ptr->High_Lane ()) continue;

			if (use_ptr->Type () == PROHIBIT) {
				if (use_flag && !Use_Permission (use_ptr->Use (), SOV)) return (false);
				if (!Use_Permission (use_ptr->Use (), use)) continue;
				if (veh_type >= 0 && use_ptr->Min_Veh_Type () >= 0) {
					if (veh_type < use_ptr->Min_Veh_Type () || veh_type > use_ptr->Max_Veh_Type ()) continue;
				}
				if (type > 0 && use_ptr->Min_Traveler () > 0) {
					if (type < use_ptr->Min_Traveler () || type > use_ptr->Max_Traveler ()) continue;
				}
				return (false);
			} else if (use_ptr->Type () == LIMIT) {
				if (use_flag && Use_Permission (use_ptr->Use (), SOV)) return (false);
				if (!Use_Permission (use_ptr->Use (), use)) return (false);
				if (veh_type >= 0 && use_ptr->Min_Veh_Type () >= 0) {
					if (veh_type < use_ptr->Min_Veh_Type () || veh_type > use_ptr->Max_Veh_Type ()) return (false);
				}
				if (type > 0 && use_ptr->Min_Traveler () > 0) {
					if (type < use_ptr->Min_Traveler () || type > use_ptr->Max_Traveler ()) return (false);
				}
				return (true);
			} else if (use_ptr->Type () == APPLY) {
				if (!Use_Permission (use_ptr->Use (), use)) continue;
				if (veh_type >= 0 && use_ptr->Min_Veh_Type () >= 0) {
					if (veh_type < use_ptr->Min_Veh_Type () || veh_type > use_ptr->Max_Veh_Type ()) continue;
				}
				if (type >= 0 && use_ptr->Min_Traveler () > 0) {
					if (type < use_ptr->Min_Traveler () || type > use_ptr->Max_Traveler ()) continue;
				}
				if (use_ptr->Min_Delay () > 0 || use_ptr->Max_Delay () > 0) {
					if (use_ptr->Offset () > 0 || use_ptr->Length () > 0) {
						if (cell != (use_ptr->Offset () + (use_ptr->Length () / 2)) / param.cell_size) break;
					} else {
						if (cell != (int) (lane_ptr->size () / 2)) break;
					}
					int diff = 0;
					if (use_ptr->Max_Delay () > use_ptr->Min_Delay ()) {
						seed = abs (index + exe->Random_Seed () + step.Vehicle () + lane);
						diff = DTOI ((use_ptr->Max_Delay () - use_ptr->Min_Delay ()) * exe->random.Probability (seed));
					}
					step.Delay (use_ptr->Min_Delay () + diff);
				}
				break;
			}
		}
	}
	return (true);
}
Exemple #3
0
bool Sim_Method::Output_Step (Travel_Step &step)
{
	int cell_offset, index, cell, lane, to_index, to_cell, to_lane, last_index, pce;
	int first_cell, last_cell, to_part, from_index;
	bool reload_flag, bound_flag, remove_flag = false;
	bool transfer_flag = false;

	Sim_Plan_Ptr plan_ptr;
	Sim_Leg_Itr leg_itr;
	Sim_Dir_Ptr sim_dir_ptr;
	Sim_Cap_Ptr sim_cap_ptr = 0;
	Sim_Veh_Ptr sim_veh_ptr;
	Cell_Itr cell_itr, veh_cell_itr, end_itr;
	Problem_Data problem_data;

	if (step.Vehicle () >= 0 && step.sim_veh_ptr == 0) {
		step.sim_veh_ptr = exe->sim_veh_array [step.Vehicle ()];
	}
	plan_ptr = step.sim_traveler_ptr->plan_ptr;

	//---- check for lost problems ----

	if (step.Status () == 1 || step.Problem () == DEPARTURE_PROBLEM || step.Problem () == ARRIVAL_PROBLEM) {
		if (plan_ptr->Person () == 0) {
			stats.num_run_lost++;
		} else {
			stats.num_veh_lost++;

			//---- check the lost vehicle event ----

			if (step.sim_veh_ptr != 0) {
				if (exe->Check_Event (VEH_LOST_EVENT, plan_ptr->Mode (), subarea)) {
					Event_Data event_data;

					event_data.Household (plan_ptr->Household ());
					event_data.Person (plan_ptr->Person ());
					event_data.Tour (plan_ptr->Tour ());
					event_data.Trip (plan_ptr->Trip ());
					event_data.Mode (plan_ptr->Mode ());

					if (step.Problem () == ARRIVAL_PROBLEM) {
						event_data.Schedule (plan_ptr->Arrive ());
					} else if (step.Problem () == DEPARTURE_PROBLEM) {
						event_data.Schedule (plan_ptr->Depart ());
					} else {
						event_data.Schedule (plan_ptr->Schedule ());
					}
					event_data.Actual (exe->step);
					event_data.Event (VEH_LOST_EVENT);

					veh_cell_itr = step.sim_veh_ptr->begin ();
					veh_cell_itr->Location (&to_index, &to_lane, &to_cell);

					event_data.Dir_Index (to_index);

					if (to_index >= 0 || to_cell > 0) {
						cell_offset = to_cell * param.cell_size + (param.cell_size >> 1);

						event_data.Offset (UnRound (cell_offset));
					} else {
						event_data.Offset (0);
					}
					event_data.Lane (to_lane);
					event_data.Route (-1);

					exe->Output_Event (event_data);
				}
			}