Skip to main content

Implementation of TOPSIS decision making

Project description

TOPSIS-Python

Inspired by TOPSIS-Python (python2).

Our python 3 code follows the same structure, defining a topsis class, but uses numpy linear algebra in order to modernise, optimise, and remove redundant code.

What is TOPSIS

Technique for Order Preference by Similarity to Ideal Solution (TOPSIS) originated in the 1980s as a multi-criteria decision making method. TOPSIS chooses the alternative of shortest Euclidean distance from the ideal solution, and farthest distance from the negative-ideal solution. More details at wikipedia. The TOPSIS algorithm is succinctly explained in this paper comparing TOPSIS and VIKOR methods

Using TOPSIS-Python

TOPSIS-Python can be run as in the following example:

>>> from topsis import topsis
>>> a = [[7, 9, 9, 8], [8, 7, 8, 7], [9, 6, 8, 9], [6, 7, 8, 6]]
>>> w = [0.1, 0.4, 0.3, 0.2]
>>> I = [1, 1, 1, 0]
>>> decision = topsis(a, w, I)

The decision matrix (a) should be constructed with each row representing an alternative, and each column representing a criterion. We have used an example given in TOPSIS Method in MADM (Dr. Farhad Faez)

Weights (w) is not already normalised will be normalised upon initialisation. Information on benefit (1) cost (0) criteria should be provided in I.

By default, the optimisation (TOPSIS calculation) does not take place. No values are stored in decision.C or decision.optimum_choice.

These can be calculated, either by calling decision.calc(), or by calling a representation of the decision (which will itself call decision.calc()):

>>> decision

Alternatives ranking C:
[0.74269409 0.40359933 0.17586999 0.44142927]

Best alternative
a[0]: [7. 9. 9. 8.]

The rankings are saved in decision.C, with the highest ranking $0.74269409$ offering us the best decision, and lowest ranking $0.17586999$ offering the worst decision making, according to TOPSIS method.

We are also then shown the best alternative index (which happens to be index 0 in this example), and the associated criteria coefficients of this alternative.

Installation

The module can be installed from pypi using pip, or downloaded and installed directly from git

pypi: https://pypi.org/project/topsis-jamesfallon git: https://gitlab.com/jamesfallon/topsis-python.git

pip

Installation with pip can be achieved in one line:

pip install topsis-jamesfallon

Anaconda

If you are using anaconda, make sure that you are using your environment's pip, and not the OS default. Your installation only if using anaconda may look like:

  1. Activate your environment
(base) $ conda activate custom_env
  1. Ensure pip is installed in your environment
(custom_env) $ conda install pip
  1. Make sure you are using your environment's pip installation. If not, you can always prepend the full path before the pip command.
(custom_env) $ which pip
.../path_to_your_anaconda_installation/anaconda3/envs/custom_env/bin/pip
  1. Now install topsis from pypi
(custom_env) $ pip install topsis-jamesfallon
Collecting topsis-jamesfallon
Installing collected packages: topsis-jamesfallon
Successfully installed topsis-jamesfallon-0.2

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-jamesfallon-0.2.3.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_jamesfallon-0.2.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file topsis-jamesfallon-0.2.3.tar.gz.

File metadata

  • Download URL: topsis-jamesfallon-0.2.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for topsis-jamesfallon-0.2.3.tar.gz
Algorithm Hash digest
SHA256 94a5c968d5c46c28d2d35e82025d4171bcc722c304e0058d9ef96b8499643841
MD5 0e7079f505333156408a89f42332505b
BLAKE2b-256 347b7711ab8c517a5def135f4f593f73562f32ce45ec8f9c2027094a2806299c

See more details on using hashes here.

File details

Details for the file topsis_jamesfallon-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: topsis_jamesfallon-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0.post20200210 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for topsis_jamesfallon-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 27e3148322be5c526a8026a934007ba2206cfc2c333615cc05e74e0a2cbbd69b
MD5 dd052caaa0e1ec8ded817167b6530544
BLAKE2b-256 055187cafef2b6a6c75acee0912dbd66404d85fb00376575e282dc9bfd5883b5

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