Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modelling Transport – CUBE Guide Examples based on the book ‘Modelling Transport’, 4 th edition by Ortuzar/Willumsen (© 2011 John Wiley & Sons, Ltd) Citilabs.

Similar presentations


Presentation on theme: "Modelling Transport – CUBE Guide Examples based on the book ‘Modelling Transport’, 4 th edition by Ortuzar/Willumsen (© 2011 John Wiley & Sons, Ltd) Citilabs."— Presentation transcript:

1 Modelling Transport – CUBE Guide Examples based on the book ‘Modelling Transport’, 4 th edition by Ortuzar/Willumsen (© 2011 John Wiley & Sons, Ltd) Citilabs © 2011

2  About Cube : a brief intro to the modelling system and its modules About Cube : a brief intro to the modelling system and its modules  About the tutorial : The Guide and Book in tandem About the tutorial : The Guide and Book in tandem  Click on the app boxes below to get to the examples  Chapter 3 : Data and Storage  Chapter 4 : Trip Generation Modelling  Chapter 5 : Trip Distribution Modelling  Chapter 6 : Modal Split and Direct Demand Models  Chapter 8 : Specification and Estimation of Discrete Choice Models  Chapter 10 : Assignment  Chapter 11 : Equilibrium and Dynamic Assignment  Chapter 12 : Simplified Transport Demand Models  Chapter 14 : Activity Based Models Main Menu

3 Desktop Professional Modeling ▪a comprehensive suite for passenger, freight, land use, and traffic simulation Cube Cloud Services - Modeling on the Internet ▪web-accessed, cloud computing framework for model application Modeling Extensions for ArcGIS ▪modeling and analysis tools for non-modelers Citilabs – software products

4 Cube: Professional Desktop Modeling Suite System Interface  Cube Base – comprehensive interface for data editing, mapping, reporting, model development and scenario creation and management Demand Modeling  Cube Voyager: urban, regional and long distance demand forecasting and assignment  Cube Land : land use model for combined transport-land use modeling  Cube Cargo: commodity-based freight forecasting Simulation  Cube Avenue: meso-scopic traffic simulation (DTA)  Cube Dynasim: multimodal micro-simulation Specialized  Cube Cluster: reduces run-times by allocating calculations over multiple processors and machines  Cube Analyst: advanced matrix estimation for all modes Our Products: Cube

5 Overview Cube Base – Built for Scenario Testing  Easy to use environment to create, test, manage and analyze scenarios.  Menus to prompt user for inputs and parameters of test  Integrated report and charting generators to assist in the analysis

6 Overview Cube Base – Flow-Chart: Easy Model Development  Famous for its flow-charting environment for designing and building transportation models  Modules are accessed through pull-down menus  Dropped into a flow chart  Data inputs and outputs linked by drag-and-drop

7 Overview Cube Base – A Transportation-GIS Built on ESRI  Only modeling system that comes with a complete transportation GIS built on ESRI’s marketing leading GIS technology.  Store all data directly in ESRI’s geodatabase format.  No need to convert data back and forth between the GIS department and the modeling team  ArcGIS Extension for network editing (Sugar)

8  Cube GIS  Click-drag-drop functionality for all typical modelling tasks  Cube integrates GIS powered by ESRI  Uses ESRI geodatabase technology  Supports other formats; Shape, CAD, Raster  Cube Model Builder (Application Manager)  Flow-chart system for model design, coding and documentation  Visual creation of the model ‘macro’  Gives direct access to data and scripts  Cube Scenario Manager  Highlights key model parameters and data for easy creation and testing of scenarios  Creates customised run menu for defining and running scenarios  Provides easy links to main output data for viewing and comparing Overview  Cube Reports  Charts and Tables integrated in model  View and compare scenario specific statistics Cube Base – the complete software interface

9 Comprehensive and Integrated Covers all facets of transportation modeling  people  goods  land use  region-wide traffic simulation  multi-modal microsimulation Open system  Seamless links to other software  Microsoft Office (Access, Excel)  User programs BACK TO MAIN MENU

10 This system of Cube modelling tutorials is based on Modelling Transport 4th Edition (the 'book')  The book has been used since its first edition in 1990 by transport modellers around the world to find and select appropriate methods to their modelling tasks and for understanding the theoretic base behind these methods  The book includes a wealth of examples of how to model, in terms of approach and mathematics, the various aspects of transport.  This guide provides a set of applications showing the examples of the book coded up in Cube scripts, grouped according to the book's chapters. About the book : Modelling Transport 4 th edition  Suggestions for the MODELLER : find and study the appropriate method in the book study the relevant example in the book see how this example is coded in Cube use the script as a base for your model and its data  Suggestions for the STUDENT : read the relevant chapter/model type and its modelling methods in the book study the examples see how these example are coded in Cube  About the MT Cube Guide : Version 1.0 September 2011 Authors : Citilabs professionals © Citilabs 2011  About the 'book' : Modelling Transport 4th Edition, © 2011 John Wiley & Sons, Ltd Authors :Juan de Dios Ortuzar Luis G. Willumsen

11  Modelling Transport" 4th Edition, John Wiley & Sons  Available from http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470760397.htmlhttp://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470760397.html  Also available from www.Amazon.com and www.Amazon.co.ukwww.Amazon.comwww.Amazon.co.uk  Available as hard copy and electronic book for Kindle, iPad and other tablets  The authors have been involved with transport modelling research for over 40 years About the book : Availability and authors  Juan de Dios Ortuzar Present Professor of Transport Engineering at Pontificia Universidad Cat ó lica de Chile Advisor to governments and international agencies  Luis (Pilo) Willumsen Present Director of Luis Willumsen Consultancy Visiting Professor at University College London Past Researcher at Leeds University and University College London Board Director at Steer Davies Gleave

12  Part of the Cube’s Learning Center on http://www.citilabs.com/support-services/learning-center http://www.citilabs.com/support-services/learning-center  Comes with downloadable Cube catalog with examples scripted in Cube  Open to all users of Cube and to those who are evaluating the system  This guide will make it easier for modellers to put the lessons learned in the book to practical use in models  The main purpose of this guide is to promote sound modeling practices based on established methods described and discussed in the book  This guide is also meant to encourage the modelling community to keep up to date on modeling methods and principles; the book is an ideal starting point About the guide : Availability and purpose BACK TO MAIN MENU

13  The main page with links to the apps with examples from each chapter of the book About the guide : The tutorial system BACK TO MAIN MENU

14 Chapter 4 : Trip Generation Modelling  Click on the boxes below to select the various examples BACK TO MAIN MENU

15 Ch4-TGM : Ex4.1 - Growth-factor Modelling  Click on the script file boxes below to see the scripts BACK …

16 Ch4-TGM: Ex4.1 - Growth - base year RUN PGM=MATRIX PRNFILE="C4MAT00A.PRN" MSG='Example 4.1 - Base Year' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter4\Results_4_1_BaseYear.DBF", FIELDS=Z, GEN FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter4\SocioEconData_4_1_BY.dbf" PAR ZONES=1 C=DBIReadRecord(1,1) ; read input data ZONEN=DI.1.Z ; zone numbers (only 1 zone in the current example) X1=DI.1.NO_CAR ; number of households without a car X2=DI.1.WITH_CAR ; number of households with 1 or more cars ; calculation of total number of trips per day GEN=X1*{GenRateNCar}+X2*{GenRateCar} ; trips per day ; ti=250 x 2.5 + 250 x 6.0 = 2125 trips/day (See page 144) ; save results to output file RO.Z=ZONEN RO.GEN=GEN WRITE RECO=1 ENDRUN BACK …

17 Ch4-TGM: Ex4.1 - Future year growth-factor RUN PGM=MATRIX PRNFILE="C4MAT00B.PRN" MSG='Example 4.1 - Future Year - Growth-factor method' FILEI DBI[3] = "C:\Modelling Transport_CG\Output\Chapter4\Results_4_1_BaseYear.DBF", SORT=Z FILEI DBI[2] = "C:\Modelling Transport_CG\Input\Chapter4\SocioEconData_4_1_FY.dbf", SORT=Z FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter4\Results_4_1_FutureYear.DBF", FIELDS=Z GEN FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter4\SocioEconData_4_1_BY.dbf" PAR ZONES=1 C=DBIReadRecord(1,1) ; read input data Base Year ZONEN=DI.1.Z ; zone numbers (only 1 zone in the current example) X1_B=DI.1.NO_CAR ; number of households without a car X2_B=DI.1.WITH_CAR ; number of households with 1 or more cars D=DBISeek(2,1) ; read input data Future Year X1_F=DI.2.NO_CAR ; number of households without a car X2_F=DI.2.WITH_CAR ; number of households with 1 or more cars E=DBISeek(3,1) ; read ti GEN_B=DI.3.GEN ; calculation of total number of trips per day Factor2=(X2_F/(X1_F+X2_F))/(X2_B/(X1_B+X2_B)) ; Fi=C_di/C_ci (See page 144) GEN_F=Factor2*GEN_B ; Ti = 2 x 2125 = 4250 trips/day (See page 144) ; save results to output file RO.Z=ZONEN RO.GEN=GEN_F WRITE RECO=1 ENDRUN BACK …

18 Ch4-TGM: Ex4.1 - Future year growth applying trip rates RUN PGM=MATRIX PRNFILE="CHAPTER4\C4MAT00C.PRN" MSG='Example 4.1 - Future Year - Applying Trip Rates' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter4\Results_4_1_FutureYear_TR.DBF", FIELDS=Z, GEN FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter4\SocioEconData_4_1_FY.dbf" PAR ZONES=1 C=DBIReadRecord(1,1) ; read input data ZONEN=DI.1.Z ; zone numbers (only 1 zone in the current example) X1=DI.1.NO_CAR ; number of households without a car X2=DI.1.WITH_CAR ; number of households with 1 or more cars ; calculation of total number of trips per day GEN=X1*{GenRateNCar}+X2*{GenRateCar} ; trips per day ; ti=250 x 2.5 + 250 x 6.0 = 2125 trips/day (See page 144) ; save results to output file RO.Z=ZONEN RO.GEN=GEN WRITE RECO=1 ENDRUN BACK …

19 Ch4-TGM : Ex4.3 - Linear regression  Click on the script file boxes below to see the scripts BACK …

20 Ch4-TGM: Ex4.3 – Linear regression RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER4\E4MAT01A.PRN“, MSG='Exmple 4.3 - Linear regression with intercept=0' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter4\RegrCoeffAndStats_4_3.DBF", FIELDS=B(10.8) R2(10.8) SERR(10.8) T_VALUE(10.8) FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter4\SocioEconData_4_3.dbf" PAR ZONES=1 ; Linear regression with intercept=0 ; Y = a + bX ; a=0 LOOP K=1,DBI.1.NUMRECORDS C=DBIReadRecord(1,K) ; read input data X1=DI.1.X1 ; number of workers in household Y=DI.1.Y ; observed trips per household ; b= sum(xy)/sum(x^2) _XY=X1*Y+_XY _X=X1^2+_X ENDLOOP ; script continues on next page NEXT …

21 Ch4-TGM: Ex4.3 – Linear regression ; script continued from previous page B=_XY/_X LOOP K=1,DBI.1.NUMRECORDS C=DBIReadRecord(1,K) ; read input data X1=DI.1.X1 ; number of workers in household Y=DI.1.Y ; observed trips per household Y_MOD=B*X1 _SSRESID=(Y-Y_MOD)^2+_SSRESID _SSTOTAL=(Y^2)+_SSTOTAL _SSX=(X1^2)+_SSX ENDLOOP N=DBI.1.NUMRECORDS-1 ; sample size minus number of regressors (1 in this case) R2=1-(_SSRESID/_SSTOTAL) ; R squared SERR=SQRT(_SSRESID/N)/SQRT(_SSX) ; Standard error for coefficient B T_VALUE=B/SERR ; t-value for coefficient B ; save results to output file RO.B=B RO.R2=R2 RO.SERR=SERR RO.T_VALUE=T_VALUE WRITE RECO=1 ENDRUN BACK …

22 Ch4-TGM : Additional examples  Click on the script file boxes below to see the scripts BACK …

23 Ch4-TGM: A – Processing tabular data in MATRIX RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER4\E4MAT01D.PRN" FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter4\CrossTabulation.dbf", FIELDS=INC_CLASS(50) ZERO_CARS ONE_CAR TWOPL_CARS TOTAL FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter4\ExampleTable.DBF", SORT=INCOME ARRAY CARS=4 ARRAY CLASS=5 CLASS[1]=125 CLASS[2]=250 CLASS[3]=500 CLASS[4]=750 CLASS[5]=2000 IF (_ID=0) _PCLASS=0 _CLASS=1 ENDIF IF(_INCOME>=CLASS[_CLASS] & _ID>0) RO.INC_CLASS='Between'+Str(CLASS[_PCLASS],4,0)+' and '+Str(CLASS[_CLASS],4,0)+' (US$/month)' RO.ZERO_CARS=CARS[1] RO.ONE_CAR=CARS[2] RO.TWOPL_CARS=CARS[3]+CARS[4] RO.TOTAL =CARS[1]+CARS[2]+CARS[3]+CARS[4] ; script continues on next page NEXT …

