Qingfeng Mathematical Modeling—Analytic Hierarchy Process

analytic hierarchy process

Do you really understand hash tables (1)

Article directory


Tip: Information can be searched from CNKI, Wanfang, Baidu Academic, Google Scholar and other platforms

image-20230723163927046

Evaluation problems can be solved by scoring

Evaluation issues should be approached from these three aspects

  1. What is the goal of our evaluation?
  2. What options do we have to achieve our goals?
  3. What are the evaluation indicators?
  • The first two questions can be found in the question, and the third question can be found by refining the question or searching.
  • To summarize: we use the questions to figure out what the goal of our evaluation is, then infer several options, then score the options based on the evaluation indicators, and finally select the optimal option.

Find the weight by comparing the data

image-20230722235144824

  • Calculate the corresponding weight of the indicator, and the indicator weights add up to 1; then define the weight score based on the object search indicator, and obtain the same indicator weight score for different objects based on the horizontal comparison of different objects, where the scores for the same indicator add up to 1; Finally, the object's score*index weight is summed and the object with the largest sum is selected.

Next, the steps of analytic hierarchy process are deduced by analyzing the topic.

  • Xiao Ming wants to travel. After checking the guide online, he selected three scenic spots in Suzhou, Hangzhou, Beidaihe, and Guilin as tourist attractions. Please determine the evaluation indicators and form an evaluation system to choose the best plan for Xiao Ming.

1. Select indicators by consulting data

image-20230728191902723

Now let’s answer three entry-level questions for evaluation questions

  1. What is the goal of our evaluation?

Choose the best tourist attractions for Xiao Ming

  1. What options do we have to achieve this goal?

There are three options, namely going to Suzhou and Hangzhou, going to Beidaihe and going to Guilin.

  1. What are the criteria or indicators for evaluation? (What do we judge good or bad based on)

Scenery, cost, residence, food, transportation

2. Draw the weight table and fill it in

  • Make the form first and then analyze it one by one and fill in the blanks.

image-20230728192113829

  • Because there are three scenic spots and five indicators involved here, it will be very difficult to analyze them together. Therefore, here we only need to compare two indicators and calculate the weight based on the comparison results . Therefore, we have the following table of pairwise comparison to indicate the degree of importance.

image-20230723164241487

2.1.Judgment matrix

  • A table can be made based on the results of pairwise comparison of indicators, which is called a judgment matrix.

image-20230723164708236

  • Based on the obtained data, compare the indicators of the two objects with each other to obtain the corresponding element a ij (the importance of indicator i compared to indicator j), and then make the matrix

  • If this matrix satisfies:

    1. When i==j, the two indicators are the same, so a ij is the same and is recorded as 1.
    2. a ij >0 and a ij xa ji =1

    Then such a matrix is ​​called a forward and inverse matrix. This matrix is ​​used as a judgment matrix in the analytic hierarchy process (for example, a 13 can be expressed as the importance of scenery is between slightly important and obviously important than living.)

    At this time, Xiao Ming gets the results based on the comparison of the two indicators, and fills them in the judgment matrix in turn. But in fact, when we participate in the competition, Xiao Ming will not fill it in for us. We need to find the information, calculate, and infer the results.

    In addition, the judgment matrix becomes a consistent matrix after meeting certain conditions. The consistent matrix is ​​a form of judgment matrix.

consistent matrix

image-20230723173919106

  • It can be expressed by the following two formulas
    aij = importance of i/importance of j, aji = importance of j/importance of i a_{ij}=importance of i/importance of j, a_{ji}=j The importance of/the importance of iaij=The importance of i / the importance of j , aji=The importance of j / the importance of i

The following formula is obtained:
aik = importance of i/importance of k = aij ∗ ajk a_{ik}=importance of i/importance of k=a_{ij}*a_{jk}ai=importance of i / importance of k=aijajk

That is, based on the judgment matrix, if a ij xa jk =a ik is satisfied , the matrix is ​​a consistent matrix . According to this formula, it can also be concluded that the matrix satisfies the multiple relationship between rows and the multiple relationship between columns.

