Configuration¶
Configuration for micropurc estimation runs (JSON and TOML).
JSON is the canonical format: human-readable and loadable straight into a
RunConfig. TOML loading is kept for backward compatibility with
existing configuration files.
- class micropurc.config.ActiveSetConfig(threshold_factor=1e-08, threshold_min=1e-10, slack_tol=0.0)[source]¶
Bases:
objectActive-set determination parameters.
A link is active when its dual slack (the KKT sign test) is negative:
\[s_j = c_j + (A^{\top}\lambda)_j < 0 .\]- Variables:
threshold_factor (float) – Multiplier in the flow-magnitude threshold
max(threshold_min, threshold_factor * x.max())that route sampling uses to clean numerically negligible flows.threshold_min (float) – Floor of that same threshold.
slack_tol (float) – A positive value tightens the cutoff above to \(-\texttt{slack\_tol}\). At the default 0.0 a link is active when its slack is strictly negative.
- Parameters:
- class micropurc.config.SolverConfig(backend='piqp', eps_abs=1e-12, eps_duality_gap_abs=1e-12, eps_rel=1e-09, eps_duality_gap_rel=1e-09, max_iter=1000, verbose=False)[source]¶
Bases:
objectInner quadratic-program solver parameters.
backendselects the forward solver;"piqp"is the only backend shipped with the package. Additional backends can be added by implementing theForwardSolverprotocol.- Parameters:
- class micropurc.config.ProjectionConfig(mode='robust_pinv')[source]¶
Bases:
objectProjection computation parameters.
robust_pinvis the only mode: one node row is grounded per connected component of the active subnetwork, which is the grounding under which the projection agrees with the pseudoinverse of the active incidence.- Parameters:
mode (str)
- class micropurc.config.EstimationConfig(max_iterations=500, fp_tol=0.0001, scale_fp_tol_by_sqrt_k=False, max_cond_H=10000.0, ls_max_tries=5, ls_tau=0.5, nm_window=3)[source]¶
Bases:
objectKrasnoselskii-Mann fixed-point iteration parameters.
- Variables:
max_iterations (int) – Cap on the number of fixed-point iterations.
fp_tol (float) – Tolerance on the residual \(\lVert \Phi_N(\beta) - \beta \rVert\).
scale_fp_tol_by_sqrt_k (bool) – Scale
fp_tolby \(\sqrt{K}\), which holds the per-coordinate tolerance fixed as \(K\) grows.max_cond_H (float) – Largest condition number of the accumulated Hessian that still counts as convergence;
infwaives the check. A run can meetfp_tolat a degenerate fixed point: from an extreme start \(\beta\) explodes, the forward-QP flows saturate at their box bounds, and \(H\) turns ill-conditioned while the residual test passes because \(\Phi_N\) has flattened. Healthy fits sit at \(\mathrm{cond}(H) \approx 10^1\) to \(10^2\) and degenerate ones near \(10^6\), so the default separates the two by orders of magnitude.ls_max_tries (int) – Backtracking steps allowed per iteration.
ls_tau (float) – Backtracking factor; trial \(m\) takes the step \(\tau^m\).
nm_window (int) – Number of recent merit values; an accepted trial step lands at or below their maximum.
- Parameters:
- class micropurc.config.SpecConfig(attributes=<factory>)[source]¶
Bases:
objectModel specification: the link attributes entering the utility.
- class micropurc.config.RunConfig(name='unnamed', data_path='', network_path='', output_dir='.', num_od_pairs_to_use='all', init_beta=<factory>, seed=42, active_set=<factory>, solver=<factory>, projection=<factory>, estimation=<factory>, spec=<factory>)[source]¶
Bases:
objectTop-level configuration for a micropurc run.
- Variables:
name (str) – Run label, used in output paths and reports.
data_path (str) – Path to the trip data.
network_path (str) – Path to the network definition.
output_dir (str) – Directory that receives the run’s output.
num_od_pairs_to_use (str | int) –
"all", or the number of OD pairs to keep.seed (int) – Seed for the run’s random draws.
active_set (micropurc.config.ActiveSetConfig) – Active-set detection settings.
solver (micropurc.config.SolverConfig) – Forward-QP settings.
projection (micropurc.config.ProjectionConfig) – Range-space projection settings.
estimation (micropurc.config.EstimationConfig) – Fixed-point iteration settings.
spec (micropurc.config.SpecConfig) – Link attributes entering the utility.
- Parameters:
name (str)
data_path (str)
network_path (str)
output_dir (str)
seed (int)
active_set (ActiveSetConfig)
solver (SolverConfig)
projection (ProjectionConfig)
estimation (EstimationConfig)
spec (SpecConfig)
- active_set: ActiveSetConfig¶
- solver: SolverConfig¶
- projection: ProjectionConfig¶
- estimation: EstimationConfig¶
- spec: SpecConfig¶
- save_json(path)[source]¶
Write the config to
pathas JSON, creating parent directories.Returns the path written.