A Python package for implementing the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method in Multi-Criteria Decision Making (MCDM)
Project description
TOPSIS Analysis Tool
This project implements the Technique for Order Preference by Similarity to Ideal Solution (TOPSIS), a method for multi-criteria decision-making. The tool processes a decision matrix, applies specified weights and impacts for each criterion, and ranks the alternatives based on their performance. This Python package, developed under the acronym topsis_Vaibhav_102203877, was created as a University Student Project.
Features
- Supports input of decision matrices in CSV or Excel formats (
.xlsx,.xls). - Allows customization of weights and impacts for each criterion.
- Generates ranked results as a CSV file.
Installation
- Clone the repository or download the script.
- Ensure Python (version 3.6 or later) is installed.
- Install the required dependencies using pip:
pip install numpy pandas openpyxl
Usage
The script uses command-line arguments to specify the input file, weights, impacts, and output file.
Command
topsis <input_file> <weights> <impacts> <output_file>
Parameters
<input_file>: Path to the decision matrix file. Accepts.csv,.xlsx, or.xlsformats.<weights>: Comma-separated weights for each criterion (e.g.,0.3,0.4,0.3).<impacts>: Comma-separated impacts for each criterion (+for beneficial,-for non-beneficial, e.g.,+,+,-).<output_file>: Path to save the output CSV file with rankings.
Example
Input File (data.csv):
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 |
|---|---|---|---|
| A1 | 250 | 16 | 12 |
| A2 | 200 | 20 | 10 |
| A3 | 300 | 18 | 15 |
Command:
topsis data.csv 0.3,0.4,0.3 +,+,- output.csv
Output File (output.csv):
| Alternatives | Criterion 1 | Criterion 2 | Criterion 3 | Rank |
|---|---|---|---|---|
| A1 | 250 | 16 | 12 | 2 |
| A2 | 200 | 20 | 10 | 3 |
| A3 | 300 | 18 | 15 | 1 |
Functions
topsis(data, weights, impacts)
Executes the TOPSIS algorithm and returns the rankings of the alternatives.
Parameters:
data: A 2D list or numpy array representing the decision matrix.weights: A list of weights for each criterion.impacts: A list of impacts (+or-) for each criterion.
Returns:
- A list of ranks for the alternatives.
excel_to_csv(excel_file, csv_output)
Converts an Excel file into a CSV file.
Parameters:
excel_file: Path to the Excel file.csv_output: Path to save the converted CSV file.
Returns:
- The path to the converted CSV file.
Notes
- The number of weights and impacts must match the number of criteria in the decision matrix.
- The decision matrix should not include alternative names in the criteria columns (e.g., the first column should list alternatives like A1, A2, etc.).
License
This project is licensed under the MIT License.
Let me know if you need further adjustments!
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 vaibhav_tandon_102203877-1.0.0.tar.gz.
File metadata
- Download URL: vaibhav_tandon_102203877-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6effc68bd2bdb064809df8d96d994aa3d53ff143c4d1853950a3f8b0c91dfd11
|
|
| MD5 |
39898b23b490a3d95affbb2ccf29f3ef
|
|
| BLAKE2b-256 |
c456a71c5d50e995f4ca5dc66ade65bb68e8746b449d2ebfba274609b68ce325
|
File details
Details for the file vaibhav_tandon_102203877-1.0.0-py3-none-any.whl.
File metadata
- Download URL: vaibhav_tandon_102203877-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a48b2ec08f24f71b8854c76ce661429f62ae65c4912cc81221d3fca67d7c0fa
|
|
| MD5 |
4d388617af6a9147d944f1eddcf408cf
|
|
| BLAKE2b-256 |
4db6a7777492c6b9f2efbe35de9e2cc30059c7fb8b9af863fe303031e9b56347
|