# TransFlower: An Explainable Transformer-Based Model with Flow-to-Flow
Attention for Commuting Flow Prediction

Yan Luo  Hong Kong Polytechnic University & Massachusetts Institute of
TechnologyChina & USA<EMAIL_ADDRESS>,  Zhuoyue Wan  Hong Kong Polytechnic
UniversityHong Kong SARChina<EMAIL_ADDRESS>,  Yuzhong Chen  Arizona
State UniversityTempeAZUSA<EMAIL_ADDRESS>,  Gengchen Mai  University of
GeorgiaAthensGAUSA<EMAIL_ADDRESS>,  Fu-lai Chung  Hong Kong
Polytechnic UniversityHong Kong SARChina<EMAIL_ADDRESS>and  Kent
Larson  Massachusetts Institute of TechnologyCambridgeMAUSA<EMAIL_ADDRESS>
(2018; 20 February 2007; 12 March 2009; 5 June 2009)

###### Abstract.

Understanding the link between urban planning and commuting flows is crucial
for guiding urban development and policymaking. This research, bridging
computer science and urban studies, addresses the challenge of integrating
these fields with their distinct focuses. Traditional urban studies methods,
like the gravity and radiation models, often underperform in complex scenarios
due to their limited handling of multiple variables and reliance on overly
simplistic and unrealistic assumptions, such as spatial isotropy. While deep
learning models offer improved accuracy, their “black box” nature poses a
trade-off between performance and explainability — both vital for analyzing
complex societal phenomena like commuting flows. To address this, we introduce
TransFlower, an explainable, transformer-based model employing flow-to-flow
attention to predict urban commuting patterns. It features a geospatial
encoder with an anisotropy-aware relative location encoder for nuanced flow
representation. Following this, the transformer-based flow predictor enhances
this by leveraging attention mechanisms to efficiently capture flow
interactions. Our model outperforms existing methods by up to 30.8% Common
Part of Commuters (CPC), offering insights into mobility dynamics crucial for
urban planning and policy decisions. The code is accessible at:
https://github.com/zwanah/TransFlower

Human mobility, Applied computing, Social computing

††copyright: acmlicensed††journalyear: 2018††doi: XXXXXXX.XXXXXXX††conference:
Make sure to enter the correct conference title from your rights confirmation
emai; June 03–05, 2018; Woodstock, NY††isbn: 978-1-4503-XXXX-X/18/06††ccs:
Applied computing Sociology††ccs: Applied computing Forecasting††ccs: Human-
centered computing Empirical studies in collaborative and social computing

##  1\. Introduction

Cities, as the epicenters of economic, social, and cultural activities, play a
pivotal role in the evolution of human civilization (Batty, 2013; Bettencourt
et al., 2007). Understanding urban human mobility is crucial for creating
equitable and sustainable cities, ensuring accessible transportation, economic
opportunities, and enhanced quality of life for residents (González et al.,
2008; Alessandretti, 2022; Barbosa et al., 2018). Commuting flows, defined as
the movements between a worker’s home and their place of employment, play a
crucial role in revealing daily movement patterns within urban settings. These
flows inform city planning, infrastructure development, and contribute to the
understanding of urban dynamics and socioeconomic factors (Hincks and Wong,
2010; Sohn, 2005). For instance, some real-world questions we have encountered
are, “If a developer plans to introduce several corporate office buildings in
a certain area, how would this affect the citywide commuting flows? How should
the government appropriately respond by preparing the necessary supporting
infrastructure?” If we translate these questions into scientific terminology,
they boil down to the problem of commuting flow prediction – learning the
correlation between urban planning and the distribution of commuting flows.
There are two main practical applications. First, given a new urban
development plan, it becomes feasible to determine the corresponding
distribution of commuting flows, aiding in the assessment of its impact.
Second, traditional methods of collecting commuting flow data rely on national
statistical bureaus (McKenzie, 2013), which are costly and untimely. With a
reliable prediction model, we can achieve real-time estimation of commuting
flows.

The task of commuting flow prediction sits at the crossroads of urban studies
and computer science, each bringing distinct approaches and limitations.
Traditionally, urban studies have depended on physical models like the gravity
model (Stewart, 1941; Zipf, 1946; Erlander and Stewart, 1990; Barthélemy,
2011) and radiation model (Simini et al., 2012) to predict and analyze urban
flows, primarily due to limitations in data availability and quantitative
analysis capabilities. These models offer a theoretical framework for
understanding urban dynamics. However, these models face significant
limitations, such as simple assumptions and limited performances (Barbosa et
al., 2018; Simini et al., 2012). The demand for enhanced performance in this
task is crucial, as it allows stakeholders to assess the feasibility of
specific planning initiatives and interventions with greater performance. This
requirement for performance necessitates access to more comprehensive datasets
and a shift away from traditional models towards more sophisticated
methodologies. In response to these challenges, deep learning models from
computer science have emerged as a powerful alternative (Liu et al., 2020;
Zhou et al., 2023; Zeng et al., 2022), offering the promise of higher
performance by leveraging large volumes of data to learn complex patterns of
urban mobility. Despite their success in achieving improved predictive
performance, these models often suffer from a lack of explainability or
provide insights that are too shallow for practical application in urban
planning. In the context of social phenomena like commuting flows, the
importance of explainability is on par with performance. A thorough
understanding of the underlying forces and dynamics of mobility is crucial for
validating the model’s credibility and supporting planning and policy
development efforts. This opacity poses a dilemma, as there traditionally
exists a trade-off between deep learning models’ performance and
explainability (Defense Advanced Research Projects Agency, 2016). Recent
advances within the Explainable Artificial Intelligence (XAI) community,
however, demonstrate that it is possible to design models that do not
sacrifice model explainability for performance (Rudin, 2019). Some works point
out that creating an explainable architecture involves designing with
explainability in mind, such as utilizing fewer hidden layers or learnable
parameters or adopting a modular design, so that every part of the model has a
clear function and explanation (Friston et al., 2024; Adadi and Berrada,
2018). Inspired by this development, an intriguing research question emerges:
”How to design a model for commuting flow prediction that achieves both high
performance and good explainability?”

