Example #1
0
	double Leg_Cost (void)            { return (Get_Double (leg_cost)); }
Example #2
0
	double Offset (void)              { return (Get_Double (offset)); }
Example #3
0
static VALUE
math_atan(VALUE unused_obj, VALUE x)
{
    return DBL2NUM(atan(Get_Double(x)));
}
Example #4
0
static VALUE
math_hypot(VALUE obj, VALUE x, VALUE y)
{
    return DBL2NUM(hypot(Get_Double(x), Get_Double(y)));
}
Example #5
0
	double Distance (void)            { return (Get_Double (distance)); }
Example #6
0
static VALUE
math_tan(VALUE obj, VALUE x)
{
    return DBL2NUM(tan(Get_Double(x)));
}
Example #7
0
static VALUE
math_cbrt(VALUE obj, VALUE x)
{
    return DBL2NUM(cbrt(Get_Double(x)));
}
Example #8
0
	double RT_Length (void)           { return (Get_Double (rt_length)); }
Example #9
0
	double RM_Length (void)           { return (Get_Double (rm_length)); }
Example #10
0
	double LM_Length (void)           { return (Get_Double (lm_length)); }    
Example #11
0
	double LT_Length (void)           { return (Get_Double (lt_length)); }
Example #12
0
	double Factor (void)              { return (Get_Double (factor)); }
