Skip to main content

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:

python3 -m 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:

Release files for topsis-Prince-3619 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for topsis-Prince-3619 1.2.0
File Size Uploaded
topsis_prince_3619-1.2.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for topsis-Prince-3619 1.2.0
File Interpreter ABI Platform
topsis_Prince_3619-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / topsis_prince_3619-1.2.0.tar.gz

Download URL topsis_prince_3619-1.2.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cea981376ea78a79c31673faefa3074c03ffa36f1d37bb1f295ad970647e149d
BLAKE2b-256 checksum
How to use checksums
86824da4694ead6a3a45c937b6e4128af9e07f80a7649a77d163eaccc5ff3b91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Release files / topsis_Prince_3619-1.2.0-py3-none-any.whl

Download URL topsis_Prince_3619-1.2.0-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e403b3cf2187fb13bbe5bbd07ed44a12a5efb29f6c6b47f7cf1acd5d873d21c6
BLAKE2b-256 checksum
How to use checksums
b82b4ccb533b933306e43dbf2a04204e9b0b04aea71098fc023bc9977c17334c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page