To answer this question, we conducted an in-depth analysis of the two
classical models previously mentioned: the gravity model and the radiation
model. The gravity model predicts flow distribution by mimicking the
gravitational forces observed in the physical world, suggesting that the
volume of commuting flow is directly proportional to the attraction between
two locations and inversely proportional to the distance between them. Despite
its explanatory power through a clear, parameter-based formula, the gravity
model’s reliance on region-specific adjustable parameters and known analytical
inconsistencies limits its applicability (Simini et al., 2012). In response,
the radiation model (Simini et al., 2012) was developed to overcome many of
the gravity model’s drawbacks, using a stochastic process to simulate local
mobility decisions and analytically deriving commuting and mobility fluxes
based on population distribution alone. Nonetheless, the radiation model’s
reliance on a limited set of variables (primarily population and distance)
results in low performance due to the omission of critical geographical
details like land use types and points of interest (POIs). Moreover, it
assumes a isotropic ideal space by simple distance decay for flow
determinants, disregarding the diverse factors and complex spatial
correlations influencing human mobility, such as transportation conditions,
topography, and land use patterns, which leads to inaccuracies in representing
the actual structure and variability of flows (Barbosa et al., 2018). The
limitations of the former can be addressed by integrating comprehensive
geographic data of urban regions into deep-learning models, while for the
latter, we aim to develop a module within our model capable of adaptively
learning location characteristics to circumvent the unrealistic assumption of
spatial isotropicity (Mai et al., 2018; Zhu et al., 2019; Zhang et al., 2009).

Additionally, it is worth noting that among the methods involving deep
learning, one particular study, DeepGravity (Simini et al., 2021), touches
upon explainability. DeepGravity claims to provide explainability through SHAP
(Lundberg and Lee, 2017), a game theory-based approach for interpreting
machine learning models. However, such model-agnostic explanation methods can
only superficially mimic the input-output relationship of the actual model,
without the ability to deeply analyze causal relationships. A fundamental
reason for the lack of deep explainability for DeepGravity is the
oversimplified modeling that relies solely on feed-forward networks to encode
information from individual flows, thereby overlooking the interplay between
flows. Given that commuting flows represent a complex network challenge,
understanding the intricate dynamics and interplay between flows is crucial.
These interactions are key to deciphering the mechanisms of information
transmission within the network and understanding how the network’s structure
impacts these processes (Donner et al., 2017). Therefore, incorporating
interactions between flows could not only enhance the model’s explainability
but also potentially contribute to an improvement in performance.

In light of these considerations, we have approached the design of our
solution from first principles, resulting in the creation of a minimalist yet
effective model. We introduce TransFlower, an explainable transformer-based
(Vaswani et al., 2017) model featuring flow-to-flow attention mechanisms
specifically tailored for the predicting of commuting flows. The transformer
is selected primarily for its efficiency in handling the interactions among
items within a sequence or a set, enabling intricate flow relationships to be
modeled. Additionally, the attention mechanism enhances model explainability.
Specifically, we first employ a novel relative location encoder to capture the
spatial relationship between the origin and destination regions of individual
flows. While the DeepGravity model only considers the distance between origins
and destinations, with the help of relative location encoding, our model can
jointly consider both distance and direction information. This encoder is
designed to adaptively learn spatial representations, effectively countering
the radiation model’s unrealistic assumption of spatial uniformity and
isotropicity. Subsequently, we integrate the spatial relationship information
with other geographic features of the flow’s origin and destination regions in
the geo-spatial encoder. This integrated data is then fed into a transformer-
based flow predictor designed to learn the interactions between different
flows. Finally, we utilize attention mechanisms between flows to investigate
the relationship between commuting flows and urban features, offering new
insights into the dynamics of urban mobility.

Our experiments, conducted across three states in the US, indicate that our
framework outperforms existing state-of-the-art deep learning models by up to
30.8% in terms of the metric Common Part of Commuters (CPC). Additionally, we
illustrate how the flows generated by our model can be explained through flow-
to-flow attention mechanisms. Moreover, we prove that our relative location
encoder is capable of capturing spatial anisotropicity. With our model,
stakeholders will be equipped to precisely describe the dynamics of commuting
flows, a crucial aspect in shaping cities in alignment with SDGs.

##  2\. Problem Formulation

It is noteworthy that the prediction of commuting flows differs from the more
common spatiotemporal traffic flow forecasting problem (Lana et al., 2018;
Vlahogianni et al., 2014). Traffic flow is a short-term, dynamic, and time-
series-related phenomenon, whereas commuting flows represent long-term,
relatively static, and time-series-independent repeated daily movements. In
traffic flow modeling, historical flows are used as input features, whereas
the inputs for commuting flow prediction problems are the geographical
attributes of urban regions.

Definition 1 Urban Region: Urban regions $u_{i}$ can be census blocks, block
groups, census tracts, counties, or states. To ensure our model has an
appropriate number of samples in each experimental area, in this paper, we use
block groups as urban regions. Each region is characterized by a variety of
geo-spatial features, including place features (e.g., POIs within the region)
and location information. Place features of each region can be represented as
$x_{u_{i}}$. The centroid coordinates of each region can be indicated by
$loc_{u_{i}}$. The distance measured along the surface of the earth between
the centroid of region $u_{i}$ and region $u_{j}$ is denoted as $r_{ij}$.

Definition 2 Commuting Flow: Commuting flows are a set of 3-tuple
$f_{ij}=(o_{i},d_{j},v_{ij})$ where $o_{i}$ is the flow origin urban region,
$d_{j}$ is the flow destination urban region, $v_{ij}$ is the number of
commuters moving from $o_{i}$ to $d_{j}$ per unit time. We use
$S=\\{f_{kl}=(o_{k},d_{l},v_{kl})\\}$ to denote the full set of all urban
commuting flows and $S_{i}=\\{f_{il}=(o_{i},d_{l},v_{il})\\}\subseteq S$ be
the subset of $S$ denoting all flows originating from region $o_{i}$. Then the
total outflow, $O_{i}$, from region $o_{i}$ is the total number of flows per
unit time originating from region $o_{i}$, i.e., $O_{i}=\sum_{f_{il}\in
S_{i}}v_{il}$.

Problem Statement Commuting Flow Prediction: Essentially, this can be
considered a task of outflow allocation. We can first forecast the
probabilities of destinations for flows originating from a specific origin
region. By multiplying these predicted probabilities with the known outflows,
we can determine the actual flows.

##  3\. Methodology

Considering the geo-spatial features $x_{u_{i}}$ and $loc_{u_{i}}$ of urban
regions, the output of TransFlower is an $n$-dimensional vector $P_{i,j}$,
where $j=1,...,n$, representing the probability of flows originating from
$o_{i}$ and arriving at each destination $d_{j}$. As illustrated in Figure 1,
the model employs two major components to achieve this: the geo-spatial
encoder and the flow predictor.

Figure 1. The framework of TransFlower which contains two major components:
geo-spatial encoder and flower predictor.

###  3.1. Geo-Spatial Encoder

Predicting commuting flows fundamentally involves geo-spatial information. To
this end, we introduce the Geo-Spatial Encoder. The input to the Geo-Spatial
Encoder is divided into three main categories: the place features $x_{u_{i}}$
of both the origin and destination regions, the coordinate information
$loc_{u_{i}}$ of these regions, and the distance $r_{o_{i},d_{j}}$ between
them. Following the practice of DeepGravity (Simini et al., 2021), we
concatenate the place features of the origin and destination, i.e.,
$x_{o_{i}}$ and $x_{d_{j}}$, as well as the distance $r_{o_{i},d_{j}}$, and
feed these features to a feed-forward neural network to obtain an embedding
capturing the characteristics of both $o_{i}$ and $d_{j}$.

However, merely accounting for the distance $r_{o_{i},d_{j}}$ falls short of
capturing comprehensive spatial information, as commuting flows exhibit
anisotropic patterns (Zhang et al., 2009), indicating that direction is also a
crucial piece of information to consider. Thus, we compute the relative
location ${rl}_{ij}=loc_{o_{i}}-loc_{d_{j}}$ ($\in\mathbb{R}^{2}$) and feed it
into a specially designed relative location encoder based on Space2Vec (Mai et
al., 2020), to jointly capture the distance and direction information.

####  3.1.1. Geographic Feature Encoder

To extract information on individual flows, we follow the practice of
benchmark model DeepGravity, by using place features and the distance feature
as inputs for our flow geographic feature encoder.

Place features, denoted by $x_{u_{i}}$ ($u_{i}$ can be either $o_{i}$ or
$d_{j}$), delineate various geographical aspects of areas, such as the number
of retail establishments present within a specific region. The dimensionality
of these place features corresponds to the aggregate count of features
evaluated. Among the place features utilized are the population magnitude of
each region and 19 attributes derived from OpenStreetMap (OpenStreetMap
contributors, 2017), spanning the following categories:

  * •

Facilities related to food (4 attributes: point-amenity, point-shop, polygon-
amenity, polygon-shop): the comprehensive tally of POIs and structures
associated with any food-related service, e.g., restaurants, fast food
outlets, and bars.

  * •

Facilities related to retail (4 attributes: point-amenity, point-shop,
polygon-amenity, polygon-shop): the comprehensive tally of POIs and structures
associated with retail services, e.g., marketplaces, pharmacies, and
convenience stores.

  * •

Facilities related to education (3 attributes: point-amenity, polygon-amenity,
polygon-building): the comprehensive tally of POIs and structures associated
with educational institutions, e.g., schools, colleges, and universities.

  * •

Facilities related to health (3 attributes: point-amenity, polygon-amenity,
polygon-building): the comprehensive tally of POIs and structures associated
with health services, e.g., dentists, hospitals, and clinics.

  * •

Facilities related to transport (5 attributes: point-amenity, point-public-
transport, polygon-amenity, polygon-building, polygon-public-transport): the
comprehensive tally of POIs and structures associated with transport services,
e.g., parking lots, bus stations, and charging stations.

We concatenate the distance feature $r_{i,j}$ with a 40-dimensional vector of
place features, $x_{u_{i}}$, which includes 19 geographic attributes from both
the origin and destination, in addition to their respective population counts,
to formulate the 41-dimensional feature embedding that define individual flow
patterns. These consolidated features are then subjected to a transformation
through a single-layer feed-forward network, resulting in a 256-dimensional
individual flow representation $x_{o_{i},d_{j}}$. This process effectively
projects the lower-dimensional features into a higher-dimensional space.

####  3.1.2. Relative Location Encoder

To overcome the unrealistic assumption of spatial isotropicity in classical
models, we introduce a relative location encoder to adaptively learn the
representation of spatial information for each flow. While there has been some
work on spatial representation learning (Luo et al., 2022, 2023), most of it
deals with specific tasks and often disregards geographic coordinates.
Space2Vec (Mai et al., 2020) is a general-purpose representation learning
model that encodes the absolute positions or spatial relationships of places
into a vector space representation. This work is inspired by the Nobel Prize-
winning neuroscience research that demonstrated mammalian grid cells provide a
multi-scale periodic representation (Abbott and Callaway, 2014). It has been
discovered that leveraging location embeddings, generated through coordinate
decomposition, assists deep-learning models in overcoming the limitations
inherent in traditional single-scale approaches by adopting multi-scale
representations (Mac Aodha et al., 2019).

Inspired by the multi-scale representations of Space2Vec, we develop a
relative location encoder that comprises two key components: a multi-scale
encoder and a feed-forward network. Unlike Space2Vec, which operates on single
coordinate points, our focus is on flow. We calculate the relative location
${rl}_{ij}=loc_{o_{i}}-loc_{d_{j}}$ as the inputs for our relative location
encoder.

More precisely, our relative location encoder represents the relative location
${rl}_{ij}$ in a multi-scale relative location embedding. While traditional
transformer position encoding layers operate in discrete 1-dimensional spaces,
such as word positions in a sentence, we tackle higher-dimensional continuous
spaces, like the Earth’s surface. To encompass a 2-dimensional space, we
utilize a set of sine and cosine functions at various frequencies, amounting
to $freq$ in total, to encode the relative location ${rl}_{ij}$. The multi-
scale encoder is denoted as
$Enc\left({rl}_{ij}\right)=\mathbf{NN}\left(PE({rl}_{ij})\right)$, where
$\mathbf{NN}$ consists of fully connected ReLU layers. Here,
$PE({rl}_{ij})=\left[PE_{0}({rl}_{ij});\ldots;PE_{K-1}({rl}_{ij})\right]$
concatenates multi-scale representations. $K$ is the total number of scales.