Example #13
0
void Snapshot_Output::Read_Control (int steps_per_second)
{
	if (exe == NULL) return;

	//---- read the output snapshot data ----

	int i, num;

	num = exe->Highest_Control_Group (OUTPUT_SNAPSHOT_FILE_x, 0);

	if (num != 0) {
		Output_Data *output;
		char *str_ptr, buffer [FIELD_BUFFER];
		int increment;

		//---- allocate array space ----

		if (!output_data.Max_Records (num)) {
			exe->Error ("Insufficient Memory for %d Output Snapshot Groups", num);
		}

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

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

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_FILE_x, i);

			if (str_ptr == NULL) continue;

			char *name_ptr = exe->Project_Filename (str_ptr);

			output = (Output_Data *) output_data.New_Record ();

			output->time_range = new Time_Range (steps_per_second);
			output->link_range = NULL;
			output->coord_flag = false;
			output->size_flag = false;
			output->max_size = 0;

			output->file = new Snapshot_File (Db_Code::CREATE);

			exe->Break_Check (7);
			exe->Print (1);
			str_fmt (buffer, sizeof (buffer), "Output Snapshot File #%d", i);

			output->file->File_Type (buffer);

			//---- set the output format ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_FORMAT_x, i);

			if (str_ptr != NULL) {
				output->file->Dbase_Format (str_ptr);
			}
			if (exe->Get_Control_Flag (OUTPUT_SNAPSHOT_LOCATION_FLAG_x, i) ||
				output->file->Dbase_Format () == Db_Code::VERSION3) {
				output->file->Location_Flag (true);
			}
			output->file->Open (name_ptr);

			//---- get the time format ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_TIME_FORMAT_x, i);

			if (str_ptr != NULL) {
				if (!output->time_range->Format (str_ptr)) {
					exe->Error ("Output Snapshot Time Format %s was Unrecognized", str_ptr);
				}
				exe->Print (1, "Output Snapshot Time Format #%d = %s", i, output->time_range->Time_Code ());
			}

			//---- get the increment ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_INCREMENT_x, i);

			if (str_ptr != NULL) {
				output->time_range->Increment (str_ptr);
				increment = output->time_range->Increment ();

				if (increment < 1 || increment > output->time_range->Duration ("1:00")) {
					exe->Error ("Output Snapshot Increment %s is Out of Range", 
						output->time_range->Format_Duration (increment));
				}
			} else {
				output->time_range->Increment ("0:15");
				increment = output->time_range->Increment ();
			}
			exe->Print (1, "Output Snapshot Increment #%d = %s", i, 
				output->time_range->Format_Duration (increment));

			if (output->time_range->Format () == Time_Step::SECONDS) {
				exe->Print (0, " second%c", (increment != output->time_range->Duration (1) ? 's' : ' '));
			} else if (output->time_range->Format () == Time_Step::HOURS) {
				exe->Print (0, " hour%c", (increment != output->time_range->Duration (1.0) ? 's' : ' '));
			}

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

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_TIME_RANGE_x, i);

			if (str_ptr != NULL) {
				if (!output->time_range->Add_Ranges (str_ptr)) {
					exe->File_Error ("Output Snapshot Time Range", str_ptr);
				}
				exe->Print (1, "Output Snapshot Time Range #%d = ", i);

				for (int j=1; j <= output->time_range->Num_Ranges (); j++) {
					str_ptr = output->time_range->Range_Format (j);

					if (str_ptr != NULL) {
						exe->Print (0, "%s ", str_ptr);
					}
				}
				if (output->time_range->Format () == Time_Step::SECONDS) {
					exe->Print (0, "seconds");
				} else if (output->time_range->Format () == Time_Step::HOURS) {
					exe->Print (0, "hours");
				}
			} else {
				output->time_range->Add_Ranges ("All");
			}

			//---- get the link range ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_LINK_RANGE_x, i);

			if (str_ptr != NULL) {
				exe->Print (1, "Output Snapshot Link Range #%d = %s", i, str_ptr);

				output->link_range = new Data_Range ();

				if (!output->link_range->Add_Ranges (str_ptr)) {
					exe->File_Error ("Output Snapshot Link Range", str_ptr);
				}
				if (output->link_range->Num_Ranges () == 0) {
					delete output->link_range;
					output->link_range = NULL;
				}
			}

			//---- get the coordinates ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_COORDINATES_x, i);

			if (str_ptr != NULL) {
				double dvalue;
				Network_Service *net = (Network_Service *) exe;

				exe->Print (1, "Output Snapshot Coordinates #%d = %s", i, str_ptr);

				str_ptr = Get_Double (str_ptr, &dvalue);
				output->x1 = net->Round (dvalue);

				if (str_ptr == NULL) goto coord_error;

				str_ptr = Get_Double (str_ptr, &dvalue);
				output->y1 = net->Round (dvalue);

				if (str_ptr == NULL) goto coord_error;

				str_ptr = Get_Double (str_ptr, &dvalue);
				output->x2 = net->Round (dvalue);
				if (output->x2 < output->x1) {
					int x = output->x2;
					output->x2 = output->x1;
					output->x1 = x;
				}

				if (str_ptr == NULL) goto coord_error;

				str_ptr = Get_Double (str_ptr, &dvalue);
				output->y2 = net->Round (dvalue);
				if (output->y2 < output->y1) {
					int y = output->y2;
					output->y2 = output->y1;
					output->y1 = y;
				}
				output->coord_flag = true;
			}

			//---- get the max size ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_MAX_SIZE_x, i);

			if (str_ptr != NULL) {
				int size = atoi (str_ptr);

				if (size < 0 || size > 2048) {
					exe->Error ("Output Snapshot Maximum Size %d is Out of Range (0..2048)", size);
				}
				output->max_size = size * 1024 * 1024;

				exe->Print (1, "Output Snapshot Maximum Size #%d = %d megabytes", i, size);
			}

			//---- get the location flag ----

			str_ptr = exe->Get_Control_String (OUTPUT_SNAPSHOT_LOCATION_FLAG_x, i);

			if (str_ptr != NULL) {
				exe->Print (1, "Output Snapshot Location Flag #%d = %s", i, str_ptr);
			}
			if (output->file->Dbase_Format () == Db_Code::VERSION3) {
				output->time_range->Format (Time_Step::SECONDS);
			}

			if (!output_data.Add ()) {
				exe->Error ("Adding Snapshot Output Group");
			}
			output_flag = true;
		}
	}
	return;

