; Do not change filenames or add or remove FILEI/FILEO statements using an editor. Use Cube/Application Manager.
RUN PGM=MATRIX PRNFILE="X:\Projects\CRTPA\Model\C\APPLICATIONS\TRMAT00F.PRN" MSG='Path-Conditioning Auto'
FILEO MATO[2] = "{SCENARIO_DIR}\output\TSKIMOP3.{alt}{year}",
MO=61-75
FILEO MATO[1] = "{SCENARIO_DIR}\output\TSKIMPK3.{alt}{year}",
MO=21-35
FILEI LOOKUPI[1] = "{CATALOG_DIR}\parameters\TRN_COEFFICIENTS.DBF"
FILEI MATI[2] = "{SCENARIO_DIR}\output\TSKIMMD3_{alt}{year}.MAT"
FILEI MATI[1] = "{SCENARIO_DIR}\output\TSKIMAM3_{alt}{year}.MAT"
DistributeINTRAStep ProcessID="FSUTMSDist" ProcessList=1-4

 ZONEMSG=100

 ; Check skims to see if they have required IVT

 LOOKUP NAME=COEFF,
     LOOKUP[1]=1,
     RESULT=3,
     FAIL=0,0,0,
     LIST=Y,
     INTERPOLATE=N,
     LOOKUPI=1

 _ovtam =COEFF(1,3)/COEFF(1,1)     ; out-of-vehicle time factor (OVT time and Wait factor)
 valtime   =0.6*COEFF(1,1)/COEFF(1,4) ; value of time (in $/hr)
 aatfactor =COEFF(1,5)/COEFF(1,1)     ; drive access to transit time factor
 _xferpen=COEFF(1,6)/COEFF(1,1)     ; transfer penalty
 _boardingpen = 2.0

 ; Check skims to see if they are better than the all-walk path & if they have required IVT
 FILLMW MW[21]=MI.1.1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
 FILLMW MW[61]=MI.2.1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
 
 LOOP x=1,4
  LOOP y=1,15
      _idx=20 + 20*(x-1) + y
   IF((_idx%20)=14)
      COMP total = ROWFAC(_idx,100.0)
   ENDIF
  ENDLOOP
 ENDLOOP

 JLOOP

  IF (I=={FromNode} && J=={ToNode}) LIST="Trace ",I(5.0),"-",J(5.0)
  IF (I=={FromNode} && J=={ToNode}) LIST="            ","       IVT","      Path","      wOVT","      wTOT"

    ; Auto-bus - peak (20 series)
    _ivt = MW[24] + MW[25] + MW[26] + MW[27] + MW[28] + MW[29] + MW[30]
    _pth = MW[24] + MW[26]
    _ovt = MW[22] + _ovtam * (MW[21] + MW[23] + MW[32] + MW[33])
    _tot = _ivt + _ovt
  IF (I=={FromNode} && J=={ToNode}) LIST="Auto-Bus  pk",_ivt(10.2),_pth(10.2),_ovt(10.2),_tot(10.2)
  IF (_ivt==0)
    MW[21]=0, MW[22]=0, MW[23]=0, MW[24]=0, MW[25]=0
    MW[26]=0, MW[27]=0, MW[28]=0, MW[29]=0, MW[30]=0
    MW[31]=0, MW[32]=0, MW[33]=0, MW[34]=0, MW[35]=0
  ENDIF
    
    _ivt = MW[23] + MW[24] + MW[25] + MW[26] + MW[27]
    _pth = MW[23]
    _ovt = MW[22] + _ovtam * (MW[21] + MW[29] + MW[30])
    _tot = _ivt + _ovt
  IF(I=={FromNode} && J=={ToNode}) LIST="            ",_ivt(10.2),_pth(10.2),_ovt(10.2),_tot(10.2)

   ; Auto-bus - off-peak (60 series)
    _ivt = MW[64] + MW[65] + MW[66] + MW[67] + MW[68] + MW[69] + MW[70]
    _pth = MW[64] + MW[66]
    _ovt = MW[62] + _ovtam * (MW[61] + MW[63] + MW[72] + MW[73])
    _tot = _ivt + _ovt
  IF (I=={FromNode} && J=={ToNode}) LIST="Auto-Bus  op",_ivt(10.2),_pth(10.2),_ovt(10.2),_tot(10.2)
  IF (_ivt==0)
    MW[61]=0, MW[62]=0, MW[63]=0, MW[64]=0, MW[65]=0
    MW[66]=0, MW[67]=0, MW[68]=0, MW[69]=0, MW[70]=0
    MW[71]=0,  MW[72]=0, MW[73]=0, MW[74]=0, MW[75]=0
  ENDIF
   
    _ivt = MW[63] + MW[64] + MW[65] + MW[66] + MW[67]
    _pth = MW[63]
    _ovt = MW[62] + _ovtam * (MW[61] + MW[69] + MW[70])
    _tot = _ivt + _ovt
  IF(I=={FromNode} && J=={ToNode}) LIST="            ",_ivt(10.2),_pth(10.2),_ovt(10.2),_tot(10.2)
   
 ENDJLOOP

ENDRUN
