Below is the uncorrected machine-read text of this chapter, intended to provide our own search engines and external engines with highly rich, chapter-representative searchable text of each book. Because it is UNCORRECTED material, please consider the following text as a useful but insufficient proxy for the authoritative book pages.
67 Analysis Tools Developed in This Project A p p e n d i x A MATLAB GUis The SHRP 2 Safety Project S01A graphical user interface (GUI) for data analysis has been implemented in the MATLAB GUI Development Environment. It displays a map of the highway and the trajectories of the tracked targets overlaid on the high- way. Playback can be controlled as desired, and there are side plots displaying other information regarding the acceleration and velocity of the tracked targets. Reference frames can be changed as required, and an output text file can be generated, which contains the trajectory of a specific target vehicle for postprocessing. The browsing tool can accommodate data from the CICAS- instrumented sites (tested with data from the Minnesota and North Carolina sites), as well as process data from the VTTI 100-car study. Figures A.1 and A.2 are screenshots of the site- based data GUI and the vehicle-based data GUI, respectively. In the case of the site-based data, the browser generates the intersection geometry based on the available survey informa- tion provided by the research team. The coordinate systems of the vehicle trajectories are all in state plane, but the browser allows the user to set any arbitrary coordinate system and performs the conversion automatically. Considering that the site-based data contain trajectories from multiple vehicles, the browser allows the user to select which vehicles to observe in order to avoid visual clutter. Selecting the Play button (Figure A.1) plays the animation. The blue trajectory of the selected target changes into green, referencing past periods. All the vehiclesâ locations are plotted on the highway, and the mantissa of the target IDs are shown next to each vehicle. The magenta circle around one of the vehicles indicates that this is the selected target. Other playback controls are as follows: ⢠The Pause button pauses the animation. Clicking Play again resumes the animation from the current frame. ⢠The Stop button stops the animation and returns to the first frame. ⢠The Forward (Rewind) button moves forward (backward) one frame at a time. ⢠The Fast Forward (Fast Rewind) button moves forward (backward) 10 frames at a time. ⢠The scroll bar above the playback controls can also be used to navigate through the animation frames. When the animation is playing, clicking any of the forward/ rewind controls or the scroll bar will immediately pause the animation. The vehicle-based data browser interface is similar in nature, but since there is no specific map to be displayed, additional measurement charts are presented instead. MATLAB estimation Scripts Straight-Line Trajectory Model function simout=traj1d(beta) % function simout=traject1d(beta) % input: % x0=beta(1) % vx0=beta(2) % ax0=beta(3) % ax1=beta(4) % ax2=beta(5) % tc1=beta(6) % tc2=beta(7) % output: % simout=[xâ² vxâ² axâ²] % global n delta global n delta x0=beta(1) vx0=beta(2) ax0=beta(3) ax1=beta(4) ax2=beta(5) tc1=beta(6) tc2=beta(7)
68 Figure A.1. Site-based data browser. Figure A.2. Vehicle-based data browser.
69 for (k in 1:n.good1) { v1[k] ~ dnorm(vhat[k],tau1) vhat[k] <- state1[index1[k],2] } for (k in 1:n.good2) { range[k] ~ dnorm(rangehat[k], tau2) rangehat[k] <- state2[index2[k],1]-state1[index2[k],1] rrate[k] ~ dnorm(ratehat[k],tau3) ratehat[k] <- state2[index2[k],2]-state1[index2[k],2] } state1[1:n.grid,1:dim] <- ode.block(inits1[1:n.block1,1:dim], grid[1:n.grid],D(A1[1:dim],t),origins1[1:n.block1],tol) D(A1[1],t) <- A1[2] D(A1[2],t) <- acc1 acc1 <- piecewise(vec.acc1[1:n.block1]) vec.acc1[1] <- a11 vec.acc1[2] <- a12 vec.acc1[3] <- 0 origins1[1] <- 0 origins1[2] <- t11 # v1x <- v10+a11*t11 # origins1[3] <- t11+v1x/(-a12) origins1[3] <- t12 inits1[1,1] <- 0-v10*delta inits1[1,2] <- v10 inits1[2,1] <- 0 inits1[2,2] <- 0 inits1[3,1] <- 0 inits1[3,2] <- 0 state2[1:n.grid,1:dim] <- ode.block(inits2[1:n. block2,1:dim],grid[1:n.grid],D(A2[1:dim],t),origins2[1:n. block2],tol) D(A2[1],t) <- A2[2] D(A2[2],t) <- acc2 acc2 <- piecewise(vec.acc2[1:n.block2]) vec.acc2[1] <- a21 vec.acc2[2] <- a22 vec.acc2[3] <- a23 vec.acc2[4] <- 0 origins2[1] <- 0 origins2[2] <- t21 origins2[3] <- t22 # v2x <- v20+a21*t21+a22*(t22-t21) # origins2[4] <- t22+v2x/(-a23) origins2[4] <- t23 # follower reaction time r <- t11-t22 yindex0 <- round(t22/delta) yy0 <- rangehat[yindex0] vv0 <- vhat[yindex0] inits2[1,1] <- range[1]-v20*delta inits2[1,2] <- v20 x(1)=x0; vx(1)=vx0; ax(1)= ax0; for t=2:n x(t)=x(t-1)+vx(t-1)*delta; vx(t)=vx(t-1)+ax(t-1)*delta; if vx(t) < 0 vx(t)=0; end ax(t)=ax0; if (t*delta > tc1) ax(t)=ax1; end if(t*delta > tc2) ax(t)=ax2; end end simout=[xâ² vxâ² axâ²]; Compute Sum-of-Squares function ss=sumsqr0(alpha) global n delta tc1 tc2 ydat1 betax=[alpha tc1 tc2]; simoutx=traj1d(betax); err=ydat1-simoutx(:,1); ss=errâ²*err; Grid Search of Change Points % grid search over critical time points for lead vehicle clear ssx; nn=size(t0grid); nt0=nn1(2); nn1=size(t1grid); nt1=nn1(2); for i=1:nt0 for j=1:nt1 t0=t0grid(i); t1=t1grid(j); alpha1=fminsearch(@sumsqr,alpha0,options); betax=[alpha1 t0 t1]; ssx(i,j)=ss2(beta2x); end end example of WinBUGS Code Model: # 100-CAR case 104119 # 3-block model for follower (vehicle 1) # 4-block model for leader (vehicle 2) # separate calls to ode.block for leader and follower # includes counterfactual simulation # lagged initialization # speed reparameterization { for (k in 1:n.grid) {grid[k] <- k*delta}
70 inits2[2,1] <- 0 inits2[2,2] <- 0 inits2[3,1] <- 0 inits2[3,2] <- 0 inits2[4,1] <- 0 inits2[4,2] <- 0 v10 ~ dnorm(0, 1.0E-06)I(0,) v11 ~ dnorm(0,1.0E-06)I(0,) # final speed is stopped v12 <- 0 a11 <- (v11-v10)/t11 a12 <- (v12-v11)/(t12-t11) v20 ~ dnorm(0,1.0E-06)I(0,) v21 ~ dnorm(0, 1.0E-06)I(0,) v22 ~ dnorm(0, 1.0E-06)I(0,) # final speed is stopped v23 <- 0 a21 <- (v21-v20)/t21 a22 <- (v22-v21)/(t22-t21) a23 <- (v23-v22)/(t23-t22) t11 ~ dunif(10,12) t12 ~ dunif(13,16) t21 ~ dunif(3,5) t22 ~ dunif(9,11.5) t23 ~ dunif(13,15) tau1 ~ dgamma(.001,.001) tau2 ~ dgamma(.001,.001) tau3 ~ dgamma(.001,.001) sig21 <- 1/tau1 sig22 <- 1/tau2 sig23 <- 1/tau3 # counterfactual simulation # follower model state1.star[1:n.grid,1:dim] <- ode.block(inits1.star[1:n. block1,1:dim], grid[1:n.grid],D(A1.star[1:dim],t),origins1. star[1:n.block1],tol) D(A1.star[1],t) <- A1.star[2] D(A1.star[2],t) <- acc1.star acc1.star <- piecewise(vec.acc1.star[1:n.block1]) vec.acc1.star[1] <- a11.star vec.acc1.star[2] <- a12.star vec.acc1.star[3] <- 0 a11.star <- a11 origins1.star[1] <- 0 origins1.star[2] <- t11 v1x.star <- v10+a11.star*t11 origins1.star[3] <- t11+v1x.star/(-a12.star) inits1.star[1,1] <- 0-v10*delta inits1.star[1,2] <- v10 inits1.star[2,1] <- 0 inits1.star[2,2] <- 0 inits1.star[3,1] <- 0 inits1.star[3,2] <- 0 # leader model state2.star[1:n.grid,1:dim] <- ode.block(inits2.star[1:n. block2,1:dim],grid[1:n.grid],D(A2.star[1:dim],t),origins2.star [1:n.block2],tol) D(A2.star[1],t) <- A2.star[2] D(A2.star[2],t) <- acc2.star acc2.star <- piecewise(vec.acc2.star[1:n.block2]) vec.acc2.star[1] <- a21.star vec.acc2.star[2] <- a22.star vec.acc2.star[3] <- a23.star vec.acc2.star[4] <- 0 a21.star <- a21 a22.star <- a22 a23.star <- a23 origins2.star[1] <- 0 origins2.star[2] <- t21 origins2.star[3] <- t22 v2x.star <- v20+a21.star*t21+a22.star*(t22-t21) origins2.star[4] <- t22+v2x.star/(-a23.star) inits2.star[1,1] <- range[1]-v20*delta inits2.star[1,2] <- v20 inits2.star[2,1] <- 0 inits2.star[2,2] <- 0 inits2.star[3,1] <- 0 inits2.star[3,2] <- 0 inits2.star[4,1] <- 0 inits2.star[4,2] <- 0 for (k in 1:n.grid) { range.star[k] <- state2.star[k,1]-state1.star[k,1] hitcheck[k] <- 1-step(range.star[k]) } hitsum <- sum(hitcheck[]) hit <- step(hitsum-0.5) } } Data click on one of the arrows to open the data Inits list(v10=20.7,v11=20,tau1=1,v20=20,v21=20,v22=20,tau2=1, tau3=1,t11=11.2,t12=14.5,t21=4,t22=10.4,t23=14)