Command line implementation of TOPSIS
Project description
TOPSIS
A Python implementation of the TOPSIS multi-criteria decision-making (MCDM) method.
Features
- Implements the standard TOPSIS algorithm
- Accepts CSV input files
- Supports custom weights and impacts
- Outputs TOPSIS score and rank
- Command-line based and easy to integrate
What is TOPSIS?
TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) is a multi-criteria decision analysis method.
It identifies solutions from a finite set of alternatives based on their distance from an ideal best and an ideal worst solution.
Input File Format
The input file must be a CSV file with:
- First column: Names/IDs of alternatives (non-numeric)
- Remaining columns: Criteria values (numeric)
Sample Input (Table)
| Name | P1 | P2 | P3 | P4 | P5 |
|---|---|---|---|---|---|
| M1 | 0.71 | 0.50 | 3.0 | 40.4 | 11.15 |
| M2 | 0.60 | 0.36 | 4.7 | 41.2 | 11.72 |
| M3 | 0.65 | 0.42 | 3.2 | 53.5 | 14.44 |
| M4 | 0.84 | 0.71 | 3.9 | 56.8 | 15.56 |
| M5 | 0.60 | 0.36 | 6.3 | 50.4 | 14.42 |
| M6 | 0.65 | 0.42 | 5.0 | 64.3 | 17.59 |
| M7 | 0.94 | 0.88 | 4.1 | 57.4 | 15.83 |
| M8 | 0.71 | 0.50 | 4.1 | 37.3 | 10.65 |
Installation
Make sure you have Python 3 installed. Then install the required libraries:
pip install pandas numpy
Usage
Run the script from the command line:
python topsis.py <InputDataFile> <Weights> <Impacts> <OutputResultFileName>
Arguments
- InputDataFile: CSV file containing the dataset
- Weights: Comma-separated numeric weights (e.g.,
1,1,1,1,1) - Impacts: Comma-separated impacts (
+for benefit,-for cost) - OutputResultFileName: Name of the output CSV file
Example
python topsis.py data.csv 1,1,1,1,1 +,+,+,+,+ result.csv
Output
The output CSV file will contain:
- Topsis Score: Performance score of each alternative
- Rank: Ranking based on TOPSIS score (higher is better)
Sample Output (Table)
| Name | P1 | P2 | P3 | P4 | P5 | Topsis Score | Rank |
|---|---|---|---|---|---|---|---|
| M1 | 0.71 | 0.50 | 3.0 | 40.4 | 11.15 | 0.1961 | 8 |
| M2 | 0.60 | 0.36 | 4.7 | 41.2 | 11.72 | 0.2386 | 7 |
| M3 | 0.65 | 0.42 | 3.2 | 53.5 | 14.44 | 0.2661 | 5 |
| M4 | 0.84 | 0.71 | 3.9 | 56.8 | 15.56 | 0.5743 | 2 |
| M5 | 0.60 | 0.36 | 6.3 | 50.4 | 14.42 | 0.4278 | 4 |
| M6 | 0.65 | 0.42 | 5.0 | 64.3 | 17.59 | 0.4689 | 3 |
| M7 | 0.94 | 0.88 | 4.1 | 57.4 | 15.83 | 0.6954 | 1 |
| M8 | 0.71 | 0.50 | 4.1 | 37.3 | 10.65 | 0.2503 | 6 |
Error Handling
The program validates:
- File existence
- Numeric criteria columns
- Correct number of weights and impacts
- Valid impact symbols (
+or-)
Meaningful error messages are shown if validation fails.
Dependencies
- pandas
- numpy
- sys (standard library)
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_vansh_102303922-0.1.1.tar.gz.
File metadata
- Download URL: topsis_vansh_102303922-0.1.1.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
baefc3aa504fd7d44a0a768f7d9a4675ab4ef984293a6baf4dfd8f10a5d07c2d
|
|
| MD5 |
9ff3055606932b1bf4fd371c0b58b518
|
|
| BLAKE2b-256 |
c04fa83c54e8482af0e86a6c292615a7ad5af7d38ea6b078ec1c810a6b9a1173
|
File details
Details for the file topsis_vansh_102303922-0.1.1-py3-none-any.whl.
File metadata
- Download URL: topsis_vansh_102303922-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6c8678448b502a4329385eff6d712644cdde0958c9a6556e206fe3545590cd2
|
|
| MD5 |
9fc14238d0065e36a2d8c5c25dd947f4
|
|
| BLAKE2b-256 |
bd0bbcb9b4f16424245f72500327a5d101ca98aef0c800533f167893f1bdff7e
|