image-20230728195344984

  • When the judgment matrix is ​​a consistent matrix, the eigenvalue = the sum of the main diagonals of the consistent matrix is ​​n
  • When the eigenvalue is n, the corresponding eigenvector is the first row of the matrix
  • When the matrix is ​​not a consistent matrix, let the judgment matrix be the determinant, and the main diagonal is reduced by the same number at the same time, let the determinant be 0, and the number is the eigenvalue of the judgment matrix, and the eigenvalue may have many solution

image-20230729103800625

In addition, some people may confuse the direct and inverse matrices mentioned here with the orthogonal matrices in linear algebra. Let me explain here:

Orthogonal matrices and direct and inverse matrices are two different concepts. An orthogonal matrix is ​​a square matrix whose column vectors are pairwise orthogonal and have length 1. Its transposed matrix multiplied by itself equals the identity matrix. Orthogonal matrices represent rotation and mirroring operations in linear transformations, keeping the length and angle of the vector unchanged. The reciprocal matrix is ​​a symmetric matrix with all eigenvalues ​​greater than zero. It satisfies that for any non-zero vector x, a ij >0 , where A is a positive reciprocal matrix. The positive reciprocal matrix expresses the positive certainty of the quadratic form and is used to describe the constraints in the optimization problem or the properties of the quadratic form optimization. Although orthogonal matrices and orthogonal and inverse matrices may have some overlap in some special cases, their definitions and application fields are different.

image-20230724191627085

  • When the judgment matrix satisfies a ij xa jk =a ik , that is, the judgment matrix is ​​a consistent matrix, the maximum eigenvalue is n; when the judgment matrix is ​​not a consistent matrix, the maximum eigenvalue must be greater than n, and the more inconsistent the matrix, the maximum eigenvalue The greater the difference from n
  • Calculation of eigenvalues: Let the judgment matrix be the square matrix A, λ
  • Taking the above figure as an example, when a=4, the eigenvalue is 3, which is the minimum value of the eigenvalue changing as a changes.

in conclusion:

  1. Compare the two indicators and draw a chart to get the judgment matrix. When the judgment matrix must satisfy i==j, that is, the two indicators are the same, which is 1 ; a ij >0 and a ij xa ji =1
  2. Based on the judgment matrix, if the matrix satisfies the multiple relationship between each row (column), then the matrix is ​​a consistent matrix
  3. The eigenvalue of a consistent matrix is ​​n. When the matrix is ​​not a consistent matrix, the maximum eigenvalue must be greater than n, and the more inconsistent the matrix, the greater the difference between the maximum eigenvalue and n.

image-20230723183545504

It can be seen that the above figure does not satisfy a ij xa jk =a ik , so it is not considered a consistent matrix, while Figure 2 satisfies a consistent matrix, so a consistency check must be performed before using the judgment matrix to calculate the weight.

2.3 Steps of consistency check

image-20230724192347989

  1. First calculate the consistency index CI

The formula is as follows:
CI = λ max − n / n − 1 CI=\lambda_{max}-n/n-1CI=lmaxn/n1

That is, the maximum value of the eigenvalue - the number of diagonal elements of the matrix divided by the number of diagonal elements of the matrix - 1

  1. Find the RI (average random consistency index) corresponding to n according to the table. The table is generally given in the question.

  2. Calculate the consistency ratio CR

The formula is as follows:
CR = CI / RI CR=CI/RICR=C I / R I

  1. If CR<0.1 is obtained, the judgment indicates that the consistency of the judgment matrix is ​​acceptable; if CR>=0.1, the judgment indicates that the consistency of the matrix is ​​unacceptable and the judgment matrix needs to be corrected.

  2. When CR>=0.1, it means that the consistency of the matrix is ​​unacceptable. At this time, the matrix needs to be adjusted upwards to the consistent matrix, so that the matrix satisfies the multiple relationship of each row and column.

After completing the consistency test on the judgment matrix, it is necessary to calculate the weight of the judgment matrix.

