npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electre-js

v1.0.4

Published

Multi-criteria decision analysis methods written in JS

Downloads

5

Readme

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

  • [x] 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 :

| properties | mandatory | expected in methods | type | rules | |-------------------------|-------------|-----------------------|-------------------------------|-----------------------------------------------------------------------------------| | numberOfCriterias | true | I | number | > 0 | | numberOfAlternatives | true | I | number | > 1 | | criterias | true | I | array of strings | size = numberOfCriterias, all values are unique, no undefined | | weights | true | I | array of numbers | size = size of criterias, no undefined | | alternatives | true | I | array of strings | size = numberOfAlternatives, all values are unique, no undefined | | evaluations | true | I | array of arrays of numbers | matrix n * p where n = size of alternatives & p = size of criterias, no undefined | | cThreshold | true | I | number | 0 < value < 1 | | dThreshold | true | I | number | 0 < value < 1 |

returns

A promise of an object with following properties :

| properties | type | rules | returned in methods | |--------------|------------------------------|-------------------------------------------------------------------|-----------------------| | inputData | object | inputData passed to the worker | I | | concordance | array of arrays of numbers | square matrix n * n where n = alternatives size | I | | discordance | array of arrays of numbers | square matrix n * n where n = alternatives size | I | | credibility | array of arrays of numbers | square matrix n * n where n = alternatives size. Values = 0 or 1 | I | | kernel | array of strings | partition of alternatives | I | | dominated | array of strings | partition of alternatives | I |

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.