TOPSIS command-line tool for multi-criteria decision making
Project description
topsis-harshleen-102303220
A Python command-line package implementing the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method for multi-criteria decision making (MCDM).
This package allows users to rank multiple alternatives based on several criteria by specifying weights and impacts through the command line.
Introduction
Decision making often involves evaluating multiple alternatives against several criteria.
TOPSIS is a widely used technique that helps identify the best alternative by comparing how close each option is to an ideal solution.
This package provides a simple and efficient command-line implementation of the TOPSIS algorithm using Python.
Features
- Command-line based TOPSIS implementation
- Supports any number of alternatives and criteria
- User-defined weights and impacts
- Automatic ranking of alternatives
- Input validation and meaningful error messages
- Outputs results in CSV format
- Suitable for small and large datasets
Installation
Install the package directly from PyPI:
pip install topsis-harshleen-102303220
Usage
Run the package using Python module execution:
python -m topsis_harshleen_102303220.topsis <InputDataFile> <Weights> <Impacts> <OutputFile>
Arguments
| Argument | Description |
|---|---|
| InputDataFile | CSV file containing the decision matrix |
| Weights | Comma-separated numeric weights for each criterion |
| Impacts | Comma-separated + (benefit) or - (cost) for each criterion |
| OutputFile | Name of output CSV file with results |
Input File Format
- The first column must contain alternative names
- Remaining columns must contain numeric values only
- Minimum 3 columns are required (1 name + at least 2 criteria)
Example Input (data.csv)
Mobile,Price,Storage,Camera,Looks
Mobile 1,250,16,12,5
Mobile 2,200,16,8,3
Mobile 3,300,32,16,4
Mobile 4,275,32,8,4
Mobile 5,225,16,16,2
Weights and Impacts
Weights
Weights represent the relative importance of each criterion:
1,1,1,1
Impacts
+→ Benefit criterion (higher is better)-→ Cost criterion (lower is better)
-,+,+,+
Algorithm Steps
- Read and validate input data
- Normalize the decision matrix using vector normalization
- Apply weights to the normalized matrix
- Determine ideal best and ideal worst solutions
- Calculate Euclidean distance from ideal solutions
- Compute TOPSIS performance score
- Rank alternatives based on scores
Output Format
The output CSV file contains:
- Original input data
- Topsis Score - Performance score (0 to 1, higher is better)
- Rank - Ranking of alternatives (1 = best)
Example Run
python -m topsis_harshleen_102303220.topsis data.csv "1,1,1,1" "-,+,+,+" output.csv
Validation and Error Handling
The package performs the following checks:
- Correct number of command-line arguments
- Input file exists
- Input file has at least 3 columns
- All criteria columns contain numeric values only
- Number of weights matches number of criteria
- Number of impacts matches number of criteria
- Each impact is either
+or-
Meaningful error messages are displayed if validation fails.
Example Output
Mobile,Price,Storage,Camera,Looks,Topsis Score,Rank
Mobile 1,250,16,12,5,0.5234,3
Mobile 2,200,16,8,3,0.3812,5
Mobile 3,300,32,16,4,0.6891,1
Mobile 4,275,32,8,4,0.5612,2
Mobile 5,225,16,16,2,0.4156,4
Author
Harshleen Singh
Roll Number: 102303220
License
This package is open source and available under the MIT License.
References
- Hwang, C. L., & Yoon, K. (1981). Multiple Attribute Decision Making: Methods and Applications. Springer-Verlag.
- TOPSIS: https://en.wikipedia.org/wiki/TOPSIS
Correct number of command-line arguments
Input file existence
Minimum number of columns
Numeric values in criteria columns
Matching count of weights, impacts, and criteria
Valid impact symbols (+ or -)
Clear error messages are displayed for invalid inputs.
Author Harshleen Kaur B.Tech Computer Engineering Thapar Institute of Engineering and Technology
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_harshleen_102303220-0.1.2.tar.gz.
File metadata
- Download URL: topsis_harshleen_102303220-0.1.2.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cbd141379a3e484da35d336ba60e10f83f4aea34bfcebc77734097d5c84b6b1
|
|
| MD5 |
8d899a282777b7242f6041d3294a14b2
|
|
| BLAKE2b-256 |
478d72222b80be3ae7ad5472699187676f14c8a5b322a67569ba16d268add200
|
File details
Details for the file topsis_harshleen_102303220-0.1.2-py3-none-any.whl.
File metadata
- Download URL: topsis_harshleen_102303220-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e1b4b73a44c4d9a7e6443273d068a9a638d2a539f947995115cc1c964281c3a
|
|
| MD5 |
eb3f1b2421e3f1d17d67ebc32b1b86c2
|
|
| BLAKE2b-256 |
7ff6881af4709f56a7fa0d0c84465f28bfdac6106d91ec0a408f0eacb9f7b088
|