24 Ch4-TGM: A – Processing tabular data in MATRIX ; script continued from previous page WRITE RECO=1 CARS[1]=0 CARS[2]=0 CARS[3]=0 CARS[4]=0 _CARS=0 _PCLASS=_PCLASS+1 _CLASS=_CLASS+1 ENDIF _ID=RI.ID _CARS=RI.CARS+1 _INCOME=RI.INCOME CARS[_CARS]=1+CARS[_CARS] ; script continues on next page NEXT …

25 Ch4-TGM: A – Processing tabular data in MATRIX ; script continued from previous page IF(I=0) RO.INC_CLASS='Between'+Str(CLASS[_PCLASS],4,0)+' and '+Str(CLASS[_CLASS],4,0)+' (US$/month)' RO.ZERO_CARS=CARS[1] RO.ONE_CAR=CARS[2] RO.TWOPL_CARS=CARS[3]+CARS[4] RO.TOTAL =CARS[1]+CARS[2]+CARS[3]+CARS[4] WRITE RECO=1 CARS[1]=0 CARS[2]=0 CARS[3]=0 CARS[4]=0 _CARS=0 _CLASS=_CLASS+1 ENDIF ENDRUN BACK …

26 Ch4-TGM: B – Use of GENERATION Program RUN PGM=GENERATION PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER4\E4GEN01A.PRN" FILEO PAO[1] = "C:\Modelling Transport_CG\Output\Chapter4\TripEnd.dbf", FORM=8.0, LIST=Z(2), P[1] P[2] P[3] P[4] A[1] A[2] A[3] A[4],DBF=T, NAMES = TAZ WORKP SCHOOLP SHOPP TOTP,WORKA SCHOOLA SHOPA TOTA FILEI ZDATI[1] = "C:\Modelling Transport_CG\Input\Chapter4\cubetown.mdb\Demographics" ; set number of zones PARAMETERS ZONES = 4 PROCESS PHASE=ILOOP ; ----- calculate generations by purpose P[1] = (0.960 * zi.1.HH1 + 1.370 * zi.1.HH2 + 1.995 * zi.1.HH3 + 1.778 * zi.1.HH4) P[2] = (0.900 * zi.1.HH1 + 0.382 * zi.1.HH2 + 0.325 * zi.1.HH3 + 0.500 * zi.1.HH4) P[3] = (0.480 * zi.1.HH1 + 1.370 * zi.1.HH2 + 1.465 * zi.1.HH3 + 1.524 * zi.1.HH4) ; ----- calculate attractions by purpose A[1] = 1.450 * zi.1.TOTAL_EMP A[2] = 0.144 * 9.0 * zi.1.RETAIL + 1.8 * zi.1.SERVICE + 0.5 * zi.1.OTHER + 0.9 * zi.1.HOUSEHOLDS A[3] = 0.220 * 9.0 * zi.1.RETAIL + 1.8 * zi.1.SERVICE + 0.5 * zi.1.OTHER + 0.9 * zi.1.HOUSEHOLDS ENDPROCESS PROCESS PHASE=ADJUST ; ----- adjust zonal attractions so total attractions match total productions BALANCE A2P=1,2,3; balance attrs to prods for purposes 1, 2, 3 ;for details on the method see pag.156 4.2.6 Matching Generations and Attraction totals P[4] = P[1] + P[2] + P[3] A[4] = A[1] + A[2] + A[3] ENDPROCESS ENDRUN BACK …

27 Chapter 5: Trip Distribution Modelling  Click on the boxes below to select the various examples BACK TO MAIN MENU

28 Ch5-TDM: Ex5.1 - Uniform Growth-factor  Click on the script file boxes below to see the scripts BACK …

29 Ch5-TDM: Ex5.1 - Uniform Growth-factor RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT00A.PRN“, MSG='Example 5.1 - Uniform Growth Factor (tau)=1.2' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_1.MAT", MO=1 NAME="Future matrix" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Base_year_trip_matrix_5_1.dbf", PATTERN=IJ:V FIELDS=O D TRIPS PAR ZONES=4 ; multiply matrix per Tau (ratio of expanded over previous total number of trips) ; Tij = (tau)*tij (5.3) ; where: ; MW[1]=Tij ; MI.1.1=tij ; (tau)={tau} MW[1]=MI.1.1*{tau} ENDRUN BACK …

30 Ch5-TDM: Ex5.2 - Singly Constrained  Click on the script file boxes below to see the scripts BACK …

31 Ch5-TDM: Ex5.2 – Preparing trip end data RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT02A.PRN“, MSG='Example 5.2 - total number of trips generated per zone' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_2_A.MAT", MO=1 FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Total_number_of_trips_generated_Base_year_5_2.DBF", FIELDS=ZONE SUM_J FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Base_year_trip_matrix_5_1.dbf", PATTERN=IJ:V FIELDS=O D TRIPS PAR ZONES=4 ;initialize work variables _Generated=0 ;read tij MW[1]=MI.1.1 ;sum tij over destinations _Generated= ROWSUM(1) ;sum over cell by row ;write totals per origins RO.ZONE=I RO.SUM_J=_Generated WRITE RECO=1 ENDRUN BACK …

32 Ch5-TDM: Ex5.2 – Singly constrained growth RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT02B.PRN“, MSG='Example 5.2 - Expanded origin-constrained growth trip table' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Base_year_trip_matrix_5_1.dbf", PATTERN=IJ:V FIELDS=O D TRIPS FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_2.MAT", MO=1 DEC=1*5 NAME="Future matrix" FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_future_year_5_2.dbf" FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Total_number_of_trips_generated_Base_year_5_2.DBF" LOOKUP LOOKUPI=1, NAME=Base, LOOKUP[1]=ZONE, RESULT=SUM_J, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=Future, LOOKUP[1]=ZONE, RESULT=OI, FAIL[3]=0 ;Set parameters and array PAR ZONES=4 ARRAY TAU=4 ;read tij MW[1]=MI.1.1 ; calculate (tau)I : (tau)i=Ti/ti ; Future(1,I)=Ti totals generated per zone in future matrix; Base(1,I)=Ti totals generated per zone in base year TAU[I]=Future(1,I)/Base(1,I) ;multiply each origin-destination value per origin values (same value per each row in the matrix) MW[1]=MW[1]*TAU[I] ENDRUN BACK …

33 Ch5-TDM: Ex5.2 – Alternative way with FRATAR BACK …  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

34 RUN PGM=FRATAR PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5FRA02A.PRN“, MSG='Example 5.2 - alternative way using FRATAR' FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Output\Chapter5\Total_number_of_trips_generated_Base_year_5_2.DBF" FILEI MATI[1] = {MATI.Q}, PATTERN=IJ:V FIELDS=O D TRIPS FILEI LOOKUPI[1] = {LOOKUPI.Q} FILEO MATO[1] = {MATO.Q}, MO=1,NAME=FACTOREDMAT, DEC=1*D PARAMETERS ZONES=4, MAXITERS=1 ; USE A LOOKUP FILE TO find appropriate factors (1.0 is assumed unless expressly provided) LOOKUP LOOKUPI=1, LIST=Y, NAME=GROWTHF, LOOKUP[1]=ZONE,RESULT=OI, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 LOOKUP LOOKUPI=2, LIST=Y, NAME=GROWTHB, LOOKUP[1]=ZONE,RESULT=SUM_J, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 ;using fratar syntax we have: ; P[1]= generation values for purpose [1] ; A[1]=0 not used to constrain the final matrix; ; MW[1]=tij ; CONTROL[1]: define how update the original matrix ; CONTROL[1]=P set the matrix matching the generation values SETPA P[1]=GROWTHF(1,I) A[1]=0 MW[1]=MI.1.1 CONTROL[1]=P ;alternative control values are: ; CONSTROL[1]=A for a destination-specific factors ; CONTROL[1]=PA the average value between generation and attraction values ENDRUN Ch5-TDM: Ex5.2 – Alternative way with FRATAR BACK …

35 RUN PGM=DISTRIBUTION PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5DST02A.PRN“, MSG='Example 5.2 - alternative way using DISTRIBUTION' FILEI ZDATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_future_year_5_2.dbf", Z=ZONE FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\FUTURE_ESTIMATED_TRIP_MATRIX_5_2_B.MAT", MO=1 DEC=5 NAME="Future Matrix" FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_2_A.MAT" PARAMETERS MAXITERS=1 ;using DISTRIBUTION syntax we have: ; P[1]= generation values for purpose [1] ; A[1]=1 not used to constrain the final matrix; ; MW[21]=tij ; ATTSUM: total of generated ; PAF= (tau)i MW[21]=MI.1.1 SETPA P[1]=ZI.1.OI A[1]=1 MW[1]=A[1]*MW[21] ATTSUM=ROWSUM(1) IF(ATTSUM>0) PAF=P[1]/ATTSUM MW[1]=PAF*MW[1] ENDRUN Ch5-TDM: Ex5.2 – Alternative way with DISTRIBUTION BACK …

36 Ch5-TDM: Ex5.3 - Doubly Constrained BACK …  Click on the script file boxes below to see the scripts

37 Ch5-TDM: Ex5.3 – Doubly constrained distribution BACK …  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

38 RUN PGM=FRATAR PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5FRA03A.PRN“, MSG='Example 5.3 - using FRATAR "as steps from 2 to 9"' FILEI MATI[1] = {MATI.Q} FILEI LOOKUPI[1] = {LOOKUPI.Q} FILEO MATO[1] = {MATO.Q}, MO=1,NAME=FACTOREDMAT, DEC=1*5 PARAMETERS MAXRMSE=0 MAXITERS=25 ; USE A LOOKUP FILE TO find appropriate factors (1.0 is assumed unless expressly provided) LOOKUP LOOKUPI=1, LIST=Y, NAME=GROWTHF, LOOKUP[1]=ZONE,RESULT=OI, LOOKUP[2]=ZONE,RESULT=DJ, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 SETPA P[1]=GROWTHF(1,I)*100 A[1]=GROWTHF(2,I)*100 MW[1]=MI.1.1*100 CONTROL[1]=AP MW[1]=MW[1]/100 ENDRUN Ch5-TDM: Ex5.3 – Doubly constrained distribution BACK …  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

39 Ch5-TDM: Ex5.3 – Step 1 - Preparing trip end data RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03A.PRN“, MSG='Example 5.3 - total number of trips generated and attracted per zone' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_3_A.MAT", MO=1 FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Total_#trips_gen_and_attr_Base_year_5_3.DBF", FIELDS=ZONE SUM_J SUM_I FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_2_A.MAT", PATTERN=IJ:V FIELDS=O D TRIPS ;read the base matrix MW[1]=MI.1.1 MW[2]=MI.1.1.T ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ENDRUN BACK …

40 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03B.PRN“, MSG='Example 5.3 - step (2)' FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter5\ai_and_bj_values_5_3.txt", APPEND=T FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5LOO03A.DBF" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5LOO03A.MAT", PATTERN=IJ:V FIELDS=O D TRIPS FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_3_1.MAT", MO=1 DEC=1*6 NAME="Step 2" FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf" LOOKUP LOOKUPI=1, NAME=Base, LOOKUP[1]=ZONE, RESULT=SUM_J, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=Future, LOOKUP[1]=ZONE, RESULT=OI, FAIL[3]=0 ;calculate (tau)i (as example 5.2) ;set parameters and array PAR ZONES=4 ARRAY TAU=4 ;base matrix MW[1]=MI.1.1 ;(tau)i=Ti/ti TAU[I]=Future(1,I)/Base(1,I) ;multiply base matrix per (tau)i MW[1]=MW[1]*TAU[I] PRINT PRINTO=1 LIST='Iteration: ', @IDLOOP@(L) ' Zone ', I(L), ' ai= ' TAU[I](10.5) ENDRUN Ch5-TDM: Ex5.3 – Step 2 - Doubly constrained BACK …

41 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03D.PRN“, MSG='Example 5.3 - total number of trips after (1)' FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03B.DBF", FIELDS=ZONE SUM_J(10.6) SUM_I(10.6) FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_3_1.MAT" ;read the base matrix MW[1]=MI.1.1 MW[2]=MI.1.1.T ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ENDRUN Ch5-TDM: Ex5.3 – Step 2 – prepare trip ends BACK …