We decompose and project the relative location ${rl}_{ij}$ into the direction
of three base vectors in $\mathbb{R}^{2}$, named $a_{1}$, $a_{2}$, $a_{3}$,
each distinctly angled at $2\pi/3$ from one another. According to Space2Vec, a
typical configuration might set $\mathbf{a}_{1}=[1,0]^{T}$,
$\mathbf{a}_{2}=[-1/2,\sqrt{3}/2]^{T}$, and
$\mathbf{a}_{3}=[-1/2,-\sqrt{3}/2]^{T}$, establishing a symmetrical geometric
structure for spatial encoding. $\lambda_{min}$ and $\lambda_{max}$ represent
the minimum and maximum scales, respectively, with
$g=\frac{\lambda_{max}}{\lambda_{min}}$. For each scale $s$,
$PE_{s}({rl}_{ij})$ combines three components as follows:

(1) $\displaystyle
PE_{s,j}({rl}_{ij})=\left[\cos\left(\frac{\left\langle{rl}_{ij},\mathbf{a}_{j}\right\rangle}{\lambda_{\min}\cdot
g^{s/(S-1)}}\right);\sin\left(\frac{\left\langle{rl}_{ij},\mathbf{a}_{j}\right\rangle}{\lambda_{\min}\cdot
g^{s/(S-1)}}\right)\right],\forall j=1,2,3;$

where $\langle{rl}_{ij},a_{j}\rangle$ is the inner product of ${rl}_{ij}$ and
$a_{j}$.

It’s noteworthy that an analysis of Figure 2(d) revealed intriguing
experimental phenomena (to be detailed in Section 4.4), prompting a
reevaluation of the design of the relative location encoder. We proposed two
designs for the Relative Location Encoder (RLE):

  * •

RLE: As shown in Figure 1b, the encoder includes two branches, each with a
multi-scale encoder and a feed-forward network. Two encoders have distinct
base vector sets. An additional feed-forward layer merges outputs from both
branches, creating $loc_{o_{i},d_{j}}$ which captures the complex geographical
relationships between origin and destination regions at multiple levels.

  * •

RLE’: Illustrated in Figure 1c, this encoder variant operates with a single
branch, utilizing the typical configuration of base vectors’ orientations as
mentioned above. The output from this branch, $loc_{o_{i},d_{j}}$, is the
relative location vector.

Subsequently, by concatenating the individual flow embedding $x_{o_{i},d_{j}}$
with the flow spatial embedding $loc_{o_{i},d_{j}}$ generated by the relative
location encoder, we create a comprehensive embedding for each flow,
represented as
$e_{o_{i},d_{j}}=\left[x_{o_{i},d_{j}};loc_{o_{i},d_{j}}\right]$. This process
effectively combines specific flow characteristics with spatial information,
facilitating a more nuanced analysis of commuting patterns.

###  3.2. Flow Predictor

In the flow predictor, the generated flow embeddings from the geo-spatial
encoder are processed through a $N$-layer transformer encoder module to model
the interactions among different flows that share the same origin with the
self-attention mechanism. This is followed by a prediction head, which
includes a feed-forward layer and a softmax layer, to generate the probability
distribution of flows from a specified origin region to various destination
regions. This structure ensures that the model captures the complex dynamics
and interactions between different commuting flows, enhancing its predictive
performance and relevance for urban planning and analysis.

####  3.2.1. Transformer Encoder

Our choice of a transformer-based model is grounded in its sequential
processing capabilities, allowing for effective representation of flow
relationships and complex mobility patterns. Its attention mechanism offers
explicit input prioritization and improved explainability through visual
insights into predictive focuses. Furthermore, transformers’ contextual
processing and parallelism enhance efficiency, making them ideal for large-
scale and complex commuting flow analyses.

Specifically, each transformer encoder layer consists of a multi-head self-
attention module and a feed-forward network. Residual connections and layer
normalizations are also employed. In each attention head, self-attention for
flow $f_{ij}$ can be formulated as:

(2) $e_{i}\prime=e_{i}+w_{z}\sum_{j=1}^{n}\frac{\exp(w_{q}e_{i}\times
w_{k}e_{j})}{\sum_{m=1}^{n}\exp(w_{q}e_{i}\times w_{k}e_{m})}w_{v}e_{j}$

where $e_{i}$ and $e_{i}\prime$ are the input and output embeddings, and
$w_{\\{q,k,v,z\\}}$ denotes linear transform weights for the query, key,
value, and output matrices.

####  3.2.2. Prediction Head

The outputs from transformer encoder layers are then fed into a feed-forward
layer, which leads to a score $s(o_{i},d_{j})$ ranging from $-\infty$ to
$+\infty$. For any region pair $(o_{i},d_{j})$, a higher score indicates a
greater likelihood of observing a flow from $o_{i}$ to $d_{j}$. Subsequently,
a softmax function converts these scores into probabilities $P_{i,j}$,
ensuring they are positive and collectively sum to one. The actual flow
between two regions is then determined by multiplying this probability with
the total outflow from the origin region.

####  3.2.3. Loss Function

The model’s loss function is defined as cross-entropy, as it measures the
difference between the predicted probabilities and the actual distribution,
effectively guiding the model to improve its predictions over time. The loss
can be denoted as:

(3) $H=-\sum_{i}\sum_{j}\frac{f_{ij}\left(o_{i},d_{j}\right)}{O_{i}}\ln
P_{i,j}$

where $\frac{f_{ij}\left(o_{i},d_{j}\right)}{O_{i}}$ represents the proportion
of observed flows departing from origin $o_{i}$ to destination $d_{j}$, while
$P_{i,j}$ signifies the predicted probability by the model for a flow from
$o_{i}$ to $d_{j}$. The aggregation of cross-entropy values across different
origins, denoted by the sum over $i$, is based on the premise that flows
originating from disparate locations are considered independent events. This
assumption enables the utilization of cross-entropy’s additive nature for
independent variables, facilitating a comprehensive evaluation of the model’s
performance across multiple origins.

##  4\. Results

In this section, we conduct extensive experiments on three datasets to
evaluate our proposed model.

###  4.1. Experiment Setups

####  4.1.1. Datasets

We evaluated our proposed model on real-world commuting flow datasets
collected from California, Massachusetts, and Texas. Our input data for urban
regions was sourced from the 2019 American block group’s cartographic boundary
files provided by the US Census Bureau. Due to computational considerations,
we selectively focused on specific areas within California (7872 block
groups), Massachusetts (2350 block groups), and Texas (7900 block groups),
ensuring coverage of the most central and significant locations. For instance,
the regions selected in California include key areas such as Los Angeles and
San Francisco, highlighting our model’s applicability to diverse and densely
populated urban environments.

