Skip to main content

TOPSIS command-line tool for multi-criteria decision making

Project description

topsis-harshleen-102303220

A Python command-line package implementing the TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution) method for multi-criteria decision making (MCDM).

This package allows users to rank multiple alternatives based on several criteria by specifying weights and impacts through the command line.


Introduction

Decision making often involves evaluating multiple alternatives against several criteria.
TOPSIS is a widely used technique that helps identify the best alternative by comparing how close each option is to an ideal solution.

This package provides a simple and efficient command-line implementation of the TOPSIS algorithm using Python.


Features

  • Command-line based TOPSIS implementation
  • Supports any number of alternatives and criteria
  • User-defined weights and impacts
  • Automatic ranking of alternatives
  • Input validation and meaningful error messages
  • Outputs results in CSV format
  • Suitable for small and large datasets

Installation

Install the package directly from PyPI:

pip install topsis-harshleen-102303220

Usage

Run the package using Python module execution:

python -m topsis_harshleen_102303220.topsis <InputDataFile> <Weights> <Impacts> <OutputFile>

Arguments

Argument Description
InputDataFile CSV file containing the decision matrix
Weights Comma-separated numeric weights for each criterion
Impacts Comma-separated + (benefit) or - (cost) for each criterion
OutputFile Name of output CSV file with results

Input File Format

  • The first column must contain alternative names
  • Remaining columns must contain numeric values only
  • Minimum 3 columns are required (1 name + at least 2 criteria)

Example Input (data.csv)

Mobile,Price,Storage,Camera,Looks
Mobile 1,250,16,12,5
Mobile 2,200,16,8,3
Mobile 3,300,32,16,4
Mobile 4,275,32,8,4
Mobile 5,225,16,16,2

Weights and Impacts

Weights

Weights represent the relative importance of each criterion:

1,1,1,1

Impacts

  • +Benefit criterion (higher is better)
  • -Cost criterion (lower is better)
-,+,+,+

Algorithm Steps

  1. Read and validate input data
  2. Normalize the decision matrix using vector normalization
  3. Apply weights to the normalized matrix
  4. Determine ideal best and ideal worst solutions
  5. Calculate Euclidean distance from ideal solutions
  6. Compute TOPSIS performance score
  7. Rank alternatives based on scores

Output Format

The output CSV file contains:

  • Original input data
  • Topsis Score - Performance score (0 to 1, higher is better)
  • Rank - Ranking of alternatives (1 = best)

Example Run

python -m topsis_harshleen_102303220.topsis data.csv "1,1,1,1" "-,+,+,+" output.csv

Validation and Error Handling

The package performs the following checks:

  • Correct number of command-line arguments
  • Input file exists
  • Input file has at least 3 columns
  • All criteria columns contain numeric values only
  • Number of weights matches number of criteria
  • Number of impacts matches number of criteria
  • Each impact is either + or -

Meaningful error messages are displayed if validation fails.


Example Output

Mobile,Price,Storage,Camera,Looks,Topsis Score,Rank
Mobile 1,250,16,12,5,0.5234,3
Mobile 2,200,16,8,3,0.3812,5
Mobile 3,300,32,16,4,0.6891,1
Mobile 4,275,32,8,4,0.5612,2
Mobile 5,225,16,16,2,0.4156,4

Author

Harshleen Singh
Roll Number: 102303220


License

This package is open source and available under the MIT License.


References

Correct number of command-line arguments

Input file existence

Minimum number of columns

Numeric values in criteria columns

Matching count of weights, impacts, and criteria

Valid impact symbols (+ or -)

Clear error messages are displayed for invalid inputs.

Author Harshleen Kaur B.Tech Computer Engineering Thapar Institute of Engineering and Technology

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_harshleen_102303220-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

topsis_harshleen_102303220-0.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file topsis_harshleen_102303220-0.1.2.tar.gz.

File metadata

File hashes

Hashes for topsis_harshleen_102303220-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4cbd141379a3e484da35d336ba60e10f83f4aea34bfcebc77734097d5c84b6b1
MD5 8d899a282777b7242f6041d3294a14b2
BLAKE2b-256 478d72222b80be3ae7ad5472699187676f14c8a5b322a67569ba16d268add200

See more details on using hashes here.

File details

Details for the file topsis_harshleen_102303220-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_harshleen_102303220-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e1b4b73a44c4d9a7e6443273d068a9a638d2a539f947995115cc1c964281c3a
MD5 eb3f1b2421e3f1d17d67ebc32b1b86c2
BLAKE2b-256 7ff6881af4709f56a7fa0d0c84465f28bfdac6106d91ec0a408f0eacb9f7b088

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