coord_error:
	exe->Error ("Output Snapshot Coordinate Data #%d", i);
}
Example #14
0
void PlanSelect::Program_Control (void)
{
	int i, nsel, lvalue;
	char *str_ptr, buffer [FIELD_BUFFER];
	double dvalue;
	Box box;

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

	Demand_Service::Program_Control ();

	//---- open the plan file ----
	
	if (Get_Control_String (NODE_LIST_PATHS) != NULL) {
		type_flag = Get_Control_Flag (NODE_LIST_PATHS);
	}
	str_ptr = Get_Control_String (PLAN_FILE);

	if (str_ptr == NULL) goto control_error;

	str_ptr = Project_Filename (str_ptr, Extension ());

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

	plan_file.Filename (str_ptr);

	str_ptr = Get_Control_String (PLAN_FORMAT);

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

	if (!plan_file.Open (0)) {
		File_Error ("Opening Plan File", plan_file.Filename ());
	}
	type_flag = plan_file.Node_Based_Flag ();

	//---- node list paths ----

	if (type_flag) {
		Print (1, "Plan File contains Node List Paths");
	} else {
		Print (1, "Plan File contains Link List Paths");
	}

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

	if (Demand_File_Flag (LINK_DELAY)) {
		Delay_File *file = (Delay_File *) Demand_Db_File (LINK_DELAY);

		if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) {
			Error ("Link and Node files are Required for Link Delay Processing");
		}
		if (file->Dbase_Format () == VERSION3) {
			turn_flag = false;
			Network_File_False (LANE_CONNECTIVITY);
		} else if (!Network_File_Flag (LANE_CONNECTIVITY)) {
			Warning ("Lane Connectivity is required for Turning Delays");
			Show_Message (1);
			turn_flag = false;
		} else {
			turn_flag = true;
		}
		delay_flag = true;
	} else {
		Network_File_False (LANE_CONNECTIVITY);
	}

	//---- open the population file ----

	str_ptr = Get_Control_String (POPULATION_FILE);

	if (str_ptr != NULL) {
		pop_file.File_Type ("Population File");
		Print (1);

		pop_file.Open (str_ptr);
		pop_flag = true;
	}

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

	str_ptr = Get_Control_String (NEW_HOUSEHOLD_LIST);

	if (str_ptr != NULL) {
		hhlist_file.File_Type ("New Household List");
		hhlist_file.File_Access (CREATE);

		str_ptr = Project_Filename (str_ptr, Extension ());
		hhlist_file.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 ());
		}
		if (hhlist_file.Extend () == 0 && plan_file.Extend () != 0) {
			Warning ("Household List File is Not Partitioned");
		}
	} else {
		str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FILE);

		if (str_ptr == NULL) {
			Error ("A New Household List or Household Record File is Required");
		}
		hhrec_flag = true;
		hhrec_file.File_Access (CREATE);

		str_ptr = Project_Filename (str_ptr, Extension ());
		hhrec_file.Filename (str_ptr);

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

		str_ptr = Get_Control_String (NEW_HOUSEHOLD_RECORD_FORMAT);

		if (str_ptr != NULL) {
			hhrec_file.Dbase_Format (str_ptr);
			Print (1, "%s Format = %s", hhrec_file.File_Type (), str_ptr);
		}
		if (!hhrec_file.Open (0)) {
			File_Error ("Opening Household Record file", hhrec_file.Filename ());
		}
		if (hhrec_file.Extend () == 0 && plan_file.Extend () != 0) {
			Warning ("Household Record File is Not Partitioned");
		}
	}

	//---- get the select travelers ----
	
	str_ptr = Get_Control_String (SELECT_TRAVELERS);

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

		if (!travelers.Add_Ranges (str_ptr)) {
			File_Error ("Traveler ID Range", str_ptr);
		}
	}
	
	//---- get the select nodes ----

	nsel = Highest_Control_Group (SELECT_NODES_x, 0);

	if (nsel > 0) {

		nodes.Max_Records (nsel);

		for (i=1; i <= nsel; i++) {
			str_ptr = Get_Control_String (SELECT_NODES_x, i);

			if (str_ptr == NULL) continue;

			Print (2, "Select Nodes for Group #%d = %s", i, str_ptr);

			Data_Range *ptr = new Data_Range ();

			if (!ptr->Add_Ranges (str_ptr)) {
				File_Error ("Path Node Numbers", str_ptr);
			}
			if (!nodes.Add (ptr)) {
				Error ("Adding Node Ranges to the List");
			}
		}
	}
	
	//---- get the select links ----

	nsel = Highest_Control_Group (SELECT_LINKS_x, 0);

	if (nsel > 0) {

		links.Max_Records (nsel);

		for (i=1; i <= nsel; i++) {
			str_ptr = Get_Control_String (SELECT_LINKS_x, i);

			if (str_ptr == NULL) continue;

			Print (2, "Select Links for Group #%d = %s", i, str_ptr);

			Data_Range *ptr = new Data_Range (1, -MAX_INTEGER, MAX_INTEGER, 0);

			if (!ptr->Add_Ranges (str_ptr)) {
				File_Error ("Path Link Numbers", str_ptr);
			}
			if (!links.Add (ptr)) {
				Error ("Adding Link Ranges to the List");
			}
		}
	}

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

		times.Format (Time_Step::HOURS);

		if (!times.Add_Ranges (str_ptr)) {
			File_Error ("Time Period Range", str_ptr);
		}
	}
	
	//---- get the select travel modes ----

	str_ptr = Get_Control_String (SELECT_TRAVEL_MODES);

	if (str_ptr != NULL) {

		Print (2, "Select Travel Modes = %s", str_ptr);

		memset (mode_flag, '\0', sizeof (mode_flag));
		nsel = 0;

		while (str_ptr != NULL) {
			char *old_ptr = str_ptr;

			str_ptr = Get_Integer (str_ptr, &i);

			if (i < 0 || i > DRIVER_MODE || (i == 0 && *old_ptr != '0')) {
				Error ("Selected Travel Mode %s is Out of Range (0..%d)", old_ptr, DRIVER_MODE);
			}
			mode_flag [i] = true;
			nsel++;
		}
		if (nsel == 0) {
			Error ("No Modes were Selected for Processing");
		}
	} else {
		for (i=0; i <= DRIVER_MODE; i++) {
			mode_flag [i] = true;
		}
	}

	//---- get the select facility types ----

	str_ptr = Get_Control_String (SELECT_FACILITY_TYPES);

	if (str_ptr != NULL) {

		Print (2, "Select Facility Types = %s", str_ptr);

		factype_flag = true;
		memset (facility_flag, '\0', sizeof (facility_flag));
		nsel = 0;

		while (str_ptr != NULL) {
			str_ptr = Get_Token (str_ptr, buffer, sizeof (buffer));
			if (buffer [0] == '\0') break;

			i = Facility_Code (buffer);
			facility_flag [i] = true;
			nsel++;
		}
		if (nsel == 0) {
			Error ("No Facility Types were Selected for Processing");
		}
	}

	//---- get the select locations ----
	
	str_ptr = Get_Control_String (SELECT_LOCATIONS);

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

		if (!locations.Add_Ranges (str_ptr)) {
			File_Error ("Activity Location Range", str_ptr);
		}
	}

	//---- get the select parking lots ----
	
	str_ptr = Get_Control_String (SELECT_PARKING_LOTS);

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

		if (!parking_lots.Add_Ranges (str_ptr)) {
			File_Error ("Parking Lot Range", str_ptr);
		}
	}

	//---- get the select transit stops ----
	
	str_ptr = Get_Control_String (SELECT_TRANSIT_STOPS);

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

		if (!transit_stops.Add_Ranges (str_ptr)) {
			File_Error ("Transit Stop Range", str_ptr);
		}
	}

	//---- get the select transit routes ----
	
	str_ptr = Get_Control_String (SELECT_TRANSIT_ROUTES);

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

		if (!transit_routes.Add_Ranges (str_ptr)) {
			File_Error ("Transit Route Range", str_ptr);
		}
	}

	//---- get the select vc ratio ----

	str_ptr = Get_Control_String (SELECT_VC_RATIOS);

	if (str_ptr != NULL) {
		if (!delay_flag) {
			Error ("Select V/C Ratios requires a Link Delay file");
		}
		vc_flag = true;
		Get_Double (str_ptr, &vc_ratio);

		if (vc_ratio < 1.0) {
			Error ("Select V/C Ratios %.2lf is Out of Range (>= 1.0)", vc_ratio);
		}
		Print (2, "Select V/C Ratios >= %.2lf", vc_ratio);
	}

	//---- get the select time ratio ----

	str_ptr = Get_Control_String (SELECT_TIME_RATIOS);

	if (str_ptr != NULL) {
		if (!delay_flag) {
			Error ("Select Travel Time Ratios requires a Link Delay file");
		}
		ratio_flag = true;
		Get_Double (str_ptr, &time_ratio);

		if (time_ratio < 1.0) {
			Error ("Select Time Ratios %.2lf is Out of Range (>= 1.0)", time_ratio);
		}
		Print (2, "Select Time Ratios >= %.2lf", time_ratio);
	}

	//---- get the select coordinates ----

	nsel = Highest_Control_Group (SELECT_COORDINATES_x, 0);

	for (i=0; i <= nsel; i++) {
		if (i == 0) {
			str_ptr = Get_Control_String (SELECT_COORDINATES);
		} else {
			str_ptr = Get_Control_String (SELECT_COORDINATES_x, i);
		}
		if (str_ptr == NULL) continue;

		if (!Network_File_Flag (NODE)) {
			Error ("Select Coordinates requires a Node file");
		}
		coord_flag = true;

		if (i == 0) {
			Print (2, "Select Coordinates = %s", str_ptr);
		} else {
			if (coord_box.Num_Records () == 0) Print (1);

			Print (1, "Select Coordinates #%d = %s", i, str_ptr);
		}
		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x1 = Round (dvalue);

		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y1 = Round (dvalue);

		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x2 = Round (dvalue);

		if (box.x2 < box.x1) {
			lvalue = box.x2;
			box.x2 = box.x1;
			box.x1 = lvalue;
		}
		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y2 = Round (dvalue);

		if (box.y2 < box.y1) {
			lvalue = box.y2;
			box.y2 = box.y1;
			box.y1 = lvalue;
		}
		if (!coord_box.Add (&box)) goto mem_error;
	}

	//---- get the select od coordinates ----

	nsel = Highest_Control_Group (SELECT_OD_COORDINATES_x, 0);

	for (i=0; i <= nsel; i++) {
		if (i == 0) {
			str_ptr = Get_Control_String (SELECT_OD_COORDINATES);
		} else {
			str_ptr = Get_Control_String (SELECT_OD_COORDINATES_x, i);
		}
		if (str_ptr == NULL) continue;

		if (!Network_File_Flag (NODE)) {
			Error ("Select OD Coordinates requires a Node file");
		}
		in_flag = true;

		if (i == 0) {
			Print (2, "Select OD Coordinates = %s", str_ptr);
		} else {
			if (od_box.Num_Records () == 0) Print (1);

			Print (1, "Select OD Coordinates #%d = %s", i, str_ptr);
		}
		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x1 = Round (dvalue);

		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y1 = Round (dvalue);

		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x2 = Round (dvalue);

		if (box.x2 < box.x1) {
			lvalue = box.x2;
			box.x2 = box.x1;
			box.x1 = lvalue;
		}
		if (str_ptr == NULL) goto coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y2 = Round (dvalue);

		if (box.y2 < box.y1) {
			lvalue = box.y2;
			box.y2 = box.y1;
			box.y1 = lvalue;
		}
		if (!od_box.Add (&box)) goto mem_error;
	}

	//---- get the exclude od coordinates ----

	nsel = Highest_Control_Group (EXCLUDE_OD_COORDINATES_x, 0);

	for (i=0; i <= nsel; i++) {
		if (i == 0) {
			str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES);
		} else {
			str_ptr = Get_Control_String (EXCLUDE_OD_COORDINATES_x, i);
		}
		if (str_ptr == NULL) continue;

		if (!Network_File_Flag (NODE)) {
			Error ("Excludet OD Coordinates requires a Node file");
		}
		out_flag =  true;

		if (i == 0) {
			Print (2, "Exclude OD Coordinates = %s", str_ptr);
		} else {
			if (exclude_box.Num_Records () == 0) Print (1);

			Print (1, "Excludet OD Coordinates #%d = %s", i, str_ptr);
		}
		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x1 = Round (dvalue);

		if (str_ptr == NULL) goto od_coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y1 = Round (dvalue);

		if (str_ptr == NULL) goto od_coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.x2 = Round (dvalue);

		if (box.x2 < box.x1) {
			lvalue = box.x2;
			box.x2 = box.x1;
			box.x1 = lvalue;
		}
		if (str_ptr == NULL) goto od_coord_error;

		str_ptr = Get_Double (str_ptr, &dvalue);
		box.y2 = Round (dvalue);

		if (box.y2 < box.y1) {
			lvalue = box.y2;
			box.y2 = box.y1;
			box.y1 = lvalue;
		}
		if (!exclude_box.Add (&box)) goto mem_error;
	}

	//---- get the select subarea polygon ----

	str_ptr = Get_Control_String (SELECT_SUBAREA_POLYGON);

	if (str_ptr != NULL) {
		if (!Network_File_Flag (LINK) || !Network_File_Flag (NODE)) {
			Error ("Link and Node files are Required for Subarea Polygon Selection");
		}
		Print (1);
		select_subarea.File_Type ("Select Subarea Polygon");

		select_subarea.Open (Project_Filename (str_ptr));
		
		if (!select_subarea.Read_Record ()) {
			Error ("Reading %s", select_subarea.File_Type ());
		}
		subarea_flag = true;
	}

	//---- get the select vehicle types ----
	
	str_ptr = Get_Control_String (SELECT_VEHICLE_TYPES);

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

		if (!vehicle_types.Add_Ranges (str_ptr)) {
			File_Error ("Vehicle Type Range", str_ptr);
		}
		vehicle_flag = true;
		if (!Demand_File_Flag (VEHICLE)) {
			Error ("A Vehicle File is Required for Vehicle Type Selection");
		}
	} else {
		Demand_File_False (VEHICLE);
	}

	//---- get the percent time difference ----

	str_ptr = Get_Control_String (PERCENT_TIME_DIFFERENCE);

	if (str_ptr != NULL) {
		if (!delay_flag) {
			Error ("Percent Time Difference requires a Link Delay file");
		}
		diff_flag = true;
        Get_Double (str_ptr, &percent_diff);

		if (percent_diff < 0.1 || percent_diff > 100.0) {
			Error ("Percent Time Difference %.2lf is Out of Range (0.1-100.0)", percent_diff);
		}
		Print (2, "Percent Time Difference = %.1lf%%", percent_diff);

		percent_diff /= 100.0;

		//---- get the minimum time difference ----

		str_ptr = Get_Control_String (MINIMUM_TIME_DIFFERENCE);

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

			if (min_time < 0 || min_time > 120) {
				Error ("Minimum Time Difference %d is Out of Range (0-120)", min_time);
			}
		}
		Print (1, "Minimum Time Difference = %d minute%s", 
			min_time, ((min_time != 1) ? "s" : " "));

		//---- get the maximum time difference ----

		str_ptr = Get_Control_String (MAXIMUM_TIME_DIFFERENCE);

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

			if (max_time < min_time || max_time > 1440) {
				Error ("Maximum Time Difference %d is Out of Range (%d-1440)", max_time, min_time);
			}
		}
		Print (1, "Maximum Time Difference = %d minutes", max_time);

		min_time *= 60;
		max_time *= 60;
	}

	//---- get the selection percentage ----

	str_ptr = Get_Control_String (SELECTION_PERCENTAGE);

	if (str_ptr != NULL) {
		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);
		}
		select_flag = (percent != 100.0);
	}
	Print (2, "Selection Percentage = %.1lf%%", percent);

	percent /= 100.0;

	//---- get the max percent selected ----

	str_ptr = Get_Control_String (MAXIMUM_PERCENT_SELECTED);

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

		if (max_percent < 1.0 || max_percent > 100.0) {
			Error ("Maximum Percent Selected %.1lf is Out of Range (1.0-100.0)", max_percent);
		}
	}
	Print (1, "Maximum Percent Selected = %.1lf%%", max_percent);

	max_percent /= 100.0;

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

	str_ptr = Get_Control_String (RANDOM_NUMBER_SEED);

	if (str_ptr != NULL) {
		random.Seed (atoi (str_ptr));
	}
	if (str_ptr != NULL || percent != 1.0 || max_percent != 1.0) {
		Print (1, "Random Number Seed = %d", random.Seed ());
	}

	//---- reset the network flags ----

	if (!vc_flag && !diff_flag && !ratio_flag) {
		delay_flag = parking_flag = turn_flag = false;
		Demand_File_False (LINK_DELAY);
		Network_File_False (LANE_USE);
		Network_File_False (PARKING);
		Network_File_False (LANE_CONNECTIVITY);

		if (!coord_flag && !out_flag && !in_flag && !subarea_flag && !factype_flag && 
			nodes.Num_Records () == 0 && links.Num_Records () == 0) {
			Network_File_False (LINK);
			Network_File_False (NODE);
			Network_File_False (TRANSIT_STOP);
			Network_File_False (TRANSIT_DRIVER);
		} else if (!factype_flag && type_flag && links.Num_Records () == 0) {
			Network_File_False (LINK);
		}
	} else {
		parking_flag = Network_File_Flag (PARKING);

		if (!diff_flag) {
			turn_flag = false;
			Network_File_False (LANE_CONNECTIVITY);
		}
	}
	transit_flag = (Network_File_Flag (TRANSIT_STOP) && Network_File_Flag (TRANSIT_DRIVER));

	return;

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