For commuting flows, we utilized the 2019 Origin-Destination Employment
Statistics (LODES) dataset (US Census Bureau, 2019). This dataset is updated
annually and captures the home and employment locations of workers, thus
offering insights into stable commuting patterns. The commuting flows are then
aggregated to the geographic unit level for analysis. In our experimental area
in California, a total of 2,552,243 origin-destination pairs accounted for
5,583,372 commuting flows. The Massachusetts dataset included 58,235 origin-
destination pairs, leading to 1,404,860 commuting flows. In Texas, there were
756,179 origin-destination pairs, resulting in 1,688,550 commuting flows.

For place attributes, we employ point and polygon data from OpenStreetMap
(OpenStreetMap contributors, 2017), a widely recognized platform for
volunteer-contributed geographic information. Each point and polygon
represents a geographic feature with a specific purpose. Typically, a polygon
is used to delineate the outline of a building. For example, Union Station
could be depicted as either a point or a polygon, categorized under public
transportation. Conversely, a restaurant located within Union Station would be
represented as an independent point separate from Union Station, and it would
fall under the category of dining.

####  4.1.2. Evaluation Metrics

To evaluate the performance of our predictions, we utilize three widely
recognized metrics: Common Part of Commuters (CPC), Mean Absolute Error (MAE),
and Root Mean Squared Error (RMSE) (Barbosa et al., 2018; Simini et al.,
2021). MAE and RMSE offer a straightforward and effective means of assessing
the magnitude of errors in regression analyses. CPC quantifies the similarity
between the predicted flow volume $v^{p}\left(o_{i},d_{j}\right)$ and real
flow volume $v^{r}\left(o_{i},d_{j}\right)$, which can be denoted as:

(4)
$CPC=\frac{2\sum_{i,j}\min\left(v^{p}\left(o_{i},d_{j}\right),v^{r}\left(o_{i},d_{j}\right)\right)}{\sum_{i,j}v^{p}\left(o_{i},d_{j}\right)+\sum_{i,j}v^{r}\left(o_{i},d_{j}\right)}.$

####  4.1.3. Implementations

To align with the settings used in DeepGravity, we randomly partition the
commuting flows into training and validation datasets using an 80:20 split.
The network training employs the early stopping technique to prevent
overfitting, with a patience setting of 20 epochs and utilizes the RMSprop
optimizer. This optimizer is configured with a momentum of 0.9 and a learning
rate of 0.0001, processing batches containing 512 origin regions each. The
feed-forward network features a hidden size of 256, and we set the network’s
random seed to 1234. A dropout rate of 0.1 is applied to mitigate overfitting,
and the Transformer encoder is structured with two layers.

To streamline the training process of the transformer and ensure alignment
with DeepGravity’s methodology, we select 256 destination regions for each
origin region. This number approximates the average count of flows originating
from each region. If the actual number of destinations surpasses 256, we
employ random sampling to select 256 destinations; Otherwise, we utilize zero-
padding to achieve this count.

Regarding the parameters within the relative location encoder, the maximum
lambda $\lambda_{max}$ is set to the maximum diameter of the study area, which
is 20013 m for California, 20009 m for Massachusetts, and 20013 m for Texas.
The number of different sinusoidal with different frequencies $freq$ and
minimum scale $\lambda_{min}$ are hyperparameters, optimized differently
across study areas. For instance, for the California dataset, $freq$ is set to
16, and the $\lambda_{min}$ to 1.

####  4.1.4. Baselines

To demonstrate our model’s efficacy, we conduct comparisons against the
following baseline models:

  * •

Gravity (Barbosa et al., 2018): This adaptation of the classic gravity model
incorporates two power exponents, suggesting that the flow of people or goods
between two areas directly correlates with their propulsiveness (outflow) and
attractiveness (inflow), while being inversely related to the distance
separating them. The model’s inputs exclude geographic features.

  * •

Radiation (Simini et al., 2012): The radiation model posits that urban
mobility is determined by the city’s population density distribution. The
likelihood of movement from origin $o_{i}$ to destination $d_{j}$ is denoted
by the following formulation:

(5)
$P_{i,j}=\frac{p_{i}p_{j}}{\left(p_{i}+S_{i,j}\right)\left(p_{i}+p_{j}+S_{i,j}\right)}$

where $p_{i}$ represents the population of the origin region $o_{i}$, and
$S_{i,j}$ denotes the total population within the circle centered at $o_{i}$
with a radius equal to the distance between the origin and destination. The
model’s inputs exclude geographic features.

  * •

Random Forest (RF) (Pourebrahim et al., 2019): As a classical machine learning
method (Breiman, 2001), RF is reported as a strong baseline (Pourebrahim et
al., 2019). The inputs are consistent with ours.

  * •

GMEL (Liu et al., 2020): This model forms an adjacency graph and utilizes two
attention-based graph neural networks (GATs) to independently learn the
embeddings for origins and destinations. Additionally, the authors designed
two supplementary tasks for forecasting inflow and outflow. To make a fair
comparison with our model, we did not adopt this supplementary part. The
inputs are consistent with ours.

  * •

DeepGravity (Simini et al., 2021): This model views flow prediction as a task
of allocating outflow and forecasts the probabilities of destinations for
flows originating from a specific origin region. The inputs are consistent
with ours.

###  4.2. Performance Analysis

We evaluated the performance of both baseline models and our proposed model
using a test set, with detailed results presented in Table 1. TransFlower
stands out as the top performer across all datasets and metrics, achieving up
to a 30.8% improvement on CPC, thereby affirming the effectiveness of our
approach. Our analysis offers several key insights.

Among the models assessed, the Radiation model ranks lowest in performance.
This shortfall is likely due to its oversimplified assumptions like spatial
anisotropy. Conversely, models incorporating geographic features (i.e., RF,
GMEL, DeepGravity, TransFlower) markedly surpass those lacking these elements
(i.e., Gravity and Radiation). This finding emphasizes the critical role of
geographic features in the accurate prediction of commuting flows. By
embedding spatial contextual information, these models gain a nuanced
understanding and depiction of commuting flow dynamics, resulting in enhanced
performance across a variety of test scenarios.

