1.0.4 • Published 6 years ago

electre-js v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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.

1.0.4

6 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago