FAQ - Matrix & Distribution
Quick search
How can I search for the closest node to an intersection record, and transfer information from that intersection to the node record?
This example uses the Matrix program to find the closest node of an intersection record with no node number and write out a new file with node number and name attribute and/or other attributes in the node database.
First, create the sample RECI file with x, y, and street names using Pilot commands.
copy file=reci.dat 2050 3550 A Street & B Street 1550 3050 Pacific Ave. & Park Way 2050 3050 I-580 NB off & Keller Ave. endcopy
Then, use Network to create a node data file:
run pgm=Network neti=a.net nodeo=a.xy, format=sdf ; in delimited format endrun
Use the Matrix module to find the closest node:
run pgm=matrix ; treat the node xy file as a zonal data file with z,x,y zdati=a.xy, z=#1, x=#2, y=#3 ; define the intersection record reci=reci.dat, xcoord=1-4, ycoord=5-9 ; set the highest node number as maximum zones zones=114 ; start the RECI record loop, do for each record in the ; RECI file ; Initialize minimum distance and closest node values min_dist=999999 closest=0 ; loop through each node jloop if ((zi.1.x[j] <> 0) && (zi.1.y[j] <> 0)) ; calculate the distance between the intersection ; location and node location dist=sqrt((ri.xcoord-zi.1.x[j])*(ri.xcoord-zi.1.x[j]) + (ri.ycoord-zi.1.y[j])*(ri.ycoord-zi.1.y[j])) ; save info if less than previous nodes if (dist < min_dist) min_dist=dist closest=j endif endif endjloop ; if there is a close by node, write out a record with ; node number and name if (closest > 0) str1=substr(reci,11,30) print file=node.dat,list=closest(5),' ',str1 endif endrun
Finally, use Network to merge the street name info back into the network.
run pgm=network neti=a.net nodei[2]=node.dat, var=n, beg=1, len=5, var=name, beg=7, len=30, typ=a neto=a2.net endrun
How can I convert a Voyager matrix to ASCII format without any zero-value cells skipped in the output file?
The MATOFORMAT=TXT process is designed to minimize file size. Therefore, when the module sees a string of zeros, instead of writing them all, it generates a new record with the next non-zero cell as the first value. By doing this the file size is minimized without losing any information of the matrix. However, this creates a problem when all cells are wanted in the output file. The following two examples will convert a Voyager matrix to ASCII format without any zero-value cells skipped.
Example 1
; Will have to remove the first two columns to get a true ; matrix run pgm=matrix mati=input.mat ; a Voyager matrix with series of zeros mato=mat.txt mo=1 dec=0 pattern=ij:v fields=4,4,6 maxfields=20 zones=20 mw[1]=mi.1.1 jloop if (mw[1][j]=0) mw[1][j]=0.0001 endjloop endrun
Example 2
run pgm=matrix mati=testmat jloop list='\\',mi.1.1[j](6),file=testfile endjloop list='\n',file=testfile endrun
How do I do non-50/50 balancing of PA matrices?
Let’s take a simple example:
MW[1] = (MI.1.1 + MI.1.1.T) * 0.5
We assume that there are 100 trips produced in zone 1 and attracted to zone 2; and 200 trips produced in zone 2 and attracted to zone 1. The above equation will end up with 150 trips going from zone 1 to zone 2 : (100 + 200) * 0.5 = 150. The equation will also yield the same result from zone 2 to zone 1: (200 + 100) * 0.5 = 150.
The above equation can also be expressed as:
MW[1] = (MI.1.1 * 0.5) + (MI.1.1.T * 0.5)
To do non-50/50 balancing, we can vary the two factors but keep the total to 1.0 (100%, unless we also want to factor the total up or down). Changing the first factor to 0.9 and the second factor to 0.1 will yield a 90/10 split with 90% going from the production end to the attraction end:
MW[1] = (MI.1.1 * 0.9) + (MI.1.1.T * 0.1)
This resembles an AM Peak condition, with most people going from their home (production zone) to their jobs (attraction zone).
How do I split a zone into four sub-zones?
The following example illustrates how to generate a zonal equivalency file using Matrix, which then renumbers zones according to that file. This example assumes that zone 743 is split into sub-zones 743, 946, 947, and 948 at 10%, 20%, 30%, and 40%, respectively. All other zones stay the same.
; generate a zonal equivalency file "zone_eq.txt" run pgm=matrix zones=945 if (z<743) list=z(5),z(5),file=zone_eq.txt elseif (z=743) list= ' 743 743 10 \n', ' 743 946 20 \n', ' 743 947 30 \n', ' 743 948 40', file=zone_eq.txt else list=z(5),z(5),file=zone_eq.txt endif endrun run pgm=matrix mati=input.mat mato=output.mat mo=1 mw[1]=mi.1.1 ; renumber zones according to "zone_eq.txt" renumber file=zone_eq.txt endrun
What do the statistics in a FREQUENCY report mean?
Total Obs is the total number of occurrences within the BASEMW work matrix for this trip purpose (VALUEMW)
Total Sum is the sum of the respective VALUEMW.
Mean is computed as sum(BASEMW*VALUEMW)/sum(VALUEMW) for all i, j. In a trip-length frequency, it is the average trip length.
is the sum of intrazonal cells of the VALUEMW.