Skip to main content

TOPSIS Implementation

Overview

TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) is a multi-criteria decision-making method. This Python package implements the TOPSIS method, allowing you to rank alternatives based on multiple criteria.

This implementation is specifically designed to work with a CSV input file and provides results with TOPSIS scores and ranks.

Features

  • Handles multi-criteria decision-making problems
  • Accepts CSV input files
  • Outputs a CSV file with TOPSIS scores and ranks
  • Validates input data and handles common errors
  • Command-line interface for ease of use

Installation

You can install this package directly from PyPI using pip:

pip install 102217227-TOPSIS

Usage

Command-Line Interface

After installing the package, you can use it from the command line. The basic usage is:

topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>

Parameters

  • InputDataFile: The path to the input CSV file containing the data.
  • Weights: A string of comma-separated numerical weights (e.g., "1,1,1,2").
  • Impacts: A string of comma-separated + or - signs indicating whether each criterion is beneficial (+) or non-beneficial (-) (e.g., "+,+,-,+").
  • ResultFileName: The path to the output CSV file where results will be saved.

Example

Suppose you have an input file named 102218041-data.csv with the following content:

Alternative,Criterion1,Criterion2,Criterion3,Criterion4
M1,250,16,12,5
M2,200,6,8,3
M3,300,16,8,4
M4,275,10,10,4

You can run the following command:

topsis 102218041-data.csv "1,1,1,2" "+,+,-,+" 102218041-result.csv

This will generate a file 102218041-result.csv containing the input data along with two additional columns for the TOPSIS score and the rank:

Alternative,Criterion1,Criterion2,Criterion3,Criterion4,TOPSIS Score,Rank
M1,250,16,12,5,0.556,2
M2,200,6,8,3,0.222,4
M3,300,16,8,4,0.778,1
M4,275,10,10,4,0.444,3

Error Handling

The program includes several checks to handle common errors:

  1. File Not Found: If the input file is not found, an appropriate error message will be displayed.
  2. Invalid Number of Parameters: The program checks if the correct number of parameters is provided.
  3. Invalid Data: The input file must contain at least three columns, with the first column being the name of alternatives, and the rest must contain numeric values.
  4. Weights and Impacts Validation: The number of weights and impacts must match the number of criteria in the input file. Impacts must be either + or -.

Examples

Here are a few examples to demonstrate how the package can be used:

Example 1: Basic Usage

topsis data.csv "1,1,1,1" "+,+,+,+" result.csv

Example 2: Different Weights and Impacts

topsis data.csv "0.5,1,1.5,2" "+,-,+,-" result.csv

Example 3: Handling Errors

If the number of weights or impacts does not match the number of criteria:

topsis data.csv "1,1,1" "+,+" result.csv

This will result in an error message indicating the mismatch.

Testing

To ensure everything works correctly, you can run some tests. If you haven't already, you can clone the repository and run the tests locally.

# Clone the repository
git clone https://github.com/TANISHQgarg60/TOPSIS

# Navigate to the project directory
cd 102217227_tanishq

# Install the required dependencies
pip install -r requirements.txt

# Run the tests (assuming you've created test scripts)
python -m unittest discover tests

Development

If you'd like to contribute to this project, follow these steps:

  1. Fork the repository on GitHub.
  2. Clone your fork to your local machine.
  3. Create a new branch for your feature or bugfix.
  4. Make your changes and commit them with descriptive messages.
  5. Push your changes to your fork.
  6. Submit a pull request to the original repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

If you have any questions, suggestions, or issues, feel free to contact me at tanishqq60@gmail.com.

Acknowledgments

  • Thanks to Thapar for their support.
  • Inspired by the original TOPSIS method developed by C.L. Hwang and K. Yoon.

### **Instructions for Customization:**

1. **PyPI Badge:** If you want to include the PyPI version badge, replace `topsis-102217227` in the badge URL with your actual package name.
  
2. **Example Commands:** Ensure that the commands and examples match your actual package usage. Replace the placeholder values with real ones.

3. **Contact Information:** Replace `your.email@example.com` with your actual contact email.

4. **Repository URL:** Update any URLs to point to your actual GitHub repository.

5. **Acknowledgments:** Customize the Acknowledgments section with any relevant names or organizations you wish to credit.

By following these steps and customizing the provided template, you'll have a thorough and professional `README.md` file ready for your project!

Metadata

Release files for 102217227-TOPSIS 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for 102217227-TOPSIS 1.0.0
File Size Uploaded Provenance Actions
102217227_topsis-1.0.0.tar.gz 5.3 kB Without provenance Details for 102217227_topsis-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for 102217227-TOPSIS 1.0.0
File Interpreter ABI Platform Actions
102217227_TOPSIS-1.0.0-py3-none-any.whl Python 3 none any Details for 102217227_TOPSIS-1.0.0-py3-none-any.whl

Total release size: 11.1 kB

Release files / 102217227_topsis-1.0.0.tar.gz

Download URL 102217227_topsis-1.0.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f4f3c008b43db8b36d4c45fa1d663b845ef40e79f0e7496ce5ce204e41cc9a5e
BLAKE2b-256 checksum
How to use checksums
70a42699df06b6172e3b535fd5e9af6097e639349128759d3d7d11cba1ed578a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.1

Release files / 102217227_TOPSIS-1.0.0-py3-none-any.whl

Download URL 102217227_TOPSIS-1.0.0-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e78969af8cd1b5090269811f42a356662fc864c36096273df866a147c3f23bc7
BLAKE2b-256 checksum
How to use checksums
e9d4fc1eb4854ee7ab9f341ce6e9f3451a930f93225da370538d58c85dbfdf90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.1

Security for 102217227-TOPSIS 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page