3. Calculate the judgment matrix weight

3.1 Arithmetic average method to calculate weight

  1. Weights are normalized

image-20230725110309294

If the judgment matrix is ​​a consistent matrix, select any column to calculate the weight

  • If the judgment matrix is ​​a consistent matrix, it means that the rows are in a multiple relationship and the columns are also in a multiple relationship, so the result of selecting any column during normalization will be the same. Normalization refers to calculating the proportion of an element in the entire population . Here is the calculation of the proportion of elements in the column

image-20230725110659494

If the judgment matrix is ​​not a consistent matrix, calculate the weights of different columns separately, and finally calculate the average weight.

  • If the matrix is ​​not a consistent matrix, it means that the columns are not in a multiple relationship, then the calculated weight of each column is different. At this time, it is necessary to calculate the weights of all columns separately, and finally find the average weight.

image-20230725111326239

image-20230725111339173

The following steps and formulas are summarized:

image-20230725115527848

image-20230725121625913

3.2 Calculating weight by geometric mean method

image-20230725124604289

( ∏ j = 1 n a i j ) / ∑ k = 1 n ( ∏ k = 1 n a k j ) 1 / n (\prod^n_{j=1}a_{ij})/\sum^n_{k=1}(\prod^n_{k=1}a_{kj})^{1/n} (j=1naij)/k=1n(k=1nakj)1/n

3.3 Calculating weight by eigenvalue method

image-20230729112026661

If the judgment matrix is ​​a consistent matrix, its eigenvalue is n, and the other eigenvalues ​​are 0

The corresponding eigenvector is the first column of the consistent matrix

  • Weight normalization:

Eigenvalue/eigenvector=n/sum of first column Eigenvalue/eigenvector=n/sum of first columnEigenvalue / eigenvector=n / Sum of first column

  • In addition, if the game time is sufficient, it is recommended to use all three calculation methods above. After using it, you can add: In order to ensure the robustness of the results, this article uses three methods to calculate the weights separately and then calculate the average. Calculate the scores of each scheme based on the obtained weight matrix, and perform ranking and comprehensive analysis. This avoids the bias caused by using a single method and the conclusions drawn will be more comprehensive and effective.

3.4 Finally, fill in the calculation results into the weight table

image-20230729112209399

4. Summarize the results to obtain the weight matrix

image-20230729112451968

5. Calculate the score of each solution

image-20230729112549760

  • Select the object with the highest score based on the score

The steps of analytic hierarchy process reflected in the paper

Generally speaking, the implementation in the paper is divided into the following steps:

  1. Analyze the relationship between factors in the system and establish a hierarchical structure of the system

image-20230729112955390

  • This picture can be generated using PPT’s smartArt, or you can use Edraw icon, ProcessOn

For specific steps, please refer to the following

image-20230729113208599

  1. Compare each element in the same level with respect to the importance of a criterion in the previous level, and construct a pairwise comparison matrix (judgment matrix)

image-20230729113229887

  1. The results are calculated based on the pairwise comparison of the judgment matrix, and the weight matrix is ​​obtained by summarizing the results.

image-20230729113412007

  1. The object with the highest score is calculated according to the weight matrix, and the object with the highest score is selected as the final goal.

Limitations of AHP

  • There should not be too many decision-making layers for evaluation. If there are too many, n will be very large. The difference between the judgment matrix and the consistency matrix may be very large. The number of n in the table of the average random consistency index RI is at most 15.
  • If the data of indicators in the decision-making layer are known, then how can we use these data to make the evaluation more accurate? We use the analytic hierarchy process to derive the decision-making layer and the target layer by searching for data and calculating. However, when the indicator data in the decision-making layer is known, the value of the analytic hierarchy process is no longer reflected. At this time, it would be better to use other algorithms.

Arithmetic average method weight calculation code

image-20230801000658710

  • First assume that matrix A is a judgment matrix and enter it into matlab. The default display of matlab is decimal

image-20230801000805618

  • Sum the matrix A by columns and assign it to the col_A matrix

