TOPSIS (MCDM) implementation for ranking alternatives using multiple criteria.
Project description
TOPSIS Package
A Python package implementing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) for Multi-Criteria Decision Making (MCDM) analysis. Rank alternatives based on multiple numeric criteria with a simple command-line interface.
Author: Harshit Kansal (Roll No: 102303554)
What is TOPSIS?
TOPSIS is a multi-criteria decision analysis method that ranks alternatives based on their geometric distance from ideal solutions. The best alternative should have:
- The shortest distance from the positive ideal solution
- The longest distance from the negative ideal solution
Installation
Install the package from PyPI:
pip install topsis-harshit-kansal-102303554
Quick Start
CLI Usage
topsis-hk <input_csv> <weights> <impacts> <output_csv>
Example Command
topsis-hk sample.csv "0.25,0.25,0.25,0.25" "+,+,-,+" output.csv
Input Format
CSV File Structure
Your input CSV must have:
- First column: Alternative names/IDs
- Remaining columns: Numeric criteria values only
Example (sample.csv):
| Model | Storage | Camera | Price | Rating |
|---|---|---|---|---|
| M1 | 16 | 12 | 250 | 5 |
| M2 | 16 | 8 | 200 | 3 |
| M3 | 32 | 16 | 300 | 4 |
| M4 | 32 | 8 | 275 | 4 |
| M5 | 16 | 16 | 225 | 2 |
Weights Vector
Comma-separated numeric values indicating criterion importance:
"0.25,0.25,0.25,0.25"
Impacts Vector
Comma-separated + or - values indicating if a criterion is beneficial (+) or non-beneficial (-):
"+,+,-,+"
+: Higher is better (Storage, Camera, Rating)-: Lower is better (Price)
Output
The output CSV contains all original columns plus two new columns:
| Column Name | Description |
|---|---|
Topsis Score (102303554) |
TOPSIS score for each alternative |
Rank (Harshit) |
Rank of each alternative (1 = best) |
Sample Output
| Model | Storage | Camera | Price | Rating | Topsis Score (102303554) | Rank (Harshit) |
|---|---|---|---|---|---|---|
| M1 | 16 | 12 | 250 | 5 | 0.7234 | 2 |
| M2 | 16 | 8 | 200 | 3 | 0.4521 | 5 |
| M3 | 32 | 16 | 300 | 4 | 0.6892 | 3 |
| M4 | 32 | 8 | 275 | 4 | 0.5643 | 4 |
| M5 | 16 | 16 | 225 | 2 | 0.8123 | 1 |
Validation Rules
The package enforces the following validations:
- Input file must be a valid CSV
- First column contains alternative names (non-numeric)
- All other columns contain numeric values only
- Number of weights must match number of criteria columns
- Number of impacts must match number of criteria columns
- Impact values must be either
+or- - Weights must be numeric and positive (> 0)
Algorithm Steps
TOPSIS performs the following steps:
- Normalize the decision matrix
- Weight the normalized decision matrix
- Calculate ideal best and ideal worst solutions
- Compute Euclidean distances from each alternative to ideal solutions
- Calculate TOPSIS score for each alternative
- Rank alternatives in descending order of TOPSIS score
Requirements
- Python >= 3.8
- numpy
- pandas
Keywords
TOPSIS MCDM Multi-Criteria Decision Making Decision Analysis Optimization Ranking
Author
Harshit Kansal
Roll No: 102303554
License
This package is part of a college assignment project.
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_harshit_kansal_102303554-1.0.1.tar.gz.
File metadata
- Download URL: topsis_harshit_kansal_102303554-1.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eea9d66590864d868158c0069761229f23dc70f518bedb97651457949bbfed40
|
|
| MD5 |
2b959467a59fa681288132a1ffef78d8
|
|
| BLAKE2b-256 |
55686358b1a32d540ca96fa859b76e8b54da5cb568a4d89b80a89c3cc05975f0
|
File details
Details for the file topsis_harshit_kansal_102303554-1.0.1-py3-none-any.whl.
File metadata
- Download URL: topsis_harshit_kansal_102303554-1.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f75d46ace96b4fcc276d4a0cd6f2e0d505620fbec459a735f16df53aa0ffbb8
|
|
| MD5 |
360897b7cf3924c9338b71ce9420d6f4
|
|
| BLAKE2b-256 |
14ad22a1f6670511869b4337927f6506596bd3cb6a6a4a232681caefbfd544fe
|