control_error:
	Error ("Missing Control Key = %s", Current_Key ());

coord_error:
	Error ("Select Coordinates are Incomplete");

od_coord_error:
	Error ("Exclude OD Coordinates are Incomplete");

mem_error:
	Error ("Insufficient Memory for Coordinate Groups");
} 
Example #15
0
	double Max_X (void)             { return (Get_Double (max_x)); }
Example #16
0
void DynusTPlan::Program_Control (void)
{
	int increment;
	char *str_ptr, buffer [STRING_BUFFER];

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

	Demand_Service::Program_Control ();

	if (Demand_File_Flag (VEHICLE) && !Demand_File_Flag (VEHICLE_TYPE)) {
		Error ("A Vehicle Type File is needed to Convert Vehicle IDs to Type Codes");
	}
	if (!Demand_File_Flag (VEHICLE) && Demand_File_Flag (VEHICLE_TYPE)) {
		Error ("A Vehicle File is needed to Convert Vehicle IDs to Type Codes");
	}

	//---- open the plan file ----
	
	if (Get_Control_String (NODE_LIST_PATHS) != NULL) {
		type_flag = Get_Control_Flag (NODE_LIST_PATHS);
	}
	str_ptr = Get_Control_String (PLAN_FILE);

	if (str_ptr == NULL) goto control_error;

	str_ptr = Project_Filename (str_ptr, Extension ());

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

	plan_file.Filename (str_ptr);
	plan_file.Plan_Sort (TIME_SORT);

	str_ptr = Get_Control_String (PLAN_FORMAT);

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

	if (!plan_file.Open (0)) {
		File_Error ("Opening Plan File", plan_file.Filename ());
	}
	type_flag = plan_file.Node_Based_Flag ();

	//---- node list paths ----

	if (type_flag) {
		Print (1, "Plan File contains Node List Paths");
	} else {
		Print (1, "Plan File contains Link List Paths");
	}

	//---- get output time increment ----
	
	str_ptr = Get_Control_String (OUTPUT_TIME_INCREMENT);

	if (str_ptr != NULL) {
		increment = atol (str_ptr);

		if (increment < 0 || increment > 240) {
			Error ("Output Time Increment %d is Out of Range (0-240)", increment);
		}
		increment *= 60;
	}
	if (!increment == 0) {
		time_range.Period_Flag (true);
	}
	time_range.Increment (increment);

	//---- get the select time period ----
	
	str_ptr = Get_Control_String (SELECT_TIME_PERIOD);

	time_range.Format (Time_Step::CLOCK24);

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

		if (!time_range.Add_Ranges (str_ptr)) {
			File_Error ("Time Period Range", str_ptr);
		}
	} else {
		time_range.Add_Ranges ("0:00..24:00");
	}
	if (increment > 0) {
		Print (1, "Output Time Increment = %d minutes", (increment / 60));
	}
	start_time = time_range.First ()->Low ();

	//---- get the selection percentage ----

	str_ptr = Get_Control_String (SELECTION_PERCENTAGE);

	if (str_ptr != NULL) {
		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);
		}
		select_flag = (percent != 100.0);
	}
	Print (2, "Selection Percentage = %.1lf%%", percent);

	percent /= 100.0;

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

	str_ptr = Get_Control_String (RANDOM_NUMBER_SEED);

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

	//---- get the DynusT directory  ----
	
	str_ptr = Get_Control_String (DYNUST_PLAN_DIRECTORY);

	if (str_ptr == NULL) goto control_error;
	str_cpy (plan_dir, sizeof (plan_dir), Project_Filename (str_ptr));

	Print (2, "DynusT Plan Directory = %s", plan_dir);

	//---- vehicle.dat ----

	veh_file.File_Type ("DynusT Vehicle File");

	str_fmt (buffer, sizeof (buffer), "%s/vehicle.dat", plan_dir);

	veh_file.Create (buffer);

	//---- path.dat ----

	path_file.File_Type ("DynusT Path File");

	str_fmt (buffer, sizeof (buffer), "%s/path.dat", plan_dir);

	path_file.Create (buffer);

	//---- DynusT user class ----

	str_ptr = Get_Control_String (DYNUST_USER_CLASS);

	if (str_ptr != NULL) {
		user_class = atoi (str_ptr);

		Print (2, "DynusT User Class = %d", user_class);

		if (user_class < 1 || user_class > 5) {
			Error ("DynusT User Class %d is Out of Range (1..5)", user_class);
		}
	}
	return;

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

