Example #1
0
void NewLandUse::Execute (void)
{
	int field;
	Str_Itr str_itr;
	Zone_Field_Itr field_itr;
	Processing_Itr process_itr;

	//---- read/open the system zone files ----

	Data_Service::Execute ();

	//---- read zone and target files ----

	Read_Files ();

	//---- coverage type density ----

	Apply_Density ();

	//---- process each data field ----

	for (field=0, str_itr = data_names.begin (); str_itr != data_names.end (); str_itr++, field++) {
		Print (1);
		Write (1, "Processing Data Field ") << *str_itr;
		Show_Message (1);

		if (field >= function.Num_Functions ()) {
			best_function = function.Num_Functions ();
		} else {
			best_function = field + 1;
		}
		for (process_itr = processing_steps.begin (); process_itr != processing_steps.end (); process_itr++) {
			Processing (field, *process_itr);
		}
	}

	//---- output the results ----

	Write_Data ();

	//---- print reports ----

	for (int i=First_Report (); i != 0; i=Next_Report ()) {
		switch (i) {
			case GROUP_REPORT:		//---- Group Report ----
				Group_Report ((int) Report_Data ());
				break;
			default:
				break;
		}
	}

	Exit_Stat (DONE);
}
Example #2
0
void PlanPrep::Execute (void)
{
	int i;

	//---- read household lists ----

	if (hhlist_flag) {
		Read_HHList ();
	}

	//---- read the delete household lists ----

	if (delete_flag) {
		Read_Deletes ();
	}

	//---- read fix plan file ----

	if (fix_flag) {
		Read_Fix_Plans ();
	}

	//---- read the plan files ----

	if (sort_flag || merge_flag || subarea_flag || (!combine_flag && output_flag)) {

		size_flag = (max_size_flag && !(combine_flag && combine == FILE_COMBINE));

		for (nfile=0; ; nfile++) {
			first_out = true;

			//---- open the input plans ----

			if (!input_plans.Open (nfile)) break;

			//---- open the merge plans ----

			if (merge_flag) {
				if (!merge_plans.Open (nfile)) {
					File_Error ("Opening Merge Plan File", merge_plans.Filename ());
				}
			} else if (subarea_flag) {
				if (subpart_flag) {
					i = nfile;
				} else {
					i = 0;
					subarea_plans.Reset_Counters ();
				}
				if (!subarea_plans.Open (i)) {
					File_Error ("Opening Subarea Plan File", subarea_plans.Filename ());
				}
			}

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

			if (combine_flag && combine == MEMORY_COMBINE) {

				//---- sort the input plans ----

				Sort_Plans ();

			} else if (sort_flag) {

				//---- sort the input plans ----

				Sort_Plans ();

				//---- merge and/or write plans ----

				if (merge_flag) {
					Sort_Merge ();
				} else {
					Write_Plans ();
				}
				plan_list.Reset ();

			} else if (hhlist_flag) {

				Partition_Plans ();

			} else {

				//---- merge sorted files or copy to output file ----

				if (merge_flag) {
					File_Merge ();
				} else if (subarea_flag) {
					Subarea_Merge ();
				} else {
					Copy_Plans ();
				}
			}
		}
		if (nfile == 0) {
			File_Error ("No Plan Files were Found", input_plans.Filename ());
		}
	}

	//---- create combined output file ----

	if (combine_flag) {
		nout = 0;
		first_out = true;
		size_flag = max_size_flag;
		input_sort_flag = (sort_flag || input_sort_flag);

		output_plans.Filename (output_name);
		output_plans.Extend (extend);
		output_plans.Reset_Counters ();
		output_plans.File_Format ((binary_flag) ? BINARY : UNFORMATED);

		if (combine == MEMORY_COMBINE) {
			Write_Plans ();
			plan_list.Clear ();
		} else {
			File_Combine ();
		}

	} else if (hhlist_flag) {

		//---- close the files and clear the memory -----

		output_plans.Close ();

		for (i=0; i < nout; i++) {
			plan_file [i]->Close ();

			output_plans.Reset_Counters (output_plans.Num_Records () + plan_file [i]->Num_Records (),
										output_plans.Num_Plans () + plan_file [i]->Num_Plans (),
										output_plans.Num_Travelers () + plan_file [i]->Num_Travelers (),
										output_plans.Num_Trips () + plan_file [i]->Num_Trips ());
			delete plan_file [i];
		}
		delete [] plan_file;
	}

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

	Break_Check (6);

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

	if (one_leg_flag) {
		Write (2, "Number of One Leg Plans Deleted = %d", num_one_leg);
	}
	if (merge_flag) {
		Break_Check (7);

		Write (2, "Number of Merge Plans = %d", merge_plans.Num_Plans ());
        Write (1, "Number of Merge Records = %d", merge_plans.Num_Records ());
		Write (1, "Number of Merge Travelers = %d", merge_plans.Num_Travelers ());
		Write (1, "Number of Merge Trips = %d", merge_plans.Num_Trips ());
		Write (2, "Number of Replaced Travelers = %d", replaced);
	} else if (subarea_flag) {
		Break_Check (6);

		Write (2, "Number of Subarea Plans = %d", subarea_plans.Num_Plans ());
        Write (1, "Number of Subarea Records = %d", subarea_plans.Num_Records ());
		Write (1, "Number of Subarea Travelers = %d", subarea_plans.Num_Travelers ());
		Write (1, "Number of Subarea Trips = %d", subarea_plans.Num_Trips ());
		Write (1, "Number of Updated Travelers = %d", updated);
	}
	if (output_flag) {
		Break_Check (6);

		Write (2, "Number of Output Files = %d", nout);
		Write (1, "Number of Output Plans = %d", output_plans.Num_Plans ());
		Write (1, "Number of Output Records = %d", output_plans.Num_Records ());
		Write (1, "Number of Output Travelers = %d", output_plans.Num_Travelers ());
		Write (1, "Number of Output Trips = %d", output_plans.Num_Trips ());
	}
	
	//---- print reports ----

	for (i=First_Report (); i != 0; i=Next_Report ()) {
		switch (i) {
			case PATH_CHANGE:		//---- percent path change ----
				Path_Change ();
				break;
			case TIME_CHANGE:		//---- percent travel time change ---
				Travel_Time_Change ();
				break;
			case FIX_PLAN:			//---- fix plan list ----
				Fix_Plan_Report ();
				break;
			default:
				break;
		}
	}
	Exit_Stat (DONE);
}
Example #3
0
void PlanSum::Execute (void)
{
	int nfile, i, j, num;

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

	Demand_Service::Execute ();

	//---- prepare data ----

	Data_Preparation ();

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

	if (hhlist_flag) {
		Read_HHList ();
	}

	//---- read the household person count ----

	if (count_flag) {
		Read_Count ();
	}

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

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

		if (update_flag) {
			if (!new_plan_file.Open (nfile)) {
				Error ("Opening %s", new_plan_file.File_Type ());
			}
		}

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

		Read_Plans ();
	}

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

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

	Break_Check (6);

	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 ());

	if (update_flag) {
		Break_Check (5);

		Write (2, "Number of Output Plans = %d", new_plan_file.Num_Plans ());
		Write (1, "Number of Output Records = %d", new_plan_file.Num_Records ());
		Write (1, "Number of Output Travelers = %d", new_plan_file.Num_Travelers ());
		Write (1, "Number of Output Trips = %d", new_plan_file.Num_Trips ());
	}
	Write (1);

	//---- write the volume file ----

	if (volume_flag) {
		Write_Volume ();
	}

	//---- write the trip time file ----

	if (time_flag) {
		Diurnal_Distribution ();
	}

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

	if (delay_out) {
		Link_Delay ();
	}

	//---- transit ridership output ----

	if (transit_flag) {
		if (Demand_File_Flag (NEW_RIDERSHIP)) {
			Write_Riders ();
		}
	}

	//---- write the skim file ----

	if (skim_flag) {
		if (time_skim_flag) {
			if (length_flag) {
				Write_Time_Length ();
			} else {
				Write_Time ();
			}
		} else {
			Write_Skim ();
		}
	}

	//---- write the trip table ----

	if (trip_flag) {
		Write_Trips ();
	}

	//---- write the turn movements ----

	if (turn_flag) {
		Write_Turns ();
	}

	//---- print reports ----

	Show_Message ("Writing Performance Reports");	

	for (i=First_Report (); i != 0; i=Next_Report ()) {
		switch (i) {
			case TOP_100:			//---- Top 100 V/C Ratio Report ----
				Top_100_Report ();
				break;
			case VC_RATIO:			//---- All V/C Ratios Greater Than x.xx ---
				VC_Ratio (Report_Data ());
				break;
			case LINK_GROUP:		//---- Link Group Report -----
				Link_Group (Report_Data ());
				break;
			case SUM_RIDERS:		//---- Transit Ridership Report ----
				Transit_Report ();
				break;
			case SUM_STOPS:			//---- Transit Stop Report ----
				Stop_Report ();
				break;
			case SUM_TRANSFERS:		//---- Transit Transfer Report ----
				Transfer_Report (0);
				break;
			case XFER_DETAILS:		//---- Transit Transfer Details ----
				num = time_periods.Num_Ranges () * 2 + 1;

				for (j=1; j < num; j++) {
					Transfer_Report (j);
				}
				break;
			case STOP_GROUP:		//---- Transit Stop Group Report ----
				Stop_Group_Report ();
				break;
			case SUM_PASSENGERS:	//---- Transit Passenger Summary ----
				Passenger_Report ();
				break;
			case RIDER_GROUP:		//---- Transit Link Group Summary ----
				Rider_Group ();
				break;
			case TRIP_TIME:			//---- Trip Time Report ----
				Trip_Time ();
				break;
			case SUM_TRAVEL:		//---- Travel Summary Report ----
				Travel_Report ();
				break;
			default:
				break;
		}
	}
	Exit_Stat (DONE);
}
Example #4
0
void EventSum::Execute (void)
{

	//---- read the network and demand files ----

	Demand_Service::Execute ();

	max_hhold = MAX_INTEGER / Traveler_Scale ();

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

	if (hhlist_flag) {
		Read_HHList ();
	}

	//---- read input travel times ----

	if (time_in_flag) {
		Read_Times ();
	}

	//---- read activity file ----

	if (activity_flag) {
		Read_Activity ();
	}

	//---- read trip file ----

	if (trip_file_flag) {
		Read_Trips ();
	}

	//---- read the event file ----

	if (combine_flag) {
		Combine_Events ();
	} else {
		Read_Events ();
	}

	//---- select travelers ----

	if (select_flag) {
		Select_Travelers ();
	}

	//---- write travel time file ----

	if (time_file_flag) {
		Write_Events ();
	}

	//---- write time summary file ----

	if (time_sum_flag) {
		Write_Times ();
	}

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

	if (link_flag) {
		Write_Links ();
	}

	//---- write the time distribution file ----

	if (distrib_flag) {
		time_diff.Write_Distribution ();
	}

	//---- update plans ----

	if (update_flag) {
		Update_Plans ();
	}

	//---- write new household list ----

	if (new_hhold_flag) {
		Write_HHList ();
	}

	//---- print the comparison summary ----

	time_diff.Total_Summary ();

	//---- print reports ----

	Show_Message ("Writing Summary Reports");	

	for (int i=First_Report (); i != 0; i=Next_Report ()) {
		switch (i) {
			case TOP_100_TTIME:		//---- top 100 travel time differences ----
				Top_100_TTime_Report ();
				break;
			case TOTAL_DISTRIB:		//---- total difference distribution ----
			case TTIME_DISTRIB:		//---- time difference distributions ----
				time_diff.Time_Distribution (i);
				break;
			case PERIOD_SUM:		//---- time period summary ----
				time_diff.Period_Summary ();
				break;
			case TOP_100_LINK:
				Top_100_Link_Report ();
				break;
			case TOP_100_PERIOD:	//---- top 100 period events ----
				Top_100_Period_Report ();
				break;
			case LINK_EVENT:		//---- link event report -----
				Link_Event_Report ((int) Report_Data ());
				break;
			case GROUP_EVENT:		//---- group event report ----
				Group_Event_Report ((int) Report_Data ());
				break;
			case TRAVELER_SUM:		//---- traveler summary report ----
				Traveler_Sum_Report ();
				break;
			case EVENT_SUM:			//---- event summary report ----
				Event_Sum_Report ();
				break;
			default:
				break;
		}
	}
	Exit_Stat (DONE);
}
Example #5
0
void PlanPrep::Program_Control (void)
{
    int i, dump;
	char *str_ptr;

	Sort_Type input_sort;

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

	Demand_Service::Program_Control ();

	//---- open the input plans ----

	if (Get_Control_String (NODE_LIST_PATHS) != NULL) {
		type_flag = Get_Control_Flag (NODE_LIST_PATHS);
	}
	str_ptr = Get_Control_String (INPUT_PLAN_FILE);

	if (str_ptr == NULL) goto control_error;

	input_plans.File_Type ("Input Plan File");	

	str_ptr = Project_Filename (str_ptr, Extension ());

	Print_Filename (2, input_plans.File_Type (), str_ptr);

	input_plans.Filename (str_ptr);

	str_ptr = Get_Control_String (INPUT_PLAN_FORMAT);

	if (str_ptr != NULL) {
		input_plans.File_Format (str_ptr);
		Print (1, "%s Format = %s", input_plans.File_Type (), str_ptr);
	}
	input_plans.Node_Based_Flag (type_flag);

	if (!input_plans.Open (0)) {
		File_Error ("Opening Input Plan File", input_plans.Filename ());
	}
	type_flag = input_plans.Node_Based_Flag ();
	parts_flag = (input_plans.Extend () > 0);

	//---- input plan sort ----

	str_ptr = Get_Control_String (INPUT_PLAN_SORT);

	if (str_ptr != NULL) {
		Print (1, "Input Plan Sort = %s", str_ptr);

		if (str_cmp (str_ptr, "TRAVELER") == 0) {
			input_sort = TRAVELER_SORT;
		} else if (str_cmp (str_ptr, "TIME") == 0) {
			input_sort = TIME_SORT;
		} else {
			Error ("Unrecognized Input Plan Sort = %s", str_ptr);
		}
		input_plans.Plan_Sort (input_sort);
		input_sort_flag = true;
	} else {
		input_sort = input_plans.Plan_Sort ();
	}

	//---- open the merge plans ----

	str_ptr = Get_Control_String (MERGE_PLAN_FILE);

	if (str_ptr != NULL) {
		merge_plans.File_Type ("Merge Plan File");

		str_ptr = Project_Filename (str_ptr, Extension ());

		Print_Filename (2, merge_plans.File_Type (), str_ptr);

		merge_plans.Filename (str_ptr);
		merge_plans.Extend (input_plans.Extend ());

		str_ptr = Get_Control_String (MERGE_PLAN_FORMAT);

		if (str_ptr != NULL) {
			merge_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", merge_plans.File_Type (), str_ptr);
		}
		merge_plans.Node_Based_Flag (type_flag);

		if (!merge_plans.Open (0)) {
			File_Error ("Opening Merge Plan File", merge_plans.Filename ());
		}
		merge_flag = true;
		if (merge_plans.Node_Based_Flag () != type_flag) {
			Error ("Incompatible Plan Formats");
		}
	}

	//---- open the subarea plans ----

	str_ptr = Get_Control_String (SUBAREA_PLAN_FILE);

	if (str_ptr != NULL) {
		if (merge_flag) {
			Error ("Merge and Subarea Plans are Incompatible");
		}
		subarea_plans.File_Type ("Subarea Plan File");

		str_ptr = Project_Filename (str_ptr);

		subarea_plans.Filename (str_ptr);

		if (subarea_plans.Extend () > 0) {
			if (parts_flag) {
				subpart_flag = true;
			} else {
				str_ptr = subarea_plans.Pathname ();
				str_ptr = Project_Filename (str_ptr, Extension ());
				subarea_plans.Filename (str_ptr);
				subarea_plans.Extend (0);
			}
		}
		Print_Filename (2, subarea_plans.File_Type (), str_ptr);

		str_ptr = Get_Control_String (SUBAREA_PLAN_FORMAT);

		if (str_ptr != NULL) {
			subarea_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", subarea_plans.File_Type (), str_ptr);
		}
		subarea_plans.Node_Based_Flag (type_flag);

		if (!subarea_plans.Open (0)) {
			File_Error ("Opening Subarea Plan File", subarea_plans.Filename ());
		}
		subarea_flag = true;
		if (subarea_plans.Node_Based_Flag () != type_flag) {
			Error ("Incompatible Plan Formats");
		}
	}

	//---- open the output plans ----

	str_ptr = Get_Control_String (OUTPUT_PLAN_FILE);

	if (str_ptr != NULL) {
		output_plans.File_Type ("Output Plan File");

		str_ptr = Project_Filename (str_ptr, Extension ());

		Print_Filename (2, output_plans.File_Type (), str_ptr);

		output_plans.Filename (str_ptr);
		output_plans.File_Access (CREATE);

		str_cpy (output_name, sizeof (output_name), output_plans.Pathname ());
		extend = output_plans.Extend ();
		output_flag = true;

		str_ptr = Get_Control_String (OUTPUT_PLAN_FORMAT);

		if (str_ptr != NULL) {
			output_plans.File_Format (str_ptr);
			Print (1, "%s Format = %s", output_plans.File_Type (), str_ptr);

			binary_flag = (output_plans.File_Format () == BINARY);
		}
		output_plans.Node_Based_Flag (type_flag);

	} else if (merge_flag) {
		Error ("Plan Merging Requires an Output File");
	} else if (subarea_flag) {
		Error ("Subarea Merging Requires an Output File");
	}

	//---- plan sort option ----

	str_ptr = Get_Control_String (PLAN_SORT_OPTION);

	if (str_ptr != NULL && output_flag) {
		Print (2, "Plan Sort Option = %s", str_ptr);

		if (str_cmp (str_ptr, "TRAVELER") == 0) {
			sort = TRAVELER_SORT;
		} else if (str_cmp (str_ptr, "TIME") == 0) {
			if (merge_flag) {
				Error ("Plan Merging must be performed in TRAVELER Sort");
			}
			sort = TIME_SORT;
		} else {
			Error ("Unrecognized Plan Sort Option = %s", str_ptr);
		}
		if (!input_sort_flag || input_sort != sort) {
			input_plans.Plan_Memory (ALLOCATE_MEMORY);
			input_plans.Plan_Sort (sort);
			sort_flag = true;
		}
		if (sort_flag && subarea_flag) {
			Error ("Sorting and Subarea Merging are Incompatible");
		}
	}

	//---- plan combine option ----

	str_ptr = Get_Control_String (PLAN_COMBINE_OPTION);

	if (str_ptr != NULL && parts_flag && output_flag) {
		Print (2, "Plan Combine Option = %s", str_ptr);

		if (!input_sort_flag && !sort_flag) {
			Error ("The Input Sort or Sort Option are needed for Plan Combining");
		}
		if (str_cmp (str_ptr, "FILE") == 0) {
			combine = FILE_COMBINE;
		} else if (str_cmp (str_ptr, "MEMORY") == 0) {
			if (merge_flag) {
				Error ("Plan Merging and Memory Combining are Incompatible");
			} else if (subarea_flag) {
				Error ("Subarea Merging and Memory Combining are Incompatible");
			}
			if (sort_flag) {
				combine = MEMORY_COMBINE;
			} else {
				combine = FILE_COMBINE;
			}
		} else {
			Error ("Unrecognized Plan Combine Option = %s", str_ptr);
		}
		combine_flag = true;
	}

	//---- max plan size ----

	str_ptr = Get_Control_String (MAX_OUTPUT_PLAN_SIZE);

	if (str_ptr != NULL && (combine_flag || (!parts_flag && output_flag))) {
		Print (2, "Maximum Output Plan Size = %s megabytes", str_ptr);

		max_size = atol (str_ptr);

		if (max_size < 1 || max_size > 2048) {
			Error ("Maximum Output Plan Size %d is Out of Range (1-2048)", max_size);
		}
		max_size *= 1024 * 1024;
		max_size_flag = true;
	}

	//---- get the select traveler range ----
	
	str_ptr = Get_Control_String (SELECT_TRAVELER_RANGE);

	if (str_ptr != NULL) {
		Print (2, "Select Traveler Range = %s", str_ptr);

		if (!hhold_range.Add_Ranges (str_ptr)) {
			Error ("Select Traveler Range", str_ptr);
		}
		hhold_flag = true;
	}

	//---- get the select time periods ----
	
	str_ptr = Get_Control_String (SELECT_TIME_PERIODS);

	if (str_ptr != NULL) {
		Print (2, "Select Time Periods = %s", str_ptr);

		time_period.Format (Time_Step::HOURS);

		if (!time_period.Add_Ranges (str_ptr)) {
			File_Error ("Time Period Range", str_ptr);
		}
		time_flag = true;
	}

	//---- read the selection percentage ----

	str_ptr = Get_Control_String (SELECTION_PERCENTAGE);

	if (str_ptr != NULL) {
		if (input_sort != TRAVELER_SORT) {
			Error ("The Input Plans must be in Traveler order for Plan Selection");
		}
		Get_Double (str_ptr, &percent);

		if (percent < 0.1 || percent > 100.0) {
			Error ("Selection Percentage %.2lf is Out of Range (0.1-100.0)", percent);
		}
		Print (2, "Selection Percentage = %.2lf", percent);

		percent /= 100.0;
		select_flag = (percent != 1.0);
	}

	if ((time_flag || select_flag || hhold_flag) && subarea_flag) {
		Error ("Subarea Merging and Plan Selections are Incompatible");
	}

	//---- check plan partitions ----

	str_ptr = Get_Control_String (CHECK_PLAN_PARTITIONS);

	if (str_ptr != NULL) {
		check_flag = Get_Control_Flag (CHECK_PLAN_PARTITIONS);

		Print (2, "Check Plan Partitions = %s", str_ptr);

		if (check_flag) {
			partition.Initialize (sizeof (Partition));
		}
	}

	//---- update plan partitions ----

	str_ptr = Get_Control_String (UPDATE_PLAN_PARTITIONS);

	if (str_ptr != NULL) {
		partition_flag = Get_Control_Flag (UPDATE_PLAN_PARTITIONS);

		Print (2, "Update Plan Partitions = %s", str_ptr);
	}

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

	str_ptr = Get_Control_String (HOUSEHOLD_LIST);

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

		Print_Filename (2, hhlist_file.File_Type (), str_ptr);

		if (!hhlist_file.Open (0)) {
			File_Error ("Opening Household List File", hhlist_file.Filename ());
		}
		hhlist_flag = true;
	} else if (partition_flag) {
		Error ("Household Lists are required for Partition Updates");
	}

	if (hhlist_flag) {
		combine_flag = false;

		if (sort_flag) {
			Error ("Plan Sorting and Household Lists are Incompatible");
		}
		if (merge_flag) {
			Error ("Plan Merging and Household Lists are Incompatible");
		} else if (subarea_flag) {
			Error ("Subarea Merging and Household Lists are Incompatible");
		}
		if (check_flag) {
			Error ("Checking and Updating Plan Partitions are Incompatible");
		}
		if (!output_flag) {
			Error ("Output Plans are Required for Household Lists");
		}
		partition.Initialize (sizeof (Partition));
	}

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

	str_ptr = Get_Control_String (DELETE_HOUSEHOLD_LIST);

	if (str_ptr != NULL) {
		delete_file.File_Type ("Delete Household List");
		delete_file.Filename (Project_Filename (str_ptr));

		Print_Filename (2, delete_file.File_Type (), str_ptr);

		if (!delete_file.Open (0)) {
			File_Error ("Opening Delete Household List File", delete_file.Filename ());
		}
		delete_flag = true;
	}

	//---- get the delete one leg plans flag ----

	str_ptr = Get_Control_String (DELETE_ONE_LEG_PLANS);

	if (str_ptr != NULL) {
		one_leg_flag = Get_Control_Flag (DELETE_ONE_LEG_PLANS);

		Print (1, "Delete One Leg Plans = %s", str_ptr);
	}

	//---- get the fix plan file ----

	str_ptr = Get_Control_String (FIX_PLAN_FILE);

	if (str_ptr != NULL) {
		fix_file.File_Type ("Fix Plan File");

		if (!fix_file.Open (Project_Filename (str_ptr))) {
			File_Error ("Opening Fix Plan File", fix_file.Filename ());
		}
		fix_flag = true;
	}

	//---- merge by trip ----

	str_ptr = Get_Control_String (MERGE_BY_TRIP);

	if (str_ptr != NULL) {
		trip_flag = Get_Control_Flag (MERGE_BY_TRIP);

		Print (2, "Merge by Trip = %s", str_ptr);
	}

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

	if (select_flag || fix_flag) {
		str_ptr = Get_Control_String (RANDOM_NUMBER_SEED);

		if (str_ptr != NULL) {
			random.Seed (atoi (str_ptr));
		}
		Print (2, "Random Number Seed = %d", random.Seed ());
	}

	//---- check output file name ----

	if (output_flag) {
		output_plans.Plan_Sort (input_plans.Plan_Sort ());

		if (max_size_flag || !combine_flag) {
			extend = output_plans.Extend (input_plans.Extend ());
			if (extend == 0 && max_size_flag) {
				extend = output_plans.Extend (1);
			}
		}
		if (!hhlist_flag || !delete_flag) {
			if (!output_plans.Open (0)) {
				File_Error ("Creating Output Plan File", output_plans.Filename ());
			}
		}
		if (combine_flag && combine == FILE_COMBINE && (sort_flag || merge_flag || subarea_flag)) {

			//---- set the temporary output filename ----

			output_plans.Filename (Filename (output_name, TEMP_LABEL));
			output_plans.Extend (input_plans.Extend ());
			output_plans.File_Format (BINARY);
		}
	}
	
	//---- read report types ----

	compare_flag = path_flag = false;
	dump_path = dump_time = MAX_INTEGER;

	for (i=First_Report (); i != 0; i=Next_Report ()) {
		if (i != FIX_PLAN) compare_flag = true;

		if (i == PATH_CHANGE || i == DUMP_PATH_CHANGES) {
			path_flag = true;
			if (i == DUMP_PATH_CHANGES) {
				dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5);
				if (dump < dump_path) {
					dump_path = dump;
				}
			}
		} else if (i == DUMP_TIME_CHANGES) {
			dump = (int) (Report_Data () * NUM_CHANGE_BINS / 100.0 + 0.5);
			if (dump < dump_time) {
				dump_time = dump;
			}
		}
	}

	if (compare_flag) {
		if (!merge_flag) {
			Write (1);
			Warning ("Change Reports require a Merge Plan File");
			compare_flag = false;
		}
		memset (time_changes, '\0', sizeof (time_changes));
		memset (path_changes, '\0', sizeof (path_changes));

		increment = MIDNIGHT / TOTAL_TIME_PERIOD;
	}
	return;

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

