﻿Commute Pattern Analyzer 通勤模式分析工具 – 王灿的个人网站

# 写在前面 Notice

1. 这是一个完全免费的工具。
This is a completely free tool.

2. 我不是专业码农，因此不能保证功能不出现问题。如果你在使用中发现任何bug，请和我联系，除了用户电脑本身的问题以外，绝大多数的问题都可以得到及时解决。
It is hard to get rid of all bugs, and I cannot make guarantee for the functionality of the tool. If you find any bug when using it, please contact with me. I promise that most of the problems (expect those caused only by your computer) could be solved in time.

3. 本工具基于Matlab 2015a GUI开发，因此，你的电脑中可能需要安装Matlab Runtime 2015a，具体请看此页
This tool is developed based on Matlab 2015a GUI, thus you might need to install Matlab Runtime 2015a in advance. You can refer to this page.

CommutePatternAnalyzer

# 功能介绍 Introduction of Functionality

The so-called commute pattern refers to the trip distribution matrix among zones. The main function of this tool is to calculate different kinds of trip distribution matrices given traffic cost and total population & jobs of zones. In fact, non-commuting trip patterns could also be analyzed in the similar way.

First, users could employ classical gravity model to generate a commute-trip distribution matrix. The gravity model of this tool is different from Huff model, which is commonly used in urban geography. Huff model is a singly-constrained gravity model: the sum of trips leaving from a zone equals the total population of that zone, while the sum of trips arriving at a zone does not necessarily equals the total jobs of that zone. Huff model is relatively simple, and already available in ArcGIS. On the other side, the gravity model in this tool is a doubly-constrained one, which make constraints on both total population and jobs. The impedance function of the gravity model is the inverse function f(cost) = cost-b，where b is commonly referred as dispersion parameter, which needs to be set. If users could import an observed trip distribution matrix, this tool could help to estimate the value of b.

Users could also adopt linear program method to generate a theoretically optimal commute-trip distribution matrix, which minimizes the average traffic cost of all commuters.

The trip distribution based on gravity matrix could be viewed as expected result with practical meanings, while the optimal trip distribution is an ideal situation. This tool would calculate average traffic cost of all commuters of different trip distribution patterns, and if the users provide observed trip distribution matrix, they are able to make comparisons among average traffic costs of different commute patterns, and evaluate possible redundant commutes.

# 算法 Algorithms

Supposing the traffic cost between zone i and zone j is dij, the total population of zone i is Pi, the total jobs of zone j is Aj, and the dispersion parameter is b.

Supposing the number of commuters from zone i to zone j is Tij, the average traffic cost of all commuters (c) could be easily calculated as follows.

c = ijTijdij / ∑ijTij

According to doubly-constrained gravity model, the count of commuters Tij from zone i to zone j could be calculated as follows.

Tij = ai * Pi * bj * Aj * f(dij)
jTij = Pi , ∑iTij = Aj
f(dij) =  (dij)-b (b>0)

aibj分别为行i和列j的平衡系数。因于二者之间相互依赖，难以直接求解，因此通过给定b的初值，然后计算a，然后再计算b，再计算a的迭代方式求解，见下式。
aand bare balance coefficients of row i and column j respectively. Since they are mutually dependent on each other, it is difficult to directly solve them, and an iterative method would be applied as follows.

ai  = 1 / kbkAkf(dik)
bj = 1 / ∑kakPkf(dkj)

When calibrating parameter b of gravity model using observed commute trip distribution, the classical way is to minimize difference between gravity-model-predicted average traffic cost and observed average traffic cost. Following iterative method could be applied to solve this problem, where c* refers to observed average traffic cost, c(k) refers to gravity-model-predicted average traffic cost at iteration k, and b(k) refers to the value of b at iteration k.

Iteration 1: b(1) = 1 / c*
Iteration 2: b(2) = b(1)c(1) / c*
Iteration 3 and afterwards: b(k) = ((c(k-1) – c*)b(k-2) – (c(k-2) – c*)b(k-1)) / (c(k-1) – c(k-2))

In addition to this classical method, this tool also provides genetic algorithm (GA) option. GA could either set the closest average traffic cost as the object, or attempt to generate a closest predicted commute trip matrix as the observed matrix. Please note that GA would generally require more solving time.

As to optimal trip distribution problem, a linear program model is employed, as follows.

min: c = ijTijdij / ∑ijTij
Subject to: ∑jTij = Pi , ∑iTij = Aj

### This Post Has 4 Comments

1. 大牛，非常厉害，感谢了！

1. 谢谢，不敢当

2. 想请教一下，如果需要在更高版本的matlab上运行这个程序，有解决办法吗

1. 请问是哪个版本？我现在也有在用更高版本的Matlab，如果正好版本一致的话，我可以打包一个新版本的。不过，建议去载安装一个matlab 8.5版本的runtime，具体方法请参见http://wangc.net/install-matlab-runtime/