Skip to main content

A Python package for implementing TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution).

Project description

TOPSIS 102203409

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-102203409

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

Arin Goyal
Email: aringoyal15@gmail.com

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

topsis_102203409-1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

topsis_102203409-1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file topsis_102203409-1.0.tar.gz.

File metadata

  • Download URL: topsis_102203409-1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for topsis_102203409-1.0.tar.gz
Algorithm Hash digest
SHA256 a6f750a13eab89a4762c7624f0a5af5b3529a68e341bab4689844798e4f8ec87
MD5 35e67e5489584a810d214eb1fc3e4f76
BLAKE2b-256 9e70f557d879c466585042de9c8a5c55cf26ef3e4b0de96d43936a8494501f0f

See more details on using hashes here.

File details

Details for the file topsis_102203409-1.0-py3-none-any.whl.

File metadata

  • Download URL: topsis_102203409-1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.4

File hashes

Hashes for topsis_102203409-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a617ac90b13110c0997df2653225087bf2de556910a2900a072400eef39757c
MD5 1506b884a6e62ea37b7b39ec2c4ff006
BLAKE2b-256 13a9d2e42552db1b352d05e109e0c13d18207dafadb679edceac17cc6cd72ed4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page