Catalog PyPI
Back to packageRELEASE DETAILS

0.2.0

PyPI

102203162-topsis

A Python library for the TOPSIS decision-making method.

Published17 Jan 2025
Direct dependencies1
Transitive dependenciesNot calculated

README

Version 0.2.0 documentation

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

Author

Raghav Manchanda

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 1

Native requirements
1 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
numpyruntime

Distribution files

2 collected
102203162_topsis-0.2.0-py3-none-any.whl

bdist_wheel · 2.08 KB · Python py3

Source file
102203162_topsis-0.2.0.tar.gz

sdist · 2.31 KB · Python source

Source file

Repository

PENDING
yourusername/102203162-topsis

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 15:08 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c95fe30838a6aa21c8d10f4bef16347f8949f716119a45a141f5f09f0dfefeef

Other collected versions

View all collected versions →