42 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03C.PRN" MSG='Example 5.3 - step(3)' FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter5\ai_and_bj_values_5_3.txt", APPEND=T FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03B.DBF" FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_3_1.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03C.MAT", MO=1 DEC=1*6 NAME="Step 2" FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf" LOOKUP LOOKUPI=1, NAME=Base, LOOKUP[1]=ZONE, RESULT=SUM_I, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=Future, LOOKUP[1]=ZONE, RESULT=DJ, FAIL[3]=0 ;calculate (tau)j (as example 5.2 but with a transposed matrix, since we have to work on destinations) ;set parameters and array PAR ZONES=4 ARRAY TAU=4 ;base matrix MW[1]=MI.1.1.T ;this is the transposed matrix ;(tau)j=Tj/tj TAU[I]=Future(1,I)/Base(1,I) ;multiply base matrix per (tau)j MW[1]=MW[1]*TAU[I] PRINT PRINTO=1 LIST='Iteration: ', @IDLOOP@(L) ' Zone ', I(L), ' bj= ' TAU[I](10.5) ENDRUN Ch5-TDM: Ex5.3 – Step 3 - Doubly constrained BACK …

43 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03E.PRN“, MSG='Example 5.3 - traspose matrix' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_3_2.MAT", MO=1 DEC=1*6 NAME="Step 2" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03C.DBF", FIELDS=ZONE SUM_J(10.6) SUM_I(10.6) FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT03C.MAT" ;read the base matrix (note that next step will work on i values, the input matrix must be transposed) MW[1]=MI.1.1.T MW[2]=MI.1.1 ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ENDRUN Ch5-TDM: Ex5.3 – Transpose matrix BACK …

44 Ch5-TDM: Ex5.4 - Properties of the Gravity Model BACK …  Click on the script file boxes below to see the scripts  Only first two program boxes and their scripts are shown

45 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT14I.PRN“, MSG='Example 5.4 - matrix exp(-beta*cij)' FILEI ZDATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf", Z=ZONE FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT14F.MAT", MO=1-2 DEC=2*5 NAME="Cost Matrix" "Exp Term" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT14D.DBF", FIELDS=TOTAL_E(10.5) TOTAL_F(10.5) TAU(10.5) FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Cost_matrix_base_year_5_4.dbf", PATTERN=IJ:V FIELDS=O D TIME ;set parameters PAR ZONES=4 ;read the base matrix MW[1]=MI.1.1 ;calculate exp(-(beta)*cij) MW[2]=exp(-{beta}*MW[1]) ;calculate the base matrix total _TOTAL=ROWSUM(2)+_TOTAL ;calculate the future matrix total _TOTAL_F=ZI.1.OI+_TOTAL_F IF(I=ZONES) ;calculate the expansion factor tau=T/t RO.TOTAL_E=_TOTAL RO.TOTAL_F=_TOTAL_F RO.TAU =_TOTAL_F/_TOTAL WRITE RECO=1 ENDIF ENDRUN Ch5-TDM: Ex5.4 – Create base matrix BACK …

46 Ch5-TDM: Ex5.4 – Gravity distribution with FRATAR BACK …  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

47 RUN PGM=FRATAR PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5FRA14A.PRN“, MSG='Example 5.4 - Gravity model using "FRATAR" as steps from 3 to 9' FILEI MATI[1] = {MATI.Q} FILEI LOOKUPI[1] = {LOOKUPI.Q} FILEO MATO[1] = {MATO.Q}, MO=1,NAME=FACTOREDMAT, DEC=1*5 PARAMETERS MAXRMSE=0 MAXITERS=50 ; USE A LOOKUP FILE TO find appropriate factors (1.0 is assumed unless expressly provided) LOOKUP LOOKUPI=1, LIST=Y, NAME=GROWTHF, LOOKUP[1]=ZONE,RESULT=OI, LOOKUP[2]=ZONE,RESULT=DJ, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 MW[3]=MI.1.1 SETPA P[1]=GROWTHF(1,I)*100 A[1]=GROWTHF(2,I)*100 MW[1]=MI.1.2*100 CONTROL[1]=P MW[1]=MW[1]/100 FREQUENCY BASEMW=3,VALUEMW=1,RANGE=1-24,4,REPORT=99, TITLE='Ranges(min)' ENDRUN Ch5-TDM: Ex5.4 – Gravity distribution with FRATAR BACK …  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

48 Ch5-TDM: Ex5.5 - Bi-proportional Fitting BACK …  Click on the script file boxes below to see the scripts

49 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5MAT05A.PRN“, MSG='Example 5.5 - create tables 5.11 and 5.13' FILEO MATO[2] = "C:\Modelling Transport_CG\Output\Chapter5\Future_estimated_trip_matrix_5_5_B.MAT", MO=2 NAME="Base Marix B" FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_5.MAT", MO=1 NAME="Base Marix A" FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_2_A.MAT" ;read the original data MW[1]=MI.1.1 MW[2]=MI.1.1 ;modify original data to perform exercises ;set to zero cells (2,1) (2,3) (2,4) and (2,2)=50 Table 5.11 JLOOP IF(I=2&&J=1,3-4) MW[1]=0 IF(I=2&&J=2) MW[1]=50 ENDJLOOP ;set to zero cells (2,1) (2,3) and (2,2)=50 (2,4)= 1 Table 5.13 JLOOP IF(I=2&&J=1,3) MW[2]=0 IF(I=2&&J=2) MW[2]=50 IF(I=2&&J=4) MW[2]=1 ENDJLOOP ENDRUN Ch5-TDM: Ex5.5 – Bi-proportional Fitting, step 1 BACK …

50 Ch5-TDM: Ex5.5 – Bi-proportional Fitting, step 2 BACK …  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

51 RUN PGM=FRATAR PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5FRA05A.PRN“, MSG='Example 5.5 - 100 iterations Table 5.12' FILEI MATI[1] = {MATI.Q} FILEI LOOKUPI[1] = {LOOKUPI.Q} FILEO MATO[1] = {MATO.Q}, MO=1,NAME=FACTOREDMAT, DEC=1*5 PARAMETERS MAXRMSE=0 MAXITERS=100 ; USE A LOOKUP FILE TO find appropriate factors (1.0 is assumed unless expressly provided) LOOKUP LOOKUPI=1, LIST=Y, NAME=GROWTHF, LOOKUP[1]=ZONE,RESULT=OI, LOOKUP[2]=ZONE,RESULT=DJ, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 SETPA P[1]=GROWTHF(1,I)*100 A[1]=GROWTHF(2,I)*100 MW[1]=MI.1.1*100 CONTROL[1]=AP MW[1]=MW[1]/100 ENDRUN Ch5-TDM: Ex5.5 – Bi-proportional Fitting, step 2 BACK …  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

52 Ch5-TDM: Ex5.5 – Bi-proportional Fitting, step 3 BACK …  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

53 RUN PGM=FRATAR PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E5FRA05B.PRN“, MSG='Example 5.5 - 100 iterations Table 5.13' FILEI MATI[1] = {MATI.Q} FILEI LOOKUPI[1] = {LOOKUPI.Q} FILEO MATO[1] = {MATO.Q}, MO=1,NAME=FACTOREDMAT, DEC=1*5 PARAMETERS MAXRMSE=0 MAXITERS=100 ; USE A LOOKUP FILE TO find appropriate factors (1.0 is assumed unless expressly provided) LOOKUP LOOKUPI=1, LIST=Y, NAME=GROWTHF, LOOKUP[1]=ZONE,RESULT=OI, LOOKUP[2]=ZONE,RESULT=DJ, FAIL[1]=1,FAIL[2]=1,FAIL[3]=1 SETPA P[1]=GROWTHF(1,I)*100 A[1]=GROWTHF(2,I)*100 MW[1]=MI.1.1*100 CONTROL[1]=AP MW[1]=MW[1]/100 ENDRUN Ch5-TDM: Ex5.5 – Bi-proportional Fitting, step 3 BACK …  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

54 Ch5-TDM: Ex5.6 – A Tri-proportional Problem BACK …  Click on the script file boxes below to see the scripts

