Skip to main content

A Python package for the TOPSIS method

Project description

TOPSIS Package

The TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) package is a Python library for multi-criteria decision-making. It helps users rank alternatives based on their proximity to the ideal solution and their distance from the worst-case solution.

Installation

You can install the package using pip:

pip install topsis

Usage

The package provides a simple interface for applying the TOPSIS method. Follow these steps:

Import the Package

from topsis import topsis

Prepare Input Data

You need the following inputs:

  1. A decision matrix (a 2D list or NumPy array) where each row represents an alternative and each column represents a criterion.
  2. A list of weights for each criterion.
  3. A list of impacts for each criterion (either '+' for positive impact or '-' for negative impact).

Example Input:

decision_matrix = [
    [250, 16, 12, 5],
    [200, 20, 15, 6],
    [300, 18, 10, 8],
    [275, 25, 16, 7]
]
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+']

Run the TOPSIS Method

Call the topsis function with the prepared inputs:

rankings = topsis(decision_matrix, weights, impacts)

The rankings variable will contain the final rankings of the alternatives.

Full Example

from topsis import topsis

decision_matrix = [
    [250, 16, 12, 5],
    [200, 20, 15, 6],
    [300, 18, 10, 8],
    [275, 25, 16, 7]
]
weights = [0.25, 0.25, 0.25, 0.25]
impacts = ['+', '+', '-', '+']

rankings = topsis(decision_matrix, weights, impacts)
print("Rankings:", rankings)

Output

The output will be a list containing the rankings of the alternatives, with 1 representing the best alternative.

Example Output:

Rankings: [2, 3, 1, 4]

Features

  • Simple interface for applying the TOPSIS method.
  • Supports any number of alternatives and criteria.
  • Customizable weights and impacts.

Testing

Run the unit tests to verify the functionality:

python -m unittest discover tests

License

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

Project details


Download files

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

Source Distribution

topsis_shubhaan_102203456-1.2.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

topsis_shubhaan_102203456-1.2.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file topsis_shubhaan_102203456-1.2.0.tar.gz.

File metadata

File hashes

Hashes for topsis_shubhaan_102203456-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c9df3ba670e53059a95876a3a1e2692e1339ffb21578b779922d091e778b5b6a
MD5 99cf6dc0414cdac292cf065eb1536674
BLAKE2b-256 fdc74a0f9e3b835e3a250da399ea70e5270357cab8fafe21dfdd6b8c5ed176ff

See more details on using hashes here.

File details

Details for the file topsis_shubhaan_102203456-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_shubhaan_102203456-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 869c1feda573487b3635e89c8df0d5b5169ebd2436addf3a58e36ef2458b499e
MD5 954d662692f020d2b35c5d19d706e537
BLAKE2b-256 86579c39cbd2695ce154a05459639ff2ecebe89ef047136b51e3096216fa10a0

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