micropurc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- micropurc-0.1.0/.clang-format +7 -0
- micropurc-0.1.0/.editorconfig +24 -0
- micropurc-0.1.0/.gitignore +63 -0
- micropurc-0.1.0/.pre-commit-config.yaml +51 -0
- micropurc-0.1.0/CHANGELOG.md +24 -0
- micropurc-0.1.0/CITATION.cff +40 -0
- micropurc-0.1.0/CMakeLists.txt +165 -0
- micropurc-0.1.0/LICENSE +21 -0
- micropurc-0.1.0/LICENSES/EIGEN_LICENSE.txt +378 -0
- micropurc-0.1.0/LICENSES/LDL_LICENSE.txt +21 -0
- micropurc-0.1.0/LICENSES/NANOBIND_LICENSE.txt +31 -0
- micropurc-0.1.0/LICENSES/PIQP_LICENSE.txt +29 -0
- micropurc-0.1.0/LICENSES/ROBIN_MAP_LICENSE.txt +26 -0
- micropurc-0.1.0/Makefile +39 -0
- micropurc-0.1.0/PKG-INFO +128 -0
- micropurc-0.1.0/README.md +84 -0
- micropurc-0.1.0/docs/Makefile +17 -0
- micropurc-0.1.0/docs/_static/custom.css +13 -0
- micropurc-0.1.0/docs/api/config.rst +5 -0
- micropurc-0.1.0/docs/api/core.rst +38 -0
- micropurc-0.1.0/docs/api/demands.rst +5 -0
- micropurc-0.1.0/docs/api/forward.rst +14 -0
- micropurc-0.1.0/docs/api/index.rst +14 -0
- micropurc-0.1.0/docs/api/network.rst +5 -0
- micropurc-0.1.0/docs/api/reporting.rst +20 -0
- micropurc-0.1.0/docs/api/simulation.rst +14 -0
- micropurc-0.1.0/docs/api/spec.rst +23 -0
- micropurc-0.1.0/docs/conf.py +75 -0
- micropurc-0.1.0/docs/examples/data/siouxfalls_net.csv +77 -0
- micropurc-0.1.0/docs/examples/data/siouxfalls_trips.csv +529 -0
- micropurc-0.1.0/docs/examples/index.rst +14 -0
- micropurc-0.1.0/docs/examples/model_spec.rst +78 -0
- micropurc-0.1.0/docs/examples/pipeline.py +138 -0
- micropurc-0.1.0/docs/examples/pipeline.rst +187 -0
- micropurc-0.1.0/docs/examples/reporting.rst +91 -0
- micropurc-0.1.0/docs/examples/simulation.rst +39 -0
- micropurc-0.1.0/docs/getting_started.rst +75 -0
- micropurc-0.1.0/docs/index.rst +37 -0
- micropurc-0.1.0/docs/requirements.txt +11 -0
- micropurc-0.1.0/extern/piqp/piqp/common.hpp +63 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/data.hpp +95 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/data.tpp +200 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/kkt.hpp +91 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/kkt.tpp +166 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/ldlt_no_pivot.hpp +498 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/model.hpp +79 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/preconditioner.hpp +319 -0
- micropurc-0.1.0/extern/piqp/piqp/dense/preconditioner.tpp +276 -0
- micropurc-0.1.0/extern/piqp/piqp/fwd.hpp +68 -0
- micropurc-0.1.0/extern/piqp/piqp/kkt_fwd.hpp +41 -0
- micropurc-0.1.0/extern/piqp/piqp/kkt_solver_base.hpp +48 -0
- micropurc-0.1.0/extern/piqp/piqp/kkt_system.hpp +124 -0
- micropurc-0.1.0/extern/piqp/piqp/kkt_system.tpp +539 -0
- micropurc-0.1.0/extern/piqp/piqp/piqp.hpp +15 -0
- micropurc-0.1.0/extern/piqp/piqp/results.hpp +100 -0
- micropurc-0.1.0/extern/piqp/piqp/settings.hpp +129 -0
- micropurc-0.1.0/extern/piqp/piqp/solver.hpp +242 -0
- micropurc-0.1.0/extern/piqp/piqp/solver.tpp +1696 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/LDL_License.txt +21 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/blocksparse/block_info.hpp +29 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/blocksparse/block_kkt.hpp +133 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/blocksparse/block_mat.hpp +149 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/blocksparse/block_vec.hpp +159 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/data.hpp +98 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/data.tpp +201 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt.hpp +106 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt.tpp +223 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt_all_eliminated.hpp +230 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt_eq_eliminated.hpp +252 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt_full.hpp +258 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/kkt_ineq_eliminated.hpp +253 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/ldlt.hpp +77 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/ldlt.tpp +209 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/model.hpp +86 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/multistage_kkt.hpp +193 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/multistage_kkt.tpp +1815 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/ordering.hpp +131 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/preconditioner.hpp +319 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/preconditioner.tpp +298 -0
- micropurc-0.1.0/extern/piqp/piqp/sparse/utils.hpp +205 -0
- micropurc-0.1.0/extern/piqp/piqp/timer.hpp +39 -0
- micropurc-0.1.0/extern/piqp/piqp/typedefs.hpp +97 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/blasfeo_mat.hpp +126 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/blasfeo_vec.hpp +125 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/blasfeo_wrapper.hpp +124 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/eigen_matio.hpp +497 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/filesystem.hpp +32 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/ghc_filesystem.hpp +6083 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/io_utils.hpp +98 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/optional.hpp +52 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/random_utils.hpp +292 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/smoothing.hpp +37 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/tl_optional.hpp +2062 -0
- micropurc-0.1.0/extern/piqp/piqp/utils/tracy.hpp +27 -0
- micropurc-0.1.0/extern/piqp/piqp/variables.hpp +115 -0
- micropurc-0.1.0/pyproject.toml +176 -0
- micropurc-0.1.0/scripts/__init__.py +0 -0
- micropurc-0.1.0/scripts/check_build_artifacts.py +61 -0
- micropurc-0.1.0/scripts/ci/upstream_python_support.py +84 -0
- micropurc-0.1.0/scripts/dev_setup.sh +31 -0
- micropurc-0.1.0/scripts/paper/__init__.py +12 -0
- micropurc-0.1.0/scripts/paper/common.py +66 -0
- micropurc-0.1.0/scripts/paper/nb01/__init__.py +0 -0
- micropurc-0.1.0/scripts/paper/nb01/s1_recovery.py +109 -0
- micropurc-0.1.0/scripts/paper/nb01/s2_initball.py +63 -0
- micropurc-0.1.0/scripts/paper/nb01/s3_margin.py +96 -0
- micropurc-0.1.0/scripts/paper/nb01/s4_switching.py +113 -0
- micropurc-0.1.0/scripts/paper/nb01/s5_nonconv.py +94 -0
- micropurc-0.1.0/scripts/paper/nb01/setup.py +156 -0
- micropurc-0.1.0/scripts/paper/nb02/__init__.py +0 -0
- micropurc-0.1.0/scripts/paper/nb02/s1_sweep_N.py +71 -0
- micropurc-0.1.0/scripts/paper/nb02/s2_sweep_L.py +118 -0
- micropurc-0.1.0/scripts/paper/nb02/s3_sweep_K.py +56 -0
- micropurc-0.1.0/scripts/paper/nb02/s4_cores.py +83 -0
- micropurc-0.1.0/scripts/paper/nb02/s5_figure.py +128 -0
- micropurc-0.1.0/scripts/paper/nb02/s7_paper_panels.py +67 -0
- micropurc-0.1.0/scripts/paper/nb02/setup.py +271 -0
- micropurc-0.1.0/scripts/paper/nb03/__init__.py +0 -0
- micropurc-0.1.0/scripts/paper/nb03/s1_finite_sample.py +93 -0
- micropurc-0.1.0/scripts/paper/nb03/s2_init_robust.py +134 -0
- micropurc-0.1.0/scripts/paper/nb03/s3_efficiency.py +51 -0
- micropurc-0.1.0/scripts/paper/nb03/s4_recovery_cdf.py +102 -0
- micropurc-0.1.0/scripts/paper/nb03/setup.py +337 -0
- micropurc-0.1.0/scripts/paper/nb04/__init__.py +0 -0
- micropurc-0.1.0/scripts/paper/nb04/s1_config_sweeps.py +68 -0
- micropurc-0.1.0/scripts/paper/nb04/s2_qp_tol.py +55 -0
- micropurc-0.1.0/scripts/paper/nb04/s3_hardstart.py +65 -0
- micropurc-0.1.0/scripts/paper/nb04/s4_figure.py +62 -0
- micropurc-0.1.0/scripts/paper/nb04/setup.py +178 -0
- micropurc-0.1.0/scripts/paper/nb06/__init__.py +0 -0
- micropurc-0.1.0/scripts/paper/nb06/s1_repeated_trips.py +163 -0
- micropurc-0.1.0/scripts/paper/nb06/setup.py +155 -0
- micropurc-0.1.0/scripts/paper/run_all.py +73 -0
- micropurc-0.1.0/src/micropurc/__init__.py +157 -0
- micropurc-0.1.0/src/micropurc/_native/activeset.cpp +252 -0
- micropurc-0.1.0/src/micropurc/_native/activeset.hpp +29 -0
- micropurc-0.1.0/src/micropurc/_native/bindings.cpp +2215 -0
- micropurc-0.1.0/src/micropurc/_native/common.hpp +171 -0
- micropurc-0.1.0/src/micropurc/_native/route_sampler.cpp +172 -0
- micropurc-0.1.0/src/micropurc/_native/route_sampler.hpp +41 -0
- micropurc-0.1.0/src/micropurc/_native/schur.cpp +236 -0
- micropurc-0.1.0/src/micropurc/_native/schur.hpp +35 -0
- micropurc-0.1.0/src/micropurc/config.py +270 -0
- micropurc-0.1.0/src/micropurc/core/__init__.py +18 -0
- micropurc-0.1.0/src/micropurc/core/activeset.py +228 -0
- micropurc-0.1.0/src/micropurc/core/covariance.py +109 -0
- micropurc-0.1.0/src/micropurc/core/diagnostics.py +1099 -0
- micropurc-0.1.0/src/micropurc/core/estimator.py +669 -0
- micropurc-0.1.0/src/micropurc/core/lazy_design.py +95 -0
- micropurc-0.1.0/src/micropurc/core/projection.py +85 -0
- micropurc-0.1.0/src/micropurc/demands.py +137 -0
- micropurc-0.1.0/src/micropurc/forward/__init__.py +11 -0
- micropurc-0.1.0/src/micropurc/forward/base.py +75 -0
- micropurc-0.1.0/src/micropurc/forward/piqp_solver.py +178 -0
- micropurc-0.1.0/src/micropurc/network.py +293 -0
- micropurc-0.1.0/src/micropurc/reporting/__init__.py +37 -0
- micropurc-0.1.0/src/micropurc/reporting/html.py +352 -0
- micropurc-0.1.0/src/micropurc/reporting/loader.py +401 -0
- micropurc-0.1.0/src/micropurc/reporting/metrics.py +271 -0
- micropurc-0.1.0/src/micropurc/reporting/runlog.py +476 -0
- micropurc-0.1.0/src/micropurc/simulation/__init__.py +12 -0
- micropurc-0.1.0/src/micropurc/simulation/dgp.py +615 -0
- micropurc-0.1.0/src/micropurc/simulation/route_sampler.py +277 -0
- micropurc-0.1.0/src/micropurc/spec/__init__.py +27 -0
- micropurc-0.1.0/src/micropurc/spec/compile.py +293 -0
- micropurc-0.1.0/src/micropurc/spec/dsl.py +182 -0
- micropurc-0.1.0/src/micropurc/spec/schema.py +173 -0
- micropurc-0.1.0/tests/__init__.py +0 -0
- micropurc-0.1.0/tests/data/EMA_net.csv +259 -0
- micropurc-0.1.0/tests/data/EMA_trips.csv +1114 -0
- micropurc-0.1.0/tests/data/SiouxFalls_net.csv +77 -0
- micropurc-0.1.0/tests/data/SiouxFalls_trips.csv +529 -0
- micropurc-0.1.0/tests/test_activeset_comparison.py +228 -0
- micropurc-0.1.0/tests/test_covariance.py +176 -0
- micropurc-0.1.0/tests/test_cts.py +162 -0
- micropurc-0.1.0/tests/test_estimator_orchestration.py +411 -0
- micropurc-0.1.0/tests/test_metrics.py +123 -0
- micropurc-0.1.0/tests/test_native.py +116 -0
- micropurc-0.1.0/tests/test_projection.py +450 -0
- micropurc-0.1.0/tests/test_projection_stress.py +637 -0
- micropurc-0.1.0/tests/test_recovery.py +735 -0
- micropurc-0.1.0/tests/test_reporting.py +181 -0
- micropurc-0.1.0/tests/test_route_sampler_native.py +196 -0
- micropurc-0.1.0/tests/test_scaling_instrumentation.py +131 -0
- micropurc-0.1.0/tests/test_spec.py +319 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
root = true
|
|
2
|
+
|
|
3
|
+
[*]
|
|
4
|
+
charset = utf-8
|
|
5
|
+
end_of_line = lf
|
|
6
|
+
insert_final_newline = true
|
|
7
|
+
trim_trailing_whitespace = true
|
|
8
|
+
indent_style = space
|
|
9
|
+
|
|
10
|
+
[*.py]
|
|
11
|
+
indent_size = 4
|
|
12
|
+
max_line_length = 100
|
|
13
|
+
|
|
14
|
+
[*.{cpp,hpp,h,cu,cuh}]
|
|
15
|
+
indent_size = 4
|
|
16
|
+
|
|
17
|
+
[*.{yml,yaml,toml}]
|
|
18
|
+
indent_size = 2
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[Makefile]
|
|
24
|
+
indent_style = tab
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
# IDE
|
|
5
|
+
.idea/
|
|
6
|
+
|
|
7
|
+
# Logs
|
|
8
|
+
log/
|
|
9
|
+
*.log
|
|
10
|
+
|
|
11
|
+
# Local configs
|
|
12
|
+
config.toml
|
|
13
|
+
configs/
|
|
14
|
+
|
|
15
|
+
# Paper-work experiments (not part of the publishable package)
|
|
16
|
+
experiments/
|
|
17
|
+
|
|
18
|
+
# Generated outputs
|
|
19
|
+
outputs*/
|
|
20
|
+
run.sh
|
|
21
|
+
run_job.sh
|
|
22
|
+
run_job.template.sh
|
|
23
|
+
|
|
24
|
+
# Python
|
|
25
|
+
__pycache__/
|
|
26
|
+
*.pyc
|
|
27
|
+
|
|
28
|
+
# Reference files
|
|
29
|
+
ref/
|
|
30
|
+
|
|
31
|
+
# Build artifacts
|
|
32
|
+
build/
|
|
33
|
+
*.so
|
|
34
|
+
*.egg-info/
|
|
35
|
+
|
|
36
|
+
# Empirical pipeline
|
|
37
|
+
empirical/
|
|
38
|
+
summary_stats.py
|
|
39
|
+
save_filtered_obs_csv.py
|
|
40
|
+
|
|
41
|
+
# Sphinx documentation build output
|
|
42
|
+
docs/_build/
|
|
43
|
+
|
|
44
|
+
# Generated experiment results (regenerable via scripts/paper/run_all.py)
|
|
45
|
+
results/
|
|
46
|
+
|
|
47
|
+
# Consolidated local archive (retired scripts, results, legacy oracle)
|
|
48
|
+
_archive/
|
|
49
|
+
|
|
50
|
+
# Doc-example run archives (generated by pipeline.py)
|
|
51
|
+
docs/examples/runs/
|
|
52
|
+
|
|
53
|
+
# --- Data-file backstops ----------------------------------------------------
|
|
54
|
+
# The rules above protect directory NAMES only. These protect by extension, so a
|
|
55
|
+
# stray data file anywhere in the tree cannot be tracked by accident. Name-based
|
|
56
|
+
# patterns are kept in .git/info/exclude instead, which is never published.
|
|
57
|
+
*.pkl
|
|
58
|
+
*.pt
|
|
59
|
+
*.npy
|
|
60
|
+
|
|
61
|
+
# Internal write-ups (not for publication)
|
|
62
|
+
docs/qa/
|
|
63
|
+
docs/prediction_metrics/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Never touch vendored code, the read-only legacy oracle, or the reference
|
|
2
|
+
# paper sources. (configs/ and experiments/ are gitignored.)
|
|
3
|
+
exclude: '^(extern/|micropurc_sim/|ref/|\.vscode/)'
|
|
4
|
+
|
|
5
|
+
repos:
|
|
6
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
7
|
+
rev: v0.14.13
|
|
8
|
+
hooks:
|
|
9
|
+
- id: ruff
|
|
10
|
+
args: ["--fix"]
|
|
11
|
+
- id: ruff-format
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/pycqa/pydocstyle
|
|
14
|
+
rev: 6.3.0
|
|
15
|
+
hooks:
|
|
16
|
+
- id: pydocstyle
|
|
17
|
+
additional_dependencies: [toml]
|
|
18
|
+
files: '^src/micropurc/.*\.py$'
|
|
19
|
+
|
|
20
|
+
- repo: https://github.com/terrencepreilly/darglint
|
|
21
|
+
rev: v1.8.1
|
|
22
|
+
hooks:
|
|
23
|
+
- id: darglint
|
|
24
|
+
args: ["--docstring-style", "google", "--strictness", "long"]
|
|
25
|
+
files: '^src/micropurc/.*\.py$'
|
|
26
|
+
# forward/base.py declares a Protocol with `...` stub bodies, which
|
|
27
|
+
# darglint misreads as excess-return (DAR202).
|
|
28
|
+
exclude: '^src/micropurc/forward/base\.py$'
|
|
29
|
+
|
|
30
|
+
- repo: https://github.com/pre-commit/mirrors-clang-format
|
|
31
|
+
rev: v19.1.7
|
|
32
|
+
hooks:
|
|
33
|
+
- id: clang-format
|
|
34
|
+
files: '^src/micropurc/_native/.*\.(cpp|hpp|h|cu|cuh)$'
|
|
35
|
+
|
|
36
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
37
|
+
rev: v5.0.0
|
|
38
|
+
hooks:
|
|
39
|
+
- id: end-of-file-fixer
|
|
40
|
+
- id: trailing-whitespace
|
|
41
|
+
- id: check-yaml
|
|
42
|
+
- id: check-added-large-files
|
|
43
|
+
args: ["--maxkb=1024"]
|
|
44
|
+
|
|
45
|
+
- repo: local
|
|
46
|
+
hooks:
|
|
47
|
+
- id: check-build-artifacts
|
|
48
|
+
name: Check for committed build artifacts
|
|
49
|
+
entry: python scripts/check_build_artifacts.py
|
|
50
|
+
language: system
|
|
51
|
+
pass_filenames: false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to
|
|
7
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-08-09
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- First public release.
|
|
14
|
+
- Trip-level PURC estimator: a nested fixed-point solver with a non-monotone
|
|
15
|
+
line search.
|
|
16
|
+
- Forward route-choice solver built on [PIQP](https://github.com/PREDICT-EPFL/piqp),
|
|
17
|
+
behind a `ForwardSolver` protocol for additional backends.
|
|
18
|
+
- Simulation tooling: a data-generating process and route samplers for
|
|
19
|
+
producing synthetic trip datasets at known parameters.
|
|
20
|
+
- Lazy design evaluation in C++ for memory-efficient handling of large
|
|
21
|
+
networks and specifications.
|
|
22
|
+
- Sandwich and cluster-robust covariance estimators.
|
|
23
|
+
- Structured run reporting with frozen configuration, diagnostics, and
|
|
24
|
+
reproducibility metadata.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite both the software and the accompanying article."
|
|
3
|
+
type: software
|
|
4
|
+
title: "micropurc"
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
date-released: '2026-08-09'
|
|
7
|
+
license: MIT
|
|
8
|
+
repository-code: "https://github.com/andyYaoR/micropurc"
|
|
9
|
+
authors:
|
|
10
|
+
- family-names: "Fosgerau"
|
|
11
|
+
given-names: "Mogens"
|
|
12
|
+
affiliation: "University of Copenhagen"
|
|
13
|
+
- family-names: "Nielsen"
|
|
14
|
+
given-names: "Nikolaj"
|
|
15
|
+
affiliation: "University of Copenhagen"
|
|
16
|
+
- family-names: "Rasmussen"
|
|
17
|
+
given-names: "Thomas"
|
|
18
|
+
affiliation: "Technical University of Denmark"
|
|
19
|
+
- family-names: "Yao"
|
|
20
|
+
given-names: "Rui"
|
|
21
|
+
affiliation: "Technion — Israel Institute of Technology"
|
|
22
|
+
email: "rui.yao@technion.ac.il"
|
|
23
|
+
preferred-citation:
|
|
24
|
+
type: article
|
|
25
|
+
title: "Estimating the perturbed utility route choice model with trip-level data"
|
|
26
|
+
year: 2026
|
|
27
|
+
authors:
|
|
28
|
+
- family-names: "Fosgerau"
|
|
29
|
+
given-names: "Mogens"
|
|
30
|
+
affiliation: "University of Copenhagen"
|
|
31
|
+
- family-names: "Nielsen"
|
|
32
|
+
given-names: "Nikolaj"
|
|
33
|
+
affiliation: "University of Copenhagen"
|
|
34
|
+
- family-names: "Rasmussen"
|
|
35
|
+
given-names: "Thomas"
|
|
36
|
+
affiliation: "Technical University of Denmark"
|
|
37
|
+
- family-names: "Yao"
|
|
38
|
+
given-names: "Rui"
|
|
39
|
+
affiliation: "Technion — Israel Institute of Technology"
|
|
40
|
+
email: "rui.yao@technion.ac.il"
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18)
|
|
2
|
+
project(micropurc_native LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
7
|
+
|
|
8
|
+
# ── Python + nanobind ────────────────────────────────────────────────
|
|
9
|
+
find_package(Python 3.10 COMPONENTS Interpreter Development.Module REQUIRED)
|
|
10
|
+
|
|
11
|
+
if(NOT nanobind_DIR)
|
|
12
|
+
execute_process(
|
|
13
|
+
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
|
|
14
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
15
|
+
OUTPUT_VARIABLE _NB_CMAKE_DIR
|
|
16
|
+
RESULT_VARIABLE _NB_RESULT)
|
|
17
|
+
if(_NB_RESULT EQUAL 0 AND _NB_CMAKE_DIR)
|
|
18
|
+
list(APPEND CMAKE_PREFIX_PATH "${_NB_CMAKE_DIR}")
|
|
19
|
+
endif()
|
|
20
|
+
endif()
|
|
21
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
22
|
+
|
|
23
|
+
# ── Eigen + PIQP (header-only) ─────────────────────────────────────
|
|
24
|
+
# conda-forge installs Eigen's CMake config and headers under the environment
|
|
25
|
+
# prefix on Unix, but under <prefix>/Library on Windows. Seed CMAKE_PREFIX_PATH
|
|
26
|
+
# with both (from CONDA_PREFIX, which the build front-end reliably inherits) so
|
|
27
|
+
# find_package(Eigen3) resolves even when scikit-build-core's PEP 517 build
|
|
28
|
+
# isolation does not forward a CMAKE_PREFIX_PATH set in the parent shell into
|
|
29
|
+
# the configure subprocess.
|
|
30
|
+
foreach(_conda_root "$ENV{CONDA_PREFIX}" "$ENV{CONDA_PREFIX}/Library"
|
|
31
|
+
"$ENV{LIBRARY_PREFIX}" "$ENV{PREFIX}")
|
|
32
|
+
if(_conda_root AND IS_DIRECTORY "${_conda_root}")
|
|
33
|
+
list(APPEND CMAKE_PREFIX_PATH "${_conda_root}")
|
|
34
|
+
endif()
|
|
35
|
+
endforeach()
|
|
36
|
+
|
|
37
|
+
# Do not pass an explicit version here. conda-forge now ships Eigen 5.x, whose
|
|
38
|
+
# Eigen3ConfigVersion.cmake rejects a `find_package(Eigen3 3.3)` request as
|
|
39
|
+
# version-incompatible (major-version mismatch) and reports NOTFOUND even when
|
|
40
|
+
# the config is on CMAKE_PREFIX_PATH — silently sending the build to the
|
|
41
|
+
# fallback below (which used to be Unix-only, hence the Windows failure). The
|
|
42
|
+
# code only needs a reasonably modern Eigen, which any conda-forge build
|
|
43
|
+
# satisfies, so we omit the version and let compilation fail loudly otherwise.
|
|
44
|
+
find_package(Eigen3 QUIET)
|
|
45
|
+
if(NOT Eigen3_FOUND)
|
|
46
|
+
# Header-only fallback: probe the conda layouts directly on both Unix
|
|
47
|
+
# (<prefix>/include/eigen3) and Windows (<prefix>/Library/include/eigen3).
|
|
48
|
+
find_path(EIGEN3_INCLUDE_DIR NAMES Eigen/Dense
|
|
49
|
+
HINTS "$ENV{CONDA_PREFIX}" "$ENV{CONDA_PREFIX}/Library"
|
|
50
|
+
"$ENV{LIBRARY_PREFIX}" "$ENV{PREFIX}"
|
|
51
|
+
PATH_SUFFIXES include/eigen3 include
|
|
52
|
+
PATHS "/usr/local" "/usr")
|
|
53
|
+
if(EIGEN3_INCLUDE_DIR)
|
|
54
|
+
message(STATUS "Found Eigen3 headers at ${EIGEN3_INCLUDE_DIR}")
|
|
55
|
+
else()
|
|
56
|
+
# Last resort, for clean CI runners with no conda or system Eigen (e.g.
|
|
57
|
+
# cibuildwheel's manylinux containers and the GitHub macOS/Windows
|
|
58
|
+
# runners): fetch a pinned Eigen release from the official GitLab mirror.
|
|
59
|
+
# Eigen is header-only, so we only populate the sources and point the
|
|
60
|
+
# include path at them -- Eigen's own CMake project (docs, tests, install
|
|
61
|
+
# rules) is never configured, so nothing of Eigen's leaks into our build
|
|
62
|
+
# or install (wheel) stage. The direct-argument FetchContent_Populate
|
|
63
|
+
# form is used deliberately: it works on CMake 3.18 (our minimum) and,
|
|
64
|
+
# unlike the single-argument form, is not deprecated by CMP0169 on
|
|
65
|
+
# CMake >= 3.30.
|
|
66
|
+
message(STATUS
|
|
67
|
+
"Eigen3 not found via find_package or header probe; "
|
|
68
|
+
"fetching Eigen 3.4.0 sources (header-only) with FetchContent")
|
|
69
|
+
include(FetchContent)
|
|
70
|
+
FetchContent_Populate(eigen
|
|
71
|
+
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
|
|
72
|
+
GIT_TAG 3.4.0
|
|
73
|
+
GIT_SHALLOW TRUE)
|
|
74
|
+
set(EIGEN3_INCLUDE_DIR "${eigen_SOURCE_DIR}" CACHE PATH
|
|
75
|
+
"Eigen3 headers (fetched by FetchContent)" FORCE)
|
|
76
|
+
message(STATUS "Using fetched Eigen3 headers at ${EIGEN3_INCLUDE_DIR}")
|
|
77
|
+
endif()
|
|
78
|
+
endif()
|
|
79
|
+
|
|
80
|
+
# PIQP header-only library (vendored in extern/piqp/).
|
|
81
|
+
set(PIQP_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extern/piqp")
|
|
82
|
+
|
|
83
|
+
# ── Build the extension ─────────────────────────────────────────────
|
|
84
|
+
# Threading via std::thread (no OpenMP — avoids dual-runtime conflicts
|
|
85
|
+
# with torch/numpy libomp on macOS).
|
|
86
|
+
nanobind_add_module(_native
|
|
87
|
+
src/micropurc/_native/bindings.cpp
|
|
88
|
+
src/micropurc/_native/activeset.cpp
|
|
89
|
+
src/micropurc/_native/schur.cpp
|
|
90
|
+
src/micropurc/_native/route_sampler.cpp)
|
|
91
|
+
|
|
92
|
+
# std::thread needs pthreads on Linux. On MinGW the pthread symbols come from
|
|
93
|
+
# winpthread, which we link *statically* in the MINGW block below so the .pyd
|
|
94
|
+
# carries no libwinpthread-1.dll dependency; using Threads::Threads there would
|
|
95
|
+
# re-introduce a dynamic winpthread reference, so it is skipped on MinGW.
|
|
96
|
+
find_package(Threads REQUIRED)
|
|
97
|
+
if(NOT MINGW)
|
|
98
|
+
target_link_libraries(_native PRIVATE Threads::Threads)
|
|
99
|
+
endif()
|
|
100
|
+
|
|
101
|
+
# Eigen + PIQP headers.
|
|
102
|
+
if(Eigen3_FOUND)
|
|
103
|
+
target_link_libraries(_native PRIVATE Eigen3::Eigen)
|
|
104
|
+
else()
|
|
105
|
+
target_include_directories(_native PRIVATE ${EIGEN3_INCLUDE_DIR})
|
|
106
|
+
endif()
|
|
107
|
+
target_include_directories(_native PRIVATE ${PIQP_INCLUDE_DIR})
|
|
108
|
+
target_compile_definitions(_native PRIVATE HAVE_PIQP)
|
|
109
|
+
|
|
110
|
+
# ── BLAS/LAPACK (for large matrix operations) ──────────────────────
|
|
111
|
+
if(APPLE)
|
|
112
|
+
target_link_libraries(_native PRIVATE "-framework Accelerate")
|
|
113
|
+
target_compile_definitions(_native PRIVATE HAVE_LAPACK)
|
|
114
|
+
else()
|
|
115
|
+
find_package(LAPACK QUIET)
|
|
116
|
+
find_package(BLAS QUIET)
|
|
117
|
+
if(LAPACK_FOUND AND BLAS_FOUND)
|
|
118
|
+
target_link_libraries(_native PRIVATE ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
|
|
119
|
+
target_compile_definitions(_native PRIVATE HAVE_LAPACK)
|
|
120
|
+
endif()
|
|
121
|
+
endif()
|
|
122
|
+
|
|
123
|
+
# ── Self-contained runtime on Windows/MinGW ─────────────────────────
|
|
124
|
+
# Built with MinGW-w64 (e.g. Strawberry Perl's GCC), the .pyd otherwise
|
|
125
|
+
# depends on libgcc_s_seh-1.dll, libstdc++-6.dll, and libwinpthread-1.dll
|
|
126
|
+
# (the last pulled in by std::thread). Since Python 3.8 the extension loader
|
|
127
|
+
# ignores PATH for a .pyd's own dependencies -- only the module's directory,
|
|
128
|
+
# the system directories, and os.add_dll_directory() are searched -- so adding
|
|
129
|
+
# the toolchain's bin to PATH does not resolve them. Statically link the GCC
|
|
130
|
+
# runtime and winpthread so the module has no external MinGW DLL dependencies.
|
|
131
|
+
# Surgical by design: BLAS/LAPACK and system DLLs stay dynamic.
|
|
132
|
+
if(MINGW)
|
|
133
|
+
target_link_options(_native PRIVATE
|
|
134
|
+
-static-libgcc -static-libstdc++
|
|
135
|
+
-Wl,-Bstatic -lwinpthread -Wl,-Bdynamic)
|
|
136
|
+
endif()
|
|
137
|
+
|
|
138
|
+
# Optimisation flags.
|
|
139
|
+
# MICROPURC_NATIVE_ARCH defaults to OFF because binaries built with
|
|
140
|
+
# -march=native are tied to the build machine's CPU: a wheel compiled on a
|
|
141
|
+
# modern CI runner would crash with SIGILL (illegal instruction) on older
|
|
142
|
+
# user CPUs. Source builders compiling for their own machine can opt in with
|
|
143
|
+
# -DMICROPURC_NATIVE_ARCH=ON; distributable wheels must leave it off.
|
|
144
|
+
option(MICROPURC_NATIVE_ARCH
|
|
145
|
+
"Optimize for the build machine's CPU (never enable for distributable wheels)"
|
|
146
|
+
OFF)
|
|
147
|
+
if(NOT MSVC)
|
|
148
|
+
target_compile_options(_native PRIVATE -O3 -funroll-loops)
|
|
149
|
+
if(MICROPURC_NATIVE_ARCH)
|
|
150
|
+
include(CheckCXXCompilerFlag)
|
|
151
|
+
check_cxx_compiler_flag("-march=native" HAS_MARCH_NATIVE)
|
|
152
|
+
if(HAS_MARCH_NATIVE)
|
|
153
|
+
target_compile_options(_native PRIVATE -march=native)
|
|
154
|
+
endif()
|
|
155
|
+
endif()
|
|
156
|
+
else()
|
|
157
|
+
# No explicit MSVC optimisation flags needed: the wheel build configures
|
|
158
|
+
# with cmake.build-type = Release (pyproject.toml), and CMake's default
|
|
159
|
+
# CMAKE_CXX_FLAGS_RELEASE for MSVC already contains /O2 /Ob2 /DNDEBUG
|
|
160
|
+
# (see Modules/Platform/Windows-MSVC.cmake). Adding /O2 here again would
|
|
161
|
+
# be redundant and risk duplicate-flag warnings.
|
|
162
|
+
endif()
|
|
163
|
+
|
|
164
|
+
# Install into the micropurc package directory.
|
|
165
|
+
install(TARGETS _native DESTINATION micropurc)
|
micropurc-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mogens Fosgerau, Nikolaj Nielsen, Thomas Rasmussen, Rui Yao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|