55 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.PRN“, MSG='Example 5.6 - costs and delta_ijm' FILEO MATO[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT", MO=2 NAME='Delta mij' FILEI MATI[2] = "C:\Modelling Transport_CG\Output\Chapter5\Base_year_trip_matrix_5_3_A.MAT" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.DBF", FIELDS=TOTAL_E(18.10) TOTAL_F(18.10) TAU(18.10) FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_TLD_future_year_5_6.dbf",SORT=RANGE_MIN RANGE_MAX FILEO RECO[2] = "C:\Modelling Transport_CG\Output\Chapter5\Delta_ijm.DBF", FIELDS=M I J DELTA FILEI ZDATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf", Z=ZONE FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.MAT", MO=3 DEC=1*5 NAME="Base Matrix" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Cost_matrix_base_year_5_4.dbf", PATTERN=IJ:V FIELDS=O D TIME ;set parameters and array PAR ZONES=4 ARRAY CLASS_MIN =6 ;minimum in the n class ARRAY CLASS_MAX =6 ;maximum in the n class ;read ranges per each class IF(I=1) LOOP K=1,DBI.1.NUMRECORDS C=DBIReadRecord(1,K) MCLASS=DI.1.M RMIN =DI.1.RANGE_MIN RMAX =DI.1.RANGE_MAX CLASS_MIN[MCLASS]=RMIN CLASS_MAX[MCLASS]=RMAX ; script continues on NEXT page ENDLOOP ENDIF Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 NEXT …

56 ; SCRIPT CONTINUED FROM PREVIOUS PAGE ;read base cost matrix MW[1]=MI.1.1 ;costs in minutes MW[3]=1 ;create the 3-dimension matrix for i, j and m with: ; 1 - if cost for the cell is in class m ; 0 - if cost for the cell is not in class m ;note: ; the same information can be represented by an i-j matrix where the od value is the class ; to make more efficient the application has been applied this representation. ; loop over classes LOOP T=1,6 JLOOP IF(I=1&&J=2) MW[2]=3 RO.M=T RO.I=I RO.J=J RO.DELTA=1 WRITE RECO=2 ELSEIF(I=2&&J=3) MW[2]=4 RO.M=T RO.I=I RO.J=J RO.DELTA=1 WRITE RECO=2 ; script continues on NEXT page Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 NEXT …

57 ; SCRIPT CONTINUED FROM PREVIOUS PAGE ELSEIF(I=3&&J=1) MW[2]=5 RO.M=T RO.I=I RO.J=J RO.DELTA=1 WRITE RECO=2 ELSEIF(CLASS_MIN[T] { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/3279459/11/slides/slide_56.jpg", "name": "; SCRIPT CONTINUED FROM PREVIOUS PAGE ELSEIF(I=3&&J=1) MW[2]=5 RO.M=T RO.I=I RO.J=J RO.DELTA=1 WRITE RECO=2 ELSEIF(CLASS_MIN[T]

58 ; SCRIPT CONTINUED FROM PREVIOUS PAGE ;calculate the base matrix total _TOTAL=ROWSUM(3)+_TOTAL ;calculate the future matrix total _TOTAL_F=ZI.1.OI+_TOTAL_F IF(I=ZONES) ;calculate the expansion factor tau=T/t RO.TOTAL_E=_TOTAL RO.TOTAL_F=_TOTAL_F RO.TAU =_TOTAL_F/_TOTAL WRITE RECO=1 ENDIF ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 BACK …

59 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06B.PRN" FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_TLD_future_year_5_6.dbf" FILEI MATI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT" FILEO RECO[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06C.DBF", FIELDS=OTIME OTRIP(10.5) MTRIP(18.10) FILEI DBI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.DBF" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06B.DBF", FIELDS=ZONE SUM_J(18.10) SUM_I(18.10) FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06B.MAT", MO=3 DEC=1*5 NAME="Matrix Prepared" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.MAT" ARRAY TFD =6 LOOKUP LOOKUPI=1, NAME=FUTVAL, LOOKUP[1]=M, RESULT=TLD, INTERPOLATE=T ;initialize work variables C=DBIReadRecord(1,1) _TAU=DI.1.TAU ; 1 ;read rescaled base matrix MW[1]=MI.1.1 MW[2]=MI.1.1.T ;multiply per tau value MW[3]=_TAU*MW[1] MW[4]=_TAU*MW[2] MW[5]=MI.2.1 ;classes ; script continues on NEXT page Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 NEXT …

60 ; SCRIPT CONTINUED FROM PREVIOUS PAGE ;calculate the generated and attracted values _Generated= ROWSUM(3) ;sum over cell by row _Attracted= ROWSUM(4) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted WRITE RECO=1 ;classify trips per length classes LOOP T=1,6 JLOOP IF(MW[5]=T) TFD[T]=TFD[T]+MW[3] ELSE TFD[T]=TFD[T] ENDIF ENDJLOOP ENDLOOP ; merge the trip length distribution for base year with forecasting year IF(I=4) LOOP U=1,6 RO.OTIME=U RO.OTRIP=FUTVAL(1,U) RO.MTRIP=TFD[U] WRITE RECO=2 ENDLOOP ENDIF ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 BACK …

61 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06C.PRN“, MSG='Example 5.6- ai calculation' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06K.PRN", APPEND=T FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6LOO06A.DBF" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6LOO06A.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06C.MAT", MO=1 DEC=1*10 NAME="Step 2" FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf" LOOKUP LOOKUPI=1, NAME=Base, LOOKUP[1]=ZONE, RESULT=SUM_J, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=Future, LOOKUP[1]=ZONE, RESULT=OI, FAIL[3]=0 ;calculate (tau)i (as example 5.2) ;set parameters and array PAR ZONES=4 ARRAY TAU=4 ;base matrix MW[1]=MI.1.1 ;ai=Ti/ti TAU[I]=Future(1,I)/Base(1,I) ;multiply base matrix per ai MW[1]=MW[1]*TAU[I] PRINT PRINTO=1 LIST='Iteration: ', @IDLOOP@(L) ' Zone ', I(L), ' ai= ' TAU[I](18.10) ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 1 BACK …

62 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06E.PRN“, MSG='Example 5.6- revised totals after ai correction' FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06C.MAT" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06D.DBF", FIELDS=ZONE SUM_J(18.10) SUM_I(18.10) ;read the base matrix MW[1]=MI.1.1 MW[2]=MI.1.1.T ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 0 BACK …

63 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.PRN“, MSG='Example 5.6 - bj calculation' FILEO PRINTO[1] = "C:\Modelling Transport_CG\Applications\Chapter5\E6MAT06K.PRN", APPEND=T FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06C.MAT" FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06D.DBF" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06D.MAT", MO=1 DEC=1*10 NAME="Step 2" FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\Input\Chapter5\Target_Oi_Dj_future_year_5_3.dbf" LOOKUP LOOKUPI=1, NAME=Base, LOOKUP[1]=ZONE, RESULT=SUM_I, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=Future, LOOKUP[1]=ZONE, RESULT=DJ, FAIL[3]=0 ;calculate bj (as example 5.2 but with a transposed matrix, since we have to work on destinations) ;set parameters and array PAR ZONES=4 ARRAY TAU=4 ;base matrix MW[1]=MI.1.1.T ;this is the transposed matrix ;bj=Tj/tj TAU[I]=Future(1,I)/Base(1,I) ;multiply base matrix per bj MW[1]=MW[1]*TAU[I] PRINT PRINTO=1 LIST='Iteration: ', @IDLOOP@(L) ' Zone ', I(L), ' bj= ' TAU[I](10.7) ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 2 BACK …

64 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.PRN“, MSG='Example 5.6- transpose matrix and Fm calculation' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06L.PRN", APPEND=T FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\Input\Chapter5\Target_TLD_future_year_5_6.dbf" FILEI MATI[3] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT" FILEI MATI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.MAT" FILEO RECO[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.DBF", FIELDS=OTIME OTRIP(18.10) MTRIP(18.10) FM(18.10) FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06D.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06E.MAT", MO=1 DEC=1*10 NAME="Step 2 Tras" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06E.DBF", FIELDS=ZONE SUM_J(18.10) SUM_I(18.10) ARRAY TFD=6 LOOKUP LOOKUPI=1, NAME=FUTVAL, LOOKUP[1]=M, RESULT=TLD, INTERPOLATE=T MW[1]=MI.1.1.T MW[2]=MI.1.1 MW[3]=MI.2.1 ;base cost matrix MW[4]=MI.3.1 ;classes ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) ; script continues on NEXT page Ch5-TDM: Ex5.6 – Tri-proportional problem, step 2 NEXT …

65 ; SCRIPT CONTINUED FROM PREVIOUS PAGE RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ;classify trips per length classes LOOP T=1,6 JLOOP IF(MW[4]=T) TFD[T]=TFD[T]+MW[1] ELSE TFD[T]=TFD[T] ENDIF ENDJLOOP ENDLOOP ; merge the trip length distribution for base year with forecasting year IF(I=4) LOOP U=1,6 RO.OTIME=U RO.OTRIP=FUTVAL(1,U) RO.MTRIP=TFD[U] _fm=FUTVAL(1,U)/TFD[U] RO.FM =FUTVAL(1,U)/TFD[U] WRITE RECO=2 PRINT PRINTO=1 CSV=T LIST= @IDLOOP@(L) U(L) _fm(10.5) ENDLOOP ENDIF ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 2 BACK …

66 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06I.PRN“, MSG='Example 5.6 - Fm* deltaijm calculation' FILEI MATI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT" FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.DBF" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06E.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.MAT", MO=3 DEC=1*10 NAME="Step 3" LOOKUP LOOKUPI=1, NAME=DetFunction, LOOKUP[1]=OTIME, RESULT=FM, FAIL[3]=0 MW[1]=MI.1.1 ;demand MW[2]=MI.2.1 ;classes JLOOP ;calculate the future demand based on the formulation: ; Tij=ai*bj*(Sum)m*Fm*(delta)ijm MW[3]=MW[1]*DetFunction(1,MW[2]) ENDJLOOP ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 3 BACK …

67 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06J.PRN" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06G.DBF", FIELDS=ZONE SUM_J(18.10) SUM_I(18.10) FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.MAT" ;read the base matrix MW[1]=MI.1.1 MW[2]=MI.1.1.T ;calculate the generated and attracted values _Generated= ROWSUM(1) ;sum over cell by row _Attracted= ROWSUM(2) RO.ZONE=I RO.SUM_J=_Generated RO.SUM_I=_Attracted ;save into table WRITE RECO=1 ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, step 3 BACK …

68 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06D.PRN“, MSG='Example 5.6 - Tri-proportional Problem' FILEI MATI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06F.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06G.MAT", MO=1 DEC=1*10 NAME="Future matrix" MW[1]=MI.1.1 MW[2]=MI.2.1 FREQUENCY BASEMW=2,VALUEMW=1,RANGE=1-6,1,REPORT=99, TITLE='Ranges(min)' ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, results BACK …

69 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06M.PRN“, MSG='Example 5.6 - Final ai, bj and FM parameters' FILEI DBI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06A.DBF" FILEO RECO[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06I.DBF", FIELDS=N_ITER_F CLASS FM(18.10) FILEI DBI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06L.PRN", DELIMITER=',' N_ITER_F=#1 CLASS=#2 FM=#3 FILEI RECI = "C:\Modelling Transport_CG\Applications\Chapter5\E6MAT06K.PRN" FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.DBF", FIELDS=N_ITER ZONE AI(18.10) BJ(18.10) ARRAY AI=4,5 ;number of zones*number of iterations ARRAY BJ=4,5 ;number of zones*number of iterations ARRAY FM=6,5 ;number of classes *number of iterations ;initialize work variables C=DBIReadRecord(2,1) _TAU=DI.2.TAU N_ITER =RECI.NFIELD[2] ZONE =RECI.NFIELD[4] _count=_count+1 IF(_count=1-4) AI[ZONE][N_ITER] =RECI.NFIELD[6] ELSE BJ[ZONE][N_ITER] =RECI.NFIELD[6] ENDIF IF(_count=8) _Count=0 ; script continues on NEXT page Ch5-TDM: Ex5.6 – Tri-proportional problem, results NEXT …

70 ; SCRIPT CONTINUED FROM PREVIOUS PAGE IF(I=0) LOOP K=1,4 ; LOOP T=1,3 ; RO.N_ITER=T RO.ZONE =K RO.AI =AI[K][1]*AI[K][2]*AI[K][3]*AI[K][4]*AI[K][5] RO.BJ =BJ[K][1]*BJ[K][2]*BJ[K][3]*BJ[K][4]*BJ[K][5] WRITE RECO=1 ; ENDLOOP ENDLOOP LOOP K=1,DBI.1.NUMRECORDS C=DBIReadRecord(1,K) N_ITER_F =DBI.1.NFIELD[1] CLASS =DBI.1.NFIELD[2] FM[CLASS][N_ITER_F]=DBI.1.NFIELD[3] IF(N_ITER_F=5) RO.N_ITER_F=N_ITER_F RO.CLASS =CLASS RO.FM=FM[CLASS][1]*FM[CLASS][2]*FM[CLASS][3]*FM[CLASS][4]*FM[CLASS][5]*_TAU WRITE RECO=2 ENDIF ENDLOOP ENDIF ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, results BACK …

71 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06G.PRN“, MSG='Example 5.6 - Check results' FILEI LOOKUPI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.DBF" FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter5\Estimated_matrix_5_6.MAT", MO=2 Name='Estimated matrix' DEC=10 FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06I.DBF" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER5\E6MAT06H.MAT" LOOKUP LOOKUPI=1, NAME=DetFunction, LOOKUP[1]=CLASS, RESULT=FM, FAIL[3]=0 LOOKUP LOOKUPI=2, NAME=AiBj_value, LOOKUP[1]=ZONE, RESULT=AI, LOOKUP[2]=ZONE, RESULT=BJ, FAIL[3]=0 MW[1]=MI.1.1 ;classes JLOOP MW[2]=AiBj_value(1,I)*AiBj_value(2,J)*DetFunction(1,MW[1]) ENDJLOOP ENDRUN Ch5-TDM: Ex5.6 – Tri-proportional problem, results BACK …

72 Chapter 6: Modal Split and Direct Demand Models  Click on the boxes below to select the various examples BACK TO MAIN MENU

73 Ch6-MSM: Ex6.2 – Binomial and Multinomial Split BACK …  Click on the script file boxes below to see the scripts

74 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT01A.PRN“, MSG='Example 6.2 - car and bus costs' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Costs_6_2_A.MAT", MO=1-2 NAME='Costs CAR' 'Costs BUS' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter6\Costs_6_2_A.DBF", PATTERN=IJM:V FIELDS=O D M COST PAR ZONES=2 FILLMW MW[1]=MI.1.1(2) ENDRUN Ch6-MSM: Ex6.2 – Binomial Split BACK …

75 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT01B.PRN“, MSG='Example 6.2 - Multimodal-split model using XCHOICE' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Probabilities_6_2_A.MAT", MO=4-6 Name='Car propabibilty' 'Bus probability' 'Composite cost kijn' FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter6\Costs_6_2_A.MAT" ;costs MW[1]=MI.1.1 ;car MW[2]=MI.1.2 ;bus ;demand JLOOP IF(I=1&&J=2) MW[3]=1 ;demand (just to calculate probabilities the demand is defined equal 1) ENDJLOOP XCHOICE, ALTERNATIVES=car, bus, ; list choices DEMANDMW = 3, ; input total demand COSTSMW= 1, 2, ; input costs ODEMANDMW= 4, 5, ; forecasted probabilities SPLIT= Total {beta6} car bus, ; Model structure SPLITCOMP= 6, ; Forecast composite cost STARTMW= 10 ; working matrices ;Note on SPLITCOMP : composite cost by mode ; Cij = - 1/beta*log(exp(-beta*CCar)+exp(-beta*CBus)) ENDRUN BACK … Ch6-MSM: Ex6.2 – Binomial Split

76 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT01C.PRN“, MSG='Example 6.2 - car, red and blue bus costs' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Costs_6_2_B.MAT", MO=1-3 NAME='Costs CAR' 'Costs BLUE BUS' 'Costs RED BUS' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter6\Costs_6_2_B.DBF", PATTERN=IJM:V FIELDS=O D M COST PAR ZONES=2 FILLMW MW[1]=MI.1.1(3) ENDRUN BACK … Ch6-MSM: Ex6.2 – Multinomial Split

77 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT01D.PRN" MSG='Example 6.2 - Multimodal-split model using XCHOICE' FILEI MATI[1] = "C:\Modelling Transport_CG\Output\Chapter6\Costs_6_2_B.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Probabilities_6_2_B.MAT", MO=5-8 Name='Car probability' 'Blue Bus probability' 'Red Bus probability' 'Composite cost kijn' ;costs MW[1]=MI.1.1 ;car MW[2]=MI.1.2 ;blue bus MW[3]=MI.1.3 ;red bus ;demand JLOOP IF(I=1&&J=2) MW[4]=1 ;demand (just to calculate probabilities the demand is defined equal 1) ENDJLOOP XCHOICE, ALTERNATIVES=car, bbus, rbus, ; list choices DEMANDMW = 4, ; input total demand COSTSMW= 1, 2, 3, ; input costs ODEMANDMW= 5, 6, 7, ; Forecasted probabilities SPLIT= Total {beta6} car bbus rbus, ; Model structure SPLITCOMP= 8, ; Forecast composite cost STARTMW= 10 ; working matrices ;Note on SPLITCOMP : composite cost by mode ; Cij = - 1/beta*log(exp(-beta*CCar)+exp(-beta*CBus)) ENDRUN BACK … Ch6-MSM: Ex6.2 – Multinomial Split

78 Ch6-MSM: Ex6.3 – Hierarchical Multinomial Split BACK …  Click on the script file boxes below to see the scripts

79 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT01A.PRN“, MSG='Example 6.2 - car and bus costs' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Costs_6_2_A.MAT", MO=1-2 NAME='Costs CAR' 'Costs BUS' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter6\Costs_6_2_A.DBF", PATTERN=IJM:V FIELDS=O D M COST PAR ZONES=2 FILLMW MW[1]=MI.1.1(2) ENDRUN Ch6-MSM: Ex6.3 – Hierarchical Multinomial Split BACK …

80 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT03D.PRN“, MSG='Example 6.3 - Hierarchich Multimodal-split model using XCHOICE' FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT03C.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Probabilities_6_3.MAT", MO=5-9 Name='Car prob‘ 'Blue Bus prob' 'Red Bus prob' 'Composite cost top level' 'Composite cost PT level' ;costs MW[1]=MI.1.1 ;car MW[2]=MI.1.2 ;blue bus MW[3]=MI.1.3 ;red bus ;demand JLOOP IF(I=1&&J=2) MW[4]=1 ;demand (just to calculate probabilities the demand is defined equal 1) ENDJLOOP XCHOICE, ALTERNATIVES=car, bbus, rbus, ;list choices top level DEMANDMW = 4, ;input total demand COSTSMW= 1, 2, 3, ;input costs ODEMANDMW= 5, 6, 7, ;Forecasted probabilities ; Model structure SPLIT= Total {lambda1} car pt, ;Top lebel nest SPLITCOMP= 8, ;Forecast composite cost top level SPLIT = PT {lambda2} bbus rbus, ;PT nest SPLITCOMP= 9, ;Forecast composite cost PT level STARTMW= 10 ;working matrices ;Note on SPLITCOMP : composite cost by mode ; CB = CBB - 1/(lambda2)*log2 ENDRUN Ch6-MSM: Ex6.3 – Hierarchical Multinomial Split BACK …

81 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT03A.PRN“, MSG='Example 6.3 - Summary Table - see page 216' FILEI LOOKUPI[1] = "C:\Modelling Transport_CG\Input\Chapter6\Lambda1_values_6_3.dbf" FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Probability_car_6_3.DAT", APPEND=T FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT03C.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT03A.MAT", MO=5-9 Name='Car prob' 'Blue Bus prob' 'Red Bus prob' 'Composite cost top level‘ 'Composite cost PT level' LOOKUP LOOKUPI=1, NAME=Lambda1, LOOKUP[1]=ITER, RESULT=LAMBDA1, FAIL[3]=0 ; example of use: v=Lambda1_values_(1,25) ; look for 25 in the ITER field and returns the LAMBDA1 value ;costs MW[1]=MI.1.1 ;car MW[2]=MI.1.2 ;blue bus MW[3]=MI.1.3 ;red bus Value=Lambda1(1,@IDLOOP@) ;demand JLOOP IF(I=1&&J=2) MW[4]=1 ;demand (just to calculate probabilities the demand is defined equal 1) ENDJLOOP ; script continues on NEXT page Ch6-MSM: Ex6.3 – Hierarchical Multinomial Split NEXT …

82 ; SCRIPT CONTINUED FROM PREVIOUS PAGE XCHOICE, ;list choices top level ALTERNATIVES=car, bbus, rbus, ;input total demand DEMANDMW = 4, ;input costs COSTSMW= 1, 2, 3, ; Forecated probabilites ODEMANDMW= 5, 6, 7, ; Model structure ; Top lebel nest SPLIT= Total Value car pt, ; Forecast composite cost top level SPLITCOMP= 8, ; PT nest SPLIT = PT {lambda2} bbus rbus, ; Forecast composite cost PT level SPLITCOMP= 9, ;working matrices STARTMW= 10 ;Note on SPLITCOMP : composite cost by mode ; CB = CBB - 1/(lambda2)*log2 JLOOP IF(I=1&&J=2) PRINT PRINTO=1 CSV=F LIST='Lambda1: ', Value(5.3L), ' Car Probability: ',MW[5](5.3L) ENDJLOOP ENDRUN Ch6-MSM: Ex6.3 – Hierarchical Multinomial Split BACK …

83 Ch6-MSM: Ex6.4 – Calibration of Binary Logit BACK …  Click on the script file boxes below to see the scripts

84 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04A.PRN“, MSG='Example 6.4 - Berkson-Theil trasformation' FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04A.DBF", FIELDS=ZONEP Axis_x(10.2) Axis_Y(10.5) FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter6\Costs_and_choices_6_4.dbf" ZONEP=RI.ZONEP ;Zone pair P1 =RI.P1 ;Observed probability for mode 1 (in percentage) P2 =RI.P2 ;Observed probability for mode 2 (in percentage) C1 =RI.C1 ;Cij1 'know' part of the generalized cost for mode 1 C2 =RI.C2 ;Cij2 'know' part of the generalized cost for mode 2 ;log[P1/(1-P1)]=log[P1/P2] depended variable ;C2 - C1 indipendent variable ;lambda - slope of the line ;lambda+delta - intercept Axis_x = C2-C1 Axis_y=LN(P1/(100-P1)) WRITE RECO=1 ENDRUN Ch6-MSM: Ex6.4 – Calibration of Binary Logit BACK …

85 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04B.PRN“, MSG='Example 6.4 - Linear regression for lambda and delta' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter6\RegreCoeffAndStats_6_4.DBF", FIELDS=AVE_X(10.5) AVE_Y(10.5) A(10.5) B(10.5) R2(10.8) LAMBDA(10.5) DELTA(10.5) FILEI RECI = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04A.DBF" ARRAY X=5 Y=5 Y_MOD=5 _Count=_Count+1 X[_Count]=RI.AXIS_X Y[_Count]=RI.AXIS_Y _SUm_X=X[_Count]+_SUM_X _SUM_Y=Y[_Count]+_SUM_Y IF(_Count=5) _AVERAGE_X=_SUM_X/_COUNT _AVERAGE_Y=_SUM_Y/_COUNT LOOP K=1,5 _SSX2=(X[K]-_AVERAGE_X)^2+_SSX2 _SSXY=(X[K]-_AVERAGE_X)*(Y[K]-_AVERAGE_Y)+_SSXY ENDLOOP ; script continues on NEXT page Ch6-MSM: Ex6.4 – Calibration of Binary Logit NEXT …

86 ; SCRIPT CONTINUED FROM PREVIOUS PAGE _A=_SSXY/_SSX2 ;this is lambda _B=_AVERAGE_Y-_A*_AVERAGE_X ;this is lambda*delta _DELTA=_B/_A LOOP K=1,5 Y_MOD[K]=_A*X[K]+_B _SSRESID=(Y_MOD[K]-_AVERAGE_Y)^2+_SSRESID _SSY2=(Y[K]-_AVERAGE_Y)^2+_SSY2 ENDLOOP _R2=_SSRESID/_SSY2 RO.R2=_R2 RO.A=_A RO.B=_B RO.AVE_X=_AVERAGE_X RO.AVE_Y=_AVERAGE_Y RO.LAMBDA=_A RO.DELTA =_DELTA WRITE RECO=1 ENDIF ENDRUN Ch6-MSM: Ex6.4 – Calibration of Binary Logit BACK …

87 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04D.PRN“, MSG='Example 6.4 - Read choices and costs as matrix' FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04B.MAT", MO=1-4 NAME=C1 C2 P1 P2 FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter6\Costs_and_choices_6_4.dbf", PATTERN=IJM:V FIELDS=ORIG DEST 0 C1 C2 P1 P2 PAR ZONES=3 FILLMW MW[1]=MI.1.1(4) ENDRUN Ch6-MSM: Ex6.4 – Calibration of Binary Logit BACK …

88 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04C.PRN“, MSG='Example 6.4 - Verify calibration using XCHOICE' FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04B.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT04A.MAT", MO=4-8 Name='Probabibilty 1' 'Probability 2' 'Composite cost kijn' 'Ril prob 1' 'Ril prob 2' ;costs MW[1]=MI.1.1 ;C1 MW[2]=MI.1.2 + 3.10978 ;C2 ;Rilevated choices MW[7]=MI.1.3 ;P1 MW[8]=MI.1.4 ;P2 ;demand JLOOP IF(MW[1]<>0) MW[3]=1 ;demand (just to calculate probabilities the demand is defined equal 1) ENDIF ENDJLOOP XCHOICE, ALTERNATIVES=mode1, mode2, ;list choices DEMANDMW = 3, ;input total demand COSTSMW= 1, 2, ;input costs ODEMANDMW= 4, 5, ;Forecast probabilities SPLIT= Total 0.72105 mode1 mode2, ;Model structure SPLITCOMP= 6, ;Forecast composite cost STARTMW= 10 ;working matrices ;percentages MW[4]=MW[4]*100 MW[5]=MW[5]*100 ENDRUN Ch6-MSM: Ex6.4 – Calibration of Binary Logit BACK …

89 Ch6-MSM: Ex6.5 – Direct Demand Models BACK …  Click on the script file boxes below to see the scripts

90 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT05A.PRN“, MSG='Example 6.5 - Tij' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Tij_6_5_A.DBF", FIELDS=Tij(5.0) Tijd(5.0) PAR ZONES=1 ;Inputs t12=2 ;Time in hours c12=1 ;Fare in dollars q12=5 ;Service frequency in trips per day _Alpha=-2 _Beta =-1 _Nu =0.8 ;model equation Tij=10000*t12^_Alpha*c12^_Beta*q12^_Nu Deltac12=0.2 Tijd=10000*t12^_Alpha*(c12*(1+Deltac12))^_Beta*q12^_Nu WRITE RECO=1 ENDRUN Ch6-MSM: Ex6.5 – Direct Demand Models BACK …

91 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER6\E6MAT05B.PRN“, MSG='Example 6.5 - Plot feasible solutions' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter6\Feasible_solutions_6_5.DBF", FIELDS=DeltaQ(10.2) DeltaT(10.5) PAR ZONES=1 ;20values for variations on q and 10 values for variations on t ;Range between -1 and +1 LOOP K=1,41 DeltaQ=(-1+(K-1)*0.05) ;DeltaT=(-0.5+(K-1)*0.1) DeltaT=0.4*DeltaQ-0.1 WRITE RECO=1 ENDLOOP ENDRUN Ch6-MSM: Ex6.5 – Direct Demand Models BACK …

92 Chapter 8: Specification and Estimation of Discrete Choice Models  Click on the boxes below to select the various examples BACK TO MAIN MENU

93 Ch8-MSM: Ex8.1 – Estimation of Models from Random Samples BACK …  Click on the script file boxes below to see the scripts

94 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER8\E8MAT01A.PRN“, MSG='Example 8.1 - L(theta) for different values of theta' FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter8\Choices_and_values_8_1.dbf" FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter8\Variation_L_theta_with_theta_8_1.DBF", FIELDS=THETA LTHETA(10.5) PAR ZONES=1 LOOP COUNT=1,100 _THETA=(COUNT-1)*0.025 LOOP K=1,DBI.1.NUMRECORDS C=DBIReadRecord(1,K) _CHOICE=DI.1.CHOICE X1Q =DI.1.X1Q X2Q =DI.1.X2Q IF(_CHOICE=1) _NUM_L=X1Q*_THETA+_NUM_L ELSE _NUM_L=X2Q*_THETA+_NUM_L ENDIF _DEN_L=_DEN_L+LN(EXP(X1Q*_THETA)+EXP(X2Q*_THETA)) _LTHETA=_NUM_L-_DEN_L ENDLOOP RO.THETA=_THETA RO.LTHETA=_LTHETA WRITE RECO=1 _DEN_L=0 _NUM_L=0 _LTHETA=0 ENDLOOP ENDRUN Ch8-MSM: Ex8.1 – Estimation of Models BACK …

95 Ch8-MSM: Ex8.11 – Stated Preference Data and Discrete Choice Modelling BACK …  Click on the script file boxes below to see the scripts

96 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER8\E8MAT02A.PRN“, MSG='Example 8.11 - Travel time' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter8\Value_Trave_Time_8_11.DBF", FIELDS=LEVEL TRAVTIME DIFFERENCES Rating DifRating RatMinute FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter8\Alternatives_and_score_8_11.dbf", SORT=TravTime ARRAY TravTime=3,2 IF(RI.TravTime=25) LEVEL=1 IF(RI.TravTime=15) LEVEL=2 IF(RI.TravTime=35) LEVEL=3 TravTime[LEVEL][1]=RI.TravTime TravTime[LEVEL][2]=RI.Score + TravTime[LEVEL][2] _MEAN=TravTime[1][1] IF(I=0) LOOP K=1,3 RO.LEVEL=K RO.TRAVTIME=TravTime[K][1] RO.DIFFERENCES=TravTime[K][1]-TravTime[K-1][1] RO.Rating=TravTime[K][2]/3 RO.DifRating=(TravTime[K][2]-TravTime[K-1][2])/3 RO.RatMinute=(TravTime[K][2]-TravTime[K-1][2])/((TravTime[K][1]-TravTime[K-1][1])*3) WRITE RECO=1 ENDLOOP ENDIF ENDRUN Ch8-MSM: Ex8.11 – Stated Preference and Discrete Choice Models BACK …

97 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER8\E8MAT02B.PRN“, MSG='Example 8.11 - Fare Level' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter8\Value_Fare_8_11.DBF", FIELDS=LEVEL Fare DIFFERENCES Rating DifRating RatingperP FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter8\Alternatives_and_score_8_11.dbf", SORT=Fare ARRAY Fare=3,2 IF(RI.Fare=1.3) LEVEL=1 IF(RI.Fare=1) LEVEL=2 IF(RI.Fare=1.5) LEVEL=3 Fare[LEVEL][1]=RI.Fare Fare[LEVEL][2]=RI.Score + Fare[LEVEL][2] _MEAN=Fare[1][1] IF(I=0) LOOP K=1,3 RO.LEVEL=K RO.Fare=Fare[K][1] RO.DIFFERENCES=Fare[K][1]-Fare[K-1][1] RO.Rating=Fare[K][2]/3 RO.DifRating=(Fare[K][2]-Fare[K-1][2])/3 RO.RatingperP=(Fare[K][2]-Fare[K-1][2])/((Fare[K][1]-Fare[K-1][1])*3) WRITE RECO=1 ENDLOOP ENDIF ENDRUN Ch8-MSM: Ex8.11 – Stated Preference and Discrete Choice Models BACK …

98 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER8\E8MAT02C.PRN“, MSG='Example 8.11 - Headway' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter8\Value_Headway_8_11.DBF", FIELDS=LEVEL Headway DIFFERENCES Rating DifRating RatingperP FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter8\Alternatives_and_score_8_11.dbf", SORT=Headway ARRAY Headway=3,2 IF(RI.Headway=5) LEVEL=1 IF(RI.Headway=10) LEVEL=2 IF(RI.Headway=20) LEVEL=3 Headway[LEVEL][1]=RI.Headway Headway[LEVEL][2]=RI.Score + Headway[LEVEL][2] _MEAN=Headway[1][1] IF(I=0) LOOP K=1,3 RO.LEVEL=K RO.Headway=Headway[K][1] RO.DIFFERENCES=Headway[K][1]-Headway[K-1][1] RO.Rating=Headway[K][2]/3 RO.DifRating=(Headway[K][2]-Headway[K-1][2])/3 RO.RatingperP=(Headway[K][2]-Headway[K-1][2])/((Headway[K][1]-Headway[K-1][1])*3) WRITE RECO=1 ENDLOOP ENDIF ENDRUN Ch8-MSM: Ex8.11 – Stated Preference and Discrete Choice Models BACK …

99 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER8\E8MAT02D.PRN“, MSG='Example 8.11 - VehicleType' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter8\Value_Vehicle_Type_8_11.DBF", FIELDS=LEVEL VEH_TYPE Rating DifRating FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter8\Alternatives_and_score_8_11.dbf", SORT=Veh_Type ARRAY TYPE=C3 Veh_TypeC=3 ARRAY Veh_Type=4 IF(RI.Veh_Type='DB') LEVEL=1 IF(RI.Veh_Type='LRT') LEVEL=2 IF(RI.Veh_Type='MB') LEVEL=3 Veh_TypeC[1]='DB' Veh_TypeC[2]='LTR' Veh_TypeC[3]='MB' Veh_Type[LEVEL]=RI.Score + Veh_Type[LEVEL] Veh_Type[4]=Veh_Type[1] IF(I=0) LOOP K=1,3 RO.LEVEL=K RO.Veh_Type=Veh_TypeC[K] RO.Rating=Veh_Type[K]/3 IF(K=1) RO.DifRating=(Veh_Type[K]-Veh_Type[4])/3 ELSE RO.DifRating=(Veh_Type[K]-Veh_Type[K-1])/3 ENDIF WRITE RECO=1 ENDLOOP ENDIF ENDRUN Ch8-MSM: Ex8.11 – Stated Preference and Discrete Choice Models BACK …

100 Chapter 10: Assignment  Click on the boxes below to select the various examples BACK TO MAIN MENU

101 Ch10-AS: Ex10.2 – All or Nothing Assignment BACK …  Click on the script file boxes below to see the scripts

102 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER10\E2HWY01A.PRN“, MSG='Example 10.2 - All or Nothing assignment' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter10\ODMAT_10_2.MAT" FILEO PATHO[1] = "C:\Modelling Transport_CG\Output\Chapter10\Paths_10_2.PTH" FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter10\Output.mdb\LoadedNet_10_2" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter10\Input.mdb\ExampleNet_10_2" PAR MAXITERS=1 PROCESS PHASE=LINKREAD T0=LI.TCOST ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=COST, VOL[1]=MI.1.1, PATHO=1 NAME=AON ENDPROCESS PROCESS PHASE=ADJUST Function { V=VOL[1] TC=T0 COST=TIME } ENDPROCESS ENDRUN Ch10-AS: Ex10.2 – All or Nothing Assignment BACK …

103 Ch10-AS: Ex10.5 – Incremental Assignment BACK …  Click on the script file box below to see the script (only full process (left box) included here)  Refer to the Cube catalog to see scripts for step by step process

104 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER10\E5HWY01B.PRN“, MSG='Example 10.5 - Incremental Assignment - Full Process' FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter10\Input.mdb\ExampleNet_10_5" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER10\E5HWY01B.NET" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter10\ODMAT_10_5.MAT" PAR COMBINE=SUM FRACTIONS=0.4,0.3,0.2,0.1 PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } ENDPROCESS ENDRUN Ch10-AS: Ex10.5 – Incremental Assignment BACK …

105 Ch10-AS: Ex10.6 – Method of Successive Averages BACK …  Click on the script file box below to see the script (only full process (left box) included here)  Refer to the Cube catalog to see scripts for step by step process

106 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER10\E6HWY01B.PRN“, MSG='Example 10.6 - Method of Successive Averages' FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter10\Input.mdb\ExampleNet_10_5" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER10\E6HWY01B.NET" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter10\ODMAT_10_5.MAT" PAR COMBINE=AVE RELATIVEGAP=0 MAXITERS=10 PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } ENDPROCESS ENDRUN Ch10-AS: Ex10.6 – Method of Successive Averages BACK …

107 Chapter 11: Equilibrium and Dynamic Assignment  Click on the boxes below to select the various examples BACK TO MAIN MENU

108 Ch11-DA: Ex11.1 – A Mathematical Programming Approach BACK …  Click on the script file boxes below to see the scripts

109 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY00A.PRN“, MSG='Example 11.1 - User Equilibrium Assignment' FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter11\TotCostByIteration_11_1.dat" FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter11\Loaded_11_1.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=AVE RELATIVEGAP=0 MAXITERS=10 PROCESS PHASE=LINKREAD ; Use this phase to obtain initial values from the input network (LI.varname) and compute ; link values (LW.varname) that can be used in other phases. C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP ; This phase performs a zonal loop (I=1,Zones). This phase is required and must contain ; at least 1 PATHLOAD statement. Almost all MATRIX operation are available in this phase ; and the PATHLOAD statement can be used to build and load paths for assignment PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS ; script continues on NEXT page NEXT … Ch11-DA: Ex11.1 – A Mathematical Programming Approach

110 ; SCRIPT CONTINUED FROM PREVIOUS PAGE PROCESS PHASE=ADJUST ; This phase is automatically run after the ILOOP phase. The volume-delay functions (TC) are ; automatically recomputed in this phase to update the link congested travel times based ; on the volumes from the ILOOP phase. User defined link computations (LW.varname) that ; need to be updated based on the new congested travel times should be coded in this phase. FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.1 – A Mathematical Programming Approach

111 Ch11-DA: Ex11.2 – Social Equilibrium BACK …  Click on the script file boxes below to see the scripts  Only steps 1 and 4 included here

112 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E2HWY01A.PRN“, MSG='Example 11.2 - Social Equilibrium assignment' FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter11\TotCostByIteration_11_2.dat" FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter11\Loaded_11_2.NET", INCLUDE=LW.COST FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=AVE RELATIVEGAP=0 MAXITERS=4 PROCESS PHASE=LINKREAD ; Use this phase to obtain initial values from the input network (LI.varname) and compute ; link values (LW.varname) that can be used in other phases. C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP ; This phase performs a zonal loop (I=1,Zones). This phase is required and must contain ; at least 1 PATHLOAD statement. Almost all MATRIX operation are available in this phase ; and the PATHLOAD statement can be used to build and load paths for assignment PATHLOAD PATH=COST VOL[1]=MI.1.1 ; SOCIAL EQUILIBRIUM - pathload based on marginal cost ENDPROCESS ; script continues on NEXT page NEXT … Ch11-DA: Ex11.2 – Social Equilibrium

113 ; SCRIPT CONTINUED FROM PREVIOUS PAGE PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V COST[2]=T0 + 0.04*V ; marginal cost town for SOCIAL EQUILIBRIUM assignment COST[3]=T0 + 0.01*V ; marginal cost by-pass for SOCIAL EQUILIBRIUM assignment } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF IF (LI.CLASS=2) LW.COST=T0 + 0.04*V ELSEIF (LI.CLASS=3) LW.COST=T0 + 0.01*V ELSE LW.COST=0 ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.2 – Social Equilibrium

114 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E2HWY01C.PRN“, MSG='Example 11.2 - User Equilibrium with penalty (charge) on town link' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E2HWY01D.PRN" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E2HWY01B.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=AVE RELATIVEGAP=0 MAXITERS=4 PROCESS PHASE=LINKREAD ; Use this phase to obtain initial values from the input network (LI.varname) and compute ; link values (LW.varname) that can be used in other phases. C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP ; This phase performs a zonal loop (I=1,Zones). This phase is required and must contain ; at least 1 PATHLOAD statement. Almost all MATRIX operation are available in this phase ; and the PATHLOAD statement can be used to build and load paths for assignment PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS ; script continues on NEXT page Ch11-DA: Ex11.2 – User Equilibrium NEXT …

115 ; SCRIPT CONTINUED FROM PREVIOUS PAGE PROCESS PHASE=ADJUST ; This phase is automatically run after the ILOOP phase. The volume-delay functions (TC) are ; automatically recomputed in this phase to update the link congested travel times based ; on the volumes from the ILOOP phase. User defined link computations (LW.varname) that ; need to be updated based on the new congested travel times should be coded in this phase. FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V + 2.5 TC[3]=T0 + 0.005*V } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.2 – User Equilibrium

116 Ch11-DA: Ex11.3 – Equilibrium and Feedback BACK …  Click on the script file boxes below to see the scripts

117 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3HWY01A.PRN“, MSG='Example 11.3 - Initial HW Costs' FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter11\HWInitCosts_11_3.MAT", MO=1 DEC=9 NAME=HW_INIT_GCOSTS FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_3" PAR MAXITERS=1 PROCESS PHASE=LINKREAD LINKCLASS=LI.CLASS IF (LI.CLASS=10) ADDTOGROUP=1 ENDPROCESS PROCESS PHASE=ILOOP ; This phase performs a zonal loop (I=1,Zones). This phase is required and must contain ; at least 1 PATHLOAD statement. Almost all MATRIX operation are available in this phase ; and the PATHLOAD statement can be used to build and load paths for assignment PATHLOAD PATH=LI.T0 EXCLUDEGROUP=1 MW[1]=PATHCOST NOACCESS=0 ENDPROCESS PROCESS PHASE=ADJUST ; This phase is automatically run after the ILOOP phase. The volume-delay functions (TC) are ; automatically recomputed in this phase to update the link congested travel times based ; on the volumes from the ILOOP phase. User defined link computations (LW.varname) that ; need to be updated based on the new congested travel times should be coded in this phase. ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

118 RUN PGM=PUBLIC TRANSPORT PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3PTR01A.PRN“, MSG='Example 11.3 - Initial PT Costs' FILEO REPORTO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3PTR01B.PRN" FILEO ROUTEO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3PTR01A.RTE" FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter11\PTInitCosts_11_3.MAT", MO=1 DEC=9 NAME=PT_INIT_GCOSTS FILEI FACTORI[1] = "C:\Modelling Transport_CG\Input\Chapter11\FactorFile_11_3.FAC" FILEI SYSTEMI = "C:\Modelling Transport_CG\Input\Chapter11\SystemFile_11_3.PTS" FILEI LINEI[1] = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NETPT_11_3" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_3" PARAMETERS TRANTIME = LW.TRANTIME ;PROCESS PHASE=NODEREAD ; loops over all nodes computes node based scalar and array variables (Optional) ;ENDPROCESS PROCESS PHASE=LINKREAD ; loops over all links Computes link based scalar and array variables (Optional) LW.TRANTIME=LI.T0 ENDPROCESS ; script continues on NEXT page NEXT … Ch11-DA: Ex11.3 – Equilibrium and Feedback

119 ; SCRIPT CONTINUED FROM PREVIOUS PAGE PROCESS PHASE=DATAPREP ; generates/reads non-transit legs (Optional - Required for PT Network Development) ; NT legs for access and egress GENERATE FROMNODE=1, TONODE=108, COST=LI.T0, MAXCOST=1, NTLEGMODE=100, DIRECTION=1, MAXNTLEGS=1 GENERATE FROMNODE=107, TONODE=2, COST=LI.T0, MAXCOST=1, NTLEGMODE=100, DIRECTION=1, MAXNTLEGS=1 ENDPROCESS PROCESS PHASE=SKIMIJ ; saves and manipulates skims for zone pairs, IJ (Optional - Required for Skimming) MW[1]=COMPCOST(0) ; composite cost ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

120 ; PILOT STEP ; INITIALIZE CONVERGENCE VARIABLES CONV.DIFF=0 CONV.P_DIFF=0 BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

121 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3MAT01A.PRN“, MSG='Example 11.3 - Modal choice step' FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_3.MAT" FILEO MATO[1] = "C:\Modelling Transport_CG\Applications\Chapter11\TripsByMode_11_3.MAT", MO=21-22,13 DEC=3*9 NAME=CAR_TRIPS, PT_TRIPS COMPCOST FILEI MATI[3] = "C:\Modelling Transport_CG\Output\Chapter11\PTInitCosts_11_3.MAT" FILEI MATI[2] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3LOO01A.MAT" MW[10]=MI.1.1 MW[11]=MI.2.1 MW[12]=MI.3.1 jloop if (MW[11]=0) MW[11]=99999 if (MW[12]=0) MW[12]=99999 endjloop XCHOICE, ALTERNATIVES = CAR, PT, ; List choices DEMANDMW = 10, ; Input total demand COSTSMW = 11, 12, ; Input costs ODEMANDMW = 21,22, ; Forecast demand SPLIT = TOTAL 0.05 CAR, PT, ; Model structure SPLITCOMP = 13, ; Forecast composite cost STARTMW = 30 ; Working matrices REPORT MATSTAT=MI,MO,MW ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

122 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3HWY01B.PRN“, MSG='Example 11.3 - Current HW Assignment' FILEI MATI[1] = "C:\Modelling Transport_CG\Applications\Chapter11\TripsByMode_11_3.MAT" FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter11\Loaded_11_3.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_3" PAR COMBINE=EQU MAXITERS=100 PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS IF (LI.CLASS=10) ADDTOGROUP=1 ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 EXCLUDEGROUP=1 MW[1]=PATHCOST NOACCESS=0 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

123 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3HWY01C.PRN“, MSG='Example 11.3 - Current HW Costs' FILEO MATO[1] = "C:\Modelling Transport_CG\Applications\Chapter11\HWCosts_11_3.MAT", MO=1 DEC=9 NAME=HW_COST FILEI NETI = "C:\Modelling Transport_CG\Output\Chapter11\Loaded_11_3.NET" PARAMETERS MAXITERS=1 PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS IF (LI.CLASS=10) ADDTOGROUP=1 ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=LI.TIME_1 EXCLUDEGROUP=1 MW[1]=PATHTRACE(LI.TIME_1) NOACCESS=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

124 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3MAT01B.PRN" MSG='Example 11.3 - Compare matrix at k and k-1 loop' FILEO RECO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3MAT01A.DBF", FIELDS=DIFF P_DIFF(15.10) FILEO MATO[1] = "C:\Modelling Transport_CG\Applications\Chapter11\PreviousIterTrips_11_3.MAT", MO=3-4, DEC=2*9 NAME=PREVITER_HW PREVITER_PT FILEI MATI[2] = "C:\Modelling Transport_CG\Applications\Chapter11\TripsByMode_11_3.MAT" FILEI MATI[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3LOO01C.MAT" mw[1]=mi.1.2 ; previous transit trips mw[2]=mi.2.2 ; current transit trips mw[3]=mi.2.1 ; current auto trips output to become previous for next feedback iteration mw[4]=mw[2] ; current transit trips output to become previous for next feedback iteration MW[5]=mw[2]+mw[3] TOT_1=TOT_1+ROWSUM(1) TOT_2=TOT_2+ROWSUM(2) TOTAL=TOTAL+ROWSUM(5) DIFF=TOT_2-TOT_1 P_DIFF=DIFF/TOTAL LOG PREFIX=CONV VAR=P_DIFF LOG PREFIX=CONV VAR=DIFF IF(I=_ZONES) WRITE RECO=1 ENDIF ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

125 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3MAT01C.PRN“, MSG='Example 11.3 - Convergence report' FILEI RECI = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E3MAT01A.DBF" FILEO PRINTO[1] = "C:\Modelling Transport_CG\Output\Chapter11\Convergence_11_3.dat", APPEND=T DIFF=RI.DIFF P_DIFF=RI.P_DIFF IDLOOP=@AMLoop_1@ IF (@AMLoop_1@=1) PRINT LIST='------------------------------------------------------------' PRINTO=1 PRINT LIST='Loop'(10.0R) 'Difference'(25.0R), 'Percentage Difference'(25.0R) PRINTO=1 PRINT LIST='------------------------------------------------------------' PRINTO=1 ENDIF PRINT LIST=IDLOOP(10.R) DIFF(25.10) P_DIFF(25.10) PRINTO=1 IF (ABS(P_DIFF) 1) Converged=1 ELSE Converged=0 ENDIF LOG VAR=Converged ENDRUN BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

126 ; PILOT STEP IF (MATRIX.Converged=1) BREAK BACK … Ch11-DA: Ex11.3 – Equilibrium and Feedback

127 Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic BACK …  Click on the script file boxes below to see the scripts

128 BACK … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

129 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E4MAT01A.PRN“, MSG='Example 11.4 - Convert to MAT format' FILEI MATI[1] = {MATI1.Q}, PATTERN=IJ:V, FIELDS=I,J,V FILEO MATO[1] = {MATO.Q}, MO=1 NAME=TRIPS PARAMETERS ZONES={zones} MW[1]=MI.1.1 ENDRUN BACK … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

130 RUN PGM=NETWORK PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E4NET01A.PRN“, MSG='Example 11.4 - Create network' FILEO NETO = "C:\Modelling Transport_CG\Applications\Chapter11\Net_11_4.NET" FILEI NODEI[1] = "C:\Modelling Transport_CG\Input\Chapter11\Nodes_11_4.dbf" FILEI LINKI[1] = "C:\Modelling Transport_CG\Input\Chapter11\Links_11_4.dbf" ZONES=2 PROCESS PHASE=LINKMERGE LANES=1 IF (A<=2 || B<=2) STORAGE=9999 CLASS=1 ELSE STORAGE=DISTANCE*1000*LANES/5.75 ; 5.75 meters used as Average Length of a vehicle in a queue CLASS=2 ENDIF ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic

131 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E4HWY01A.PRN“, MSG='Example 11.4 - Conventional traffic assignment' FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter11\Highway_11_4.NET" FILEI NETI = "C:\Modelling Transport_CG\Applications\Chapter11\Net_11_4.NET" FILEI MATI[1] = "C:\Modelling Transport_CG\Applications\Chapter11\MATRIX_11_4.MAT" PARAMETERS MAXITERS=1 ALPHA=4 BETA=4 PROCESS PHASE=LINKREAD DISTANCE=LI.DISTANCE C=LI.CAPACITY T0=LI.T0 LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=LI.T0 ; assume free flow speed for centroid connectors TC[2]=T0*(1+ALPHA*(V/C)^BETA) ; See page 353 equation 10.6 } ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic

132 RUN PGM=AVENUE PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E4AVN01A.PRN" MSG='Example 11.4 - DTA' FILEO PACKETLOG = "C:\Modelling Transport_CG\Output\Chapter11\PacketLog_11_4.LOG" FILEO NETO = "C:\Modelling Transport_CG\Output\Chapter11\Avenue_11_4.NET", EXCLUDE=LANES FILEI NETI = "C:\Modelling Transport_CG\Applications\Chapter11\Net_11_4.NET" FILEI MATI[1] = "C:\Modelling Transport_CG\Applications\Chapter11\MATRIX_11_4.MAT" PARAMETERS MAXITERS=3 MODELPERIOD=60, SEGMENTS=1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, VEHPERDIST=181.81 X=RANDSEED(165) ; seed random numbers ALPHA=4 BETA=4 PROCESS PHASE=LINKREAD DISTANCE=LI.DISTANCE C=LI.CAPACITY T0=LI.T0 LINKCLASS=LI.CLASS STORAGE=LI.STORAGE ENDPROCESS ; script continues on NEXT page NEXT … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic

133 ; SCRIPT CONTINUED FROM PREVIOUS PAGE PROCESS PHASE=ILOOP ; This phase performs a zonal loop (I=1,Zones). ; DYNAMICLOAD is the dynamic analogue of the static PATHLOAD statement. ; If DYNAMICLOAD is used for dynamic traffic assignment the PARAMETERS MODELPERIOD= and SEGMENTS= must be used. ; During the ILOOP phase with DYNAMICLOAD, the path-building algorithm is invoked to calculate routes, and any ; flows resulting from the movement of packets during previous iterations are removed from the volume fields. ; Unlike a static load, no flows are assigned to the network at this stage in the process. LOOP K=1,60 MW[K]=mi.1.1 ENDLOOP DYNAMICLOAD PATH=TIME PACKETSIZE=1 VOL[1]=MW[__TS__] DEMANDISHOURLY=T ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=LI.T0 ; assume free flow speed for centroid connectors TC[2]=T0*(1+ALPHA*(V/C)^BETA) ; See page 353 equation 10.6 } ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.4 – The Dynamic Nature of Traffic

134 Ch11-DA: Ex11.5 – Equilibrium and Simulation BACK …  Click on the script file boxes below to see the scripts

135 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01A.PRN“, MSG='Example 11.5 - Prioity Junction' FILEO TURNPENO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01A.DAT" FILEO TURNVOLO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01A.TRN" FILEO JUNCTIONO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01A.INT" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01A.NET" FILEI JUNCTIONI = "C:\Modelling Transport_CG\Input\Chapter11\JunctionFile1_11_5.ind", SET=1 PERIOD=60 FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_5" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PARAMETERS COMBINE=EQUI MAXITERS=50 EQUITURNCOSTFAC=1 PROCESS PHASE=LINKREAD T0=LI.T0 C=LI.CAPACITY ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 PENI=1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION TC=T0 ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.5 – Equilibrium and Simulation

136 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01B.PRN“, MSG='Example 11.5 - Roundabout' FILEO TURNPENO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01B.DAT" FILEO TURNVOLO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01B.TRN" FILEO JUNCTIONO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01B.INT" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\E1HWY01B.NET" FILEI JUNCTIONI = "C:\Modelling Transport_CG\Input\Chapter11\JunctionFile2_11_5.ind", SET=1 PERIOD=60 FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_5" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PARAMETERS COMBINE=EQUI EQUITURNCOSTFAC=1 MAXITERS=50 PROCESS PHASE=LINKREAD T0=LI.T0 C=LI.CAPACITY ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 PENI=1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION TC=T0 ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 ENDPROCESS ENDRUN BACK … Ch11-DA: Ex11.5 – Equilibrium and Simulation

137 Ch11-DA: Additional Examples (convergence) BACK …  As Example 11.1 using... 1) Frank-Wolfe and 2) Route Based Assignment  Click on the script file boxes below to see the scripts

138 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01A.PRN“, MSG='Frank-Wolfe Algorithm' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01B.PRN" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01A.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=EQUI RELATIVEGAP=0 MAXITERS=10 ;The Frank-Wolfe algorithm has invoked using COMBINE=EQUI PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Additional Examples (convergence)

139 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01C.PRN“, MSG='Route-Based Assignment' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01D.PRN" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01B.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=PATH RELATIVEGAP=0 MAXITERS=10 ; The Route Based Assignment algorithm has invoked using COMBINE=PATH PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME VOL[1]=MI.1.1 ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Additional Examples (convergence)

140 RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01E.PRN“, MSG='Burrell Assignment' FILEO PRINTO[1] = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01F.PRN" FILEO NETO = "C:\Modelling Transport_CG\APPLICATIONS\CHAPTER11\AEHWY01C.NET" FILEI NETI = "C:\Modelling Transport_CG\Input\Chapter11\Input.mdb\NET_11_1" FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter11\ODMat_11_1.MAT" PAR COMBINE=BURRELL STOCHASTICSEED=123 RELATIVEGAP=0 MAXITERS=10 ; The Burrell Assignment algorithm has invoked ; using COMBINE=PROBIT and adding few keywords on the PATH statement PROCESS PHASE=LINKREAD C=LI.CAPACITY LINKCLASS=LI.CLASS ENDPROCESS PROCESS PHASE=ILOOP PATHLOAD PATH=TIME SPREADMAX=5 SPREADPERC=100 VOL[1]=MI.1.1 ;for burrell two more keywords SPREADMAX/SPREADPERC ENDPROCESS PROCESS PHASE=ADJUST FUNCTION { TC[1]=T0 TC[2]=T0 + 0.02*V TC[3]=T0 + 0.005*V } IF (ITERATION>1) TOT_COST=TOT_COST+V*TIME ENDIF ENDPROCESS PROCESS PHASE=CONVERGE IF (RGAP=0) BALANCE=1 PRINT LIST='ITERATION:', ITERATION(5.0), ' TOTAL EXPENDITURE:', TOT_COST(10.0) PRINTO=1 TOT_COST=0 ENDPROCESS ENDRUN BACK … Ch11-DA: Additional Examples (convergence)

141 Chapter 12: Simplified Transport Demand Models  Click on the boxes below to select the various examples BACK TO MAIN MENU

142 Ch12-SDM: Ex12.1 – Incremental Elasticity Analysis BACK …  Click on the script file boxes below to see the scripts

143 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER12\E2MAT01A.PRN“, MSG='Example 12.1' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter12\Results_12_1.DBF", FIELDS=ES S T DeltaT FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter12\Inputs_12_1.dbf" T0 = RI.T0 ;initial level of demand ES = RI.ES ;the fare/demand elasticity of public transport S0 = RI.AVEFARE ;average fare [Pence/trip] ;Using T-T0=Es*T0*(S-S0)/S0 S =S0*(1+0.025) ;fare increases by 2.5% T=T0+ES*T0*(S-S0)/S0 DeltaT=T-T0 WRITE RECO=1 ENDRUN BACK … Ch12-SDM: Ex12.1 – Incremental Elasticity Analysis

144 Ch12-SDM: Ex12.2 – Incremental or Pivot-point BACK …  Click on the script file boxes below to see the scripts

145 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\APPLICATIONS\CHAPTER12\E2MAT02A.PRN“, MSG='Example 12.2' FILEI DBI[1] = "C:\Modelling Transport_CG\Input\Chapter12\Inputs_12_2.dbf" FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter12\Results_12_2.DBF", FIELDS=BUS1 RAIL1 CAR1 FILEI RECI = "C:\Modelling Transport_CG\Input\Chapter12\LOS_12_2.dbf" ARRAY WAITRAIL=2 WAITBUS=2 PERIOD=RI.PERIOD WAITRAIL[PERIOD]=RI.WAITTIMER ;wait time for period 0 and 1 on rail wR WAITBUS[PERIOD] =RI.WAITTIMEB ;wait time for period 0 and 1 on bus wB IF(I=0) C=DBIReadRecord(1,1) BUS0=DI.1.BUS0 ;initial proportion of trips on bus RAIL0=DI.1.RAIL0 ;initial proportion of trips on rail CAR0=DI.1.CAR0 ;initial proportion of trips on car ; script continues on NEXT page NEXT … Ch12-SDM: Ex12.2 –Incremental or Pivot-point

146 ; SCRIPT CONTINUED FROM PREVIOUS PAGE ;generalised utility function ; Vk = -0.10*tk-0.20*wk-0.05Ck/I + (delta)k ; where: ; - tk: in-vehicle travel time; ; - wk: waiting time; ; - Ck/I: cost divided by Income; ; - (delta)k: modal penalty. ;apply the equation (12.3) BUS1=BUS0*EXP(-0.2*(WAITBUS[2]-WAITBUS[1]))/(BUS0*EXP(-0.2*(WAITBUS[2]-WAITBUS[1]))+RAIL0*EXP(-0.2*(WAITRAIL[2]- WAITRAIL[1]))+CAR0*EXP(0)) RAIL1=RAIL0*EXP(-0.2*(WAITRAIL[2]-WAITRAIL[1]))/(BUS0*EXP(-0.2*(WAITBUS[2]-WAITBUS[1]))+RAIL0*EXP(- 0.2*(WAITRAIL[2]-WAITRAIL[1]))+CAR0*EXP(0)) CAR1=CAR0*EXP(0)/(BUS0*EXP(-0.2*(WAITBUS[2]-WAITBUS[1]))+RAIL0*EXP(-0.2*(WAITRAIL[2]-WAITRAIL[1]))+CAR0*EXP(0)) WRITE RECO=1 ENDIF ENDRUN BACK … Ch12-SDM: Ex12.2 –Incremental or Pivot-point

147 Ch12-SDM: Ex12.3 – Matrix Estimation (w/ Analyst) BACK …  Click on the script file boxes below to see the scripts

148 RUN PGM=MATRIX PRNFILE="C:\Modelling Transport_CG\Applications\Chapter12\E2MAT03A.PRN“, MSG='Example 12.3 - Calculate S(Tij) and S1(Tij/tij)' FILEO RECO[1] = "C:\Modelling Transport_CG\Output\Chapter12\ObjectFunctions_12_3.DBF", FIELDS=S_Tij_1(10.5) S_Tij_2(10.5) S_Tij_3(10.5) S_Tij_4(10.5) S_Tij_5(10.5) S_Tij_6(10.5) FILEO MATO[1] = "C:\Modelling Transport_CG\Output\Chapter14\ODMAT_12_3.MAT", MO=7-8 NAME= PRIOR CONF FILEI MATI[1] = "C:\Modelling Transport_CG\Input\Chapter12\Matrices_12_3.dbf", PATTERN=IJM:V FIELDS=O D 0 TRIPS_1 TRIPS_2 TRIPS_3 TRIPS_4 TRIPS_5 TRIPS_6 PRIOR PAR ZONES=4 ARRAY S_Tij=6 S1_Tij_tij=6 FILLMW MW[1]=MI.1.1(7) JLOOP IF(MW[1]!=0) S_Tij[1]=S_Tij[1]+MW[1]*LN(MW[1])-MW[1] S1_Tij_tij[1]=S1_Tij_tij[1]+MW[1]*LN(MW[1]/MW[7])-MW[1]+MW[7] ELSE S_Tij[1]=S_Tij[1] S1_Tij_tij[1]=S1_Tij_tij[1] ENDIF IF(MW[2]!=0) S_Tij[2]=S_Tij[2]+MW[2]*LN(MW[2])-MW[2] S1_Tij_tij[2]=S1_Tij_tij[2]+MW[2]*LN(MW[2]/MW[7])-MW[2]+MW[7] ELSE S_Tij[2]=S_Tij[2] S1_Tij_tij[2]=S1_Tij_tij[2] ENDIF ; script continues on NEXT page NEXT … Ch12-SDM: Ex12.3 –Matrix Estimation (w/ Analyst)

149 ; SCRIPT CONTINUED FROM PREVIOUS PAGE IF(MW[3]!=0) S_Tij[3]=S_Tij[3]+MW[3]*LN(MW[3])-MW[3] S1_Tij_tij[3]=S1_Tij_tij[3]+MW[3]*LN(MW[3]/MW[7])-MW[3]+MW[7] ELSE S_Tij[3]=S_Tij[3] S1_Tij_tij[3]=S1_Tij_tij[3] ENDIF IF(MW[4]!=0) S_Tij[4]=S_Tij[4]+MW[4]*LN(MW[4])-MW[4] S1_Tij_tij[4]=S1_Tij_tij[4]+MW[4]*LN(MW[4]/MW[7])-MW[4]+MW[7] ELSE S_Tij[4]=S_Tij[4] S1_Tij_tij[4]=S1_Tij_tij[4] ENDIF IF(MW[5]!=0) S_Tij[5]=S_Tij[5]+MW[5]*LN(MW[5])-MW[5] S1_Tij_tij[5]=S1_Tij_tij[5]+MW[5]*LN(MW[5]/MW[7])-MW[5]+MW[7] ELSE S_Tij[5]=S_Tij[5] S1_Tij_tij[5]=S1_Tij_tij[5] ENDIF ; script continues on NEXT page Ch12-SDM: Ex12.3 –Matrix Estimation (w/ Analyst) NEXT …

150 ; SCRIPT CONTINUED FROM PREVIOUS PAGE IF(MW[6]!=0) S_Tij[6]=S_Tij[6]+MW[6]*LN(MW[6])-MW[6] S1_Tij_tij[6]=S1_Tij_tij[6]+MW[6]*LN(MW[6]/MW[7])-MW[6]+MW[7] ELSE S_Tij[6]=S_Tij[6] S1_Tij_tij[6]=S1_Tij_tij[6] ENDIF ENDJLOOP MW[8]=1 IF(I=_ZONES) RO.S_Tij_1=-S_Tij[1] RO.S_Tij_2=-S_Tij[2] RO.S_Tij_3=-S_Tij[3] RO.S_Tij_4=-S_Tij[4] RO.S_Tij_5=-S_Tij[5] RO.S_Tij_6=-S_Tij[6] WRITE RECO=1 RO.S_Tij_1=-S1_Tij_tij[1] RO.S_Tij_2=-S1_Tij_tij[2] RO.S_Tij_3=-S1_Tij_tij[3] RO.S_Tij_4=-S1_Tij_tij[4] RO.S_Tij_5=-S1_Tij_tij[5] RO.S_Tij_6=-S1_Tij_tij[6] WRITE RECO=1 ENDIF ENDRUN BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)

