const linearAlgebra = ;const Matrix = linearAlgebraMatrix; `const topsis = require('topsis');
This is the first npm library in NodeJS to implement TOPSIS (Technique for Order of Preference by Similarity to Ideal Solution). This library is fully open-source and free to use. TOPSIS is an algorithm developed in 1981 by Hwang and Yoon. It is a technique commonly utilised in the field of operations research, managerial accounting, decision science and prescriptive analytics for multi-attribute decision-making problems (MADC). Its most common use case is to select the optimal choice from an array of alternatives with conflicting criteria. (For instance, to select a celphone to buy that have the highest quality camera at the lowest price). The central idea behind the algorithm is that the most desirable solution is the one that has the highest geometric distance (euclidean distance) to the anti-ideal solution and the lowest euclidean distance to the ideal solution.
npm i topsis
let m =2 5 560 26 420 20 4500 2 450 23 325 10 1;// m argument is the alternative matrix. Each row is an alternative and each column is a criterion.let w = 027033040; // This argument indicates the weights of each criteria.let ia = 'min' 'min' 'max'; // This argument indicates if a criterion is beneficial or not.topsis;
2 5 5
|m||m argument stands for 'alternative matrix' and is a matrix that contains the data from all alternatives. Columns are criteria and rows are alternatives.||True||Matrix of numeric data||This argument MUST be a matrix object from linear-algebra module and MUST contain only numeric data.|
|w||w argument stands for 'weights argument' or also known as eigenvector and this is the argument that indicates the weighting of each criterion.||True||Array of float numbers.||This argument MUST have the exact same length than the number of columns that the alternative matrix has. Each weight MUST be a number from 0 to 1 and all weights MUST sum 1.|
|ia||ia argument stands for 'impact argument' and this is the argument that indicates which criteria is beneficial and which is not. So which ones we want to minimise and which ones we want to maximise.||True||Array of strings.||This argument MUST have the exact same length than the number of columns that the alternative matrix has. All of the elements of the array MUST be strings containing the string 'max' or 'min' accordingly.|
NOTE: Make sure to read through bibliography below of TOPSIS to understand how the algorithm works.
- Computing normalised alternative matrix. (Alternative matrix divided by calculated norm of each column).
- Computing weighted normalised alternative matrix. (Alternative matrix multiplied by eigenvector).
- Calculating the ideal solution. (An hypothetical alternative that maximises benefits and minimises costs the most).
- Calculating the anti-ideal solution. (An hypothetical alternative that minimises benefits and maximises costs the most).
- For each alternative in the weighted normalised alternative matrix, calculate the euclidean distance to the ideal and anti-ideal solution.
- Calculate a performance score for each alternative. (Distance to the anti-ideal solution divided by the sum of the distance of the ideal and anti-ideal solution).
- Rank in descending order performance scores for each alternative.
- Return the top-one.
topsis; // Creates random arguments for a topsis.getBest function.
m :data:478 6 184 1000805 34 703 770216 210 294 225857 253 396 63244 652 886 736378 824 948 769298 76 573 604rows: 7cols: 4w: 052 026 004 018ia: 'max' 'min' 'max' 'max'
- Support for Linear-Algebra matrices.
- Support for MathJS matrices.
- Fuzzy TOPSIS
- Intuisionistic Fuzzy TOPSIS
- Neutrosophic TOPSIS
- AIRBNB AIRBNB JS CODE STYLE
- Eslint v-4.19.1 // AIRBNB Configuration
- Error check:
npm run check
- Error fix:
npm run lintor
npm run lint -- --fix
- Hwang, C. L., & Yoon, K. (1981). Methods for multiple attribute decision making. In Multiple attribute decision making (pp. 58-191).Springer, Berlin, Heidelberg. cd do cd do