New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

electre-js

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electre-js

Multi-criteria decision analysis methods written in JS

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

electre-js

version tests coverage dependencies Greenkeeper badge Codacy Badge License: MIT

ELECTRE is a set of multi-criteria decision analysis methods.
If you've never heard of these methods, you can have a look at this document from José Rui FIGUEIRA.

You can use this package in your Node.js and / or web projects.
It uses Workers to calculate results in a separated thread.

Implemented methods

Algorithms come from J-Electre.

Methods for choosing

  • ELECTRE I
  • ELECTRE Is (Seuil)
  • ELECTRE Iv (Veto)

Methods for ranking

  • ELECTRE II
  • ELECTRE III
  • ELECTRE IV

Methods for ordinal classification or sorting

  • ELECTRE TRI
  • ELECTRE TRI ME (Multi-Evaluator)

Only checked methods are implemented at this time, I'll slowly implement the others but tell me if you want to focus on a particular one.

Web version

If you want to use this package in its web version and are using a bundler, you'll have to manually copy web workers.

Example with Spike SSG

By using copy-webpack-plugin in your app.js:

const CopyWebpackPlugin = require('copy-webpack-plugin')
const path = require('path')

module.exports = {
  // ...
  afterSpikePlugins: [
    new CopyWebpackPlugin([{
      from: path.resolve(__dirname, 'node_modules/electre-js/lib/workers'),
      to: path.resolve(__dirname, 'public/workers')
    }])
  ]
}

API

How to use

import electre from 'electre-js';

where electre is an object with two methods : start & kill as described bellow.
You can only run one calculation at a time.

electre.start(version, inputData)

Set calculator state to busy (electre._idle = false) and send a message to related worker that will handle calculation. Throws an error if calculator isn't idle.

inputData

An object with following properties :

propertiesmandatoryexpected in methodstyperules
numberOfCriteriastrueInumber> 0
numberOfAlternativestrueInumber> 1
criteriastrueIarray of stringssize = numberOfCriterias, all values are unique, no undefined
weightstrueIarray of numberssize = size of criterias, no undefined
alternativestrueIarray of stringssize = numberOfAlternatives, all values are unique, no undefined
evaluationstrueIarray of arrays of numbersmatrix n * p where n = size of alternatives & p = size of criterias, no undefined
cThresholdtrueInumber0 < value < 1
dThresholdtrueInumber0 < value < 1

returns

A promise of an object with following properties :

propertiestyperulesreturned in methods
inputDataobjectinputData passed to the workerI
concordancearray of arrays of numberssquare matrix n * n where n = alternatives sizeI
discordancearray of arrays of numberssquare matrix n * n where n = alternatives sizeI
credibilityarray of arrays of numberssquare matrix n * n where n = alternatives size. Values = 0 or 1I
kernelarray of stringspartition of alternativesI
dominatedarray of stringspartition of alternativesI

electre.kill()

Ask to terminate busy worker and set calculator state back to idle (electre._idle = true).
Promise returned when electre.start() is rejected.

Demo

On electre-www, you can discover electre-js and use ELECTRE methods

Credits

Algorithms come from J-Electre.

Keywords

decision making

FAQs

Package last updated on 01 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts