GithubHelp home page GithubHelp logo

codewithpatelo / topsis Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 5.0 1.9 MB

NPM module with an implementation of TOPSIS algorithm for multi-criteria decision-making systems.

Home Page: https://www.npmjs.com/package/topsis

License: MIT License

JavaScript 100.00%
topsis topsis-methodology prescriptive-analytics prescriptive javascript nodejs npm npm-package

topsis's Introduction

const linearAlgebra = require('linear-algebra')();
const Matrix = linearAlgebra.Matrix; `
	
const topsis = require('topsis');

Topsis

Codacy Badge npm version build Coverage Status Known Vulnerabilities dependencies Status GitHub license Greenkeeper badge

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.

Installation

npm i topsis

Example Usage

let m = new Matrix([
                    [2, 5, 5], 
                    [60, 26, 4], 
                    [20, 20, 4],  
                    [500, 2, 4], 
                    [50, 23, 3], 
                    [25, 10, 1]
                    ]); 
// m argument is the alternative matrix. Each row is an alternative and each column is a criterion.
                    
let w = [0.27,0.33,0.40];  // This argument indicates the weights of each criteria.
let ia = ['min', 'min', 'max']; // This argument indicates if a criterion is beneficial or not.


topsis.getBest(m, w, ia);

Returns:

[2, 5, 5]

DEMO

https://runkit.com/patelotech/runkit-npm-topsis

Documentation

Argument Description Mandatory Type Rules
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.

Algorithm Steps

  1. Computing normalised alternative matrix. (Alternative matrix divided by calculated norm of each column).
  2. Computing weighted normalised alternative matrix. (Alternative matrix multiplied by eigenvector).
  3. Calculating the ideal solution. (An hypothetical alternative that maximises benefits and minimises costs the most).
  4. Calculating the anti-ideal solution. (An hypothetical alternative that minimises benefits and maximises costs the most).
  5. For each alternative in the weighted normalised alternative matrix, calculate the euclidean distance to the ideal and anti-ideal solution.
  6. 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).
  7. Rank in descending order performance scores for each alternative.
  8. Return the top-one.

Aditional functions...

CreateRandom

topsis.createRandom(); // Creates random arguments for a topsis.getBest function.

Returns:

{ 
  m : 
    { data:
     [ [ 478, 6, 184, 1000 ],
       [ 805, 34, 703, 770 ],
       [ 216, 210, 294, 225 ],
       [ 857, 253, 396, 63 ],
       [ 244, 652, 886, 736 ],
       [ 378, 824, 948, 769 ],
       [ 298, 76, 573, 604 ] ],
      rows: 7,
      cols: 4 
    },
  w: [ 0.52, 0.26, 0.04, 0.18 ],
  ia: [ 'max', 'min', 'max', 'max' ]
}

Package roadmap

  • TOPSIS.
  • Support for Linear-Algebra matrices.
  • Support for MathJS matrices.
  • (FTOPSIS) Fuzzy TOPSIS
  • (IFTOPSIS) Intuisionistic Fuzzy TOPSIS
  • (NTOPSIS) Neutrosophic TOPSIS

Package Dependencies

  • linear-algebra

License

MIT

Contributing

https://github.com/patelotech/topsis

Linting

Configuration

  • Eslint v-4.19.1 // AIRBNB Configuration

Linting scripts

  • Error check: npm run check
  • Error fix: npm run lint or npm run lint -- --fix

Bibliography

  • 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

topsis's People

Contributors

codacy-badger avatar codewithpatelo avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

topsis's Issues

Output the ranking instead of the top alternative?

Hi,
is it possible instead of the top product to get the ranking of all the alternatives included, since topsis is used for ranking reasons it could be useful to get the whole ranking instead of just the top I assume..

thanks

An in-range update of coveralls is breaking the build ๐Ÿšจ

The devDependency coveralls was updated from 3.0.2 to 3.0.3.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for Dependency security updates

As suggested by NPM and Snyk.

Commits

The new version differs by 1 commits.

  • aa2519c dependency security audit fixes from npm & snyk (#210)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint-plugin-react is breaking the build ๐Ÿšจ

The devDependency eslint-plugin-react was updated from 7.12.2 to 7.12.3.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-react is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v7.12.3

Fixed

Changed

Commits

The new version differs by 14 commits.

  • 2f5cec9 Update CHANGELOG and bump version
  • 096161a Merge pull request #2120 from jomasti/issue-2119
  • 9d3955a Prevent crash of jsx-indent rule
  • 230c7e0 Merge pull request #2117 from haideralsh/patch-1
  • b4b0e72 fix: add a missing in the JSON settings
  • d2aa260 Merge pull request #2115 from drx/class_body_prop_types
  • 41974e5 Fix propType detection inside class bodies
  • 40f2565 [Docs] update README to document React version detection
  • dd0757f Merge pull request #2113 from alexzherdev/2112-fix-self-closing-fragments
  • e997f6c [Fix] avoid crashing on self-closing fragments
  • b48b479 Merge pull request #2111 from drx/prop_types_class_properties
  • e15bafa [Fix] no-unused-prop-types: fix issue with propTypes misclassifying props
  • a86b339 Merge pull request #2109 from jomasti/issue-2105
  • 5f9863e Fix display-name false positive for React.memo

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint is breaking the build ๐Ÿšจ

The devDependency eslint was updated from 5.14.1 to 5.15.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Release Notes for v5.15.0
  • 4088c6c Build: Remove path.resolve in webpack build (#11462) (Kevin Partington)
  • ec59ec0 New: add rule "prefer-named-capture-group" (fixes #11381) (#11392) (Pig Fang)
  • a44f750 Upgrade: [email protected] (#11461) (Teddy Katz)
  • d3ce611 Sponsors: Sync README with website (ESLint Jenkins)
  • ee88475 Chore: add utils for rule tests (#11453) (่–›ๅฎš่ฐ”็š„็Œซ)
  • d4824e4 Sponsors: Sync README with website (ESLint Jenkins)
  • 6489518 Fix: no-extra-parens crash when code is "((let))" (#11444) (Teddy Katz)
  • 9d20de2 Sponsors: Sync README with website (ESLint Jenkins)
  • 3f14de4 Sponsors: Sync README with website (ESLint Jenkins)
  • 3d6c770 Sponsors: Sync README with website (ESLint Jenkins)
  • de5cbc5 Update: remove invalid defaults from core rules (fixes #11415) (#11427) (Teddy Katz)
  • eb0650b Build: fix linting errors on master (#11428) (Teddy Katz)
  • 5018378 Chore: enable require-unicode-regexp on ESLint codebase (#11422) (Teddy Katz)
  • f6ba633 Chore: lint all files in the repo at the same time (#11425) (Teddy Katz)
  • 8f3d717 Docs: Add non-attending TSC member info (#11411) (Nicholas C. Zakas)
  • ce0777d Docs: use more common spelling (#11417) (่–›ๅฎš่ฐ”็š„็Œซ)
  • b9aabe3 Chore: run fuzzer along with unit tests (#11404) (Teddy Katz)
  • db0c5e2 Build: switch from browserify to webpack (fixes #11366) (#11398) (Pig Fang)
Commits

The new version differs by 22 commits.

  • b00a5e9 5.15.0
  • c3aebb1 Build: changelog update for 5.15.0
  • 4088c6c Build: Remove path.resolve in webpack build (#11462)
  • ec59ec0 New: add rule "prefer-named-capture-group" (fixes #11381) (#11392)
  • a44f750 Upgrade: [email protected] (#11461)
  • 341140f Revert "Chore: remove devDependency common-tags (#11455)" (#11460)
  • d3ce611 Sponsors: Sync README with website
  • aaba636 Chore: remove devDependency common-tags (#11455)
  • ee88475 Chore: add utils for rule tests (#11453)
  • d4824e4 Sponsors: Sync README with website
  • 6489518 Fix: no-extra-parens crash when code is "((let))" (#11444)
  • 9d20de2 Sponsors: Sync README with website
  • 3f14de4 Sponsors: Sync README with website
  • 3d6c770 Sponsors: Sync README with website
  • de5cbc5 Update: remove invalid defaults from core rules (fixes #11415) (#11427)

There are 22 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

An in-range update of eslint-plugin-import is breaking the build ๐Ÿšจ

The devDependency eslint-plugin-import was updated from 2.16.0 to 2.17.0.

๐Ÿšจ View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-import is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • โŒ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 61 commits.

  • 0499050 bump to v2.17.0
  • f479635 [webpack] v0.11.1
  • 8a4226d Merge pull request #1320 from bradzacher/export-ts-namespaces
  • 988e12b fix(export): Support typescript namespaces
  • 70c3679 [docs] make rule names consistent
  • 6ab25ea [Tests] skip a TS test in eslint < 4
  • 405900e [Tests] fix tests from #1319
  • 2098797 [fix] export: false positives for typescript type + value export
  • 70a59fe [fix] Fix overwriting of dynamic import() CallExpression
  • e4850df [ExportMap] fix condition for checking if block comment
  • 918567d [fix] namespace: add check for null ExportMap
  • 2d21c4c Merge pull request #1297 from echenley/ech/fix-isBuiltIn-local-aliases
  • 0ff1c83 [dev deps] lock typescript to ~, since it doesnโ€™t follow semver
  • 40bf40a [*] [deps] update resolve
  • 28dd614 Merge pull request #1304 from bradennapier/feature/typescript-export-type

There are 61 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those donโ€™t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot ๐ŸŒด

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.