ahp.js – nodejs module for Analytic Hierarchy Process (AHP)

AHP node.js module

Recently I wrote a node.js library for AHP.

If you do not know what is AHP, you may see a brief AHP intro post I wrote. Basically it is a methodology to help decision making scenario which we have to evaluate several choices against multiple criteria.

Example problem:

Github: https://github.com/airicyu/ahp
NPM: https://www.npmjs.com/package/ahp

Sample code:

const AHP = require('ahp');
var ahpContext = new AHP();

ahpContext.addItems(['VendorA', 'VendorB', 'VendorC']);

ahpContext.addCriteria(['price', 'functionality', 'UX']);

ahpContext.rankCriteriaItem('price', [
    ['VendorC', 'VendorB', 2],
    ['VendorC', 'VendorA', 2],
    ['VendorA', 'VendorB', 1]
]);
ahpContext.rankCriteriaItem('functionality', [
    ['VendorB', 'VendorC', 1],
    ['VendorA', 'VendorC', 3],
    ['VendorA', 'VendorB', 3]
]);
ahpContext.rankCriteriaItem('UX', [
    ['VendorB', 'VendorC', 10],
    ['VendorA', 'VendorC', 10],
    ['VendorA', 'VendorB', 1]
]);

ahpContext.rankCriteria(
    [
        ['price', 'functionality', 3],
        ['price', 'UX', 3],
        ['functionality', 'UX', 1]
    ]
);

let output = ahpContext.run();
console.log(output);

 

Console output:

{ error: null,
  rankingMatrix:
   [ [ 0.25, 0.6000000000000001, 0.4761904761904761 ],
     [ 0.25, 0.20000000000000004, 0.4761904761904761 ],
     [ 0.5, 0.20000000000000004, 0.047619047619047616 ] ],
  criteriaRankMetaMap:
   { price: { ci: 0, ri: 0.58, cr: 0 },
     functionality: { ci: 0, ri: 0.58, cr: 0 },
     UX: { ci: 0, ri: 0.58, cr: 0 } },
  critWeightVector: [ 0.6000000000000001, 0.20000000000000004, 0.20000000000000004 ],
  rankedScoreMap:
   { VendorA: 0.3652380952380953,
     VendorB: 0.2852380952380953,
     VendorC: 0.3495238095238096 } }

Interpretation:

The overall rank score(higher is better) of the choices are:
VendorA: 0.3652
VendorB: 0.2852
VendorC: 0.3495
Hence, “VendorA” is preferred in overall ranking.

Leave a Reply

Your email address will not be published.