control_error:
	Error ("Missing Control Key = %s", Current_Key ());
} 
Example #6
0
void CheckSurvey::Execute (void)
{
	
	//---- read the household type script ----

	if (survey_type_flag) {
		Type_Script ();
		Flush ();
	}

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

	if (hhlist_flag) {
		Household_List ();
	}	

	//---- read the survey files ----

	Survey_Households ();

	if (weight_flag) {
		Survey_Weights ();
	}
	Survey_Population ();

	Survey_Activity ();

	//---- print reports ----

	for (int i=First_Report (); i != 0; i=Next_Report ()) {
		switch (i) {
			case SURVEY_TYPE:		//---- Survey Type Summary ----
				Type_Report ();
				break;
			case TRIP_LENGTH:
				trip_length.Report (TRIP_LENGTH, "Trip Length Summary", "Purpose");
				break;
			case TOUR_LENGTH:
				tour_length.Report (TOUR_LENGTH, "Tour Length Summary", "Purpose");
				break;
			case TRIP_PURPOSE:
				trip_purpose.Report (TRIP_PURPOSE, "Trip Purpose Summary", " ", "Purpose");
				break;
			case TOUR_PURPOSE:	
				tour_purpose.Report (TOUR_PURPOSE, "Tour Purpose Summary", "Purpose", "-Stops");
				break;
			case MODE_LENGTH:
				mode_length.Report (MODE_LENGTH, "Mode Length Summary", " Mode");
				break;
			case MODE_PURPOSE:	
				mode_purpose.Report (MODE_PURPOSE, "Mode Purpose Summary", " Mode-", "Purpose");
				break;
			default:
				break;
		}
	}

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

	Print (2, "Number of Households = %d", nhhold);
	Print (1, "Number of Persons = %d", nperson);
	Print (1, "Number of Workers = %d", nwork);

	if (nhhold == 0) nhhold = 1;

	Print (2, "Persons per Household = %.2lf", (double) nperson / nhhold);
	Print (1, "Workers per Household = %.2lf", (double) nwork / nhhold);

	if (nperson == 0) nperson = 1;

	if (num_problem > 0 || num_act_gen != num_activity) {
		Print (2, "Number of Activities Generated = %d", num_act_gen);

		if (num_problem > 0) {
			Print (1, "Number of Activities with Problems = %d (%.1lf%%)", num_problem,
				(100.0 * num_problem / num_act_gen));
		}
		Print (1, "Number of Activities Written = %d (%.1lf%%)", num_activity,
			(100.0 * num_activity / num_act_gen));
	} else {
		Print (2, "Number of Activities = %d", num_activity);
	}
	Print (2, "Activities per Household = %.2lf", (double) num_activity / nhhold);
	Print (1, "Activities per Person = %.2lf", (double) num_activity / nperson);

	if (nproblem) {
		Write (2, "Number of Households with Problems = %d (%.1lf%%)", nproblem,
			(100.0 * nproblem / survey_hh_data.Num_Records ()));
	}
	Report_Problems ();

	Exit_Stat (DONE);
}