Skip to main content

A Python library for the TOPSIS decision-making method.

Project description

TOPSIS Library

Overview

The TOPSIS (Technique for Order Preference by Similarity to Ideal Solution) library provides an implementation of the TOPSIS decision-making method. This technique is used to rank alternatives based on multiple criteria by comparing their distance from an ideal best and an ideal worst solution.

Features

  • Normalize decision matrices
  • Apply weights and impacts to criteria
  • Calculate rankings and performance scores

Installation

Install the library via pip:

pip install topsis-library

Usage

Here’s a quick guide to using the library:

from topsis.topsis import topsis

# Define the decision matrix
# Each row is an alternative, and each column is a criterion
data = [
    [250, 16, 12, 5],
    [200, 16, 8, 3],
    [300, 32, 16, 4],
    [275, 32, 8, 4],
    [225, 16, 16, 2]
]

# Define weights for each criterion
weights = [0.25, 0.25, 0.25, 0.25]

# Define impacts for each criterion ('+' for benefit, '-' for cost)
impacts = ['+', '+', '-', '+']

# Calculate rankings and scores
rankings, scores = topsis(data, weights, impacts)

print("Rankings:", rankings)
print("Scores:", scores)

Output Example

Rankings: [3, 1, 4, 2, 5]
Scores: [0.7722, 0.5634, 0.8523, 0.6472, 0.4321]

How It Works

  1. Normalization: The decision matrix is normalized to make criteria comparable.
  2. Weight Application: Each criterion is weighted to reflect its importance.
  3. Ideal Solutions: The algorithm calculates the ideal best and worst values for each criterion.
  4. Distance Calculation: Distances from the ideal best and worst solutions are computed.
  5. Performance Scores: Scores are calculated based on proximity to the ideal solutions.
  6. Ranking: Alternatives are ranked based on their scores.

Testing

Run unit tests to ensure functionality:

python -m unittest discover tests

License

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

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.

Author

Your Name (your.email@example.com)

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

102203162_topsis-0.1.0.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

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

102203162_topsis-0.1.0-py3-none-any.whl (2.3 kB view details)

Uploaded Python 3

File details

Details for the file 102203162_topsis-0.1.0.tar.gz.

File metadata

  • Download URL: 102203162_topsis-0.1.0.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for 102203162_topsis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8af84a3b0d7647fdf0e3b8bace2d54f6a94fd4a445f999296fe276f8f614cb0b
MD5 d79190bde090a7f5b3fde2364fea40d2
BLAKE2b-256 8f3d26970f71a8177fa4408f8a5f3ef6812244e436a73d53a6fddf0c18f88d49

See more details on using hashes here.

File details

Details for the file 102203162_topsis-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for 102203162_topsis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8802329ddb1d7f2838283bbe92d9d5aab55529dcd971605fb7ae1b0bf032502a
MD5 c4d41cc8ab67cfce1c7f7d05bbace871
BLAKE2b-256 2cb4cf821f19cdf9c7b58a52bf43fee11caff96bfd99c77d6462343c6c279f3f

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