Skip to main content

A Python package to implement the TOPSIS method for decision making.

Project description

TOPSIS Package

This repository contains a Python implementation of the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method, a multi-criteria decision-making technique. The package supports command-line execution and enables users to calculate TOPSIS scores and rankings based on input data.


Features

  • Calculates TOPSIS scores and rankings for multi-criteria decision-making.
  • Handles both positive and negative impacts of criteria.
  • Provides results in a CSV file with scores and rankings.
  • Fully customizable through weights and impacts specified as command-line arguments.

Installation

To install the package from PyPI:

pip install topsis-Prince-3619

Usage

Command-Line Interface (CLI)

Run the TOPSIS program directly from the command line:

topsis <InputDataFile> <Weights> <Impacts> <ResultFileName>

Arguments

  1. <InputDataFile>: Path to the input CSV file.

    • The first column must contain object names (e.g., M1, M2, M3).
    • The remaining columns must contain numeric values for criteria.
  2. <Weights>: Comma-separated weights for the criteria (e.g., "1,1,1,2").

  3. <Impacts>: Comma-separated impacts for the criteria (+ for positive impact, - for negative impact).

  4. <ResultFileName>: Name of the output CSV file where results will be saved.


Example

Input Data

Input file (102203619-data.csv):

Model Criterion 1 Criterion 2 Criterion 3 Criterion 4
M1 250 16 12 5
M2 200 18 8 3
M3 300 14 16 10
M4 275 17 10 8

Command

topsis 102203619-data.csv "1,1,1,2" "+,+,-,+" result.csv

Output File

Output file (result.csv):

Model Criterion 1 Criterion 2 Criterion 3 Criterion 4 Topsis Score Rank
M1 250 16 12 5 0.5346 2
M2 200 18 8 3 0.3084 4
M3 300 14 16 10 0.6912 1
M4 275 17 10 8 0.5340 3

How It Works

  1. Normalization: The decision matrix is normalized using vector normalization:

    [ R_{ij} = \frac{a_{ij}}{\sqrt{\sum_{k=1}^{m} a_{kj}^2}} ]

  2. Weighted Normalized Matrix: Each criterion is weighted according to user-defined weights:

    [ V_{ij} = R_{ij} \cdot w_j ]

  3. Identify Ideal Solutions:

    • Positive Ideal Solution (PIS): Maximum values for positive impacts and minimum values for negative impacts.
    • Negative Ideal Solution (NIS): Minimum values for positive impacts and maximum values for negative impacts.
  4. Calculate Separation Measures:

    • Separation from PIS (( S_i^+ )) and NIS (( S_i^- )) are computed using Euclidean distance.
  5. Calculate TOPSIS Scores:

    • The score is calculated as: [ C_i = \frac{S_i^-}{S_i^+ + S_i^-} ]
  6. Rank Alternatives:

    • Alternatives are ranked based on their scores, with higher scores indicating better performance.

Development

Project Structure

topsis-package/
├── topsis/
│   ├── __init__.py
│   ├── __main__.py
├── README.md
├── LICENSE
├── setup.py
├── pyproject.toml
└── MANIFEST.in

Dependencies

  • numpy
  • pandas

Setup for Development

  1. Clone the repository:
    git clone https://github.com/Prince-05/TOPSIS
    
  2. Navigate to the project directory:
    cd Topsis-Prince-3619
    
  3. Install dependencies:
    pip install -r requirements.txt
    

Testing

Run the tests to ensure the package works correctly:

pytest

License

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


Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with a detailed explanation of your changes.

Contact

For any questions or issues, please contact:

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_prince_3619-1.0.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

topsis_Prince_3619-1.0.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file topsis_prince_3619-1.0.0.tar.gz.

File metadata

  • Download URL: topsis_prince_3619-1.0.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.5

File hashes

Hashes for topsis_prince_3619-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c029b79eab0b6144443b954f0a31efc5c08bf9824d6bfefe3c67c15a99d4cd41
MD5 169688c7618247558029f75fe5bf2583
BLAKE2b-256 7a19d1be7fe8199ccd121c2a6a969bc13428fd2a60040fbb4995491d33e9ee0b

See more details on using hashes here.

File details

Details for the file topsis_Prince_3619-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_Prince_3619-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6f5b8657d11f5bb7e7f0443c5dd698682c8e4326055a4af0ae7a510bddb7a6e
MD5 6db9ef2dd30ae7ba639549f34e72db34
BLAKE2b-256 b16fc0df4c93cebb68d16232739af7f4647e91b76fc4b18241583c47d6bf6936

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