A Python package for the TOPSIS method
Project description
TOPSIS Package
The TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) package is a Python library for multi-criteria decision-making. It helps users rank alternatives based on their proximity to the ideal solution and their distance from the worst-case solution.
Installation
You can install the package using pip:
pip install topsis
Usage
The package provides a simple interface for applying the TOPSIS method. Follow these steps:
Import the Package
from topsis import topsis
Prepare Input Data
You need the following inputs:
- A decision matrix (a 2D list or NumPy array) where each row represents an alternative and each column represents a criterion.
- A list of weights for each criterion.
- A list of impacts for each criterion (either
'+'for positive impact or'-'for negative impact).
Example Input:
decision_matrix = [
[250, 16, 12, 5],
[200, 20, 15, 6],
[300, 18, 10, 8],
[275, 25, 16, 7]
]
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+']
Run the TOPSIS Method
Call the topsis function with the prepared inputs:
rankings = topsis(decision_matrix, weights, impacts)
The rankings variable will contain the final rankings of the alternatives.
Full Example
from topsis import topsis
decision_matrix = [
[250, 16, 12, 5],
[200, 20, 15, 6],
[300, 18, 10, 8],
[275, 25, 16, 7]
]
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+']
rankings = topsis(decision_matrix, weights, impacts)
print("Rankings:", rankings)
Output
The output will be a list containing the rankings of the alternatives, with 1 representing the best alternative.
Example Output:
Rankings: [2, 3, 1, 4]
Features
- Simple interface for applying the TOPSIS method.
- Supports any number of alternatives and criteria.
- Customizable weights and impacts.
Testing
Run the unit tests to verify the functionality:
python -m unittest discover tests
License
This package is licensed under the MIT License. See the LICENSE file for details.
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 topsis_shubhaan_102203456-1.2.0.tar.gz.
File metadata
- Download URL: topsis_shubhaan_102203456-1.2.0.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9df3ba670e53059a95876a3a1e2692e1339ffb21578b779922d091e778b5b6a
|
|
| MD5 |
99cf6dc0414cdac292cf065eb1536674
|
|
| BLAKE2b-256 |
fdc74a0f9e3b835e3a250da399ea70e5270357cab8fafe21dfdd6b8c5ed176ff
|
File details
Details for the file topsis_shubhaan_102203456-1.2.0-py3-none-any.whl.
File metadata
- Download URL: topsis_shubhaan_102203456-1.2.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
869c1feda573487b3635e89c8df0d5b5169ebd2436addf3a58e36ef2458b499e
|
|
| MD5 |
954d662692f020d2b35c5d19d706e537
|
|
| BLAKE2b-256 |
86579c39cbd2695ce154a05459639ff2ecebe89ef047136b51e3096216fa10a0
|