control_error:
	Error ("Missing Control Key = %s", Current_Key ());
} 
Example #17
0
	double Max_Y (void)             { return (Get_Double (max_y)); }
Example #18
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 ());
}
Example #19
0
static VALUE
math_asinh(VALUE obj, VALUE x)
{
    return DBL2NUM(asinh(Get_Double(x)));
}
Example #20
0
	double X (void)                 { return (Get_Double (x)); }
Example #21
0
static VALUE
math_ldexp(VALUE obj, VALUE x, VALUE n)
{
    return DBL2NUM(ldexp(Get_Double(x), NUM2INT(n)));
}
Example #22
0
	double Y (void)                 { return (Get_Double (y)); }
Example #23
0
static VALUE
math_erfc(VALUE obj, VALUE x)
{
    return DBL2NUM(erfc(Get_Double(x)));
}
Example #24
0
	double Z (void)                 { return (Get_Double (z)); }
Example #25
0
	double Speed (void)               { return (Get_Double (speed)); }
Example #26
0
	double Min_X (void)             { return (Get_Double (min_x)); }
Example #27
0
static VALUE
math_cos(VALUE unused_obj, VALUE x)
{
    return DBL2NUM(cos(Get_Double(x)));
}
Example #28
0
	double Min_Y (void)             { return (Get_Double (min_y)); }
Example #29
0
static VALUE
math_tanh(VALUE unused_obj, VALUE x)
{
    return DBL2NUM(tanh(Get_Double(x)));
}
Example #30
0
	double Leg_Length (void)          { return (Get_Double (leg_length)); }