Skip to content

mcda

TOPSIS ranking with incomplete rows left unranked.

quakecascade.mcda

Multi-criteria ranking: TOPSIS with incomplete rows left unranked.

TOPSIS (Hwang & Yoon 1981) ranks alternatives by their relative closeness to an ideal and away from an anti-ideal solution:

  1. vector normalisation \(r_{ij} = x_{ij} / \sqrt{\sum_k x_{kj}^2}\);
  2. weighting \(v_{ij} = w_j r_{ij}\) with \(\sum_j w_j = 1\);
  3. ideal \(A^+_j = \max_i v_{ij}\) for a benefit criterion (\(\min\) for a cost criterion) and anti-ideal \(A^-_j\) the opposite;
  4. separations \(S^\pm_i = \lVert v_i - A^\pm \rVert_2\);
  5. closeness \(C_i = S^-_i / (S^+_i + S^-_i) \in [0, 1]\), ranked descending.

An alternative with any missing criterion (NaN or ±inf) is not ranked: it gets a NaN score and a status naming what is missing, and it does not enter the normalisation of the others. Missing is never filled with a neutral value.

topsis

topsis(matrix, weights=None, benefit=None, criteria=None)

Rank alternatives with TOPSIS (Hwang & Yoon 1981).

Parameters:

Name Type Description Default
matrix DataFrame or (n, m) array

Criteria values; columns are criteria (named by the DataFrame, by criteria or c0..c{m-1}). NaN or ±inf = missing.

required
weights (None, sequence, mapping or Series)

Criterion weights (normalised to sum 1). None gives equal weights. A mapping or pandas Series is keyed by criterion name.

None
benefit sequence of bool, mapping or Series

True where a higher value is better (benefit criterion), False where lower is better (cost criterion). Required: the direction is a property of each indicator, never assumed. Only booleans (or 0/1) are accepted, so a label such as "cost" cannot pass as True.

None
criteria sequence of str

Names for array input.

None

Returns:

Type Description
DataFrame

Same index as matrix: score (closeness, NaN when unranked), rank (1 = closest to the ideal; ties share the lower rank; NA when unranked), d_plus, d_minus and topsis_status: computed, no_<criterion> when exactly one criterion is missing, no_criteria when several are. attrs holds n_ranked, n_unranked and weights.

Notes

When every ranked alternative is identical on every criterion, \(S^+ = S^- = 0\) and all scores are set to 0.5 (a full tie).