A Python package to implement the TOPSIS method for decision making.
Project description
TOPSIS Package
This repository contains a Python implementation of the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method, a multi-criteria decision-making technique. The package supports command-line execution and enables users to calculate TOPSIS scores and rankings based on input data.
Features
- Calculates TOPSIS scores and rankings for multi-criteria decision-making.
- Handles both positive and negative impacts of criteria.
- Provides results in a CSV file with scores and rankings.
- Fully customizable through weights and impacts specified as command-line arguments.
Installation
To install the package from PyPI:
pip install topsis-Prince-3619
Usage
Command-Line Interface (CLI)
Run the TOPSIS program directly from the command line:
python3 -m Topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>
Arguments
-
<InputDataFile>: Path to the input CSV file.- The first column must contain object names (e.g., M1, M2, M3).
- The remaining columns must contain numeric values for criteria.
-
<Weights>: Comma-separated weights for the criteria (e.g.,"1,1,1,2"). -
<Impacts>: Comma-separated impacts for the criteria (+for positive impact,-for negative impact). -
<ResultFileName>: Name of the output CSV file where results will be saved.
Example
Input Data
Input file (102203619-data.csv):
| Model | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 |
|---|---|---|---|---|
| M1 | 250 | 16 | 12 | 5 |
| M2 | 200 | 18 | 8 | 3 |
| M3 | 300 | 14 | 16 | 10 |
| M4 | 275 | 17 | 10 | 8 |
Command
topsis 102203619-data.csv "1,1,1,2" "+,+,-,+" result.csv
Output File
Output file (result.csv):
| Model | Criterion 1 | Criterion 2 | Criterion 3 | Criterion 4 | Topsis Score | Rank |
|---|---|---|---|---|---|---|
| M1 | 250 | 16 | 12 | 5 | 0.5346 | 2 |
| M2 | 200 | 18 | 8 | 3 | 0.3084 | 4 |
| M3 | 300 | 14 | 16 | 10 | 0.6912 | 1 |
| M4 | 275 | 17 | 10 | 8 | 0.5340 | 3 |
How It Works
-
Normalization: The decision matrix is normalized using vector normalization:
[ R_{ij} = \frac{a_{ij}}{\sqrt{\sum_{k=1}^{m} a_{kj}^2}} ]
-
Weighted Normalized Matrix: Each criterion is weighted according to user-defined weights:
[ V_{ij} = R_{ij} \cdot w_j ]
-
Identify Ideal Solutions:
- Positive Ideal Solution (PIS): Maximum values for positive impacts and minimum values for negative impacts.
- Negative Ideal Solution (NIS): Minimum values for positive impacts and maximum values for negative impacts.
-
Calculate Separation Measures:
- Separation from PIS (( S_i^+ )) and NIS (( S_i^- )) are computed using Euclidean distance.
-
Calculate TOPSIS Scores:
- The score is calculated as: [ C_i = \frac{S_i^-}{S_i^+ + S_i^-} ]
-
Rank Alternatives:
- Alternatives are ranked based on their scores, with higher scores indicating better performance.
Development
Project Structure
topsis-package/
├── topsis/
│ ├── __init__.py
│ ├── __main__.py
├── README.md
├── LICENSE
├── setup.py
├── pyproject.toml
└── MANIFEST.in
Dependencies
numpypandas
Setup for Development
- Clone the repository:
git clone https://github.com/Prince-05/TOPSIS
- Navigate to the project directory:
cd Topsis-Prince-3619
- Install dependencies:
pip install -r requirements.txt
Testing
Run the tests to ensure the package works correctly:
pytest
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed explanation of your changes.
Contact
For any questions or issues, please contact:
- Name: Prince
- Email: pprince_be22@thapar.edu
- GitHub: Prince-05
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_prince_3619-1.2.0.tar.gz.
File metadata
- Download URL: topsis_prince_3619-1.2.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea981376ea78a79c31673faefa3074c03ffa36f1d37bb1f295ad970647e149d
|
|
| MD5 |
1ed8f5ccb8e700656bead39207798aa2
|
|
| BLAKE2b-256 |
86824da4694ead6a3a45c937b6e4128af9e07f80a7649a77d163eaccc5ff3b91
|
File details
Details for the file topsis_Prince_3619-1.2.0-py3-none-any.whl.
File metadata
- Download URL: topsis_Prince_3619-1.2.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e403b3cf2187fb13bbe5bbd07ed44a12a5efb29f6c6b47f7cf1acd5d873d21c6
|
|
| MD5 |
c0aced348f732ca9e87cf79d9d0dbf04
|
|
| BLAKE2b-256 |
b82b4ccb533b933306e43dbf2a04204e9b0b04aea71098fc023bc9977c17334c
|