151 BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)  This example uses Cube’s template system  Click on ‘Go To Editor’ in the menu below to see the script

152 ;; > > > > > >;; ;{Title,note,12,"Single Matrix Equilibrium Traffic using Time"}>>> ;{note2,note,10,"Input / Output Specification"}>>> ;Input Highway Network: {neti,filename,"Input Highway Network File",x,"C:\Modelling Transport_CG\Input\Chapter12\NET_12_3.NET","Network File (*.net)|*.net"} ;Input OD Matrix: {mati,filename,"Input OD Matrix File",x,"C:\Modelling Transport_CG\Output\Chapter14\ODMAT_12_3.MAT","Matrix File (*.mat)|*.mat"} ;Output Highway Network: {neto,filename,"Output Highway Network File",x,"C:\Modelling Transport_CG\Applications\Chapter12\E2HWY03A.NET","Network File (*.net)|*.net"} ;{note3,note,10,"Cost Function"} Highway Assignment>>> ;Cost function:{cost_fun,editbox,"Cost Function e.g. TIME*1+LI.DISTANCE*0.3",T,"TIME*1"} ;Number of paths:{NPATH,editbox,"Number of paths to be generated",N,"1"} ;; >;; RUN PGM=HIGHWAY PRNFILE="C:\Modelling Transport_CG\Applications\Chapter12\E2HWY03A.PRN" MSG='Example 12.3' FILEO ESTMICPO="C:\Modelling Transport_CG\Applications\Chapter12\E2HWY03A.ICP",COUNTVAR=LI.COUNT,DEFAULTCONF=100 FILEO ESTMDATO = "C:\Modelling Transport_CG\Applications\Chapter12\E2HWY03A.DAT" FILEI NETI = {NETI.Q} FILEI MATI[1] = {MATI.Q} FILEO NETO = {NETO.Q} PAR MAXITERS={NPATH} PROCESS PHASE=ILOOP PATHLOAD PATH=TIME, VOL[1]=MI.1.1 ESTMO=1 ALLJ=T ; load trips ENDPROCESS ENDRUN BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)  This is a script generated by a template  The FILEI, FILEO and parameter settings come from the dialog on the previous slide

