Python modules for typical travel demand modeling calculations
Contributors: Chetan Joshi, Portland OR
Requires: Python with standard modules and numpy
Tested With: Data from DVRPC and Waterloo demand models
License: The MIT License (MIT)
License URI: https://opensource.org/licenses/MIT
Description: These are some python scripts that can be used as modules for performing typical calculations in a travel demand model. The expected usage is to put the py file in the site packages or other directory and then to use the import command in python to load the functions in the modules. The documentation for usage of each of the functions is shown in the python scripts and it should also show up in the help as you type the function.
a) CalcFratar : Calculates a Fratar/IPF on a seed matrix given row and column (P and A) totals
b) CalcSinglyConstrained : Calculates a singly constrained trip distribution for given P/A vectors and a friction factor matrix
c) CalcDoublyConstrained : Calculates a doubly constrained trip distribution for given P/A vectors and a friction factor matrix (P and A should be balanced before usage, if not then A is scaled to P)
d) CalcMultiFratar : Applies fratar model to given set of trip matrices with multiple target production vectors and one attraction vector
e) CalcMultiDistribute : Applies gravity model to a given set of friction matrices with multiple production vectors and one target attraction vector
f) CalcGravityShadow : Implements attraction balancing by scaling attractions instead of furnessing flows, this method is more 'correct'
a) CalcMultinomialChoice : Calculates a multinomial choice model probability given a dictionary of mode utilities
b) CalcPivotPoint : Calculates pivot point choice probability given base utilities, current utilities and base proabilities
c) CalcNestedChoice : Calculates n-level nested mode choice probabilities given dictionary with tree definition, matrix references and number of zones
d) CalcNestedChoiceFlat : Calculate nested choice on flat array so it can be used for stuff like microsim ABM etc. usage is same as c) but inputs are flat arrays instead of square matrices and length of vector/s instead of number of zones
Matrix estimation (ODME):
a) MatEstimateGradient : Performs synthetic matrix estimation using a least squares formulation. The solution algorithm is gradient descent (see Spiess, H., "A GRADIENT APPROACH FOR THE O-D MATRIX ADJUSTMENT PROBLEM", Publication 693, CRT, University of Montreal, 1990.)
If you use some of the components or code in this repo, please consider citing as shown below. Have fun!
Joshi. C, python-tdm, (2015), GitHub repository, https://github.com/joshchea/python-tdm#python-tdm