Metadata-Version: 2.4
Name: tradeoff
Version: 0.1.0
Summary: Choose between options when none is best on every count: Pareto front and weighted ranking
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: decision,multi-criteria,pareto,ranking,trade-off
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# tradeoff

Choose between options when none is best on every count.

```bash
pip install tradeoff
```

```python
import tradeoff

flights = [
    {"name": "A", "price": 420, "hours": 7.5, "stops": 0},
    {"name": "B", "price": 260, "hours": 11.0, "stops": 1},
    {"name": "C", "price": 300, "hours": 12.5, "stops": 2},
    {"name": "D", "price": 180, "hours": 19.0, "stops": 2},
]

# The options worth considering: C is out, because B is cheaper, faster and has fewer stops.
tradeoff.pareto(flights, minimize=["price", "hours", "stops"])  # A, B, D

# All options, best first. Price matters twice as much as time.
tradeoff.rank(flights, {"price": -2, "hours": -1})  # B, D, C, A
```

- `pareto(options, maximize=[...], minimize=[...])`: the options no other option beats on every
  count, in their original order.
- `rank(options, weights)`: all options, best first. Each criterion is scaled to 0..1 across the
  options, then weighted. A positive weight means more is better, a negative one means less is better.
- `scores(options, weights)`: each option with its score.
- `dominates(a, b, maximize=[...], minimize=[...])`: whether `a` beats `b` on every count.

A criterion is a dict key, an attribute name, or a function that takes an option and returns a
number. No dependencies. Python 3.9 or newer.

## License

Apache-2.0
