ahp-criteria-helper
Version:
A simple package that helps to find the weights of n criteria, and also calculate your consistency ratio.
21 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.calculateConsistency = void 0;
var calculate_weights_1 = require("./calculate-weights");
var random_consistency_index_1 = require("./random-consistency-index");
var calculateConsistency = function (matrix, weights) {
if (matrix.length < 3)
throw new Error('You need at lest 3 criteria to calculate de consistency');
var scopeWeights = weights || (0, calculate_weights_1.calculateWeights)(matrix);
return ((matrix.reduce(function (acc, array, rowIndex) {
return acc +
array.reduce(function (arrAcc, item, colIndex) { return arrAcc + scopeWeights[colIndex] * item; }, 0) /
scopeWeights[rowIndex];
}, 0) /
scopeWeights.length -
matrix.length) /
(matrix.length - 1) /
(0, random_consistency_index_1.randomConsistencyIndex)(matrix.length));
};
exports.calculateConsistency = calculateConsistency;
//# sourceMappingURL=calculate-consistency.js.map