• No results found

Modelling Transport - Cube Guidebook

N/A
N/A
Protected

Academic year: 2021

Share "Modelling Transport - Cube Guidebook"

Copied!
159
0
0

Loading.... (view fulltext now)

Full text

(1)

Modelling Transport

– CUBE Guide

Examples based on the book

‘Modelling Transport’, 4th 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 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

(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

 

(4)

Cube: Professional Desktop Modeling

Suite

Click to edit Master text styles

Second level

Third level

Fourth level

Fifth level

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

(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

(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

(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

(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

(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 4th

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

(11)

§

Modelling Transport" 4th Edition, John Wiley & Sons

§

Available from http://

eu.wiley.com/WileyCDA/WileyTitle/productCd-0470760397.html

§

Also available from www.Amazon.com and www.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

(12)

§

Part of the Cube’s Learning Center on

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

(13)

§

The main page with links to the apps with examples from each chapter of the book

(14)

Chapter 4 : Trip Generation Modelling

(15)

Ch4-TGM : Ex4.1 - Growth-factor Modelling

(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

(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

(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

(19)

Ch4-TGM : Ex4.3 - Linear regression

(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

(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

(22)

Ch4-TGM : Additional examples

(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]

(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]

(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

(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

(27)

Chapter 5: Trip Distribution Modelling

(28)

Ch5-TDM: Ex5.1 - Uniform Growth-factor

(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

(30)

Ch5-TDM: Ex5.2 - Singly Constrained

(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

(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]

(33)

Ch5-TDM: Ex5.2 – Alternative way with

FRATAR

§

This example uses Cube’s template system

(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

(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)

Ch5-TDM: Ex5.2 – Alternative way with

DISTRIBUTION

(36)

Ch5-TDM: Ex5.3 - Doubly Constrained

(37)

Ch5-TDM: Ex5.3 – Doubly constrained

distribution

§

This example uses Cube’s template system

(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

§

This is a script generated by a template

(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

(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

(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

(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

(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

(44)

Ch5-TDM: Ex5.4 - Properties of the Gravity

Model

§

Click on the script file boxes below to see the scripts

(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

(46)

Ch5-TDM: Ex5.4 – Gravity distribution with

FRATAR

§

This example uses Cube’s template system

(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

(48)

Ch5-TDM: Ex5.5 - Bi-proportional Fitting

(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

Ch5-TDM: Ex5.5 – Bi-proportional Fitting,

step 1

(50)

Ch5-TDM: Ex5.5 – Bi-proportional Fitting,

step 2

§

This example uses Cube’s template system

(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

(52)

Ch5-TDM: Ex5.5 – Bi-proportional Fitting,

step 3

§

This example uses Cube’s template system

(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

(54)

Ch5-TDM: Ex5.6 – A Tri-proportional

Problem

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 0

(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

(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]<MW[1]&&MW[1]<=CLASS_MAX[T]) MW[2]=T RO.M=T RO.I=I RO.J=J RO.DELTA=1 WRITE RECO=2 ELSE RO.M=T RO.I=I RO.J=J RO.DELTA=0 WRITE RECO=2 ENDIF ENDJLOOP

ENDLOOP ; script continues on NEXT page

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 0

(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

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 0

(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

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 1

(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

(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)

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 2

(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

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

step 2

(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

(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

(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

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

results

(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

(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

Ch5-TDM: Ex5.6 – Tri-proportional problem,

results

(72)

Chapter 6: Modal Split and Direct Demand

Models

(73)

Ch6-MSM: Ex6.2 – Binomial and

Multinomial Split

(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

(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))

(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

(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

(78)

Ch6-MSM: Ex6.3 – Hierarchical Multinomial

Split

(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

(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

(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)

Ch6-MSM: Ex6.3 – Hierarchical Multinomial

Split

(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

(83)

Ch6-MSM: Ex6.4 – Calibration of Binary

Logit

(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

(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

Ch6-MSM: Ex6.4 – Calibration of Binary

Logit

(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

(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

(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

(89)

Ch6-MSM: Ex6.5 – Direct Demand Models

(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

(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

(92)

Chapter 8: Specification and Estimation of

Discrete Choice Models

(93)

Ch8-MSM: Ex8.1 – Estimation of Models

from

Random Samples

(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

(95)

Ch8-MSM: Ex8.11 – Stated Preference Data

and

Discrete Choice Modelling

(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

(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)

Ch8-MSM: Ex8.11 – Stated Preference and

Discrete Choice Models

References

Related documents

The twenty seed samples for two varieties (Qulqulluu and Digalu) each from ten seed sources [seed samples obtained from Haramaya University Wheat Research

Cube Reports works seam- lessly through Cube Base, supporting mod- els from Cube Voyager, Cube Cargo, Cube Avenue, Cube Analyst, and Cube Compact. Cube Reports can be used on any

When I disconnect the cable connecting the PC to the camera and double- click the removable disk icon, a message appears and the window does not open.. FinePixViewer automatic

Feelings Cube Game How much play its first player rolls the cubes reading take two words that fabulous face because The player who rolled the dice.. When exactly as well done within

The emotion caused by what for a moment seemed almost a diplomatic incident was diverted by the appearance of two Chinese servants in long silk robes and four-sided hats

The other three faces look similar to the three shown in Fig. To obtain this pattern, start with the pattern shown in Fig. The front upper right and back lower left corners may

Being longer in size and having greater number of moves and steps, Pakistani acknowledgements were highly complex, elaborated, and distinct variety in its generic

Services available through a public cloud, or private clouds hosted externally with Cube52, benefit from the physical security afforded to the servers which are hosted within