AHP in Python
Project description
AHP
层次分析法
How to use
Install
pip install ahp
use
from AHP import AHP
import numpy as np
# 准则重要性矩阵
criteria = np.array([[1, 2, 7, 5, 5],
[1 / 2, 1, 4, 3, 3],
[1 / 7, 1 / 4, 1, 1 / 2, 1 / 3],
[1 / 5, 1 / 3, 2, 1, 1],
[1 / 5, 1 / 3, 3, 1, 1]])
# 对每个准则,方案优劣排序
b1 = np.array([[1, 1 / 3, 1 / 8], [3, 1, 1 / 3], [8, 3, 1]])
b2 = np.array([[1, 2, 5], [1 / 2, 1, 2], [1 / 5, 1 / 2, 1]])
b3 = np.array([[1, 1, 3], [1, 1, 3], [1 / 3, 1 / 3, 1]])
b4 = np.array([[1, 3, 4], [1 / 3, 1, 1], [1 / 4, 1, 1]])
b5 = np.array([[1, 4, 1 / 2], [1 / 4, 1, 1 / 4], [2, 4, 1]])
b = [b1, b2, b3, b4, b5]
a = AHP(criteria, b).run()
打印:
==========准则层==========
最大特征值5.072084,CR=0.014533,检验通过
准则层权重 = [0.47583538 0.26360349 0.0538146 0.09806829 0.10867824]
==========方案层==========
方案0 方案1 方案2 最大特征值 CR 一致性检验
准则0 0.081935 0.236341 0.681725 3.001542 8.564584e-04 True
准则1 0.595379 0.276350 0.128271 3.005535 3.075062e-03 True
准则2 0.428571 0.428571 0.142857 3.000000 -4.934325e-16 True
准则3 0.633708 0.191921 0.174371 3.009203 5.112618e-03 True
准则4 0.344545 0.108525 0.546931 3.053622 2.978976e-02 True
==========目标层==========
[[0.318586 0.23898522 0.44242878]]
最优选择是方案2
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
AHP-0.0.1.tar.gz
(3.4 kB
view details)
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
AHP-0.0.1-py3-none-any.whl
(3.4 kB
view details)
File details
Details for the file AHP-0.0.1.tar.gz.
File metadata
- Download URL: AHP-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab75ab7b775c7319c5b1a65ff9cf33deed222b4094957680a273d22d4468f3c9
|
|
| MD5 |
1c42bdc11ab4090e0801ed74dec18324
|
|
| BLAKE2b-256 |
d3b99dc234a7051b1c66b87897f2f1df024705b4cf3320810cdaefa1e9e6ab15
|
File details
Details for the file AHP-0.0.1-py3-none-any.whl.
File metadata
- Download URL: AHP-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f16f699a8a9858c5f7f3dbfbb64895d54a8cf4e703e394f4236bdd66d3129fc7
|
|
| MD5 |
0662896be2f2d075b5af52aaa7285318
|
|
| BLAKE2b-256 |
e4cbe13751b706129406c61c5abda077568607f9c06e7976af02a004dd2109d7
|