Metadata-Version: 2.4
Name: certiflow-ue
Version: 0.1.0
Summary: Certified accuracy for user-equilibrium traffic assignment and scheme appraisal
Author: Yue Li, Shujuan Chen, Ying Jin
License-Expression: MIT
Project-URL: Homepage, https://github.com/yueli901/CertiFlow
Project-URL: Documentation, https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md
Project-URL: Issues, https://github.com/yueli901/CertiFlow/issues
Keywords: traffic assignment,user equilibrium,transport appraisal,verified computation
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21
Requires-Dist: scipy>=1.7
Dynamic: license-file

# CertiFlow

Certified accuracy for user-equilibrium traffic assignment and scheme appraisal.

A traffic assignment stopped at a small convergence gap gives a total travel cost, and a scheme benefit, of unknown
accuracy. CertiFlow returns intervals that are guaranteed to contain the equilibrium values: the total travel cost of
a network, the benefit of a scheme and the difference between the benefits of two schemes. It runs each assignment
only until the benefit meets the accuracy you ask for.

## Installation

```
pip install certiflow-ue
```

CertiFlow needs Python 3.10 or later and installs NumPy and SciPy with it. The
[user guide](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#installation) covers conda, GitHub and
fixed versions.

## Quick start

```
certiflow demo
```

or, in Python,

```python
import certiflow_ue as cf

cf.demo()
```

Both run Example 1 of the paper and print:

```text
CertiFlow demo: Example 1 of Li, Chen and Jin (2026)

One OD pair with demand 1 has two routes. Route 1 costs 1 + x at flow x and route 2 costs 2. Both costs are 1 higher
than in the paper's Figure 1, because a BPR cost cannot be x, and the shift leaves the gap, the error and its bound
unchanged. At equilibrium every trip uses route 1, so the equilibrium total cost is 2. Each row moves z trips to
route 2, certifies the total cost at that flow and compares the error of the usual estimate (the shortest-path travel
time) with its certified bound.

       z       gap    actual error    certified bound
     0.5      0.25             0.5           0.500001
     0.1      0.01             0.1           0.100001
    0.01    0.0001            0.01          0.0100001
   0.001      1e-6           0.001         0.00100001

The bound equals the error in exact arithmetic. The computed bound is rounded upwards at every step, so that it stays
guaranteed, and this raises only its last digit shown. The error is the square root of the gap, so a small gap does
not mean a small error.
```

## Appraise your own schemes

Give your network and its trips as
[TNTP files](https://github.com/yueli901/CertiFlow/blob/main/docs/input_formats.md), and list the schemes in a CSV
file, each row multiplying the capacity of one link:

```text
scheme,init_node,term_node,capacity_multiplier
wider,1,3,2
wider,3,2,2
narrower,1,2,0.5
```

Then run

```python
import certiflow_ue as cf

base = cf.read_tntp("net.tntp", "trips.tntp")
schemes = cf.read_schemes("schemes.csv", base)
result = cf.appraise(base, schemes)
print(result)
result.to_csv("results.csv")
```

or `certiflow appraise net.tntp trips.tntp schemes.csv -o results.csv`. Each row of the result is one scheme: the
estimate of its benefit (the fall in total travel cost), an interval guaranteed to contain the equilibrium benefit,
and whether the estimate is certified to be within the tolerance.

## Next steps

- [Set the tolerance or build schemes in Python](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#appraise-schemes-on-your-network)
- [Compare schemes and find the best one](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#compare-schemes)
- [Certify the total cost of one network](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#certify-one-network)
- [Certify route flows from another solver](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#route-flows-from-another-solver)
- [Build a network in Python](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#build-a-network-in-python)
- [Understand a result or a status](https://github.com/yueli901/CertiFlow/blob/main/docs/user_guide.md#reading-the-results)
- [Prepare input files](https://github.com/yueli901/CertiFlow/blob/main/docs/input_formats.md)
- [Look up a function](https://github.com/yueli901/CertiFlow/blob/main/docs/api_reference.md)

## Citation

Li, Y., Chen, S. and Jin, Y. (2026). Certified benefit intervals for network changes under user equilibrium.
arXiv preprint.

## License

MIT.
