skcriteria.ranksrev.rank_transitivity_check module
Transitivity Checker for MCDM Robustness Evaluation.
This module evaluates the logical consistency and stability of Multi-Criteria Decision Making (MCDM) methods through transitivity analysis. It decomposes decision problems into pairwise comparisons and reconstructs global rankings to assess method robustness.
The module validates whether rankings satisfy the transitivity property (if A ≻ B and B ≻ C, then A ≻ C) and provides mechanisms to handle violations.
Key Features
Transitivity validation through pairwise decomposition
Ranking recomposition with cycle-breaking strategies
Comprehensive diagnostic reporting
- class skcriteria.ranksrev.rank_transitivity_check.RankTransitivityChecker(dmaker, *, allow_missing_alternatives=False, ranking_strategy='generations', max_toposort_rankings=50, preferred_parallel_backend=None, n_jobs=None, parallel_backend=None)[source]
Bases:
SKCMethodABCRobustness evaluator for Multi-Criteria Decision Making (MCDM) methods.
This class validates the logical consistency and stability of MCDM method rankings by analyzing transitivity properties through pairwise alternative comparisons. It identifies ranking inconsistencies and provides alternative ranking reconstructions when transitivity violations occur.
The evaluation process is the following:
Pairwise Dominance Analysis: Evaluates all possible pairs of alternatives using the provided MCDM method to construct a directed dominance graph representing preference relationships.
Transitivity Validation (Test Criterion 2): Detects cycles in the dominance graph that violate the transitivity property. A transitive ranking requires that if A > B and B > C, then A > C must hold.
Ranking Stability Assessment (Test Criterion 3): Compares the original ranking with reconstructed rankings to evaluate consistency when the decision problem is decomposed and recomposed.
Ranking Reconstruction: When transitivity violations exist, applies cycle-breaking strategies to generate alternative valid rankings through graph decomposition techniques.
- Parameters:
dmaker (object) – Decision maker instance that must implement an
evaluate(dm)method. This represents the MCDM method or pipeline to be evaluated for robustness.allow_missing_alternatives (bool, default=False) – Whether to allow rankings that don’t include all original alternatives (using a pipeline that implements a filter, for example can remove alternatives). When False, raises ValueError if any alternative is missing from results. When True, missing alternatives are assigned the worst ranking + 1.
ranking_strategy (str, default="generations") –
Strategy for generating reconstructed rankings from the dominance graph:
”generations”: Generate a single ranking based on topological layers (alternatives in the same layer receive the same rank, producing ties)
”cycle_permutations”: Generate multiple rankings from topological sorts (number controlled by max_toposort_rankings parameter)
max_toposort_rankings (int or None, default=50) – Cap on the number of rankings generated from topological sorts, to bound computational cost. Must be at least 1, or None for no limit (all possible rankings). Only used when ranking_strategy=”cycle_permutations”; ignored otherwise.
preferred_parallel_backend (str or None, default=None) – Backend for parallel computation of pairwise evaluations. Options include ‘threading’, ‘multiprocessing’, or None for sequential. Improves performance for large numbers of alternatives.
n_jobs (int or None, default=None) – Number of parallel jobs for pairwise evaluation. When None, uses all available processors. Set to 1 for sequential processing.
parallel_backend (str or None, default=None (deprecated)) – Use
preferred_parallel_backendinstead.
- Raises:
TypeError – If
dmakerdoesn’t implement the requiredevaluate()method.ValueError – If
allow_missing_alternatives=Falseand alternatives are missing from results. Ifmax_toposort_rankingsis less than 1 (when not None). Ifranking_strategyis not “generations” or “cycle_permutations”.
Examples
Basic usage evaluating transitivity of a decision maker:
>>> from skcriteria.agg import simple >>> from skcriteria import mkdm >>> >>> # Create a decision matrix >>> dm = mkdm( ... matrix=[[1, 2], [3, 4], [5, 6]], ... objectives=[max, max], ... alternatives=["A", "B", "C"] ... ) >>> >>> # Create checker with generations strategy >>> dmaker = simple.WeightedSum() >>> checker = RankTransitivityChecker( ... dmaker, ranking_strategy="generations") >>> >>> # Evaluate transitivity >>> result = checker.evaluate(dm) >>> print(result.extra_["test_criterion_2"]) # Transitivity test >>> print(result.extra_["test_criterion_3"]) # Stability test >>> >>> # Or use toposorts strategy for multiple rankings >>> checker2 = RankTransitivityChecker( ... dmaker, ranking_strategy="cycle_permutations", ... max_toposort_rankings=10 ... ) >>> result2 = checker2.evaluate(dm)
- property dmaker
The MCDA method, or pipeline to evaluate.
- property allow_missing_alternatives
Whether rankings are allowed that don’t contain all original alternatives.
- property ranking_strategy
Strategy for generating reconstructed rankings (‘generations’ or ‘toposorts’).
- property max_toposort_rankings
Maximum number of toposort rankings to generate (must be >= 1, None means unlimited).
- property preferred_parallel_backend
The parallel backend used to generate all the alternatives.
- property parallel_backend
The parallel backend used to generate all the alternatives.
Deprecated since version 0.10.0: Use ‘preferred_parallel_backend’ instead
- property n_jobs
The number of parallel jobs used in the pairwise evaluations.
- evaluate(dm)[source]
Execute the complete transitivity test and ranking analysis.
This method performs a comprehensive transitivity analysis, including dominance graph construction, transitivity testing, and ranking recomposition. It provides multiple ranking perspectives when cycles are present and diagnostic information about the decision problem’s structure.
- Parameters:
dm (DecisionMatrix) – The decision matrix to be evaluated, containing alternatives and criteria values for multi-criteria decision analysis.
- Returns:
A comprehensive result object containing:
Multiple named rankings (original + recompositions)
- Diagnostic information in the extra attribute:
test_criterion_2: Transitivity consistency test result
test_criterion_3: Ranking stability test result
pairwise_dominance_graph: The constructed dominance graph
transitivity_break: List of transitivity violations
transitivity_break_rate: Normalized violation rate
dag: Condensed reduced DAG used to reconstruct rankings
mpr: Maximum possible number of distinct rankings derivable from the dag
pairwise_comparisons: All pairwise comparison results
- Return type: