예제 #1
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);
}
예제 #2
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);
}
예제 #3
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 ();
}
예제 #4
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);
} 
예제 #5
0
void PlanSum::Program_Control (void)
{
	String key;
	bool link_flag, report_flag;

	link_flag = report_flag = false;

	if (!Set_Control_Flag (UPDATE_FLOW_RATES) && !Set_Control_Flag (UPDATE_TRAVEL_TIMES)) {
		System_File_False (NEW_LINK_DELAY);
	}

	//---- initialize the MPI thread range ----

	MPI_Setup ();

	//---- set equivalence flags ---
	
	if (Report_Flag (LINK_GROUP) || Report_Flag (RIDER_GROUP)) {
		Link_Equiv_Flag (true);
		link_flag = true;
	}
	if (skim_flag || trip_flag) {
		Zone_Equiv_Flag (true);
		zone_flag = true;
	}
	Stop_Equiv_Flag (Report_Flag (STOP_GROUP));

	//---- create the network files ----

	Data_Service::Program_Control ();
	
	Read_Select_Keys ();
	Read_Flow_Time_Keys ();

	plan_file = (Plan_File *) System_File_Handle (PLAN);
	if (!plan_file->Part_Flag ()) Num_Threads (1);

	select_flag = System_File_Flag (SELECTION);
	new_delay_flag = System_File_Flag (NEW_LINK_DELAY);

	if (System_File_Flag (LINK_DELAY)) {
		link_flag = true;
		Link_Delay_File *file = (Link_Delay_File *) System_File_Handle (LINK_DELAY);
		turn_flag = file->Turn_Flag ();
	}
	if (new_delay_flag) {
		link_flag = true;
		Link_Delay_File *file = (Link_Delay_File *) System_File_Handle (NEW_LINK_DELAY);
		turn_flag = file->Turn_Flag ();
	} else {
		turn_flag = System_File_Flag (CONNECTION);
	}
	Print (2, String ("%s Control Keys:") % Program ());

	//---- new trip time file ----

	key = Get_Control_String (NEW_TRIP_TIME_FILE);

	if (!key.empty ()) {
		time_file.File_Type ("New Trip Time File");
		time_file.File_ID ("Time");

		if (Master ()) {
			time_file.Create (Project_Filename (key));
		}
		time_flag = true;
	}

	//---- new link volume file ----

	key = Get_Control_String (NEW_LINK_VOLUME_FILE);

	if (!key.empty ()) {
		volume_file.File_Type ("New Link Volume File");
		volume_file.File_ID ("Volume");

		if (Master ()) {
			volume_file.Create (Project_Filename (key));

			volume_file.Num_Decimals (1);
			volume_file.Data_Units (Performance_Units_Map (FLOW_DATA));
			volume_file.Copy_Periods (sum_periods);

			volume_file.Create_Fields ();
			volume_file.Write_Header ();
		}
		volume_flag = new_delay_flag = link_flag = true;
	}

	//---- read report types ----

	List_Reports ();

	if (Report_Flag (TOP_100) || Report_Flag (VC_RATIO) || Report_Flag (LINK_GROUP)) {
		new_delay_flag = link_flag = report_flag = true;
		cap_factor = (double) sum_periods.Range_Length () / (Dtime (1, HOURS) * sum_periods.Num_Periods ());
	}
	if (link_flag && (!System_File_Flag (LINK) || !System_File_Flag (NODE))) {
		Error ("Link and Node Files are Required for Link-Based Output");
	}
	if (System_File_Flag (LANE_USE) && !System_File_Flag (LINK)) {
		Error ("A Link File is Required for Lane-Use Processing");
	}
	travel_flag = Report_Flag (SUM_TRAVEL);

	//---- ridership summary ----

	passenger_flag = Report_Flag (SUM_PASSENGERS);
	transfer_flag = (Report_Flag (SUM_STOPS) || Report_Flag (STOP_GROUP));
	rider_flag = (System_File_Flag (NEW_RIDERSHIP) || Report_Flag (SUM_RIDERS) || Report_Flag (RIDER_GROUP));
	xfer_flag = Report_Flag (SUM_TRANSFERS);
	xfer_detail = Report_Flag (XFER_DETAILS);

	if (passenger_flag || transfer_flag || rider_flag || xfer_flag || xfer_detail) {
		if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) ||
			!System_File_Flag (TRANSIT_SCHEDULE)) {

			Error ("Transit Network Files are Required for Ridership Output");
		}
		if ((passenger_flag || rider_flag) && !System_File_Flag (TRANSIT_DRIVER)) {
			Error ("A Transit Driver File is needed for Passengers Summaries");
		}
	} else {
		System_File_False (TRANSIT_STOP);
		System_File_False (TRANSIT_ROUTE);
		System_File_False (TRANSIT_SCHEDULE);
		System_File_False (TRANSIT_DRIVER);
	}

	//---- process support data ----

	if (Link_Equiv_Flag ()) {
		link_equiv.Read (Report_Flag (LINK_EQUIV));
	}
	if (Zone_Equiv_Flag ()) {
		zone_equiv.Read (Report_Flag (ZONE_EQUIV));
	}
	if (Stop_Equiv_Flag ()) {
		stop_equiv.Read (Report_Flag (STOP_EQUIV));
	}

	//---- allocate work space ----

	if (time_flag || Report_Flag (TRIP_TIME)) {
		time_flag = true;

		int periods = sum_periods.Num_Periods ();
		
		start_time.assign (periods, 0);
		mid_time.assign (periods, 0);
		end_time.assign (periods, 0);
	}

	//---- transfer arrays ----

	if (xfer_flag || xfer_detail) {
		Integers rail;

		rail.assign (10, 0);
		total_on_array.assign (10, rail);

		if (xfer_detail) {
			int num = sum_periods.Num_Periods ();
			if (num < 1) num = 1;

			walk_on_array.assign (num, total_on_array);
			drive_on_array.assign (num, total_on_array);
		}
	}

	//---- initialize the trip summary data ----

	if (travel_flag) {
		trip_sum_data.Copy_Periods (sum_periods);
	}

	//---- initialize the passenger summary data ----

	if (passenger_flag) {
		pass_sum_data.Copy_Periods (sum_periods);
	}
}
예제 #6
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);
}
예제 #7
0
파일: Control.cpp 프로젝트: qingswu/Transim
void LinkSum::Program_Control (void)
{
	int i, field, ngroup, num;
	bool binary;
	String key, token;

	Location_File *location_file;
	Db_Field *fld;	
	Doubles dbl;
	Doubles_Itr itr;

	//---- set the equivalence flags ----

	Zone_Equiv_Flag (Check_Control_Key (NEW_GROUP_TRAVEL_FILE));

	group_select = Set_Control_Flag (SELECT_BY_LINK_GROUP);
	Link_Equiv_Flag (group_select || Report_Flag (LINK_GROUP) || Report_Flag (TRAVEL_TIME) || 
		Report_Flag (GROUP_REPORT) || Report_Flag (GROUP_SUMMARY) || Check_Control_Key (NEW_GROUP_SUMMARY_FILE));

	//---- open network files ----

	Data_Service::Program_Control ();

	Read_Select_Keys ();

	turn_flag = System_File_Flag (TURN_DELAY);
	
	Print (2, String ("%s Control Keys:") % Program ());	

	//---- open the compare performance file ----
	
	key = Get_Control_String (COMPARE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		compare_file.File_Type ("Compare Performance File");
		Print (1);

		if (Check_Control_Key (COMPARE_PERFORMANCE_FORMAT)) {
			compare_file.Dbase_Format (Get_Control_String (COMPARE_PERFORMANCE_FORMAT));
		}
		compare_file.Open (Project_Filename (key));
		compare_flag = true;
	}
	num_inc = sum_periods.Num_Periods ();
	if (num_inc < 1) num_inc = 1;

	cap_factor = (double) sum_periods.Range_Length () / (Dtime (1, HOURS) * num_inc);
	if (cap_factor <= 0.0) cap_factor = 1.0;

	//---- open the compare link map file ----
	
	key = Get_Control_String (COMPARE_LINK_MAP_FILE);

	if (!key.empty ()) {
		link_map_file.File_Type ("Compare Link Map File");
		Print (1);

		if (Check_Control_Key (COMPARE_LINK_MAP_FORMAT)) {
			link_map_file.Dbase_Format (Get_Control_String (COMPARE_LINK_MAP_FORMAT));
		}
		link_map_file.Open (Project_Filename (key));
		link_map_flag = true;
	}

	//---- get minimum volume ----
	
	minimum_volume = Get_Control_Double (MINIMUM_LINK_VOLUME);

	//---- person-based statistics ----

	person_flag = Get_Control_Flag (PERSON_BASED_STATISTICS);

	//---- get the select by link group flag ----

	group_select = Get_Control_Flag (SELECT_BY_LINK_GROUP);
	if (group_select || select_subareas || select_polygon || select_facilities) select_flag = true;

	//---- turning movement data ----

	if (turn_flag) {

		//---- open the compare turn delays file ----
	
		key = Get_Control_String (COMPARE_TURN_DELAY_FILE);

		if (!key.empty ()) {
			turn_compare_file.File_Type ("Compare Turn Delay File");
			Print (1);

			if (Check_Control_Key (COMPARE_TURN_DELAY_FORMAT)) {
				turn_compare_file.Dbase_Format (Get_Control_String (COMPARE_TURN_DELAY_FORMAT));
			}
			turn_compare_file.Open (Project_Filename (key));
			turn_compare_flag = true;
		}

		//---- select turn nodes----
	
		key = exe->Get_Control_Text (TURN_NODE_RANGE);

		if (!key.empty () && !key.Equals ("ALL")) {
			if (!turn_range.Add_Ranges (key)) {
				exe->Error ("Adding Turn Node Ranges");
			}
		}
	}

	//---- create link activity file ----

	key = Get_Control_String (NEW_LINK_ACTIVITY_FILE);

	if (!key.empty ()) {
		if (!System_File_Flag (LOCATION)) {
			Error ("A Location File is needed for the Link Activity File");
		}
		location_file = System_Location_File ();
		binary = (location_file->Record_Format () == BINARY);

		Print (1);
		activity_file.File_Type ("New Link Activity File");

		if (Check_Control_Key (NEW_LINK_ACTIVITY_FORMAT)) {
			activity_file.Dbase_Format (Get_Control_String (NEW_LINK_ACTIVITY_FORMAT));
		}
		activity_file.Create (Project_Filename (key));

		//---- copy location field name ----

		key = Get_Control_Text (COPY_LOCATION_FIELDS);
		if (key.empty ()) {
			Error ("Location Field Names are Required for Link Activity File");
		}
		link_db.File_Type ("Link Location Database");

		//---- set required fields ----

		link_db.Add_Field ("LINK", DB_INTEGER, 10);
		activity_file.Add_Field ("LINK", DB_INTEGER, 10);

		//---- copy selected fields ----

		while (!key.Split (token)) {
			field = location_file->Field_Number (token);
			if (field < 0) {
				Error (String ("Field %s was Not Found in the Location File") % token);
			}
			field_list.push_back (field);

			fld = location_file->Field (field);

			link_db.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary);
			activity_file.Add_Field (fld->Name (), fld->Type (), fld->Size (), fld->Units (), binary);
		}
		activity_file.Write_Header ();
		activity_flag = true;
	}

	//---- create zone travel file ----

	key = Get_Control_String (NEW_ZONE_TRAVEL_FILE);

	if (!key.empty ()) {
		if (!System_File_Flag (LOCATION)) {
			Error ("A Location File is needed for the Zone Travel File");
		}
		Print (1);
		zone_file.File_Type ("New Zone Travel File");

		if (Check_Control_Key (NEW_ZONE_TRAVEL_FORMAT)) {
			zone_file.Dbase_Format (Get_Control_String (NEW_ZONE_TRAVEL_FORMAT));
		}
		zone_file.Create (Project_Filename (key));
		zone_flag = true;
	}

	//---- create zone group travel file ----

	key = Get_Control_String (NEW_GROUP_TRAVEL_FILE);

	if (!key.empty ()) {
		if (!System_File_Flag (LOCATION)) {
			Error ("A Location File is needed for the Group Travel File");
		}
		Print (1);
		group_file.File_Type ("New Group Travel File");

		if (Check_Control_Key (NEW_GROUP_TRAVEL_FORMAT)) {
			group_file.Dbase_Format (Get_Control_String (NEW_GROUP_TRAVEL_FORMAT));
		}
		group_file.Create (Project_Filename (key));
		group_flag = true;
	}

	if (!activity_flag && !zone_flag && !group_flag) {
		System_File_False (LOCATION);
	}

	//---- get the number of direction groups ----

	ngroup = Highest_Control_Group (NEW_LINK_DIRECTION_FILE, 0);

	if (ngroup > 0) {
		Dir_Group group, *group_ptr;

		//---- process each group ----

		for (i=1; i <= ngroup; i++) {
			key = Get_Control_String (NEW_LINK_DIRECTION_FILE, i);
			if (key.empty ()) continue;

			Print (1);
			dir_group.push_back (group);
			group_ptr = &dir_group.back ();

			group_ptr->group = i;
			group_ptr->file = new Link_Direction_File ();
			group_ptr->file->File_Type (String ("New Link Direction File #%d") % i);

			if (Check_Control_Key (NEW_LINK_DIRECTION_FORMAT, i)) {
				group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DIRECTION_FORMAT, i));
			}
			group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ());
			group_ptr->file->Create (Project_Filename (key));

			//---- get the field name ----

			key = Get_Control_Text (NEW_LINK_DIRECTION_FIELD, i);
			if (key.empty ()) {
				Error (String ("New Link Direction Field #%d is Missing") % i);
			}
			group_ptr->field = Performance_Code (key);

			group_ptr->index = Get_Control_Flag (NEW_LINK_DIRECTION_INDEX, i);
			
			group_ptr->flip = Get_Control_Flag (NEW_LINK_DIRECTION_FLIP, i);

			if (group_ptr->flip && !compare_flag) {
				Warning ("Link Direction Flipping requires Comparison Data");
				group_ptr->flip = false;
			}
			Set_Link_Dir (group_ptr);
		}
	}

	//---- get the number of groups ----

	ngroup = Highest_Control_Group (NEW_LINK_DATA_FILE, 0);

	if (ngroup > 0) {
		Data_Group group, *group_ptr;

		//---- process each group ----

		for (i=1; i <= ngroup; i++) {
			key = Get_Control_String (NEW_LINK_DATA_FILE, i);
			if (key.empty ()) continue;

			Print (1);
			data_group.push_back (group);
			group_ptr = &data_group.back ();

			group_ptr->group = i;
			group_ptr->file = new Link_Data_File ();
			group_ptr->file->File_Type (String ("New Link Data File #%d") % i);

			if (Check_Control_Key (NEW_LINK_DATA_FORMAT, i)) {
				group_ptr->file->Dbase_Format (Get_Control_String (NEW_LINK_DATA_FORMAT, i));
			}
			group_ptr->file->Lane_Use_Flows (Lane_Use_Flows ());
			group_ptr->file->Create (Project_Filename (key));

			//---- get the field name ----

			key = Get_Control_Text (NEW_LINK_DATA_FIELD, i);
			if (key.empty ()) {
				Error (String ("New Link Data Field #%d is Missing") % i);
			}
			group_ptr->field = Performance_Code (key);

			Set_Link_Data (group_ptr);
		}
	}

	//---- data summary file ----

	key = Get_Control_String (NEW_DATA_SUMMARY_FILE);

	if (!key.empty ()) {
		Print (1);
		summary_file.File_Type ("New Data Summary File");

		if (Check_Control_Key (NEW_DATA_SUMMARY_FORMAT)) {
			summary_file.Dbase_Format (Get_Control_String (NEW_DATA_SUMMARY_FORMAT));
		}
		summary_file.Add_Field ("MEASURE", DB_STRING, 40);
		summary_file.Add_Field ("VALUE", DB_DOUBLE, 12.2);
		if (compare_flag) summary_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2);

		summary_file.Create (Project_Filename (key));
		summary_flag = true;

		//---- data summary periods ----

		if (!Control_Key_Empty (NEW_DATA_SUMMARY_PERIODS)) {
			periods_flag = data_periods.Add_Ranges (Get_Control_Text (NEW_DATA_SUMMARY_PERIODS));
		}

		//---- data summary ratios ----

		if (Check_Control_Key (NEW_DATA_SUMMARY_RATIOS)) {
			Double_List list;
			Dbl_Itr itr;

			Get_Control_List (NEW_DATA_SUMMARY_RATIOS, list);

			for (i=0, itr = list.begin (); itr != list.end (); itr++, i++) {
				if (i > 0 && *itr >= 1.0) {
					data_ratios.push_back (Round (*itr * 100.0));
					ratios_flag = true;
				}
			}
		}
	}

	//---- group summary file ----

	key = Get_Control_String (NEW_GROUP_SUMMARY_FILE);

	if (!key.empty ()) {
		Print (1);
		group_sum_file.File_Type ("New Group Summary File");

		if (Check_Control_Key (NEW_GROUP_SUMMARY_FORMAT)) {
			group_sum_file.Dbase_Format (Get_Control_String (NEW_GROUP_SUMMARY_FORMAT));
		}
		group_sum_file.Add_Field ("MEASURE", DB_STRING, 40);
		group_sum_file.Add_Field ("VALUE", DB_DOUBLE, 12.2);
		if (compare_flag) group_sum_file.Add_Field ("COMPARE", DB_DOUBLE, 12.2);

		group_sum_file.Create (Project_Filename (key));
		group_sum_flag = true;
	}

	//---- read report types ----

	List_Reports ();

	if (!compare_flag && (Report_Flag (TIME_CHANGE) || Report_Flag (VOLUME_CHANGE) ||
		Report_Flag (TOP_TIME_CHANGE) || Report_Flag (TOP_VOL_CHANGE) || Report_Flag (RELATIVE_GAP))) {

		Error ("A Compare Performance File is Required for Change Reports");
	}

	//---- process support data ----

	if (Link_Equiv_Flag ()) {
		link_equiv.Read (Report_Flag (LINK_EQUIV));
	}

	if (group_flag) {
		zone_equiv.Read (Report_Flag (ZONE_EQUIV));
	}

	//---- allocate work space ----

	if (periods_flag || ratios_flag) {
		num = (periods_flag) ? (int) data_periods.size () : 1;
		num += (ratios_flag) ? (int) data_ratios.size () : 1;
		if (num_inc + 1 > num) {
			num = num_inc + 1;
		}
	} else {
		num = num_inc + 1;
	}
	sum_bin.assign (num, dbl);

	for (itr = sum_bin.begin (); itr != sum_bin.end (); itr++) {
		itr->assign (NUM_SUM_BINS, 0.0);
	}
} 
예제 #8
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 ());
}
예제 #9
0
void EventSum::Program_Control (void)
{
	String key;

	//---- create the network files ----

	Data_Service::Program_Control ();

	Read_Select_Keys ();
	
	select_flag = System_File_Flag (SELECTION);
	trip_file_flag = System_File_Flag (TRIP);
	new_select_flag = System_File_Flag (NEW_SELECTION);
	update_flag = System_File_Flag (PLAN) || System_File_Flag (NEW_PLAN);

	if (update_flag && (!System_File_Flag (PLAN) || !System_File_Flag (NEW_PLAN))) {
		Error ("Input and Output Plan Files are Required for Plan Updates");
	}
	num_inc = sum_periods.Num_Periods ();

	Print (2, String ("%s Control Keys:") % Program ());

	//---- get the compare travel time file ----

	key = Get_Control_String (TRAVEL_TIME_FILE);

	if (!key.empty ()) {
		if (Check_Control_Key (TRAVEL_TIME_FORMAT)) {
			time_in_file.Dbase_Format (Get_Control_String (TRAVEL_TIME_FORMAT));
		}
		time_in_file.Open (Project_Filename (key));
		time_in_flag = true;
	}

	//---- get the travel time file ----

	key = Get_Control_String (NEW_TRAVEL_TIME_FILE);

	if (!key.empty ()) {
		if (Check_Control_Key (NEW_TRAVEL_TIME_FORMAT)) {
			travel_time_file.Dbase_Format (Get_Control_String (NEW_TRAVEL_TIME_FORMAT));
		}
		travel_time_file.Create (Project_Filename (key));
		time_file_flag = true;
	}

	//---- get the time summary file ----

	key = Get_Control_String (NEW_TIME_SUMMARY_FILE);

	if (!key.empty ()) {
		time_sum_file.File_Type ("New Time Summary File");

		if (Check_Control_Key (NEW_TIME_SUMMARY_FORMAT)) {
			time_sum_file.Dbase_Format (Get_Control_String (NEW_TIME_SUMMARY_FORMAT));
		}
		time_sum_file.Create (Project_Filename (key));
		time_sum_flag = true;

		//---- get the minimum schedule variance ----

		min_variance = Get_Control_Time (MINIMUM_SCHEDULE_VARIANCE);
	}

	//---- get the link event file ----

	key = Get_Control_String (NEW_LINK_EVENT_FILE);

	if (!key.empty ()) {
		link_event_file.File_Type ("New Link Event File");

		if (Check_Control_Key (NEW_LINK_EVENT_FORMAT)) {
			link_event_file.Dbase_Format (Get_Control_String (NEW_LINK_EVENT_FORMAT));
		}
		link_event_file.Create (Project_Filename (key));
		link_event_flag = true;
	}

	//---- new time distribution file ----

	time_diff.Open_Distribution (Get_Control_String (NEW_TIME_DISTRIBUTION_FILE));

	//---- new trip time gap file ----

	time_gap.Open_Trip_Gap_File (Get_Control_String (NEW_TRIP_TIME_GAP_FILE));

	//---- read report types ----

	List_Reports ();

	//---- set report flags ----

	time_flag = time_diff.Report_Flags (Report_Flag (TOTAL_TIME), Report_Flag (PERIOD_TIME), 
										Report_Flag (TOT_TIME_SUM), Report_Flag (PER_TIME_SUM));

	if (time_diff.Output_Flag () || Report_Flag (PERIOD_TIME) || Report_Flag (PER_TIME_SUM)) {
		time_diff.Set_Periods (sum_periods);
		time_flag = time_diff_flag = true;
	}
	if (time_gap.Output_Flag () || Report_Flag (TRP_TIME_GAP)) {
		time_gap.Report_Flags (Report_Flag (TRP_TIME_GAP));
		time_gap.Set_Periods (sum_periods);
		time_gap_flag = true;
	}

	//---- set the compare flag ----

	compare_flag = (time_in_flag || trip_file_flag);
} 
예제 #10
0
파일: Control.cpp 프로젝트: qingswu/Transim
void PerfPrep::Program_Control (void)
{
	String key;
	Strings list;
	Str_Itr str_itr;

	//---- open network files ----

	Data_Service::Program_Control ();
	
	Read_Select_Keys ();
	Read_Flow_Time_Keys ();

	Print (2, String ("%s Control Keys:") % Program ());

	new_file_flag = System_File_Flag (NEW_PERFORMANCE);

	//---- open the merge performance ----
	
	key = Get_Control_String (MERGE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		merge_file.File_Type ("Merge Performance File");
		Print (1);

		if (Check_Control_Key (MERGE_PERFORMANCE_FORMAT)) {
			merge_file.Dbase_Format (Get_Control_String (MERGE_PERFORMANCE_FORMAT));
		}
		merge_file.Open (Project_Filename (key));
		merge_flag = true;

		if (!new_file_flag) {
			Error ("A New Performance File is required for Merge Processing");
		}
	}

	//---- open the base performance ----
	
	key = Get_Control_String (BASE_PERFORMANCE_FILE);

	if (!key.empty ()) {
		base_file.File_Type ("Base Performance File");
		Print (1);

		if (Check_Control_Key (BASE_PERFORMANCE_FORMAT)) {
			base_file.Dbase_Format (Get_Control_String (BASE_PERFORMANCE_FORMAT));
		}
		base_file.Open (Project_Filename (key));
		base_flag = true;

		if (!new_file_flag) {
			Error ("A New Performance File is required for Base Processing");
		}
	}

	//---- open the merge turn delay ----

	turn_flag = System_File_Flag (TURN_DELAY);

	if (turn_flag) {
		key = Get_Control_String (MERGE_TURN_DELAY_FILE);

		if (!key.empty ()) {
			turn_file.File_Type ("Merge Turn Delay File");
			Print (1);

			if (Check_Control_Key (MERGE_TURN_DELAY_FORMAT)) {
				turn_file.Dbase_Format (Get_Control_String (MERGE_TURN_DELAY_FORMAT));
			}
			turn_file.Open (Project_Filename (key));
			turn_merge_flag = true;

			if (!System_File_Flag (NEW_TURN_DELAY)) {
				Error ("A New Turn Delay File is required for Merge Processing");
			}
		}
	}

	//---- processing method ----

	Print (1);
	key = Get_Control_Text (PROCESSING_METHOD);

	if (!key.empty ()) {
		method = Combine_Code (key);

		if (method != UPDATE_TIMES) {
			if (merge_flag || turn_merge_flag) {
				if (method == WEIGHTED_LINK_AVG || method == REPLACE_AVERAGE) {

					//---- merge weighting factor ----

					factor = Get_Control_Double (MERGE_WEIGHTING_FACTOR);
				}
			} else {
				//Error (String ("Processing Method %s requires Merge Files") % key);
			}
		}
	}

	//---- read the smoothing parameters ----

	smooth_flag = smooth_data.Read_Control ();

	if (smooth_flag) {
		if (!smooth_data.Num_Input (time_periods.Num_Periods ())) {
			Error ("Smooth Parameters are Illogical");
		}
		if (!new_file_flag) {
			Error ("A New Performance File is required for Data Smoothing");
		}
	}

	//---- set min travel time ----

	min_time_flag = Get_Control_Flag (SET_MIN_TRAVEL_TIME);

	if (min_time_flag && !new_file_flag) {
		Error ("A New Performance File is required for Minimum Travel Times");
	}

	//---- set merge transit data ----

	key = Get_Control_Text (MERGE_TRANSIT_DATA);

	if (!key.empty ()) {
		transit_flag = true;

		if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) ||
			!System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER)) {

			Error ("Transit Network Files are Required for Transit Loading");
		}
		if (!new_file_flag) {
			Error ("A New Performance File is required to Merge Transit Data");
		}
		key.Parse (list);
		for (str_itr = list.begin (); str_itr != list.end (); str_itr++) {
			if (str_itr->Starts_With ("VEH")) {
				transit_veh_flag = true;
			} else if (str_itr->Starts_With ("PER")) {
				transit_person_flag = true;
			} else if (str_itr->Starts_With ("PCE") || str_itr->Starts_With ("CAR_EQ")) {
				transit_pce_flag = true;
			}
		}
		if (!System_File_Flag (VEHICLE_TYPE) && transit_pce_flag) {
			Warning ("Vehicle Type File is Required for Transit PCE Loading");
		}
		if (!System_File_Flag (RIDERSHIP) && transit_person_flag) {
			Warning ("Ridership File is Required for Transit Person Loading");
		}
		if (!merge_flag) {
			method = Combine_Code (Get_Control_Text (PROCESSING_METHOD));
		}
	}

	//---- open the time constraint file ----
	
	key = Get_Control_String (TIME_CONSTRAINT_FILE);

	if (!key.empty ()) {
		constraint_file.File_Type ("Time Constraint File");
		Print (1);

		if (Check_Control_Key (TIME_CONSTRAINT_FORMAT)) {
			constraint_file.Dbase_Format (Get_Control_String (TIME_CONSTRAINT_FORMAT));
		}
		constraint_file.Open (Project_Filename (key));
		constraint_flag = true;
	}

	//---- open the time ratio file ----
	
	key = Get_Control_String (NEW_TIME_RATIO_FILE);

	if (!key.empty ()) {
		time_ratio_file.File_Type ("New Time Ratio File");

		time_ratio_file.Create (Project_Filename (key));
		time_ratio_flag = true;
	}

	//---- open the deleted record file ----
	
	key = Get_Control_String (NEW_DELETED_RECORD_FILE);

	if (!key.empty ()) {
		deleted_file.File_Type ("New Deleted Record File");
		Print (1);

		if (Check_Control_Key (NEW_DELETED_RECORD_FORMAT)) {
			deleted_file.Dbase_Format (Get_Control_String (NEW_DELETED_RECORD_FORMAT));
		}
		deleted_file.Create (Project_Filename (key));
		del_file_flag = true;
	}

	List_Reports ();

	first_delete = deleted_flag = (Report_Flag (DELETED_RECORDS) || del_file_flag);
}
예제 #11
0
void Validate::Program_Control (void)
{
	int i, num;
	String key, record;
	Dtime low, high;
	Db_File label_file;
	Str_Map_Stat map_stat;

	//---- set equivalence flags ----

	line_flag = Report_Flag (LINE_GROUP);
	stop_flag = (Report_Flag (STOP_GROUP) || Report_Flag (BOARD_GROUP) || Report_Flag (ALIGHT_GROUP));

	Link_Equiv_Flag (Report_Flag (LINK_GROUP) || Report_Flag (GROUP_DETAILS));
	Zone_Equiv_Flag (Report_Flag (ZONE_GROUP));
	Stop_Equiv_Flag (stop_flag);
	Line_Equiv_Flag (line_flag);

	//---- open network files ----

	Data_Service::Program_Control ();
	
	Print (2, String ("%s Control Keys:") % Program ());	

	//---- check for traffic counts ----

	if (Check_Control_Key (TRAFFIC_COUNT_FILE)) {
		link_flag = true;

		if (Report_Flag (ZONE_GROUP)) {
			if (!System_File_Flag (ZONE)) {
				Error ("Zone File is Required for Zone Group Reports");
			}
			zone_flag = true;
		} else if (Report_Flag (AREA_TYPE)) {
			zone_flag = System_File_Flag (ZONE);
		}
	} else {
		if (Report_Flag (VOLUME_LEVEL) || Report_Flag (FACILITY_TYPE) ||
			Report_Flag (AREA_TYPE) || Report_Flag (ZONE_GROUP) ||
			Report_Flag (LINK_GROUP) || Report_Flag (GROUP_DETAILS)) {

			Error ("Traffic Count file is Required for Link-Based Reports");
		}
	}

	//---- check for turning movements ----

	if (Check_Control_Key (TURN_COUNT_FILE)) {
		if ((Report_Flag (TURN_MOVEMENT) || Report_Flag (TURN_LOS)) && 
			!System_File_Flag (CONNECTION)) {

			Error ("Connection File is Required for Turning Movement Reports");
		}
		if (Report_Flag (TURN_LOS) && !(System_File_Flag (SIGNAL) &&
			System_File_Flag (TIMING_PLAN) && System_File_Flag (PHASING_PLAN))) {

			Error ("Signal Data is Required for Turn Level of Service Analysis");
		}
		turn_flag = true;
	} else {
		if (Report_Flag (TURN_MOVEMENT) || Report_Flag (TURN_LOS)) {
			Error ("Turn Count File is Required for Turning Movement Reports");
		}
		System_File_False (POCKET);
		System_File_False (CONNECTION);
		System_File_False (SIGNAL);
		System_File_False (TIMING_PLAN);
		System_File_False (PHASING_PLAN);
	}

	//---- check for transit reports ----

	if (line_flag || stop_flag) {
		if (!System_File_Flag (TRANSIT_STOP) || !System_File_Flag (TRANSIT_ROUTE) ||
			!System_File_Flag (TRANSIT_SCHEDULE) || !System_File_Flag (TRANSIT_DRIVER) ||
			!System_File_Flag (RIDERSHIP)) {

			Error ("Transit Network and Ridership are Required for Transit Reports");
		}
		if (line_flag && !Check_Control_Key (LINE_EQUIVALENCE_FILE)) {
			Error ("Line Group Equivalance is Required for Line Group Reports");
		}
		if (line_flag && !Check_Control_Key (LINE_GROUP_COUNT_FILE)) {
			Error ("Line Group Counts are Required for Line Group Reports");
		}
		if (stop_flag && !Check_Control_Key (STOP_EQUIVALENCE_FILE)) {
			Error ("Stop Group Equivalance is Required for Stop Group Reports");
		}
		if (stop_flag && !Check_Control_Key (STOP_GROUP_COUNT_FILE)) {
			Error ("Stop Group Counts are Required for Stop Group Reports");
		}
	} else {
		System_File_False (TRANSIT_STOP);
		System_File_False (TRANSIT_ROUTE);
		System_File_False (TRANSIT_SCHEDULE);
		System_File_False (TRANSIT_DRIVER);
		System_File_False (RIDERSHIP);
	}

	//---- check for a link delay file ----

	if (!System_File_Flag (LINK_DELAY)) {

		//---- open the link volume file ----

		if (link_flag) {
			key = Get_Control_String (INPUT_VOLUME_FILE);

			if (key.empty ()) goto control_error;

			Print (1);
			volume_file.File_Type ("Input Volume File");

			volume_file.Open (Project_Filename (key));
		
			Print (1, "Number of Time Periods = ") << volume_file.Num_Periods ();
		}

		//---- open the turn movement file ----

		if (turn_flag) {
			key = Get_Control_String (TURN_VOLUME_FILE);

			if (key.empty ()) goto control_error;

			Print (1);
			turn_volume.File_Type ("Turn Volume File");

			turn_volume.Open (Project_Filename (key));
		}
	} else {
		delay_flag = true;
	}

	//---- open the traffic count file ----

	if (link_flag) {
		key = Get_Control_String (TRAFFIC_COUNT_FILE);

		Print (1);
		count_file.File_Type ("Traffic Count File");

		count_file.Open (Project_Filename (key));

		Print (1, "Number of Time Periods = ") << count_file.Num_Periods ();
	}

	//---- open the turn count file ----

	if (turn_flag) {
		key = Get_Control_String (TURN_COUNT_FILE);

		Print (1);
		turn_count.File_Type ("Turn Count File");

		turn_count.Open (Project_Filename (key));
	}

	//---- open the transit line group count file ----

	if (line_flag) {
		key = Get_Control_String (LINE_GROUP_COUNT_FILE);

		Print (1);
		line_count_file.File_Type ("Transit Line Group Count File");

		line_count_file.Open (Project_Filename (key));

		line_count_file.Required_Field ("GROUP", "LINE", "LINEGROUP", "LINEGRP", "ID");
		line_count_file.Required_Field ("COUNT", "RIDERS", "PASSENGERS", "TOTAL", "VOLUME");
	}

	//---- open the transit stop group count file ----

	if (stop_flag) {
		key = Get_Control_String (STOP_GROUP_COUNT_FILE);

		Print (1);
		stop_count_file.File_Type ("Transit Stop Group Count File");

		stop_count_file.Open (Project_Filename (key));

		stop_count_file.Required_Field ("GROUP", "STOP", "STOPGROUP", "STOPGRP", "ID");

		if (Report_Flag (STOP_GROUP)) {
			stop_count_file.Required_Field ("TOTAL",  "ONOFF", "ON_OFF", "PASSENGERS", "COUNT");
		}
		if (Report_Flag (BOARD_GROUP)) {
			stop_count_file.Required_Field ("BOARDINGS", "BOARD", "ON", "PASSENGERS", "COUNT");
		}
		if (Report_Flag (ALIGHT_GROUP)) {
			stop_count_file.Required_Field ("ALIGHTINGS", "ALIGHT", "OFF", "PASSENGERS", "COUNT");
		}
	}

	//---- create new volume file ----

	key = Get_Control_String (NEW_VOLUME_FILE);

	if (!key.empty ()) {
		if (!delay_flag && !link_flag) {
			Error ("Link Delay or Volume File is Required to Output Volume Data");
		}
		Print (1);
		output_file.File_Type ("New Volume File");

		output_file.Create (Project_Filename (key));
		output_flag = true;
	}

	//---- create new volume count file ----

	key = Get_Control_String (NEW_VOLUME_COUNT_FILE);

	if (!key.empty ()) {
		if (!delay_flag && !link_flag) {
			Error ("Volume and Count Files are Required to Output Volume Count Data");
		}
		Print (1);
		vol_cnt_file.File_Type ("New Volume Count File");

		vol_cnt_file.Create (Project_Filename (key));
		vc_flag = true;
	}

	//---- adjust the volume ranges ----

	hours = 24.0 * sum_periods.Range_Length () / Dtime (MIDNIGHT, SECONDS);

	if (hours < 12.0) {
		double adjust = (hours <= 4.0) ? 0.1 : 0.5;

		for (i=0; volume_level [i] > 0; i++) {
			volume_level [i] = (int) (volume_level [i] * adjust + 0.5);
		}
	}
	hours = hours / sum_periods.Num_Periods ();

	//---- check the data fields ----

	if (link_flag) {
		key = "Traffic Count";

		num = sum_periods.Num_Periods ();

		if (count_file.Num_Periods () < num) goto field_error;

		for (i=0; i < num; i++) {
			sum_periods.Period_Range (i, low, high);
			if (!count_file.In_Range (low) || !count_file.In_Range ((low + high) / 2)) goto field_error;
		}
		if (!delay_flag) {
			key = "Input Volume";

			if (volume_file.Num_Periods () < num) goto field_error;

			for (i=0; i < num; i++) {
				sum_periods.Period_Range (i, low, high);
				if (!volume_file.In_Range (low) || !volume_file.In_Range ((low + high) / 2)) goto field_error;
			}
		}
	}

	//---- read the analysis method ----

	key = Get_Control_Text (ANALYSIS_METHOD);

	if (!key.empty ()) {
		if (key.Equals ("VOLUME")) {
			method = false;
		} else if (key.Equals ("VMT")) {
			method = true;
		} else {
			Error (String ("Analysis Method = %s was Unrecognized") % key);
		}
	}
	header1 = String ("\n%29cNum.  ------%s------ ---Difference---  --Abs.Error--    Std.     %%     R   ----V/C----") %
				BLANK % ((method) ? "--VMT-" : "Volume") % FINISH;

	header2 = String ("    Obs.  Estimate  Observed   %6.6s      %%     Avg.     %%     Dev.   RMSE   Sq.   Avg.  Max.\n") %
				((method) ? "VMT" : "Volume") % FINISH;
	
	//---- read the adjustment factor ----

	factor = Get_Control_Double (ADJUSTMENT_FACTOR);

	//---- open the facility type labels ----

	if (Report_Flag (FACILITY_TYPE)) {
		key = Get_Control_String (FACILITY_TYPE_LABELS);

		if (!key.empty ()) {
			label_file.File_Type ("Facility Type Label File");
			Print (1);

			label_file.Open (Project_Filename (key));

			while (label_file.Read ()) {
				record = label_file.Record_String ();
				if (record.empty ()) continue;

				record.Split (key);
				i = key.Integer ();

				map_stat = facility_type.insert (Str_Map_Data (i, record));

				if (!map_stat.second) {
					Error ("Duplicate Facility Type Label");
				}
			}
			label_file.Close ();
		}
	}

	//---- open the area type labels ----

	if (Report_Flag (AREA_TYPE)) {
		key = Get_Control_String (AREA_TYPE_LABELS);

		if (!key.empty ()) {
			label_file.File_Type ("Area Type Label File");
			Print (1);

			label_file.Open (Project_Filename (key));

			while (label_file.Read ()) {
				record = label_file.Record_String ();
				if (record.empty ()) continue;

				record.Split (key);
				i = key.Integer ();

				map_stat = area_type.insert (Str_Map_Data (i, record));

				if (!map_stat.second) {
					Error ("Duplicate Area Type Label");
				}
			}
			label_file.Close ();
		}
	}

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

	List_Reports ();

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

	if (Zone_Equiv_Flag ()) {
		zone_equiv.Read (Report_Flag (ZONE_EQUIV));
	}

	//---- process support data ----

	if (Link_Equiv_Flag ()) {
		link_equiv.Read (Report_Flag (LINK_EQUIV));
	}

	//---- read the line equiv ----

	if (line_flag) {
		line_equiv.Read (Report_Flag (LINE_EQUIV));
	}

	//---- read the stop equiv ----

	if (stop_flag) {
		stop_equiv.Read (Report_Flag (STOP_EQUIV));
	}
	return;

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

field_error:
	Error (String ("The %s File has insufficient data for %d Time Increments") % key % num);

control_error:
	Error (String ("Missing Control Key = %s") % Current_Key ());
} 
예제 #12
0
void ConvertTours::Execute (void)
{
	int hhold1, vehicle1;

	File_Group *group;

	//---- compile the tour group script ----

	if (script_flag) {
		Show_Message (1);

		script_base.File_ID ("GROUP");
		script_base.Dbase_Format (BINARY);
		script_base.File_Access (MODIFY);

		script_base.Add_Field ("GROUP_OUT", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("GROUP_IN", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("DIURNAL_OUT", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("DIURNAL_IN", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("MODE_OUT", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("MODE_IN", INTEGER, 2, 0, -1, true);
		script_base.Add_Field ("WORK_CODE", INTEGER, 2, 0, -1, true);

		if (!group_script.Set_Files (2, &tour_file_db, &script_base)) {
			Error ("Initializing Tour Group Script Files");
		}
		group_script.Random_Seed (random_org.Seed () + 4);

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

			if (!Break_Check (10)) {
				Print (1);
				Page_Header ();
			}
		}
		if (!group_script.Compile (&script_file, Report_Flag (SCRIPT_REPORT))) {
			Error ("Compiling Tour Group Script");
		}
		if (Report_Flag (STACK_REPORT)) {
			Header_Number (STACK_REPORT);

			group_script.Print_Commands (Report_Flag (STACK_REPORT));
		}
		Header_Number (0);
	}
	Show_Message (1);

	for (group = file_group.First (); group != NULL; group = file_group.Next ()) {
		Time_Processing (group);
	}

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

	Demand_Service::Execute ();

	//---- generate the zone map ----

	Zone_Location ();

	//---- check the parking lots ----

	Parking_Check ();

	//---- check the vehicle types ----

	if (Demand_File_Flag (VEHICLE_TYPE)) {
		for (group = file_group.First (); group != NULL; group = file_group.Next ()) {
			if (veh_type_data.Get (group->Type (), group->SubType ()) == NULL) {
				Error ("Vehicle Type %d-%d was Not Found in the Vehicle Type Flle", group->Type (), group->SubType ());
			}
		}
	}

	//---- read the household list ----

	if (hhlist_flag) {
		Read_HHList ();
	}

	//---- process each trip table -----

	if (hhold_id <= max_hh_in) hhold_id = 100 * ((max_hh_in / 100) + 1);
	if (vehicle_id <= max_veh_in) vehicle_id = 100 * ((max_veh_in / 100) + 1);

	hhold1 = hhold_id;
	vehicle1 = vehicle_id;

	//---- travel time skim ----

	if (skim_flag) {
		Skim_Processing ();
	}

	//---- read the tour file ----

	Tour_Processing ();

	//---- diurnal allocation file ----

	if (diurnal_flag) {
		Diurnal_Results ();
	}

	//---- summarize the results ----

	if (trip_copy > 0 || hhold_copy > 0 || pop_copy > 0 || veh_copy > 0) {
		Break_Check (5);

		Write (2, "Number of Trip Records Copied      = %d", trip_copy);
		Write (1, "Number of Household Records Copied = %d", hhold_copy);
		Write (1, "Number of Person Records Copied    = %d", pop_copy);
		Write (1, "Number of Vehicle Records Copied   = %d", veh_copy);
	}

	Break_Check (10);

	Write (2, "Total Number of Tours Read     = %d", tot_trips);
	Write (1, "Total Number of Trips Written  = %d", num_trip);
	if (tot_add > 0.5) {
		Write (1, "Total Number of Trips Added    = %.0lf", tot_add);
	}
	if (tot_del > 0.5) {
		Write (1, "Total Number of Trips Deleted  = %.0lf", tot_del);
	}
	Write (1, "Number of Trips Not Allocated  = %d", tot_errors);

	Write (2, "Number of Households Generated = %d", nhhold);
	Write (1, "Number of Persons Generated    = %d", nperson);
	Write (1, "Number of Vehicles Generated   = %d", (vehicle_id - vehicle1));

	Exit_Stat (DONE);
}
예제 #13
0
void Progression::Read_Weights (void)
{
	int group, num_periods;
	double weight;
	String record;
	Strings parts;
	Str_Itr str_itr;

	Doubles weights;
	Dbls_Map_Itr grp_itr;
	Dbls_Map_Stat map_stat;
	Dbl_Itr wt_itr;

	Show_Message (String ("Reading %s -- Record") % weight_file.File_Type ());
	Set_Progress ();

	num_periods = progress_time.Num_Periods ();

	while (weight_file.Read ()) {
		Show_Progress ();

		record = weight_file.Record_String ();
		record.Parse (parts);

		if ((int) parts.size () < 2) continue;

		str_itr = parts.begin ();
		group = str_itr->Integer ();

		weights.clear ();
		weight = 1.0;

		for (++str_itr; str_itr != parts.end (); str_itr++) {
			weight = str_itr->Double ();

			if (weight < 0.01 || weight > 1000.0) {
				Error (String ("Group %d Period Weight %.2lf is Out of Range (0.01..1000.0)") % group % weight);
			}
			weights.push_back (weight);
		}

		//---- check the data ----

		while ((int) weights.size () < num_periods) {
			weights.push_back (weight);
		}

		map_stat = weight_data.insert (Dbls_Map_Data (group, weights));

		if (!map_stat.second) {
			Warning ("Duplicate Weight Group = ") << group;
		}
	}
	End_Progress ();
	weight_file.Close ();

	Print (2, "Number of Group Period Weight Records = ") << Progress_Count ();

	if (Report_Flag (WEIGHT_REPORT)) {

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

		Header_Number (WEIGHT_REPORT);

		if (!Break_Check (weight_data.size () + 6)) {
			Print (1);
			Weight_Header ();
		}

		for (grp_itr = weight_data.begin (); grp_itr != weight_data.end (); grp_itr++) {
			Print (1, String ("%5d") % grp_itr->first);

			for (wt_itr = grp_itr->second.begin (); wt_itr != grp_itr->second.end (); wt_itr++) {
				Print (0, String ("  %8.2lf") % *wt_itr);
			}
		}
		Header_Number (0);
	}
}