153 BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)  This example uses Cube’s control file editor for Analyst  Click on ‘Choose Option’ and ‘Set Parameters’ in the menu below to continue

154 BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)  This is Analyst’s options menu  Options are selected by ticking the relevant boxes  Click on ‘Parameters’ or ‘OK’ to go back to previous menu

155 BACK … Ch12-SDM: Ex12.3 –Matrix Estimation (w/Analyst)  This is Analyst’s parameters menu  Parameters are set by ticking the relevant items and entering the values downn left  Click on ‘Options’ or ‘OK’ to go back to previous menu

156 Ch12-SDM: Ex12.4 – Matrix Estimation (w/ Analyst) BACK …  This example shows the complexity of Analyst’s matrix estimation  Each step inside an Analyst run is completed with Voyager programs  For more information please see the full setup and scripts in the live version of the guide

157 Ch12-SDM: Ex12.5 – Matrix Estimation (w/ Analyst) BACK …  This example shows how Voyager’s programs are used to prepare data for estimation  For more information please see the full setup and scripts in the live version of the guide

158 Chapter 12: Simplified Transport Demand Models  Click on the boxes below to select the various examples BACK TO MAIN MENU

159 Ch14-ABM: Ex14.1 – Population Synthesis BACK …  This example shows how Voyager’s programs are used to prepare data for an activity based model  For more information please see the full setup and scripts in the live version of the guide


Download ppt "Modelling Transport – CUBE Guide Examples based on the book ‘Modelling Transport’, 4 th edition by Ortuzar/Willumsen (© 2011 John Wiley & Sons, Ltd) Citilabs."

Similar presentations


Ads by Google