Analytic hierarchy process (AHP) is an operational research method

### Method background and Application Overview

AHP is a hierarchical weight decision-making analysis method, which is proposed by American operational research professor satty of Pittsburgh University in the early 1970s when he studied the subject of “power distribution according to the contribution of each industrial sector to the national welfare” for the U.S. Department of defense, applying network system theory and multi-objective comprehensive evaluation method.

- When a company wants to select talents, it will examine multiple dimensions. Who is the subjective choice or is there an objective methodology?
- How to choose multiple brands if you want to give your parents a chair?
- How to choose multiple destination for a national day tour?
- Tear this method by hand with JS and generalize it

### Let’s first understand the steps of this method from a practical example

- The scenery is good, but the cost should not be too high
- If the cost is cheap, will the living and food be too bad?
- For multiple attributes, you may not be able to level them at one time

- What does the picture above mean?
- This is a table with subjective judgments, such as
- Scenery: how much do you think it will cost? I think the scenery is a little more important, that is 3:1, if the reverse is 1:3
- So: the cost is a numerical value
- By analogy, each decision dimension is compared in pairs to form a decision model
**Judgment matrix**

- The diagonal of a matrix is reciprocal to each other, which means that we only need to compare it once
**Judgment matrix** - Only need to complete the matrix, the upper triangle or the lower triangle, other automatic completion

Consistency judgment

- In pairwise comparison, a is better than B, B is better than C, and C is better than A. We can use the inconsistent ratio judgment
**“Hierarchical list sorting and consistency test”** - Consistency index:

- It’s an eigenvalue
And N is the number of features

- The Ci was close to 0 and the consistency was satisfactory
- The larger the CI, the more inconsistent it is
- After calculating Ci, Cr = CI / ri < 0.1 was used to judge whether it was consistent
- If the consistency is not satisfied, please compare them again
- RI (random consistency index) look up the table, to find RI, you can construct n contrast matrices, and then find the average of eigenvalues
- The RI is as follows
- When n = 1 ~ 12, RI were 0, 0, 0.52, 0.89, 1.12, 1.26, 1.36, 1.41, 1.46, 1.49, 1.52, 1.54, respectively
- Looking up the table is very simple. The dimension of judgment is no more than 12. The above example is 5
- The above formula needs to be worked out. The eigenvalue of the matrix is slightly complicated. We use the sum product method to approximate it
**“Eigenvalue”**as well as**Eigenvector**

JS code to find a judgment matrix Cr and eigenvector

- Add notes to explain the code in detail

- With this function, we complete the core of this method

Comparison matrix of each judgment dimension corresponding to the target

- To put it simply, choose the scenery, this dimension, compare each other, the contrast matrix of Suzhou and Hangzhou, Beidaihe and Guilin, and then ensure consistency.
- In this way, there will be five contrast matrices, all of which are 3 * 3
- With the comparison matrix of dimensions, there are 6 matrices
- The specific matrix is as follows

- Again, it’s diagonal reciprocal
- The following code is so easy, so short

give the result as follows

With this small tool, we can do talent selection

- Of course, AHP method is subjective. It can use multiple people to produce contrast matrix and form decision tree, which is more fair
- We can make the above process into a visual interface, for example:

- We use the AHP algorithm in the demand feedback system

### summary

- Understand AHP and use it in actual business scenarios
- Through JS implementation, after generalization, it can solve any problem that needs multi-level decision-making