Skip to main content

TOPSIS 102203427

PyPI Version A Python package for implementing the Technique for Order of Preference by Similarity to Ideal Solution (TOPSIS). This is a multi-criteria decision analysis method that helps in ranking alternatives based on multiple criteria.


Installation

Install the package using pip:

pip install topsis-102203427

Usage

Command-Line Interface (CLI)

You can run the TOPSIS method directly from the command line.

Syntax

topsis <input_file> <weights> <impacts> <output_file>

Arguments

  1. <input_file>: Path to the input CSV file containing the data.

    • The first column should contain the names of the alternatives.
    • The remaining columns should contain numerical values for the criteria.
  2. <weights>: A comma-separated string of weights for each criterion (e.g., "1,1,1,1").

  3. <impacts>: A comma-separated string of impacts (+ for positive, - for negative) corresponding to each criterion (e.g., "+,+,-,+").

  4. <output_file>: Path to save the resulting output file, which will include the computed scores and ranks.


Example

Input File (input.csv)

Alternative Criterion1 Criterion2 Criterion3 Criterion4
Alt1 250 16 12 5
Alt2 200 32 8 3
Alt3 300 24 10 4
Alt4 275 20 11 4.5
Alt5 225 28 9 4

Command

topsis input.csv "1,1,1,1" "+,+,-,+" output.csv

Output File (output.csv)

Alternative Criterion1 Criterion2 Criterion3 Criterion4 Score Rank
Alt1 250 16 12 5 0.8729 1
Alt2 200 32 8 3 0.3243 4
Alt3 300 24 10 4 0.2985 5
Alt4 275 20 11 4.5 0.7315 3
Alt5 225 28 9 4 0.4532 2

Library Usage

You can also use the package programmatically in Python.

from topsis_package.main import topsis

topsis("input.csv", "1,1,1,1", "+,+,-,+", "output.csv")

Dependencies

  • Python >= 3.7
  • pandas
  • numpy

How TOPSIS Works

  1. Normalize the Decision Matrix
    Convert each criterion to a unit vector.

  2. Calculate the Weighted Normalized Decision Matrix
    Multiply each normalized value by its weight.

  3. Determine the Ideal Best and Worst Solutions

    • For positive impacts: Max value.
    • For negative impacts: Min value.
  4. Calculate Separation Measures

    • Distance from the ideal best.
    • Distance from the ideal worst.
  5. Compute Relative Closeness to the Ideal Solution
    Rank the alternatives based on their closeness.


License

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


Author

Aditya Raj Singh
Email: aditya003rs@gmail.com

Release files for topsis-102203427 1.0.2

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

Source distribution (sdist)

Source distribution for topsis-102203427 1.0.2
File Size Uploaded
topsis_102203427-1.0.2.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for topsis-102203427 1.0.2
File Interpreter ABI Platform
topsis_102203427-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.2 kB

Release files / topsis_102203427-1.0.2.tar.gz

Download URL topsis_102203427-1.0.2.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c4b450fe6855e10007043c521bdbc5b96b6bd53f88e1555aadfb83c2a0275c07
BLAKE2b-256 checksum
How to use checksums
b701111fa91055c6869f113af9a867207a348421d5522f430a3e5e5ed862c29b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.2

Release files / topsis_102203427-1.0.2-py3-none-any.whl

Download URL topsis_102203427-1.0.2-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
783befb446a9433e5a8de01330f9e4baa15a259a7aa53b171b3e52c2f94b0598
BLAKE2b-256 checksum
How to use checksums
7b8edf6906a48a97e42aa00d1b9642c592e773d4ae5ed8e58ed610878147677f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.0

2 release files

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