Skip to main content

Technique for Order Preference by Similarity to Ideal Solution(TOPSIS) Package

Project description

TOPSIS Analysis Tool

This project implements the Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) for multi-criteria decision making. The tool takes a decision matrix, applies weights and impacts for each criterion, and ranks the alternatives based on their relative performance. This python package was built under acronym topsis_102203733 as University Student Project.

Features

  • Supports decision matrix input via CSV or Excel files (.xlsx, .xls).
  • Allows customizable weights and impacts for each criterion.
  • Outputs ranked results in a CSV file.

Installation

  1. Clone this repository or download the script file.
  2. Ensure you have Python installed (version 3.6 or later).
  3. Install the required dependencies using pip:
pip install numpy pandas openpyxl

Usage

The script accepts command-line arguments to specify the input file, weights, impacts, and output file.

Command

topsis <input_file> <weights> <impacts> <output_file>

Parameters

  • <input_file>: Path to the input decision matrix file. Accepts .csv, .xlsx, or .xls files.
  • <weights>: Comma-separated weights for each criterion (e.g., 0.3,0.4,0.3).
  • <impacts>: Comma-separated impacts for each criterion (+ for beneficial, - for non-beneficial, e.g., +,+,-).
  • <output_file>: Path to save the output CSV file containing ranks.

Example

Input File (data.csv):

Alternatives Criterion 1 Criterion 2 Criterion 3
A1 250 16 12
A2 200 20 10
A3 300 18 15

Command:

topsis <input_file> <weights> <impacts> <output_file>

Output File (output.csv):

Alternatives Criterion 1 Criterion 2 Criterion 3 Rank
A1 250 16 12 2
A2 200 20 10 3
A3 300 18 15 1

Functions

topsis(data, weights, impacts)

Performs TOPSIS analysis and returns the ranks of the alternatives.

Parameters:

  • data: 2D list or numpy array representing the decision matrix.
  • weights: List of weights for each criterion.
  • impacts: List of impacts (+ or -) for each criterion.

Returns:

  • List of ranks for the alternatives.

excel_to_csv(excel_file, csv_output)

Converts an Excel file to a CSV file.

Parameters:

  • excel_file: Path to the Excel file.
  • csv_output: Path to save the converted CSV file.

Returns:

  • The path to the converted CSV file.

Notes

  • Ensure that the weights and impacts match the number of criteria in the decision matrix.
  • The decision matrix should not include the alternative names in the criteria columns (e.g., the first column in the input file should contain names like A1, A2, etc.).

License

This project is licensed under the MIT License.

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_102203733-0.0.1.tar.gz (4.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_102203733-0.0.1-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file topsis_102203733-0.0.1.tar.gz.

File metadata

  • Download URL: topsis_102203733-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for topsis_102203733-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0c0fcd6ed7ba9e5863ce60e18e6dd33eacfb3d7adc8199c712ffd1ecf375af8c
MD5 7dcefb773099e7e5437157c0f4c33be0
BLAKE2b-256 3655c7100e6d200ae1d51cf0dedaaf12c4cbbc0975baab6f7dcb2253fab8c741

See more details on using hashes here.

File details

Details for the file topsis_102203733-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for topsis_102203733-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88506db5bab6e1f62e8b0a835d202ce457f396a74b0ed473268c5f98b73de4e8
MD5 31cb771284bdb6c9b7bc3a8dc6218faf
BLAKE2b-256 868774d2d0783d9cfee68c81ec00c3c48b11ee6946d93752c377ef74f0c9f657

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