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.1.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.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topsis_prince_3619-1.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 80a56077e2c3b4a1bc2098e819d92d4ef6ed3735174ac4cc5cf572f3f88b7415
MD5 5f35b1012b8369874b767e95ff93efad
BLAKE2b-256 5dc80451746f31f98af53cddeee9ad529f2767b1dd09e01652aecd3faf1fa400

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for topsis_Prince_3619-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 229651f872848cf48de54c60851b4ab0f2690998702fa3145edd15d2950640df
MD5 3a10a85d498ff8a7da9d6305bdc52997
BLAKE2b-256 c1874c50e6f24af91072a94f2ef14e0116088c024e8dbc6f4df2200d2abef484

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