TransFlower’s superiority over the Gravity model demonstrates how a relative
location encoder, capable of assimilating spatial anisotropy, combined with a
sophisticated neural network framework, can significantly improve commuting
flow prediction performance. Its advantage over DeepGravity further
accentuates the value of capturing flow interactions via transformer encoder
layers. Additionally, TransFlower outperforms GMEL, a model leveraging GAT,
indicating that transformers’ implicit approach to modeling flow relationships
is more efficacious than GAT’s explicit method based on geographical
proximity. This suggests that in the complex network challenge of commuting
flows, the interplay between flows is influenced not solely by geographical
proximity but also by complex, latent higher-order relationships.

Table 1. Performance analysis

Dataset | Model Name | CPC | MAE | RMSE
---|---|---|---|---
California | Gravity | 0.6847 | 1.1626 | 3.5443
Radiation | 0.4074 | 2.0782 | 6.4025
RF | 0.6451 | 1.2987 | 3.2309
DeepGravity | 0.6571 | 1.2475 | 3.1099
GMEL | 0.6533 | 1.2563 | 3.1407
TransFlower | 0.7691 | 0.8380 | 2.0780
Massachusetts | Gravity | 0.6403 | 1.5147 | 3.5032
Radiation | 0.3221 | 2.6807 | 6.2174
RF | 0.6829 | 1.4343 | 3.0398
DeepGravity | 0.6871 | 1.4151 | 2.9036
GMEL | 0.6831 | 1.4347 | 2.9233
TransFlower | 0.7573 | 1.0980 | 2.2700
Texas | Gravity | 0.5886 | 1.7434 | 6.1830
Radiation | 0.3060 | 2.6764 | 7.2387
RF | 0.4811 | 0.6517 | 3.0475
DeepGravity | 0.4786 | 0.6819 | 3.0313
GMEL | 0.4535 | 0.6942 | 3.0753
TransFlower | 0.6262 | 0.4794 | 2.3590

###  4.3. Ablation Study

As shown in Table 2, we validate the effectiveness of the key components
contributing to performance enhancement: the transformer module and the
relative location encoder (RLE). We tested three variants of TransFlower to
confirm this: (1) without RLE, (2) with RLE’, and (3) without the transformer
module (i.e., DeepGravity with RLE). The experimental results indicate that
removing the RLE leads to a minimum drop of 9.7% in CPC.

Table 2. Ablation Study

Dataset | Model Name | CPC | MAE | RMSE
---|---|---|---|---
California | DeepGravity w/ RLE | 0.7337 | 0.9779 | 2.4580
w/o RLE | 0.6820 | 1.1491 | 2.8219
w/ RLE’ | 0.7602 | 0.8708 | 2.1120
w/ RLE (i.e., TransFlower) | 0.7691 | 0.8380 | 2.0780
Massachusetts | DeepGravity w/ RLE | 0.7333 | 1.2060 | 2.3950
w/o RLE | 0.6905 | 1.3997 | 2.8613
w/ RLE’ | 0.7499 | 1.1310 | 2.3190
w/ RLE (i.e., TransFlower) | 0.7573 | 1.0980 | 2.2700
Texas | DeepGravity w/ RLE | 0.5837 | 0.5339 | 2.5580
w/o RLE | 0.4990 | 0.6265 | 2.8168
w/ RLE’ | 0.6104 | 0.4959 | 2.4440
w/ RLE (i.e., TransFlower) | 0.6262 | 0.4794 | 2.3590

###  4.4. Residual Analysis

(a) w/ RLE - DeepGravity

(b) w/ RLE - DeepGravity w/ RLE

(c) w/ RLE - w/o RLE

(d) w/ RLE’

(e) w/ RLE

(f) w/ RLE - w/ RLE’

Figure 2. Comparison between different modules.

Taking the experimental area in California as an example, as depicted in
Figure 2, we aimed to further assess the effectiveness of various components
of our model. We achieved this by analyzing the relative spatial distribution
of the differences between the predicted and actual commuting flows and
comparing different models or variants of the model through subtraction.

We started by organizing the comprehensive dataset of commuting flows based on
their relative locations, subsequently dividing these into distinct cells. In
this study, the data was segmented into cells measuring 20 by 20 meters.
Within each cell, we calculated the average residual value. This involved
first identifying the difference between the actual and predicted values for
two models being compared, such as model A and model B, within the spatial
extent of that cell. We then subtracted the residual value of model A in that
cell from model B’s value and computed their average. This residual value
difference is represented by color. Red indicates a positive residual value,
meaning model A performs better than model B within that relative spatial
range. Conversely, blue indicates a negative residual value, where model A
performs worse than model B. The deeper the color, the greater the absolute
value of the performance difference is.

Figure 2(a) essentially illustrates the performance improvement brought by the
combined effect of the transformer and RLE modules. Figure 2(b) underscores
the contribution of the transformer to performance improvement, while Figure
2(c) focuses on the performance enhancement attributed to the RLE alone. It is
evident that our proposed modules enhance performance across almost all
relative spatial ranges, with a few exceptions in cells at great relative
distances, which have very few flows, often in single digits, and can be
considered outliers.

Moreover, we further explore the performance differences between two types of
relative location encoders. Figure 2(d) shows the residual map of true versus
predicted values using RLE’, where darker green cells indicate poorer
performance in predicting flows from their origins to destinations within that
spatial range, with lighter green cells indicating smaller differences. The
areas of deeper blue are roughly distributed at the vertices of a hexagon,
which is an artifact created due to the use of 3 base vectors oriented
$2\pi/3$ apart from each other. Therefore, to enhance performance and correct
this artifact, we experimented with introducing an additional set of base
vectors rotated by a certain angle, constructing the RLE. The residual map, as
shown in Figure 2(e), visibly eliminates the hexagonal pattern. Figure 2(f),
depicting the difference between RLE and RLE’, further validates our
hypothesis.

(a) Catesian Coordinate System

(b) Polar Coordinate System

Figure 3. Location embedding clustering of the relative location encoder from
the trained TransFlower.

###  4.5. Explainability Analysis

(a) Flow-to-flow attention map

(b) Map visualization

Figure 4. Case study for flow prediction of one origin region in San
Francisco.

Grasping the rationale behind a model’s prediction is essential for
interpreting outcomes, elucidating disparities among models, and gauging our
comprehension of the phenomenon being studied.

Our model is elucidated through two primary aspects: Firstly, we investigate
the patterns learned by our specially designed relative location encoder, as
evidenced by the clustering effectiveness of the generated embeddings.
Secondly, we delve into the interpretation of the significance encapsulated
within the flow-to-flow attention mechanism.