sum(A): Sum matrix A, the default is the sum of column vectors; sum(A,2) means sum of row vectors

image-20230801001002997

  • Find the number of rows x and number of columns y of the matrix according to the size function, because the matrix A here is a square matrix, so x=y

size(A): View the number of rows and columns of matrix A

image-20230801001205637

  • Set the number of rows of the summation matrix col_A to the number of rows of the A matrix, which provides the denominator for subsequent normalization

image-20230801001706046

  • Use each element of the original judgment matrix A as the numerator and each element of the sum matrix sum_A as the denominator for normalization.

image-20230801002234280

  • Sum the normalized matrix nor_A row by row

image-20230801002901880

  • Finally, find the average weight

Geometric mean method to find weight code

image-20230801132957945

  • Multiply each element row by row to obtain a column matrix row_A

sum(A): multiplies matrix A, the default is column vector multiplication; sum(A,2) means row vector multiplication

image-20230801133126643

  • Find the number of columns n of the judgment matrix A. Because the matrix A here is a square matrix, the number of columns = the number of rows = 5

image-20230801133237284

  • Raise each element of the column vector row_A to the 1/nth power to obtain a new column matrix den_A

image-20230801133902985

  • Divide each element of the column matrix den_A by the sum of the matrix den_A

Eigenvalue method to find weight code

image-20230801140238090

  • Find the eigenvector V and eigenvalue D of the A matrix

E=eig(A), E is the eigenvalue; [V,E]=eig(A), V is the eigenvector, E is the eigenvalue, and the eigenvalue corresponds to the eigenvector of the column where it is located, and E is the diagonal Presented in matrix format

image-20230801140848533

  • Find the maximum eigenvalue

max(A): Find the maximum of matrix A: take the maximum in each column and return a row matrix. max(max(A)): Take the maximum value in each column

image-20230801141210424

  • Find the row index r and column index c corresponding to the maximum eigenvalue, that is, the corresponding eigenvector can be found based on the position of the maximum eigenvalue

D == max_eig means finding an element equal to max_eig in the matrix, and returns 1 if it is found and 0 if it is not found. [r,c] = find(D == Max_eig, 1) means: the return value of parameter one of the find function is compared with parameter two 1 of find. If they are equal, the row and column labels of the corresponding result of parameter one are returned. .

image-20230801143345469

  • Find the column with the largest eigenvalue, which is the corresponding eigenvector, and then normalize

Calculate consistency check code

CI = λ max − n / n − 1 CI=\lambda_{max}-n/n-1CI=lmaxn/n1

image-20230801144312330

  • Max_eig is the maximum eigenvalue. Since the judgment matrix A is a square matrix, n is the number of rows and columns of the matrix A.

image-20230801144437634

  • Enter the consistency index RI according to the question

image-20230801144521344

  • Calculate the consistency ratio CR

  • If CR<0.1 is obtained, the judgment indicates that the consistency of the judgment matrix is ​​acceptable; if CR>=0.1, the judgment indicates that the consistency of the matrix is ​​unacceptable and the judgment matrix needs to be corrected.
    The corresponding feature vector is then normalized

Calculate consistency check code

CI = λ max − n / n − 1 CI=\lambda_{max}-n/n-1CI=lmaxn/n1

[External link pictures are being transferred...(img-Wu6k78Gr-1690872654596)]

  • Max_eig is the maximum eigenvalue. Since the judgment matrix A is a square matrix, n is the number of rows and columns of the matrix A.

[External link pictures are being transferred...(img-OkTUQOkZ-1690872654596)]

  • Enter the consistency index RI according to the question

[External link pictures are being transferred...(img-RlICO43U-1690872654596)]

  • Calculate the consistency ratio CR

  • If CR<0.1 is obtained, the judgment indicates that the consistency of the judgment matrix is ​​acceptable; if CR>=0.1, the judgment indicates that the consistency of the matrix is ​​unacceptable and the judgment matrix needs to be corrected.

Guess you like

Origin blog.csdn.net/m0_71841506/article/details/132042190