mcdakit 0.2.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.
- mcdakit-0.2.0/.env.example +20 -0
- mcdakit-0.2.0/.github/ISSUE_TEMPLATE/bug_report.md +27 -0
- mcdakit-0.2.0/.github/ISSUE_TEMPLATE/new_method.md +36 -0
- mcdakit-0.2.0/.github/PULL_REQUEST_TEMPLATE.md +25 -0
- mcdakit-0.2.0/.github/workflows/ci.yml +92 -0
- mcdakit-0.2.0/.github/workflows/docs.yml +55 -0
- mcdakit-0.2.0/.gitignore +26 -0
- mcdakit-0.2.0/.vulture-allowlist.py +21 -0
- mcdakit-0.2.0/CHANGELOG.md +278 -0
- mcdakit-0.2.0/CITATION.cff +33 -0
- mcdakit-0.2.0/CONTRIBUTING.md +250 -0
- mcdakit-0.2.0/LICENSE +202 -0
- mcdakit-0.2.0/PKG-INFO +627 -0
- mcdakit-0.2.0/README.md +581 -0
- mcdakit-0.2.0/benchmarks/comparison.py +547 -0
- mcdakit-0.2.0/benchmarks/crosscheck.py +547 -0
- mcdakit-0.2.0/benchmarks/reversal.py +108 -0
- mcdakit-0.2.0/docs/_static/custom.css +217 -0
- mcdakit-0.2.0/docs/_static/favicon.svg +9 -0
- mcdakit-0.2.0/docs/adr/0000-original-build-brief.md +382 -0
- mcdakit-0.2.0/docs/adr/0001-method-registry.md +76 -0
- mcdakit-0.2.0/docs/adr/index.md +11 -0
- mcdakit-0.2.0/docs/ai.md +388 -0
- mcdakit-0.2.0/docs/api.md +230 -0
- mcdakit-0.2.0/docs/changelog.md +2 -0
- mcdakit-0.2.0/docs/citing.md +25 -0
- mcdakit-0.2.0/docs/conf.py +129 -0
- mcdakit-0.2.0/docs/contributing.md +2 -0
- mcdakit-0.2.0/docs/extending.md +389 -0
- mcdakit-0.2.0/docs/index.md +114 -0
- mcdakit-0.2.0/docs/limitations.md +62 -0
- mcdakit-0.2.0/docs/quickstart.md +104 -0
- mcdakit-0.2.0/docs/stability.md +97 -0
- mcdakit-0.2.0/examples/README.md +92 -0
- mcdakit-0.2.0/examples/ai_assisted.py +304 -0
- mcdakit-0.2.0/examples/same_problem_every_library.py +164 -0
- mcdakit-0.2.0/examples/supplier_selection.py +168 -0
- mcdakit-0.2.0/pyproject.toml +133 -0
- mcdakit-0.2.0/src/mcdakit/__init__.py +180 -0
- mcdakit-0.2.0/src/mcdakit/ahp.py +372 -0
- mcdakit-0.2.0/src/mcdakit/ai.py +802 -0
- mcdakit-0.2.0/src/mcdakit/ai_providers.py +438 -0
- mcdakit-0.2.0/src/mcdakit/explain.py +346 -0
- mcdakit-0.2.0/src/mcdakit/group.py +296 -0
- mcdakit-0.2.0/src/mcdakit/methods/__init__.py +157 -0
- mcdakit-0.2.0/src/mcdakit/methods/_common.py +25 -0
- mcdakit-0.2.0/src/mcdakit/methods/aras.py +63 -0
- mcdakit-0.2.0/src/mcdakit/methods/base.py +305 -0
- mcdakit-0.2.0/src/mcdakit/methods/cocoso.py +80 -0
- mcdakit-0.2.0/src/mcdakit/methods/codas.py +71 -0
- mcdakit-0.2.0/src/mcdakit/methods/copras.py +100 -0
- mcdakit-0.2.0/src/mcdakit/methods/edas.py +66 -0
- mcdakit-0.2.0/src/mcdakit/methods/electre.py +83 -0
- mcdakit-0.2.0/src/mcdakit/methods/mabac.py +54 -0
- mcdakit-0.2.0/src/mcdakit/methods/marcos.py +71 -0
- mcdakit-0.2.0/src/mcdakit/methods/promethee.py +162 -0
- mcdakit-0.2.0/src/mcdakit/methods/registry.py +218 -0
- mcdakit-0.2.0/src/mcdakit/methods/scoring.py +97 -0
- mcdakit-0.2.0/src/mcdakit/methods/spotis.py +164 -0
- mcdakit-0.2.0/src/mcdakit/methods/topsis.py +69 -0
- mcdakit-0.2.0/src/mcdakit/methods/vikor.py +68 -0
- mcdakit-0.2.0/src/mcdakit/methods/waspas.py +133 -0
- mcdakit-0.2.0/src/mcdakit/normalization.py +240 -0
- mcdakit-0.2.0/src/mcdakit/orientation.py +47 -0
- mcdakit-0.2.0/src/mcdakit/py.typed +0 -0
- mcdakit-0.2.0/src/mcdakit/ranking.py +289 -0
- mcdakit-0.2.0/src/mcdakit/sensitivity.py +231 -0
- mcdakit-0.2.0/src/mcdakit/testing.py +444 -0
- mcdakit-0.2.0/src/mcdakit/types.py +394 -0
- mcdakit-0.2.0/src/mcdakit/weighting.py +341 -0
- mcdakit-0.2.0/tests/conftest.py +66 -0
- mcdakit-0.2.0/tests/test_ahp.py +145 -0
- mcdakit-0.2.0/tests/test_ahp_rank.py +225 -0
- mcdakit-0.2.0/tests/test_ai.py +847 -0
- mcdakit-0.2.0/tests/test_ai_providers.py +469 -0
- mcdakit-0.2.0/tests/test_api.py +255 -0
- mcdakit-0.2.0/tests/test_benchmark.py +58 -0
- mcdakit-0.2.0/tests/test_copras.py +170 -0
- mcdakit-0.2.0/tests/test_coverage_gaps.py +277 -0
- mcdakit-0.2.0/tests/test_cross_validation.py +431 -0
- mcdakit-0.2.0/tests/test_explain.py +280 -0
- mcdakit-0.2.0/tests/test_group.py +241 -0
- mcdakit-0.2.0/tests/test_methods.py +269 -0
- mcdakit-0.2.0/tests/test_normalization.py +339 -0
- mcdakit-0.2.0/tests/test_packaging.py +298 -0
- mcdakit-0.2.0/tests/test_properties.py +147 -0
- mcdakit-0.2.0/tests/test_reference_point_methods.py +210 -0
- mcdakit-0.2.0/tests/test_registry.py +428 -0
- mcdakit-0.2.0/tests/test_sensitivity.py +165 -0
- mcdakit-0.2.0/tests/test_spotis.py +185 -0
- mcdakit-0.2.0/tests/test_testing.py +514 -0
- mcdakit-0.2.0/tests/test_types.py +133 -0
- mcdakit-0.2.0/tests/test_waspas.py +199 -0
- mcdakit-0.2.0/tests/test_weighting.py +273 -0
- mcdakit-0.2.0/tests/test_wpm.py +172 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Copy to .env and fill in whichever you use. .env is gitignored; this file
|
|
2
|
+
# is the committed template, so never put a real key here.
|
|
3
|
+
#
|
|
4
|
+
# cp .env.example .env
|
|
5
|
+
#
|
|
6
|
+
# Then, in Python:
|
|
7
|
+
#
|
|
8
|
+
# from mcdakit.ai_providers import load_env, anthropic
|
|
9
|
+
# load_env()
|
|
10
|
+
# ask = anthropic()
|
|
11
|
+
|
|
12
|
+
ANTHROPIC_API_KEY=
|
|
13
|
+
OPENAI_API_KEY=
|
|
14
|
+
GOOGLE_API_KEY=
|
|
15
|
+
# GEMINI_API_KEY is read as a fallback when GOOGLE_API_KEY is unset.
|
|
16
|
+
# GEMINI_API_KEY=
|
|
17
|
+
|
|
18
|
+
# Local models need no key at all:
|
|
19
|
+
# ask = ollama("llama3")
|
|
20
|
+
# ask = openai_compatible("mistral-7b", "http://localhost:8000/v1")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Something produced a wrong or surprising result
|
|
4
|
+
title: ""
|
|
5
|
+
labels: bug
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## What happened
|
|
9
|
+
|
|
10
|
+
## Reproducing it
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
# The smallest script that shows the problem, please — including the matrix,
|
|
14
|
+
# the criteria (with directions and bounds), and the method.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What you expected, and why
|
|
18
|
+
|
|
19
|
+
If a ranking looks wrong, say which option you expected to win and what makes
|
|
20
|
+
you confident. A cross-method disagreement is often a real finding rather than
|
|
21
|
+
a bug — `compare_methods()` and `sensitivity()` will say which.
|
|
22
|
+
|
|
23
|
+
## Environment
|
|
24
|
+
|
|
25
|
+
- mcdakit version:
|
|
26
|
+
- Python version:
|
|
27
|
+
- numpy version:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Propose a method
|
|
3
|
+
about: Suggest an MCDA method to add, or announce one you have implemented
|
|
4
|
+
title: "Method: "
|
|
5
|
+
labels: method
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## The method
|
|
9
|
+
|
|
10
|
+
**Name:**
|
|
11
|
+
**Reference:** (paper, with year — this library is read by people who know them)
|
|
12
|
+
|
|
13
|
+
## Does it need to live here?
|
|
14
|
+
|
|
15
|
+
A method distributed as a plugin is a first-class citizen: reachable by name
|
|
16
|
+
from `rank()`, included in `compare_methods()`, analysable by `sensitivity()`.
|
|
17
|
+
See `docs/extending.md`. Adding it to core is worth it when the method is
|
|
18
|
+
widely used, or when it needs something the extension contract cannot express.
|
|
19
|
+
|
|
20
|
+
- [ ] I have read `docs/extending.md`
|
|
21
|
+
- [ ] This cannot be done as a plugin, because:
|
|
22
|
+
|
|
23
|
+
## Conformance
|
|
24
|
+
|
|
25
|
+
- [ ] `python -m mcdakit.testing my_module:MyMethod` passes
|
|
26
|
+
|
|
27
|
+
If it does not, paste the output — a failing check usually names the fix.
|
|
28
|
+
|
|
29
|
+
## Verifiable values
|
|
30
|
+
|
|
31
|
+
Every method here is tested against numbers verified **outside** this
|
|
32
|
+
codebase. Which do you have?
|
|
33
|
+
|
|
34
|
+
- [ ] A worked example from a published paper (cite table/section)
|
|
35
|
+
- [ ] A hand computation
|
|
36
|
+
- [ ] A cross-check against another library (name it and its version)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## What this changes
|
|
2
|
+
|
|
3
|
+
## Checks
|
|
4
|
+
|
|
5
|
+
The same ones CI runs:
|
|
6
|
+
|
|
7
|
+
- [ ] `pytest -q`
|
|
8
|
+
- [ ] `ruff check . && ruff format --check .`
|
|
9
|
+
- [ ] `mypy`
|
|
10
|
+
- [ ] `python benchmarks/reversal.py` — SPOTIS still measures 0.0%
|
|
11
|
+
|
|
12
|
+
## If this adds or changes a method
|
|
13
|
+
|
|
14
|
+
- [ ] `python -m mcdakit.testing <module>:<Method>` passes
|
|
15
|
+
- [ ] Tested against values verified outside this codebase (paper, hand
|
|
16
|
+
computation, or another library — say which in the test's docstring)
|
|
17
|
+
- [ ] Docstring names the source
|
|
18
|
+
- [ ] Added to the README method table
|
|
19
|
+
|
|
20
|
+
## If this changes a published number
|
|
21
|
+
|
|
22
|
+
Benchmark rates, worked-example scores and documented outputs appear in the
|
|
23
|
+
README, the docs and the changelog. A stale number there is a correctness bug.
|
|
24
|
+
|
|
25
|
+
- [ ] README, docs and `CHANGELOG.md` updated together
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, dev]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: py${{ matrix.python }} on ${{ matrix.os }}
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
os: [ubuntu-latest]
|
|
21
|
+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
22
|
+
include:
|
|
23
|
+
# The oldest and newest supported versions on the other platforms,
|
|
24
|
+
# which is where path and float-formatting differences show up.
|
|
25
|
+
- os: macos-latest
|
|
26
|
+
python: "3.12"
|
|
27
|
+
- os: windows-latest
|
|
28
|
+
python: "3.12"
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
- uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python }}
|
|
34
|
+
- name: Install
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade pip
|
|
37
|
+
pip install -e ".[dev,compare]"
|
|
38
|
+
- name: Test
|
|
39
|
+
run: pytest -q --cov=mcdakit --cov-report=term-missing --cov-fail-under=100
|
|
40
|
+
- name: The reversal benchmark must still measure SPOTIS at 0.0%
|
|
41
|
+
run: python benchmarks/reversal.py --trials 200
|
|
42
|
+
# A shell loop here would need one form for bash and another for
|
|
43
|
+
# PowerShell. TestConformanceCli in tests/test_packaging.py already
|
|
44
|
+
# drives the same command for every built-in, cross-platform, so this
|
|
45
|
+
# only has to prove the entry point itself works when invoked directly.
|
|
46
|
+
- name: The conformance CLI runs
|
|
47
|
+
run: python -m mcdakit.testing mcdakit.methods:Spotis --no-strict
|
|
48
|
+
|
|
49
|
+
lint:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v4
|
|
53
|
+
- uses: actions/setup-python@v5
|
|
54
|
+
with:
|
|
55
|
+
python-version: "3.12"
|
|
56
|
+
- run: pip install -e ".[dev]"
|
|
57
|
+
- run: ruff check .
|
|
58
|
+
- run: ruff format --check .
|
|
59
|
+
- run: mypy
|
|
60
|
+
- name: No dead code
|
|
61
|
+
run: vulture src/ .vulture-allowlist.py --min-confidence 60
|
|
62
|
+
|
|
63
|
+
build:
|
|
64
|
+
runs-on: ubuntu-latest
|
|
65
|
+
steps:
|
|
66
|
+
- uses: actions/checkout@v4
|
|
67
|
+
- uses: actions/setup-python@v5
|
|
68
|
+
with:
|
|
69
|
+
python-version: "3.12"
|
|
70
|
+
- run: pip install build twine
|
|
71
|
+
- run: python -m build
|
|
72
|
+
- run: twine check dist/*
|
|
73
|
+
- name: Install the built wheel into a clean environment
|
|
74
|
+
run: |
|
|
75
|
+
python -m venv /tmp/clean
|
|
76
|
+
/tmp/clean/bin/pip install dist/*.whl
|
|
77
|
+
/tmp/clean/bin/python -c "import mcdakit; print(mcdakit.__version__)"
|
|
78
|
+
- uses: actions/upload-artifact@v4
|
|
79
|
+
with:
|
|
80
|
+
name: dist
|
|
81
|
+
path: dist/
|
|
82
|
+
|
|
83
|
+
docs:
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
steps:
|
|
86
|
+
- uses: actions/checkout@v4
|
|
87
|
+
- uses: actions/setup-python@v5
|
|
88
|
+
with:
|
|
89
|
+
python-version: "3.12"
|
|
90
|
+
- run: pip install -e ".[docs]"
|
|
91
|
+
- name: Build the docs, warnings are errors
|
|
92
|
+
run: sphinx-build -b html -W docs docs/_build/html
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Docs
|
|
2
|
+
|
|
3
|
+
# Publishes the Sphinx site to GitHub Pages on every push to main.
|
|
4
|
+
# An alternative to Read the Docs, not a complement: pick one and delete the
|
|
5
|
+
# other, or the two will drift and readers will find whichever ranks higher.
|
|
6
|
+
#
|
|
7
|
+
# To enable: repository Settings -> Pages -> Source: GitHub Actions.
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
branches: [main, dev]
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
pages: write
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
concurrency:
|
|
20
|
+
group: pages
|
|
21
|
+
cancel-in-progress: false
|
|
22
|
+
|
|
23
|
+
jobs:
|
|
24
|
+
build:
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
- uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: "3.12"
|
|
31
|
+
- run: pip install -e ".[docs]"
|
|
32
|
+
- name: Build, warnings are errors
|
|
33
|
+
run: sphinx-build -b html -W docs docs/_build/html
|
|
34
|
+
- uses: actions/upload-pages-artifact@v3
|
|
35
|
+
with:
|
|
36
|
+
path: docs/_build/html
|
|
37
|
+
|
|
38
|
+
# GitHub Pages needs a public repository on the free plan, so this step is
|
|
39
|
+
# skipped while the repo is private rather than failing every push. It
|
|
40
|
+
# starts working by itself once the repo is made public and Pages is
|
|
41
|
+
# enabled (Settings -> Pages -> Source: GitHub Actions).
|
|
42
|
+
# Only main publishes. A dev push still builds above, so a broken -W build
|
|
43
|
+
# is caught before it reaches main, but it must not overwrite the live site.
|
|
44
|
+
deploy:
|
|
45
|
+
needs: build
|
|
46
|
+
if: >-
|
|
47
|
+
github.event.repository.visibility == 'public'
|
|
48
|
+
&& github.ref == 'refs/heads/main'
|
|
49
|
+
runs-on: ubuntu-latest
|
|
50
|
+
environment:
|
|
51
|
+
name: github-pages
|
|
52
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
53
|
+
steps:
|
|
54
|
+
- id: deployment
|
|
55
|
+
uses: actions/deploy-pages@v4
|
mcdakit-0.2.0/.gitignore
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
.venv/
|
|
7
|
+
venv/
|
|
8
|
+
.pytest_cache/
|
|
9
|
+
.ruff_cache/
|
|
10
|
+
.hypothesis/
|
|
11
|
+
.coverage
|
|
12
|
+
htmlcov/
|
|
13
|
+
docs/_build/
|
|
14
|
+
.mypy_cache/
|
|
15
|
+
|
|
16
|
+
# Manuscript drafts — kept out of the repo until submission.
|
|
17
|
+
paper/
|
|
18
|
+
paper-*/
|
|
19
|
+
|
|
20
|
+
# macOS
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# Secrets. Never commit a key.
|
|
24
|
+
.env
|
|
25
|
+
.env.*
|
|
26
|
+
!.env.example
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""Names vulture cannot see are used, with the reason for each.
|
|
2
|
+
|
|
3
|
+
Run `vulture src/ .vulture-allowlist.py --min-confidence 60` to find dead code.
|
|
4
|
+
Anything listed here is reachable — vulture just cannot see the caller. Add an
|
|
5
|
+
entry only with a reason; an allowlist that accumulates unexplained names stops
|
|
6
|
+
being a check.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from mcdakit.ai import AiProposal, WeightProposal
|
|
10
|
+
from mcdakit.explain import Explanation
|
|
11
|
+
from mcdakit.methods.registry import _reset_for_testing # used by tests/
|
|
12
|
+
from mcdakit.types import Criterion, Result
|
|
13
|
+
|
|
14
|
+
Criterion.is_cost # public API, exercised in tests/test_types.py
|
|
15
|
+
Result.score_of # public API, used throughout the README and docs
|
|
16
|
+
_reset_for_testing # test support, used in tests/test_registry.py
|
|
17
|
+
|
|
18
|
+
AiProposal.accepted # public API; asserted in tests/test_ai.py
|
|
19
|
+
WeightProposal.accepted # public API; the "nothing is applied" contract
|
|
20
|
+
WeightProposal.disagrees_with # public API; asserted in tests/test_ai.py
|
|
21
|
+
Explanation.dominant # public API; asserted in tests/test_explain.py
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
Nothing yet.
|
|
10
|
+
|
|
11
|
+
## [0.2.0] - 2026-09-18
|
|
12
|
+
|
|
13
|
+
The first published release. Version 0.1.0 below was tagged in the changelog
|
|
14
|
+
during the initial port but never released, so this is what a user can
|
|
15
|
+
actually install.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- `agreement()` returns `consensus: None` when two or more options tie for the
|
|
20
|
+
lead, and names the joint leaders in a new `tied` field. It previously
|
|
21
|
+
returned whichever tied option happened to be counted first, which reported
|
|
22
|
+
a split vote as though it were a decision — concealing the disagreement the
|
|
23
|
+
function exists to surface. Adding the seventeenth method turned the
|
|
24
|
+
documented example into a 7--7 tie and exposed this.
|
|
25
|
+
- One module per method under `mcdakit.methods`, replacing the grouped
|
|
26
|
+
`reference_point` module. Import paths change for direct function imports
|
|
27
|
+
(`from mcdakit.methods.aras import aras`); `rank(method="aras")` and every
|
|
28
|
+
other public entry point are unaffected.
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- **Provider adapters** (`mcdakit.ai_providers`): `openai()`, `anthropic()`,
|
|
33
|
+
`google()`, `ollama()` and `openai_compatible()` return ready-made `ask`
|
|
34
|
+
callables, reading `OPENAI_API_KEY`, `ANTHROPIC_API_KEY` and
|
|
35
|
+
`GOOGLE_API_KEY`/`GEMINI_API_KEY` from the environment. `openai_compatible`
|
|
36
|
+
covers any server exposing `/chat/completions` — vLLM, LM Studio,
|
|
37
|
+
llama.cpp, Groq, Together, OpenRouter — so a local model needs no key and
|
|
38
|
+
nothing leaves the machine.
|
|
39
|
+
|
|
40
|
+
**No provider SDK is required.** Each adapter speaks the vendor's HTTP API
|
|
41
|
+
through the standard library, so NumPy remains the only runtime dependency
|
|
42
|
+
and the one-dependency comparison in the paper still holds. A test parses
|
|
43
|
+
the module's imports and fails if any non-stdlib name appears.
|
|
44
|
+
|
|
45
|
+
Rate limits and transient 5xx are retried with exponential backoff
|
|
46
|
+
honouring the provider's `Retry-After`; a 400 is not retried, since it will
|
|
47
|
+
fail identically however often it is sent. A missing key names the
|
|
48
|
+
environment variable to set instead of surfacing a vendor 401, and an
|
|
49
|
+
unexpected reply shape names the provider and shows what arrived.
|
|
50
|
+
|
|
51
|
+
`mcdakit.ai` still takes any `Callable[[str], str]`, so an in-house gateway
|
|
52
|
+
or a test fixture works exactly as before. The adapters are a convenience,
|
|
53
|
+
not a requirement.
|
|
54
|
+
- `load_env()` reads `KEY=value` lines from a `.env` file into the
|
|
55
|
+
environment, so keys live in a gitignored file rather than in source. It
|
|
56
|
+
searches parent directories, understands `export`, quotes and comments, and
|
|
57
|
+
leaves an already-set variable alone unless `override=True` — a file in a
|
|
58
|
+
checkout should not silently beat what a deployment set. No dependency is
|
|
59
|
+
added; `python-dotenv` would cost more than the dozen lines it replaces.
|
|
60
|
+
A `.env.example` template ships with the repository, and `.env` is
|
|
61
|
+
gitignored.
|
|
62
|
+
|
|
63
|
+
- **WPM** (`wpm`), the weighted product model, also called MEW. Where a
|
|
64
|
+
weighted sum lets a strength pay for a weakness, the product does not: one
|
|
65
|
+
near-zero value drags the whole score down however good the rest are, which
|
|
66
|
+
is the reason to choose it when a criterion is disqualifying rather than
|
|
67
|
+
merely undesirable. It is `waspas(lambda_=0.0)` and is implemented as that
|
|
68
|
+
call so the two cannot drift apart, but is exposed under its own name
|
|
69
|
+
because nobody searching for WPM would think to look inside a WASPAS
|
|
70
|
+
parameter. Agrees with `pymcdm` to 1e-12 once both use the same
|
|
71
|
+
normalisation — `pymcdm` defaults to sum normalisation where mcdakit uses
|
|
72
|
+
linear, which rescales the values without changing their order — and with
|
|
73
|
+
the published formula written out independently. This completes the set of
|
|
74
|
+
methods common to the surveyed libraries; seventeen are now provided.
|
|
75
|
+
- **Full AHP** (`ahp_rank`), ranking alternatives from pairwise comparisons
|
|
76
|
+
alone — no decision matrix. Alternatives are compared against each other
|
|
77
|
+
under each criterion, so criteria nobody can measure numerically can still
|
|
78
|
+
drive the ranking. Reproduces Saaty's car example, and reports a consistency
|
|
79
|
+
ratio for every comparison matrix separately rather than averaging them,
|
|
80
|
+
since a hierarchy is only as sound as its least coherent judgement set.
|
|
81
|
+
`AhpResult.inconsistent` names the offenders. Cross-checked against
|
|
82
|
+
`pyrepo-mcda`'s `_classic_ahp`, which agrees on weights, global priorities
|
|
83
|
+
and consistency ratios to fourteen significant figures.
|
|
84
|
+
|
|
85
|
+
Note that the *public* `AHP` of `pyrepo-mcda` is a min-max weighted sum over
|
|
86
|
+
a numeric matrix (verified identical to `weighted_scoring` here, as its own
|
|
87
|
+
docstring concedes), and `pyDecision`'s `ahp_method` is the weighting step
|
|
88
|
+
alone (identical to `ahp_weights` here). Full AHP exists in `pyrepo-mcda`
|
|
89
|
+
only as a private method.
|
|
90
|
+
- **ARAS, COCOSO, CODAS, EDAS, MABAC and MARCOS**, completing the set of
|
|
91
|
+
methods common to every other Python MCDA library. Each reproduces values
|
|
92
|
+
that `pymcdm` and `pyrepo-mcda` independently agree on, and matches `pymcdm`
|
|
93
|
+
on 40 random problems spanning different shapes, weightings and direction
|
|
94
|
+
mixtures. The package now provides sixteen methods.
|
|
95
|
+
- **WASPAS** (`waspas`), blending the weighted sum and weighted product
|
|
96
|
+
models under a `lambda_` parameter. Agrees with `pymcdm` and `pyrepo-mcda`
|
|
97
|
+
to machine precision and with the published formula of Zavadskas et al.
|
|
98
|
+
(2012) written out independently.
|
|
99
|
+
- Methods may declare `requires_positive`, which the conformance suite honours
|
|
100
|
+
by not demanding a score for a column of zeros — and then checks that the
|
|
101
|
+
method genuinely refuses such input rather than returning NaN, so the
|
|
102
|
+
exemption has to be earned.
|
|
103
|
+
- **COPRAS** (`copras`), the first of the methods common to every other Python
|
|
104
|
+
MCDA library. Validated against the published formula of Zavadskas,
|
|
105
|
+
Kaklauskas and Sarka (1994) written out independently, and agreeing with
|
|
106
|
+
`pyrepo-mcda` and `pyDecision`. It resolves criterion direction itself and
|
|
107
|
+
so takes the matrix as measured; negative values are refused, since
|
|
108
|
+
sum-normalisation is defined for ratio-scale data.
|
|
109
|
+
|
|
110
|
+
- **Explaining a ranking** (`mcdakit.explain`). `explain()` decomposes an
|
|
111
|
+
option's score by criterion; `compare()` decomposes the margin between two
|
|
112
|
+
options and identifies a criterion as *decisive* when reversing it alone
|
|
113
|
+
would reverse the outcome. Transparency is treated in the recent
|
|
114
|
+
decision-analysis literature as a precondition for trusting a computed
|
|
115
|
+
result, and no other Python MCDA library provides it.
|
|
116
|
+
- The attribution is honest about its own validity. For an additive method the
|
|
117
|
+
contributions sum exactly to the score, and a test asserts it. For TOPSIS,
|
|
118
|
+
VIKOR, ELECTRE and PROMETHEE no exact decomposition exists, so each
|
|
119
|
+
criterion is attributed by muting it and re-scoring; `basis` reports which
|
|
120
|
+
was used, and the printed output carries the caveat.
|
|
121
|
+
|
|
122
|
+
- **Language-model assistance** (`mcdakit.ai`), opt-in and designed so that
|
|
123
|
+
the model proposes and the package verifies. `propose_criteria()` and
|
|
124
|
+
`propose_weights()` turn a described problem into validated
|
|
125
|
+
`Criterion` objects; anything malformed or out of range is rejected with a
|
|
126
|
+
reason rather than absorbed. Proposed weights are run through
|
|
127
|
+
`sensitivity()`, so the caller learns whether the resulting recommendation
|
|
128
|
+
would survive the model being somewhat wrong, and are compared against the
|
|
129
|
+
objective schemes in `mcdakit.weighting`, so a model that orders importance
|
|
130
|
+
unlike every data-driven method is flagged. Asking more than once measures
|
|
131
|
+
the model's self-consistency, which a single reply cannot reveal. Nothing is
|
|
132
|
+
applied automatically.
|
|
133
|
+
- `propose_comparisons()` elicits *pairwise* judgements rather than a weight
|
|
134
|
+
vector, because a weight vector cannot contradict itself and a set of
|
|
135
|
+
ratios can. The replies are assembled into a reciprocal matrix and put
|
|
136
|
+
through `ahp_weights()`, so a model that answers inconsistently is caught by
|
|
137
|
+
Saaty's consistency ratio rather than by inspection.
|
|
138
|
+
- `simulate_panel()` scores a problem once per expert persona and returns
|
|
139
|
+
`Participant` objects, so a simulated panel is scrutinised by the same
|
|
140
|
+
`group_rank()` and `disagreement()` machinery as a real one. A persona whose
|
|
141
|
+
reply is malformed is discarded with its reason, and `spread` reports
|
|
142
|
+
whether the personas differed at all — one that agrees exactly added nothing
|
|
143
|
+
over a single opinion.
|
|
144
|
+
- `narrate()` writes a result up for a decision report from computed figures
|
|
145
|
+
only, then checks every numeric literal in the reply against those figures
|
|
146
|
+
and lists any the model invented.
|
|
147
|
+
- `critique_weights()` applies the same scrutiny to weights from any source —
|
|
148
|
+
elicited from a person, taken from a previous study, or produced by a model
|
|
149
|
+
this package never saw.
|
|
150
|
+
- Nothing in `mcdakit.ai` is re-exported from the package namespace, so using
|
|
151
|
+
it requires an explicit `from mcdakit.ai import ...` that remains visible in
|
|
152
|
+
the importing module. An MCDA result is frequently used to justify a
|
|
153
|
+
decision to a third party, and whether a model shaped the inputs belongs in
|
|
154
|
+
that record. Importing `mcdakit` does not load the module.
|
|
155
|
+
- The provider is injected as a plain callable, so **no LLM dependency is
|
|
156
|
+
added**: NumPy remains the only runtime requirement, there is no optional
|
|
157
|
+
extra to install, and the module is deterministic under test.
|
|
158
|
+
|
|
159
|
+
- **Weights derived from the data** (`mcdakit.weighting`). `derive_weights()`
|
|
160
|
+
with `entropy`, `critic`, `std` and `equal`, plus a registry so a scheme
|
|
161
|
+
written elsewhere is reachable by name. AHP asks a person what matters;
|
|
162
|
+
these read it off the decision matrix, for when nobody has a view or the
|
|
163
|
+
analyst wants a starting point that is not an opinion. `entropy` is
|
|
164
|
+
scale-invariant, `std` is not, and `critic` additionally discounts criteria
|
|
165
|
+
that duplicate each other so a doubled dimension is not counted twice.
|
|
166
|
+
Documented as *computed*, not *correct*: a criterion can be uninformative in
|
|
167
|
+
the current shortlist and still be the one that matters.
|
|
168
|
+
|
|
169
|
+
- **Group decisions** (`mcdakit.group`). `group_rank()` combines several
|
|
170
|
+
stakeholders and reports how much they disagreed. Two aggregations are run
|
|
171
|
+
because they answer different questions: averaging the scores treats the
|
|
172
|
+
group as one better-informed judge, while Borda-combining each person's
|
|
173
|
+
ranking treats them as voters and stops one outlying score dragging the
|
|
174
|
+
mean. When the two pick different winners, `agree` is `False` — that
|
|
175
|
+
divergence is a finding about the group, not a defect to hide.
|
|
176
|
+
- `disagreement()` separates a mean of 5.5 everyone agreed on from one that
|
|
177
|
+
averages 9 and 2 — identical numbers, opposite findings — and names the most
|
|
178
|
+
contested option and criterion.
|
|
179
|
+
- `Participant` carries a weight, so a chair with a casting vote is expressed
|
|
180
|
+
as a weight rather than by entering them twice. Spread is measured
|
|
181
|
+
unweighted, because the question is how far the people differ, not how much
|
|
182
|
+
the chair outweighs them.
|
|
183
|
+
- Participants scoring different options or criteria are refused rather than
|
|
184
|
+
averaged over uneven evidence.
|
|
185
|
+
|
|
186
|
+
## [0.1.0] - 2026-08-27
|
|
187
|
+
|
|
188
|
+
The initial port from the Odoo module. Recorded here for continuity;
|
|
189
|
+
never tagged and never published to PyPI.
|
|
190
|
+
|
|
191
|
+
### The package
|
|
192
|
+
|
|
193
|
+
- **Extensible methods.** A ranking method is a `Method` object that
|
|
194
|
+
declares what it needs, registered by name. A method defined outside the
|
|
195
|
+
package is a first-class citizen: reachable from `rank()`, included in
|
|
196
|
+
`compare_methods()`, analysable by `sensitivity()`. See `docs/extending.md`.
|
|
197
|
+
- `Method`, `ScoringContext`, `MethodResult` and `Wants` — the extension
|
|
198
|
+
contract. `Wants.RAW` lets a method ask for the un-oriented matrix, which
|
|
199
|
+
is how SPOTIS avoids needing a special case.
|
|
200
|
+
- `register()`, `unregister()`, `available()`, `get_method()`, `has_method()`
|
|
201
|
+
and `method_names()` — the registry. `METHODS` is a live view of it, so a
|
|
202
|
+
method registered at any point is immediately visible, while still behaving
|
|
203
|
+
like the tuple it reads as (`in`, iteration, indexing, `len`, `==`).
|
|
204
|
+
- Entry-point discovery under the `mcdakit.methods` group: an installed
|
|
205
|
+
package's methods are found automatically, with no import by the user. A
|
|
206
|
+
plugin that fails to load warns (`PluginLoadError`) rather than taking the
|
|
207
|
+
registry down with it.
|
|
208
|
+
- **`mcdakit.testing` — a conformance suite for method authors.**
|
|
209
|
+
`check_method(MyMethod())`, or
|
|
210
|
+
`python -m mcdakit.testing my_package:MyMethod`, checks thirteen properties
|
|
211
|
+
every sound method holds. It catches the failures that are otherwise
|
|
212
|
+
silent: a smallest-is-best measure returned without negating (every ranking
|
|
213
|
+
upside down), a NaN on a zero-variance criterion, criterion direction
|
|
214
|
+
handled twice, a `reversal_free` claim that does not hold. Every built-in
|
|
215
|
+
passes it and CI enforces that.
|
|
216
|
+
- **Pluggable normalisation.** `rank(..., normalization="minmax")` swaps the
|
|
217
|
+
scheme a method uses; `vector`, `minmax`, `max` and `sum` ship, and
|
|
218
|
+
`@register_normalization` or a bare callable adds more. Each method declares
|
|
219
|
+
the scheme it is defined with, so defaults reproduce the textbook method.
|
|
220
|
+
This is a modelling axis, not a detail: on the same data the choice changes
|
|
221
|
+
the winner *and* whether the ranking survives removing a loser. Methods
|
|
222
|
+
whose guarantee depends on their own scaling — SPOTIS — declare
|
|
223
|
+
`normalization = None` and refuse the argument rather than silently
|
|
224
|
+
discarding it.
|
|
225
|
+
- `py.typed`, so downstream type checkers see the annotations.
|
|
226
|
+
- `CITATION.cff`, issue templates for bug reports and method proposals, and a
|
|
227
|
+
pull-request checklist.
|
|
228
|
+
- Sphinx documentation, a CI matrix over Python 3.9-3.13 on Linux, macOS and
|
|
229
|
+
Windows, `CONTRIBUTING.md`, and an architecture decision record.
|
|
230
|
+
|
|
231
|
+
### Refuses to guess
|
|
232
|
+
|
|
233
|
+
Nothing here degrades quietly. Each of these was a real defect during
|
|
234
|
+
development, caught and turned into an error rather than left to surprise
|
|
235
|
+
someone downstream.
|
|
236
|
+
|
|
237
|
+
- A method reading `ctx.directions` while declaring `Wants.ORIENTED` raises.
|
|
238
|
+
The matrix arrives with cost columns already mirrored, so handling direction
|
|
239
|
+
again flips them back and the cheapest option ranks last — a confident,
|
|
240
|
+
exactly reversed ranking with no error. Found by writing a method (COPRAS)
|
|
241
|
+
against the extension API and getting a plausible-looking wrong answer.
|
|
242
|
+
- A method returning `NaN` or infinity is refused, naming the options
|
|
243
|
+
affected. NaN sorts unpredictably, so a ranking containing one is not a
|
|
244
|
+
ranking.
|
|
245
|
+
- A keyword argument no method reads raises rather than being ignored, so
|
|
246
|
+
`rank(..., v=0.5)` on a method without a `v` cannot look like it worked.
|
|
247
|
+
- SPOTIS without bounds warns and reports `reversal_free = False` rather than
|
|
248
|
+
returning a number that looks guaranteed.
|
|
249
|
+
- A flat list where a matrix was meant — `[1, 2]` rather than `[[1, 2]]` —
|
|
250
|
+
explains the nesting instead of raising numpy's "object of type float has
|
|
251
|
+
no len()".
|
|
252
|
+
- A ragged matrix, unknown direction, all-zero weights or reversed bounds are
|
|
253
|
+
each refused at construction, where the mistake was made.
|
|
254
|
+
|
|
255
|
+
### Core, from the initial port
|
|
256
|
+
|
|
257
|
+
- `Criterion`, `Decision` and `Result` core types with validation at
|
|
258
|
+
construction — ragged matrices, unknown directions, and degenerate weights
|
|
259
|
+
are refused with an explanatory error rather than a numpy traceback.
|
|
260
|
+
- Eight ranking methods: `simple_scoring`, `weighted_scoring`, `saw`,
|
|
261
|
+
`topsis`, `vikor`, `electre`, `promethee`, `spotis`.
|
|
262
|
+
- `spotis` — rank-reversal-free ranking against fixed criterion bounds. Warns
|
|
263
|
+
(and records `Result.reversal_free is False`) when a criterion has no bounds
|
|
264
|
+
and observed min/max have to stand in.
|
|
265
|
+
- PROMETHEE with all six of Brans and Vincke's preference shapes.
|
|
266
|
+
- `sensitivity()` — per-criterion weight tolerance by bisection on the real
|
|
267
|
+
scoring function, with fragile / moderate / robust / immovable bands.
|
|
268
|
+
- `ahp_weights()` — Saaty pairwise comparison to weights, with the
|
|
269
|
+
consistency ratio reported rather than enforced.
|
|
270
|
+
- `compare_methods()` — every method's ranking side by side, so cross-method
|
|
271
|
+
disagreement is visible instead of hidden behind one number.
|
|
272
|
+
- Reversal benchmark under `benchmarks/`, measuring SPOTIS at 0.0% against
|
|
273
|
+
18-34% for the comparison-based methods, and pinned as a test so the
|
|
274
|
+
headline claim cannot regress unnoticed.
|
|
275
|
+
- SPOTIS and TOPSIS cross-validated against `pymcdm` 1.4.0 to 1e-12. TOPSIS
|
|
276
|
+
differs from pymcdm's *default* only because pymcdm normalises min-max where
|
|
277
|
+
this package uses Hwang and Yoon's vector normalisation; told to use vector
|
|
278
|
+
normalisation, the two agree exactly.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: "mcdakit: multi-criteria decision analysis with stable rankings"
|
|
3
|
+
message: "If you use this software in research, please cite it."
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Ait-Mlouk
|
|
7
|
+
given-names: Addi
|
|
8
|
+
email: aitmlouk@gmail.com
|
|
9
|
+
repository-code: "https://github.com/aitmlouk/mcdakit"
|
|
10
|
+
url: "https://aitmlouk.github.io/mcdakit"
|
|
11
|
+
license: Apache-2.0
|
|
12
|
+
version: 0.2.0
|
|
13
|
+
date-released: "2026-09-18"
|
|
14
|
+
keywords:
|
|
15
|
+
- multi-criteria decision analysis
|
|
16
|
+
- rank reversal
|
|
17
|
+
- sensitivity analysis
|
|
18
|
+
- SPOTIS
|
|
19
|
+
- TOPSIS
|
|
20
|
+
# The paper describing this software. Once it is published, replace the
|
|
21
|
+
# journal, year, volume, pages and DOI with the real values and delete the
|
|
22
|
+
# `notes` line; until then this records the work as submitted rather than
|
|
23
|
+
# implying a citation that does not yet exist.
|
|
24
|
+
preferred-citation:
|
|
25
|
+
type: article
|
|
26
|
+
title: "mcdakit: a Python package for multi-criteria decision analysis with stability guarantees"
|
|
27
|
+
authors:
|
|
28
|
+
- family-names: Ait-Mlouk
|
|
29
|
+
given-names: Addi
|
|
30
|
+
email: aitmlouk@gmail.com/addi.ait-mlouk@his.se
|
|
31
|
+
journal: "SoftwareX"
|
|
32
|
+
year: 2026
|
|
33
|
+
notes: "Submitted; not yet published. Volume, pages and DOI to be announced."
|