####  4.5.1. Location Embedding Clustering

We extracted the RLE from the trained TransFlower to investigate how it
functions. Starting with the maximum diameter $lambda_{max}$ of the study
area, we determined the range for visualizing coordinates to be between
$[-\lambda_{max},\lambda_{max}]$. Taking California as an example, where
$-\lambda_{max}=20013$, the range of both longitude and latitude in the
Cartesian coordinate system, as shown in Figure 3, spans from
$[-20013,20013]$. We then divided this range into 100 equal intervals,
creating a grid of 100x100 cells. The coordinate ranges of these 100x100 cells
were fed as inputs into the previously trained RLE to generate embeddings for
each cell. Subsequently, we applied a hierarchical clustering algorithm to
cluster the cells, opting for a 10-category classification and assigning
different colors to different categories. To enhance clarity, we also
performed visualization in polar coordinates. Figure 3(a) demonstrates that
the clusters of location embeddings primarily form based on their relative
distance. However, there is also a subtle variation in clustering by
direction, as evidenced by the clusters not forming perfect concentric rings.
This indicates that the embeddings obtained from the relative location encoder
are anisotropy-aware and capable of capturing both direction and distance.

####  4.5.2. Flow-to-Flow Attention Map

To gain deeper insights into what the model learns from the interactions
between flows, we created a flow-to-flow attention map. We select an origin
region in San Francisco as an example, for which the 256 predicted
destinations formed a 256x256 attention matrix. The sum of each row in this
matrix equals 1. As depicted in Figure 4(a), we visualize this matrix where
the y-axis represents the destinations, the x-axis denotes the regions
influencing the predicted probability of these destinations, and the color
intensity signifies the attention values. The darker red points indicate that
the x-axis region has a more significant influence on the flow prediction for
the y-axis corresponding destination region. Remarkably, the map displays
several vertical red lines, suggesting that some regions consistently have a
substantial impact on the flow predictions for that origin region.

Naturally, we seek to further investigate what these influential regions
correspond to. As shown in Figure 4(b), we mark these regions on the map: the
origin region in a red icon and the significantly influential regions in green
icons. It is observed that these regions carry distinct significance, such as
the central business district, the train station, downtown Berkeley, and the
University of San Francisco. This demonstrates that our model has learned
physically meaningful attention patterns, further emphasizing the critical
role of flow interactions in predicting commuting flows.

##  5\. Conclusion

This paper tackles the challenge of predicting commuting flows, crucial for
urban planning and policymaking. Traditional models like the gravity model and
radiation model fall short due to complex variables, whereas deep learning
models often compromise explainability for performance. We introduce
TransFlower, a transformer-based approach with flow-to-flow attention for
precise flow predictions. It features an anisotropy-aware geo-spatial encoder
for detailed flow analysis, processed by a transformer with flow-to-flow
attention to understand flow interactions. TransFlower excels in both
explainability and performance, paving the way for more informed and effective
urban development strategies.

