pyrepo_mcda.mcda_methods.temporal_promethee
Classes
Temporal extension of the PROMETHEE II method that incorporates |
Module Contents
- class pyrepo_mcda.mcda_methods.temporal_promethee.Temporal_PROMETHEE_II
Temporal extension of the PROMETHEE II method that incorporates variability of preferences over multiple time periods using DARIA.
- __call__(matrices: dict[str, numpy.ndarray], weights: numpy.ndarray, types: numpy.ndarray, variability_function: Callable[[numpy.ndarray], numpy.ndarray] | None = None, preference_functions: list[Callable] | None = None, ps: list[float | int] | None = None, qs: list[float | int] | None = None, alt_names: list[str] | None = None) tuple[numpy.ndarray, tuple[numpy.ndarray, numpy.ndarray, pandas.DataFrame]]
Calculate Temporal PROMETHEE II scores considering variability of alternative preferences over multiple time periods.
The method first calculates PROMETHEE II net flows for each decision matrix representing a separate time period. Next, variability and direction of changes in preferences are determined using selected DARIA measures. Finally, the PROMETHEE II scores from the most recent period are updated using variability information to obtain temporal preference scores.
Decision matrices must contain the same number of alternatives and criteria in all periods.
Parameters
- matricesdict[str, np.ndarray]
Dictionary containing decision matrices for subsequent time periods. Keys represent time periods (for example years) and values are decision matrices. All matrices must have the same shape, where rows represent alternatives and columns represent criteria.
- weightsnp.ndarray
Criteria weights.
- typesnp.ndarray
Criteria types. Use 1 for profit criteria and -1 for cost criteria.
- variability_functionCallable[[np.ndarray], np.ndarray], optional
Function used to calculate variability values for alternatives based on preference values obtained in consecutive periods. The function should accept a matrix with periods in rows and alternatives in columns and return a one-dimensional array of variability values.
If
None, standard deviation from the DARIA method is used.Examples include:
DARIA()._stdDARIA()._giniDARIA()._entropyDARIA()._stat_varDARIA()._coeff_var
- preference_functionslist[Callable], optional
Preference functions used by the PROMETHEE II method for each criterion. If None, default PROMETHEE preference function (usual) is applied.
- pslist[float | int], optional
Preference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE preference thresholds are applied.
- qslist[float | int], optional
Indifference thresholds used by selected PROMETHEE preference functions. If None, default PROMETHEE indifference thresholds are applied.
- alt_nameslist[str], optional
Names of alternatives. If provided, they are assigned as row labels in the returned DataFrame containing PROMETHEE II net flows.
Returns
- tuple[np.ndarray, tuple[np.ndarray, np.ndarray, pd.DataFrame]]
- updated_scoresnp.ndarray
Final temporal preference scores obtained after updating the most recent PROMETHEE II net flows using DARIA variability information.
- tuple[np.ndarray, np.ndarray, pd.DataFrame]
- variabilitynp.ndarray
Variability values for alternatives calculated with the selected variability function.
- directionnp.ndarray
Numerical direction of preference changes over time. Values equal to 1 indicate improvement, -1 indicate deterioration, and 0 indicate stability.
- all_net_flows_dfpd.DataFrame
DataFrame containing PROMETHEE II net flows for all analyzed periods. Rows correspond to alternatives and columns correspond to time periods.
Raises
- ValueError
If no decision matrices are provided.
- ValueError
If decision matrices do not have identical shapes.
- ValueError
If the number of alternative names does not match the number of alternatives.
- TypeError
If variability_function is not callable.
Examples
>>> import numpy as np >>> from pyrepo_mcda.mcda_methods import Temporal_PROMETHEE_II, DARIA >>> matrices = { ... "2022": np.array([ ... [10, 5], ... [12, 7], ... [8, 9] ... ]), ... "2023": np.array([ ... [11, 6], ... [13, 7], ... [9, 8] ... ]), ... "2024": np.array([ ... [12, 7], ... [14, 8], ... [10, 9] ... ]) ... } >>> weights = np.array([0.6, 0.4]) >>> types = np.array([1, -1]) >>> tp = Temporal_PROMETHEE_II() >>> daria = DARIA() >>> scores, (variability, direction, net_flows) = tp( ... matrices=matrices, ... weights=weights, ... types=types, ... variability_function=daria._gini ... ) >>> scores