The AHP-Gaussian Decision Support Library is a extensible solution designed for multi-criteria decision-making (MCDM) leveraging both traditional and advanced AHP methodologies
Project description
Claro! Aqui está uma versão mais técnica e detalhada da documentação para o README:
AHP-Gaussian Decision Support Library
Overview
The AHP-Gaussian Decision Support Library is a extensible solution designed for multi-criteria decision-making (MCDM) leveraging both traditional and advanced AHP methodologies. It provides an implementation of Saaty's Analytic Hierarchy Process (AHP) and an enhanced Gaussian-based AHP, developed to handle complex scenarios involving a large number of criteria. This library is structured to facilitate the application of decision-support systems in research, data analysis, and organizational decision-making processes.
Key Features
- AHP using Saaty’s Method: Enables decision analysis with pairwise criteria comparisons, generating consistency-validated weightings.
- Gaussian-AHP: Offers a pairwise comparison-free alternative, ideal for scalability, by assigning weights based on sensitivity analysis through the Gaussian distribution.
- Configurable Settings: Allows fine-tuning via YAML configuration, including parameters for consistency thresholds and optimization objectives.
- Comprehensive Visualization: Supports graphical output of decision matrices, judgment matrices, and preference rankings for clear insight into each step of the decision-making process.
Project Structure
.
├── ahp_gaussian.py # Gaussian-AHP class for advanced MCDM with Gaussian factors
├── ahp_saaty.py # Traditional AHP class implementing Saaty’s methodology
├── config_manager.py # YAML-based configuration manager
├── create_csv_files.py # Script to generate sample CSV files for testing
├── data/ # Folder to store decision and judgment matrices
├── decision_helper.py # Helper functions for matrix validation, normalization, and aggregation
├── main.py # Primary script to execute decision-making processes
├── requirements.txt # Library dependencies
├── results/ # Folder to save result outputs, including CSVs and visualizations
├── settings/ # Configuration directory with YAML settings
└── tests/ # Unit tests for functional validation
Each module is structured to allow modular application and customization for specific decision-making frameworks.
Installation
To use this library, clone the repository and install the required dependencies:
git clone <repository_url>
cd <repository_name>
pip install -r requirements.txt
Usage
Overview of Execution
The main.py script is designed as the primary entry point, which initializes configurations, loads matrices, and executes both AHP-Saaty and AHP-Gaussian analyses. It automatically saves output results in the results/ directory and provides optional visualizations.
Step-by-Step Execution
-
Data Preparation: Ensure that
decision_matrix.csvandjudgment_matrix.csvare available in thedata/directory. These files should represent the decision criteria and pairwise comparisons, respectively.- Decision Matrix: Rows represent alternatives, and columns represent criteria.
- Judgment Matrix: A square matrix representing pairwise comparison for criteria weight calculation.
-
Run Analysis: Execute the main script:
python main.py -
Results: Results are stored in the
results/directory. The directory includes global and local preference CSV files and graphical representations.
Example File Generation
The create_csv_files.py script provides an example decision matrix and judgment matrix. Execute it to generate sample data for testing purposes:
python create_csv_files.py
Module Descriptions
ahp_gaussian.py
The AHPGaussian class is a novel, scalable approach to multi-criteria decision-making. By analyzing the sensitivity of criteria weights using Gaussian distribution factors, this method circumvents the need for pairwise comparison, allowing it to handle large matrices efficiently.
-
Attributes:
local_preference: Matrix of alternatives' local preferences for each criterion.gaussian_factor: Represents the criteria's variance as a proportion of the mean, essential for weight calculation.weights: Weighting of each criterion based on Gaussian sensitivity analysis.
-
Core Methods:
global_preference(): Ranks alternatives by global preference scores.visualize_decision_matrix(),visualize_local_preference(),visualize_global_preference(): Visualize decision matrices and preferences.
ahp_saaty.py
The AHPSaaty class implements the traditional AHP method, where criteria weights are derived from a reciprocal pairwise comparison matrix. This method validates the consistency of the judgments using Saaty’s Consistency Ratio (CR).
-
Attributes:
weights: Criterion weights derived from normalized judgment matrices.cr: Consistency ratio to evaluate the matrix's adherence to transitivity.
-
Core Methods:
local_preference(decision_matrix): Computes alternative preferences for each criterion.global_preference(decision_matrix): Provides global ranking based on combined criterion weights.- Visualization methods for judgment, local, and global preferences.
config_manager.py
Manages external configuration through a YAML file (ahp_settings.yaml), enabling users to define decision-making parameters such as consistency indices and objectives.
YAML Configuration:
consistency_index:
"1": 0
"2": 0
"3": 0.58
"4": 0.9
"5": 1.12
"6": 1.24
"7": 1.32
"8": 1.41
"9": 1.45
"10": 1.49
"11": 1.51
"12": 1.48
"13": 1.56
"14": 1.57
"15": 1.59
decision_helper.py
DecisionHelper is a utility class providing essential operations such as:
- Matrix Validation: Ensures matrices align with required structure and criteria.
- Normalization and Aggregation: Prepares matrices for consistent and valid decision-making.
- Visualization Tools: Includes functions for heatmaps and bar charts, enhancing data interpretability.
Key Methods:
normalize_decision_matrix(): Adjusts each criterion based on optimization objectives (maximize or minimize).aggregate_matrix(): Aggregates preferences with weights to produce global rankings.plot_*functions for detailed visual representations.
Visualization
The library offers in-depth visual analysis for decision matrices and preferences, with heatmaps and bar charts generated using Matplotlib and Seaborn. These visualizations are essential for interpreting judgment consistency, criterion weighting, and preference rankings.
Example Workflow
- Initialize Configuration and Load Data: Load settings from YAML and input CSVs.
- Analyze with AHP-Saaty:
- Calculate local and global preferences.
- Validate consistency.
- Generate visualizations and export results.
- Analyze with AHP-Gaussian:
- Compute preferences using Gaussian factor sensitivity.
- Rank alternatives by preference scores.
- Save results and generate graphical insights.
Example Code Snippet
from ahp_saaty import AHPSaaty
import pandas as pd
# Load judgment matrix
judgment_matrix = pd.read_csv('data/judgment_matrix.csv', index_col=0)
# Perform Saaty's AHP analysis
ahp_saaty = AHPSaaty(judgment_matrix, objective='max')
local_preferences = ahp_saaty.local_preference(decision_matrix)
global_preferences = ahp_saaty.global_preference(decision_matrix)
# Visualize results
ahp_saaty.visualize_judgment_matrix()
ahp_saaty.visualize_global_preference(decision_matrix)
Results
The results are saved as follows:
- Local Preference (Saaty):
results/local_pref_saaty.csv - Global Preference (Saaty):
results/global_pref_saaty.csv - Global Preference (Gaussian):
results/global_pref_gaussian.csv
Each output file provides a ranked listing of alternatives based on the respective method's calculated scores.
Testing and Validation
Unit tests are provided for all core modules under tests/. The tests ensure functional accuracy of criteria weighting, consistency validation, preference calculation, and result aggregation. To execute tests:
pytest tests/
Requirements
- Python 3.10 or later
- Required Libraries:
pandasfor data manipulationmatplotlibandseabornfor data visualizationyamlfor configuration management
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ahp_gauss-0.1.3.tar.gz.
File metadata
- Download URL: ahp_gauss-0.1.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
761b7977a82d71ad853296eab968d3bd98b5a431de6385e41e4a57a529b02144
|
|
| MD5 |
4b9df980663402c30e741695f9e69785
|
|
| BLAKE2b-256 |
ade9f1e48543bfd48b0711882494e252409d6befb305c0d8639f685bf219f980
|
File details
Details for the file ahp_gauss-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ahp_gauss-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cb45842a3e116b72429d85fbd2af419e2a4c2ebe321757f18e761370caaea83
|
|
| MD5 |
06f2dd0494befdd5825e9e5499d223fe
|
|
| BLAKE2b-256 |
2734cf353e5f9d71a9879a3cd751046dcb2dbcc3136fd284abd85f4a754161e3
|