## References

  * (1)
  * Abbott and Callaway (2014) Alison Abbott and Ewen Callaway. 2014.  Nobel prize for decoding brain’s sense of place.  _Nature News_ 514, 7521 (2014), 153.
  * Adadi and Berrada (2018) Amina Adadi and Mohammed Berrada. 2018.  Peeking Inside the Black-Box: A Survey on Explainable Artificial Intelligence (XAI).  _IEEE Access_ 6 (2018), 52138–52160.  https://doi.org/10.1109/ACCESS.2018.2870052
  * Alessandretti (2022) Laura Alessandretti. 2022.  What human mobility data tell us about COVID-19 spread.  _Nat. Rev. Phys._ 4 (2022), 12–13.
  * Barbosa et al. (2018) Hugo Barbosa, Marc Barthelemy, Gourab Ghoshal, Charlotte R James, Maxime Lenormand, Thomas Louail, Ronaldo Menezes, José J Ramasco, Filippo Simini, and Marcello Tomasini. 2018.  Human mobility: Models and applications.  _Physics Reports_ 734 (2018), 1–74.
  * Barthélemy (2011) Marc Barthélemy. 2011.  Spatial networks.  _Physics reports_ 499, 1-3 (2011), 1–101.
  * Batty (2013) Michael Batty. 2013.  _The New Science of Cities_.  The MIT Press.
  * Bettencourt et al. (2007) Luís MA Bettencourt, José Lobo, Dirk Helbing, Christian Kühnert, and Geoffrey B West. 2007.  Growth, innovation, scaling, and the pace of life in cities.  _Proceedings of the national academy of sciences_ 104, 17 (2007), 7301–7306.
  * Breiman (2001) Leo Breiman. 2001.  Random forests.  _Machine learning_ 45 (2001), 5–32.
  * Defense Advanced Research Projects Agency (2016) Defense Advanced Research Projects Agency. 2016.  Broad Agency Announcement, Explainable Artificial Intelligence (XAI).  DARPA-BAA-16-53.  https://www.darpa.mil/attachments/DARPA-BAA-16-53.pdf
  * Donner et al. (2017) Reik V Donner, Emilio Hernández-García, and Enrico Ser-Giacomi. 2017.  Introduction to Focus Issue: Complex network perspectives on flow systems.  _Chaos: An Interdisciplinary Journal of Nonlinear Science_ 27, 3 (2017).
  * Erlander and Stewart (1990) Sven Erlander and Neil F Stewart. 1990.  _The gravity model in transportation analysis: theory and extensions_. Vol. 3.  Vsp.
  * Friston et al. (2024) Karl J Friston, Maxwell JD Ramstead, Alex B Kiefer, Alexander Tschantz, Christopher L Buckley, Mahault Albarracin, Riddhi J Pitliya, Conor Heins, Brennan Klein, Beren Millidge, et al. 2024\.  Designing ecosystems of intelligence from first principles.  _Collective Intelligence_ 3, 1 (2024), 26339137231222481.
  * González et al. (2008) Marta C. González, César A. Hidalgo, and Albert-László Barabási. 2008.  Understanding individual human mobility patterns.  _Nature_ 453 (2008), 779–782.
  * Hincks and Wong (2010) Stephen Hincks and Cecilia Wong. 2010.  The spatial interaction of housing and labour markets: commuting flow analysis of North West England.  _Urban Studies_ 47, 3 (2010), 620–649.
  * Lana et al. (2018) Ibai Lana, Javier Del Ser, Manuel Velez, and Eleni I Vlahogianni. 2018.  Road traffic forecasting: Recent advances and new challenges.  _IEEE Intelligent Transportation Systems Magazine_ 10, 2 (2018), 93–109.
  * Liu et al. (2020) Zhicheng Liu, Fábio Miranda, Weiting Xiong, Junyan Yang, Qiao Wang, and Cláudio T. Silva. 2020.  Learning Geo-Contextual Embeddings for Commuting Flow Prediction. In _AAAI Conference on Artificial Intelligence_.  https://api.semanticscholar.org/CorpusID:211037977
  * Lundberg and Lee (2017) Scott M Lundberg and Su-In Lee. 2017.  A unified approach to interpreting model predictions.  _Advances in neural information processing systems_ 30 (2017).
  * Luo et al. (2022) Yan Luo, Fu-lai Chung, and Kai Chen. 2022.  Urban Region Profiling via Multi-Graph Representation Learning. In _Proceedings of the 31st ACM International Conference on Information & Knowledge Management_ (Atlanta, GA, USA) _(CIKM ’22)_. Association for Computing Machinery, New York, NY, USA, 4294–4298.
  * Luo et al. (2023) Yan Luo, Haoyi Duan, Ye Liu, and Fu-Lai Chung. 2023.  Timestamps as Prompts for Geography-Aware Location Recommendation. In _Proceedings of the 32nd ACM International Conference on Information and Knowledge Management_ (¡conf-loc¿, ¡city¿Birmingham¡/city¿, ¡country¿United Kingdom¡/country¿, ¡/conf-loc¿) _(CIKM ’23)_. Association for Computing Machinery, New York, NY, USA, 1697–1706.
  * Mac Aodha et al. (2019) Oisin Mac Aodha, Elijah Cole, and Pietro Perona. 2019.  Presence-only geographical priors for fine-grained image classification. In _Proceedings of the IEEE/CVF International Conference on Computer Vision_. 9596–9606.
  * Mai et al. (2018) Gengchen Mai, Krzysztof Janowicz, Yingjie Hu, and Song Gao. 2018.  ADCN: An anisotropic density-based clustering algorithm for discovering spatial point patterns with noise.  _Transactions in GIS_ 22, 1 (2018), 348–369.
  * Mai et al. (2020) Gengchen Mai, Krzysztof Janowicz, Bo Yan, Rui Zhu, Ling Cai, and Ni Lao. 2020.  Multi-Scale Representation Learning for Spatial Feature Distributions using Grid Cells. In _International Conference on Learning Representations_.
  * McKenzie (2013) Brian McKenzie. 2013.  County-to-county commuting flows: 2006-10.  _US Census Bureau_ (2013).
  * OpenStreetMap contributors (2017) OpenStreetMap contributors. 2017.  Planet dump.  https://planet.osm.org.  Available online at https://www.openstreetmap.org.
  * Pourebrahim et al. (2019) N. Pourebrahim, S. Sultana, A. Niakanlahiji, and J.-C. Thill. 2019.  Trip distribution modeling with Twitter data.  _Computers, Environment and Urban Systems_ 77 (2019), 101354.
  * Rudin (2019) Cynthia Rudin. 2019.  Stop explaining black box machine learning models for high stakes decisions and use interpretable models instead.  _Nature machine intelligence_ 1, 5 (2019), 206–215.
  * Simini et al. (2021) Filippo Simini, Gianni Barlacchi, Massimilano Luca, and Luca Pappalardo. 2021.  A deep gravity model for mobility flows generation.  _Nature communications_ 12, 1 (2021), 6576.
  * Simini et al. (2012) Filippo Simini, Marta C González, Amos Maritan, and Albert-László Barabási. 2012.  A universal model for mobility and migration patterns.  _Nature_ 484, 7392 (2012), 96–100.
  * Sohn (2005) Jungyul Sohn. 2005.  Are commuting patterns a good indicator of urban spatial structure?  _Journal of Transport geography_ 13, 4 (2005), 306–317.
  * Stewart (1941) John Q Stewart. 1941.  An inverse distance variation for certain social influences.  _Science_ 93, 2404 (1941), 89–90.
  * US Census Bureau (2019) US Census Bureau. 2019.  Longitudinal Employer-Household Dynamics.  https://lehd.ces.census.gov/data/.
  * Vaswani et al. (2017) Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017.  Attention is all you need.  _Advances in neural information processing systems_ 30 (2017).
  * Vlahogianni et al. (2014) Eleni I Vlahogianni, Matthew G Karlaftis, and John C Golias. 2014.  Short-term traffic forecasting: Where we are and where we’re going.  _Transportation Research Part C: Emerging Technologies_ 43 (2014), 3–19.
  * Zeng et al. (2022) Jinwei Zeng, Guozhen Zhang, Can Rong, Jingtao Ding, Jian Yuan, and Yong Li. 2022.  Causal Learning Empowered OD Prediction for Urban Planning. In _Proceedings of the 31st ACM International Conference on Information & Knowledge Management_ (Atlanta, GA, USA) _(CIKM ’22)_. Association for Computing Machinery, New York, NY, USA, 2455–2464.  https://doi.org/10.1145/3511808.3557255
  * Zhang et al. (2009) Peng Zhang, SC Wong, and SQ Dai. 2009.  A conserved higher-order anisotropic traffic flow model: description of equilibrium and non-equilibrium flows.  _Transportation Research Part B: Methodological_ 43, 5 (2009), 562–574.
  * Zhou et al. (2023) Zhilun Zhou, Jingtao Ding, Yu Liu, Depeng Jin, and Yong Li. 2023.  Towards Generative Modeling of Urban Flow through Knowledge-enhanced Denoising Diffusion.  _Proceedings of the 31st ACM International Conference on Advances in Geographic Information Systems_ (2023).  https://api.semanticscholar.org/CorpusID:262054030
  * Zhu et al. (2019) Rui Zhu, Krzysztof Janowicz, and Gengchen Mai. 2019.  Making direction a first-class citizen of Tobler’s first law of geography.  _Transactions in GIS_ 23, 3 (2019), 398–416.
  * Zipf (1946) George Kingsley Zipf. 1946.  The P 1 P 2/D hypothesis: on the intercity movement of persons.  _American sociological review_ 11, 6 (1946), 677–686.