Rust mode-sequence search kernel for mobility
Project description
mobility-mode-sequence-search
Rust package for mode-sequence search in mobility.
Scope
This package owns:
- compact indexing of mode and cost data
- top-k mode-sequence search
- chain-level parallelism
- a Python extension API that accepts and returns columnar data
The main mobility repository remains responsible for orchestration,
validation, and any fallback Python implementation.
How It Works
This package searches feasible mode sequences for an ordered chain of places.
For example, if someone goes from home to a shop, feasible answers might include:
- walk, walk
- car outbound, car return
- bike outbound, bike return
Feasibility is constrained by a few simple rules:
- a vehicle can only be used if it is currently at the traveler's location
- if a vehicle leaves home, it must end back at home
- some outbound choices come in matched pairs, requiring a linked return mode later in the same subtour
Conceptually, the algorithm has four stages:
- Split long chains into smaller home-to-home segments when possible.
- Search each segment incrementally, always expanding the cheapest partial answer first.
- Merge the best segment-level answers into full-chain answers.
- Keep only the leading answers needed to reach the requested cumulative probability threshold.
Before search, each input chain is closed internally by appending the starting location to the end. This matches the legacy Python backend, which searches a closed tour rather than the raw caller-provided chain.
Pseudocode
for each chain:
split the chain into home-to-home segments
for each segment:
start with one empty partial answer
while there are still partial answers to explore:
take the cheapest partial answer so far
if it already covers every leg:
if all vehicles are back home:
save it as a feasible full answer
continue
look up the next leg's available modes
for each allowed mode:
update vehicle locations
update any forced future return-mode rule
if the partial answer is still feasible:
put the extended partial answer back into the queue
merge the best segment answers into full-chain answers
prune the low-probability tail
write the retained answers as output rows
Implementation details are in rust/search.rs and rust/input.rs.
Python API
import polars as pl
from mobility_mode_sequence_search import search_mode_sequences
result = search_mode_sequences(
location_chain_steps=pl.DataFrame(...),
leg_mode_costs=pl.DataFrame(...),
mode_metadata=pl.DataFrame(...),
k_sequences=20,
cumulative_prob_threshold=0.98,
n_threads=None,
)
Input Schemas
location_chain_steps
Grouped form:
dest_seq_id: UInt64locations: List[UInt32]
Long-form:
dest_seq_id: UInt64seq_step_index: UInt32location: UInt32
leg_mode_costs
origin: UInt32destination: UInt32mode_id: UInt16cost: Float64
mode_metadata
mode_id: UInt16needs_vehicle: Booleanvehicle_id: UInt8 | Utf8 | nullmultimodal: Booleanis_return_mode: Booleanreturn_mode_id: UInt16 | null
At the package boundary, vehicle_id may be integer/null or string/null.
String labels are normalized internally into numeric ids before search. Mixed
integer and string representations within one call are rejected.
Output Schema
dest_seq_id: UInt64mode_seq_index: UInt32seq_step_index: UInt32location: UInt32mode_index: UInt16
Development
mamba run -n mobility python -m pip install -e .[dev]
mamba run -n mobility python -m pytest
mamba run -n mobility python -m maturin build --release
Performance Fixture
A standalone synthetic performance case is available at tests/perf_synthetic_case.py.
Example:
mamba run -n mobility python tests/perf_synthetic_case.py --n-chains 2000 --chain-len 18 --n-locations 128 --k-sequences 20
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mobility_mode_sequence_search-0.1.0.tar.gz.
File metadata
- Download URL: mobility_mode_sequence_search-0.1.0.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
021cc39ad301afd33f2c307557747cf71be83f4e0691b46914dd24c54e8076de
|
|
| MD5 |
d9791658136db2d1a64581b44e9db298
|
|
| BLAKE2b-256 |
3bcb84dd70aa64a8c3ebd6ef0e9b9e259f282cd76df25afe8562122c5e4a2eae
|
Provenance
The following attestation bundles were made for mobility_mode_sequence_search-0.1.0.tar.gz:
Publisher:
wheels.yml on mobility-team/mobility-mode-sequence-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mobility_mode_sequence_search-0.1.0.tar.gz -
Subject digest:
021cc39ad301afd33f2c307557747cf71be83f4e0691b46914dd24c54e8076de - Sigstore transparency entry: 1435671146
- Sigstore integration time:
-
Permalink:
mobility-team/mobility-mode-sequence-search@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mobility-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mobility_mode_sequence_search-0.1.0-cp311-abi3-win_amd64.whl.
File metadata
- Download URL: mobility_mode_sequence_search-0.1.0-cp311-abi3-win_amd64.whl
- Upload date:
- Size: 205.0 kB
- Tags: CPython 3.11+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec1d644572c7576ac5dc34f286e28c79002a95f4bee7eda8e1745b6351669763
|
|
| MD5 |
2254450e2abea480c7a3f338837bc4ff
|
|
| BLAKE2b-256 |
6b754d7e76a1a0a860a2334e14096f7bc63c52c1493dfa7ef387bff37340b022
|
Provenance
The following attestation bundles were made for mobility_mode_sequence_search-0.1.0-cp311-abi3-win_amd64.whl:
Publisher:
wheels.yml on mobility-team/mobility-mode-sequence-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mobility_mode_sequence_search-0.1.0-cp311-abi3-win_amd64.whl -
Subject digest:
ec1d644572c7576ac5dc34f286e28c79002a95f4bee7eda8e1745b6351669763 - Sigstore transparency entry: 1435671293
- Sigstore integration time:
-
Permalink:
mobility-team/mobility-mode-sequence-search@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mobility-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mobility_mode_sequence_search-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: mobility_mode_sequence_search-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 331.3 kB
- Tags: CPython 3.11+, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf9944cf0cf8141c95d1a6eacac5a97eae943ca78abe824ecd30c7de97c87072
|
|
| MD5 |
a8f84576401704b2dcbdaf55bda8af46
|
|
| BLAKE2b-256 |
551b3d2cd22393a3c588f9e892189fe491ced7120d7181deafd1e3c3b280f732
|
Provenance
The following attestation bundles were made for mobility_mode_sequence_search-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl:
Publisher:
wheels.yml on mobility-team/mobility-mode-sequence-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mobility_mode_sequence_search-0.1.0-cp311-abi3-manylinux_2_34_x86_64.whl -
Subject digest:
bf9944cf0cf8141c95d1a6eacac5a97eae943ca78abe824ecd30c7de97c87072 - Sigstore transparency entry: 1435671364
- Sigstore integration time:
-
Permalink:
mobility-team/mobility-mode-sequence-search@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mobility-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mobility_mode_sequence_search-0.1.0-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: mobility_mode_sequence_search-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 288.1 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d4f4bd239f250150413bdb0fe550bdb5c42126e58e286e5db51956383257948
|
|
| MD5 |
c70056ca062438abd148041a5a0f596b
|
|
| BLAKE2b-256 |
378abbb90d66d6d4748b8b8ca7e2af4b6b186c2459e66ed980430018440621c2
|
Provenance
The following attestation bundles were made for mobility_mode_sequence_search-0.1.0-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on mobility-team/mobility-mode-sequence-search
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mobility_mode_sequence_search-0.1.0-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
5d4f4bd239f250150413bdb0fe550bdb5c42126e58e286e5db51956383257948 - Sigstore transparency entry: 1435671206
- Sigstore integration time:
-
Permalink:
mobility-team/mobility-mode-sequence-search@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/mobility-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@eb57296375c0b60f5cbb37b1d8146966f96b8704 -
Trigger Event:
push
-
Statement type: