Exemplo n.º 1
0
void Validate::Link_Group_Header (void)
{
	Page_Check (5);
	Print (0, String ("\n%44cSummary Statistics by Link Group\n") % BLANK);
	Print (0, header1);
	Print (0, String ("\nLink Group               ") + header2);
}
Exemplo n.º 2
0
void Validate::Facility_Header (void)
{
Page_Check (5);
	Print (0, String ("\n%41cSummary Statistics by Facility Type\n") % BLANK);
	Print (0, header1);
	Print (0, String ("\n            Facility Type") + header2);
}
Exemplo n.º 3
0
void Validate::Turn_Header (void)
{
	Page_Check (5);
	Print (0, String ("\n%47cTurning Movement Validation\n") % BLANK);
	Print (0, String ("\n%63c-----------Volume---------- -----------Percent----------") % BLANK);
	Print (0, "\nStreet/Link              Dir  Cross Street/Link     Source     ");
	Print (0, "  Left   Thru  Right  Uturn    Left   Thru  Right  Uturn\n");
}
Exemplo n.º 4
0
void Validate::Group_Detail_Header (void)
{
	Page_Check (5);
	Print (0, "\n%35cDetailed Statistics for Link Group: %s\n", BLANK, group_label);
	Print (0, "\n%30cNum. ------%s------ ---Difference---  ", BLANK, ((method) ? "--VMT-" : "Volume"));
	Print (0, "--Abs.Error--    Std.     %%     R   ----V/C----");
	Print (0, "\nLink Name                Dir  Obs. Estimate  Observed   %6.6s", ((method) ? "VMT" : "Volume"));
	Print (0, "      %%     Avg.     %%     Dev.   RMSE   Sq.   Avg.  Max.\n");
}
Exemplo n.º 5
0
void Validate::Facility_Stats (void)
{
	int i, n;
	String label;

	Group_Data *data;
	Group_Map_Itr map_itr;
	Statistics stats;
	Link_Itr link_itr;
	Str_Map_Itr str_itr;

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		if (link_itr->AB_Dir () >= 0) {
			Sum_Group (link_itr->Type (), &(*link_itr), link_itr->AB_Dir ());
		}
		if (link_itr->BA_Dir () >= 0) {
			Sum_Group (link_itr->Type (), &(*link_itr), link_itr->BA_Dir ());
		}
	}

	//---- print the page header ----

	Header_Number (FACILITY_TYPE);

	if (!Break_Check ((int) group_data.size () + 9)) {
		Print (1);
		Facility_Header ();
	}

	//---- print each functional class ----

	for (map_itr = group_data.begin (); map_itr != group_data.end (); map_itr++) {
		data = &map_itr->second;
		n = data->number;
		if (n == 0) continue;
	
		Calc_Stats (data, stats);
		
		i = data->index;

		str_itr = facility_type.find (i);
		if (str_itr == facility_type.end ()) {
			label = Facility_Code ((Facility_Type) i);
		} else {
			label = str_itr->second;
		}
		Page_Check (1);

		Print (0, String (stats_format) % label % n % data->volume % data->count % 
			(data->volume - data->count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % data->max_vc);
	}
		
	//---- calculate the total statistics ----
	
	n = total.number;
	if (n > 0) {
		Calc_Stats (&total, stats);
		
		Page_Check (3);
		Print (0, "\n");
		Print (0, String (stats_format) % "TOTAL" % n % total.volume % total.count % 
			(total.volume - total.count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % total.max_vc);
		Print (0, "\n");
	}
	Header_Number (0);
}
Exemplo n.º 6
0
void Validate::Turn_Stats (void)
{
	int i, num, link, dir, node, index, in_index, in_bearing;
	int out_link, out_index;
	double total, volume;
	double left_obs, thru_obs, right_obs, uturn_obs;
	double left_est, thru_est, right_est, uturn_est;
	double per_left_est, per_thru_est, per_right_est, per_uturn_est, fac;
	double per_left_obs, per_thru_obs, per_right_obs, per_uturn_obs;
	String label, bearing;
	bool count_flag;

	Node_Data *node_ptr;
	Link_Data *link_ptr;
	Dir_Data *dir_ptr;
	Dir_Itr dir_itr;
	Connect_Data *connect_ptr;
	Turn_Period *period_ptr;
	Turn_Data *turn_ptr;

	//---- print the page header ----
	
	Header_Number (TURN_MOVEMENT);

	if (!Break_Check ((int) connect_array.size () + 9)) {
		Print (1);
		Turn_Header ();
	}
	link = dir = node = in_index = in_bearing = out_link = out_index = 0;
	count_flag = false;

	num = sum_periods.Num_Periods ();

	//---- process each approach link ----

	for (dir_itr = dir_array.begin (); dir_itr != dir_array.end (); dir_itr++) {

		//---- initialize the approach ----

		in_bearing = dir_itr->Out_Bearing ();
		in_index = dir_itr->Link ();

		link_ptr = &link_array [in_index];
		link = link_ptr->Link ();
		dir = dir_itr->Dir ();

		if (dir == 0) {
			node = link_ptr->Bnode ();
		} else {
			node = link_ptr->Anode ();
		}
		out_index = -1;
		left_obs = thru_obs = right_obs = uturn_obs = 0;
		left_est = thru_est = right_est = uturn_est = 0;
		count_flag = false;

		//---- process each link connection ----

		for (index = dir_itr->First_Connect (); index >= 0; index = connect_ptr->Next_Index ()) {
			connect_ptr = &connect_array [index];

			//---- sum the time period data ----

			total = volume = 0;

			for (i=0; i < num; i++) {
				period_ptr = turn_count_array.Period_Ptr (i);
				turn_ptr = period_ptr->Data_Ptr (index);
				total += turn_ptr->Turn ();

				period_ptr = turn_period_array.Period_Ptr (i);
				turn_ptr = period_ptr->Data_Ptr (index);
				volume += turn_ptr->Turn ();
			}
			if (volume == 0 && total == 0) continue;

			if (total > 0) count_flag = true;
			total *= factor;

			//---- sum the movement type ----

			if (connect_ptr->Type () == THRU || 
				connect_ptr->Type () == L_MERGE || connect_ptr->Type () == R_MERGE) {
				thru_est += volume;
				thru_obs += total;
			} else if (connect_ptr->Type () == UTURN) {
				uturn_est += volume;
				uturn_obs += total;
			} else if (connect_ptr->Type () == LEFT || connect_ptr->Type () == L_SPLIT) {
				out_index = connect_ptr->To_Index ();
				left_est += volume;
				left_obs += total;
			} else if (connect_ptr->Type () == RIGHT || connect_ptr->Type () == R_SPLIT) {
				out_index = connect_ptr->To_Index ();
				right_est += volume;
				right_obs += total;
			}
		}
		if (!count_flag) continue;

		//---- get the link name ----

		label = link_ptr->Name ();
		if (label.empty ()) {
			label = String ("Link %d %s") % link_ptr->Link () % ((dir == 0) ? "AB" : "BA");
		}

		//---- get the link direction ----
		
		bearing = compass.Point_Text (dir_itr->Out_Bearing ());
		if (bearing.empty ()) {
			bearing = "B";
		}

		//---- print the street name ----

		Page_Check (5);
		Print (0, String ("\n%-25.25s %-2.2s  ") % label % bearing);

		//---- get the cross street ----

		if (out_index >= 0) {
			dir_ptr = &dir_array [out_index];
			link_ptr = &link_array [dir_ptr->Link ()];
			label = link_ptr->Name ();
		} else {
			label.clear ();
		}
		if (label.empty ()) {
			node_ptr = &node_array [node];
			label = String ("Node %d") % node_ptr->Node ();
		}
		
		//---- estimate ----

		Print (0, String ("%-20.20s  Estimate   %6d %6d %6d %6d") % label %
			left_est % thru_est % right_est % uturn_est);

		total = left_est + thru_est + right_est + uturn_est;
		if (total < 1) total = 1;
		fac = 100.0 / total;

		per_left_est = left_est * fac;
		per_thru_est = thru_est * fac;
		per_right_est = right_est * fac;
		per_uturn_est = uturn_est * fac;

		Print (0, String ("  %6.1lf %6.1lf %6.1lf %6.1lf") % 
			per_left_est % per_thru_est % per_right_est % per_uturn_est);

		//---- observed ----

		Print (0, String ("\n%52cObserved   %6d %6d %6d %6d") % BLANK %
			left_obs % thru_obs % right_obs % uturn_obs);

		total = left_obs + thru_obs + right_obs + uturn_obs;
		if (total < 1) total = 1;
		fac = 100.0 / total;

		per_left_obs = left_obs * fac;
		per_thru_obs = thru_obs * fac;
		per_right_obs = right_obs * fac;
		per_uturn_obs = uturn_obs * fac;

		Print (0, String ("  %6.1lf %6.1lf %6.1lf %6.1lf") % 
			per_left_obs % per_thru_obs % per_right_obs % per_uturn_obs);

		//---- difference ----

		left_est -= left_obs;
		thru_est -= thru_obs;
		right_est -= right_obs;
		uturn_est -= uturn_obs;

		Print (0, String ("\n%52cDifference %6d %6d %6d %6d") % BLANK % 
			left_est % thru_est % right_est % uturn_est);

		per_left_est -= per_left_obs;
		per_thru_est -= per_thru_obs;
		per_right_est -= per_right_obs;
		per_uturn_est -= per_uturn_obs;

		Print (0, String ("  %6.1lf %6.1lf %6.1lf %6.1lf") % 
			per_left_est % per_thru_est % per_right_est % per_uturn_est);

		//---- percent error ----

		if (per_left_obs != 0.0) {
			per_left_est = 100.0 * per_left_est / per_left_obs;
			if (per_left_est > 999.9) {
				per_left_est = 999.9;
			} else if (per_left_est < -999.9) {
				per_left_est = -999.9;
			}
		}
		if (per_thru_obs != 0.0) {
			per_thru_est = 100.0 * per_thru_est / per_thru_obs;
			if (per_thru_est > 999.9) {
				per_thru_est = 999.9;
			} else if (per_thru_est < -999.9) {
				per_thru_est = -999.9;
			}
		}
		if (per_right_obs != 0.0) {
			per_right_est = 100.0 * per_right_est / per_right_obs;
			if (per_right_est > 999.9) {
				per_right_est = 999.9;
			} else if (per_right_est < -999.9) {
				per_right_est = -999.9;
			}
		}
		if (per_uturn_obs != 0.0) {
			per_uturn_est = 100.0 * per_uturn_est / per_uturn_obs;
			if (per_uturn_est > 999.9) {
				per_uturn_est = 999.9;
			} else if (per_uturn_est < -999.9) {
				per_uturn_est = -999.9;
			}
		}

		//---- volume error ----

		per_left_obs = 100.0 * left_est / ((left_obs) ? left_obs : 1);
		if (per_left_obs > 999.9) {
			per_left_obs = 999.9;
		} else if (per_left_obs < -999.9) {
			per_left_obs = -999.9;
		}
		per_thru_obs = 100.0 * thru_est / ((thru_obs) ? thru_obs : 1);
		if (per_thru_obs > 999.9) {
			per_thru_obs = 999.9;
		} else if (per_thru_obs < -999.9) {
			per_thru_obs = -999.9;
		}
		per_right_obs = 100.0 * right_est / ((right_obs) ? right_obs : 1);
		if (per_right_obs > 999.9) {
			per_right_obs = 999.9;
		} else if (per_right_obs < -999.9) {
			per_right_obs = -999.9;
		}
		per_uturn_obs = 100.0 * uturn_est / ((uturn_obs) ? uturn_obs : 1);
		if (per_uturn_obs > 999.9) {
			per_uturn_obs = 999.9;
		} else if (per_uturn_obs < -999.9) {
			per_uturn_obs = -999.9;
		}

		Print (0, String ("\n%52c%% Error    %6.1lf %6.1lf %6.1lf %6.1lf") % BLANK % 
			per_left_obs % per_thru_obs % per_right_obs % per_uturn_obs);

		Print (0, String ("  %6.1lf %6.1lf %6.1lf %6.1lf\n") % 
			per_left_est % per_thru_est % per_right_est % per_uturn_est);

	}
	Header_Number (0);
}
Exemplo n.º 7
0
void Validate::Link_Group_Stats (void)
{
	int i, n, lnk;
	String label;

	Group_Data *data;
	Group_Map_Itr map_itr;
	Statistics stats;
	Link_Data *link_ptr;
	Int_Set *list;
	Int_Set_Itr itr;
	Int_Map_Itr int_itr;

	for (i = 1; i <= link_equiv.Max_Group (); i++) {
		list = link_equiv.Group_List (i);

		if (list == 0) continue;

		for (itr = list->begin (); itr != list->end (); itr++) {
			lnk = *itr;
			int_itr = link_map.find (abs (lnk));
			if (int_itr == link_map.end ()) continue;

			link_ptr = &link_array [int_itr->second];

			if (lnk > 0 && link_ptr->AB_Dir () >= 0) {
				Sum_Group (i, link_ptr, link_ptr->AB_Dir ());
			} else if (lnk < 0 && link_ptr->BA_Dir () >= 0) {
				Sum_Group (i, link_ptr, link_ptr->BA_Dir ());
			}
		}
	}

	//---- print the page header ----
	
	Header_Number (LINK_GROUP);

	if (!Break_Check ((int) group_data.size () + 9)) {
		Print (1);
		Link_Group_Header ();
	}

	//---- print each link group ----

	for (map_itr = group_data.begin (); map_itr != group_data.end (); map_itr++) {
		data = &map_itr->second;
		n = data->number;
		if (n == 0) continue;
	
		Calc_Stats (data, stats);
		
		i = data->index;
		
		label = link_equiv.Group_Label (i);
		if (label.empty ()) {
			label = String ("Link Group %d") % i;
		}
		label = String ("%-25.25s") % label;
		Page_Check (1);
		Print (0, String (stats_format) % label % n % data->volume % data->count % 
			(data->volume - data->count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % data->max_vc);
	}
		
	//---- calculate the total statistics ----
	
	n = total.number;
	if (n > 0) {
		Calc_Stats (&total, stats);
		
		Page_Check (3);
		Print (0, "\n");
		label = String ("%-25.25s") % "TOTAL";
		Print (0, String (stats_format) % "TOTAL" % n % total.volume % total.count % 
			(total.volume - total.count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % total.max_vc);
		Print (0, "\n");
	}
	Header_Number (0);
}
Exemplo n.º 8
0
void Validate::Zone_Group_Stats (void)
{
	int i, n, type;
	String label;

	Group_Data *data;
	Group_Map_Itr map_itr;
	Statistics stats;
	Link_Itr link_itr;
	Str_Map_Itr str_itr;

	for (link_itr = link_array.begin (); link_itr != link_array.end (); link_itr++) {
		if (link_itr->AB_Dir () >= 0) {
			n = node_zone [link_itr->Anode ()];
			type = zone_equiv.Zone_Group (n);

			Sum_Group (type, &(*link_itr), link_itr->AB_Dir ());
		}
		if (link_itr->BA_Dir () >= 0) {
			n = node_zone [link_itr->Bnode ()];
			type = zone_equiv.Zone_Group (n);

			Sum_Group (type, &(*link_itr), link_itr->BA_Dir ());
		}
	}

	//---- print the page header ----
	
	Header_Number (ZONE_GROUP);

	if (!Break_Check ((int) group_data.size () + 9)) {
		Print (1);
		Zone_Group_Header ();
	}

	//---- print each zone group ----

	for (map_itr = group_data.begin (); map_itr != group_data.end (); map_itr++) {
		data = &map_itr->second;
		n = data->number;
		if (n == 0) continue;

		Calc_Stats (data, stats);

		i = data->index;
		
		label = zone_equiv.Group_Label (i);
		if (label.empty ()) {
			label = String ("Zone Group %d") % i;
		}
		Page_Check (1);
		Print (0, String (stats_format) % label % n % data->volume % data->count % 
			(data->volume - data->count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % data->max_vc);
	}
		
	//---- calculate the total statistics ----

	n = total.number;
	if (n > 0) {
		Calc_Stats (&total, stats);
		
		Page_Check (3);
		Print (0, "\n");
		Print (0, String (stats_format) % "TOTAL" % n % total.volume % total.count % 
			(total.volume - total.count) % stats.per_diff % stats.avg_error % stats.per_error % 
			stats.std_dev % stats.rmse % stats.r_sq % stats.avg_vc % total.max_vc);
		Print (0, "\n");
	}
	Header_Number (0);
}
Exemplo n.º 9
0
void Validate::Link_Group_Details (void)
{
	int i, j, n, lnk;
	char *str_ptr, buffer [32], bearing [8];

	Group_Data *data;
	Statistics stats;
	Link_Data *link_ptr;
	Dir_Data *dir_ptr;
	Integer_List *list;

	for (i = 1; i <= link_equiv.Max_Group (); i++) {
		list = link_equiv.Group_List (i);

		if (list == NULL) continue;

		for (j=1, lnk = list->First (); lnk != 0; lnk = list->Next ()) {

			link_ptr = link_data.Get (abs (lnk));

			if (link_ptr == NULL) continue;

			if (lnk > 0 && link_ptr->AB_Dir () > 0) {
				Sum_Group (j++, link_ptr, link_ptr->AB_Dir ());
			} else if (lnk < 0 && link_ptr->BA_Dir () > 0) {
				Sum_Group (j++, link_ptr, link_ptr->BA_Dir ());
			}
		}

		//---- get the link group label ----

		group_label = link_equiv.Group_Label (i);

		if (group_label == NULL) {
			str_fmt (buffer, sizeof (buffer), "Link Group %d", i);
			group_label = buffer;
		}

		//---- print the page header ----
		
		Header_Number (GROUP_DETAILS);

		if (!Break_Check (group_data.Num_Records () + 9)) {
			Print (1);
			Group_Detail_Header ();
		}

		//---- print each link ----

		for (j=1, lnk = list->First (); lnk != 0; lnk = list->Next ()) {

			link_ptr = link_data.Get (abs (lnk));
			if (link_ptr == NULL) continue;

			if ((lnk > 0 && link_ptr->AB_Dir () <= 0) || 
				(lnk < 0 && link_ptr->BA_Dir () <= 0)) {
				continue;
			}
			data = (Group_Data *) group_data.Get (&j);
			j++;

			if (data == NULL) continue;
			if (!(n = data->number)) continue;

			Calc_Stats (data, &stats);

			//---- get the link name ----

			if (street_name != NULL) {
				str_ptr = street_name [link_data.Record_Index () - 1];
			} else {
				str_ptr = NULL;
			}

			if (str_ptr == NULL) {
				str_ptr = str_fmt (buffer, sizeof (buffer), "Link %d %s", abs (lnk), ((lnk > 0) ? "AB" : "BA"));
			}

			//---- get the link direction ----
			
			if (lnk > 0) {
				dir_ptr = dir_data [link_ptr->AB_Dir ()];
			} else {
				dir_ptr = dir_data [link_ptr->BA_Dir ()];
			}
			str_cpy (bearing, sizeof (bearing), compass.Point_Text (dir_ptr->Out_Bearing ()));

			if (bearing [1] == '\0') {
				bearing [1] = 'B';
				bearing [2] = '\0';
			}

			//---- print the record ----

			Page_Check (1);
			Print (0, "\n%-25.25s %-2.2s ", str_ptr, bearing);
			Print (0, "%4d%10.0lf%10.0lf%9.0lf %7.1lf %7.0lf %6.1lf %7.0lf %6.1lf %6.3lf%6.2lf%6.2lf",
				n, data->volume, data->count, (data->volume - data->count), 
				stats.per_diff, stats.avg_error, stats.per_error, stats.std_dev, 
				stats.rmse, stats.r_sq, stats.avg_vc, data->max_vc);
		}
	
		//---- calculate the total statistics ----
		
		if ((n = total.number)) {
			Calc_Stats (&total, &stats);

			Page_Check (3);
			Print (0, "\n\n%-25.25s ", "TOTAL");
			Print (0, "%7d%10.0lf%10.0lf%9.0lf %7.1lf %7.0lf %6.1lf %7.0lf %6.1lf %6.3lf%6.2lf%6.2lf\n",
				n, total.volume, total.count, (total.volume - total.count), 
				stats.per_diff, stats.avg_error, stats.per_error, stats.std_dev, 
				stats.rmse, stats.r_sq, stats.avg_vc, total.max_vc);
		}
		Header_Number (0);

		group_data.Reset ();
		memset (&total, '\0', sizeof (total));
	}
}