Matlab-based AHP and use

Abstract: In this paper, use the Matlab software programming, to meet the same level of each index for all subordinate impact indicators are under the assumption that, to achieve the AHP analysis algorithms. This program allows the user to freely set within the hierarchy of indicators number of levels and the number of indicators within the various levels, through the process of circulation, the user simply enter part of the judgment matrix data, the program can be based on analytic hierarchy process is calculated and the calculation of its judgment in this program can easily handle AHP under large amount of computation to solve AHP efficiency, improve the timeliness of computer-aided decision-making.

Keywords: Matlab AHP judgment matrix Decision

In the current information technology, in the context of globalization, the traditional manual calculation has been unable to meet the people of high efficiency, high accuracy in decision-making needs. Therefore aided decision-making responsibility and become a new tool for management decision-making, the new method. Based on this, In this paper, give full play to the computer based on the powerful computing capabilities, the choice of the U.S. The MathWorks Matlab R2009a integrated mathematical modeling environment as a development platform, using the M programming language, computer-aided decision-making in the use of AHP for discussion. trying AHP program on the use of computer systems for management decision to explore a new road titles of papers.

A calculation flow AHP

According to the theory of AHP, AHP The basic idea is to decompose the complex decision problem, get a number of underlying indicators, and then the decomposition of the underlying index, and then get a number of lower index, so established hierarchical structure model, and then According to the structure model of judgment matrix, a single sort, finally, calculate the weight of each index corresponding coefficient for the total level of sort.

1.1 hierarchical model constructed during the AHP analysis, the most important step is to create a hierarchical structure model index, based on structural models judgment matrix, and only passed judgment matrix consistency test only after the analysis and calculation. Among them, the structural model can be designed into three levels, the highest level for the target layer, the purpose of decision-making and problem to be solved, the middle layer of the factors to be considered for decision-making, decision-making criteria, the lowest level is an alternative decision-making programs. Generally speaking, the guidelines of the lower layer of each index indicator is no limit, but in this article only in the design process Shangqie each indicator has the same number of lower-level indicators under the assumption completed AHP analysis, so this article later selected case also satisfy this assumption.

1.2 establish judgment matrix judgment matrix is ​​a factor for all of the layers of a layer of a comparison of the relative importance of factors to determine the matrix elements of the assignment, often using nine scale method (which uses the numbers 1 through 9 and its inverse represents the relative importance of indexes), the specific scaling method shown in Table 1.

1.3 Inspection judgment matrix determines the complexity of multi-stage, often makes certain value judgment matrix inconsistent with the possibility that the judgment matrix does not guarantee complete harmony when judgment matrix can not guarantee full consistency with , the corresponding characteristic root of judgment matrix will also change, so you can use judgment matrix eigenvalue test to determine the change in the degree of consistency in the analytic hierarchy, so that the largest judgment matrix eigenvalues ​​λmax, the order number n, then the consistency of judgment matrix test indicators denoted as:

The larger the value of CI, the worse the judgment matrix when the order is greater than 2, the judgment matrix consistency index CI and the same order of average random consistency index RI ratio as random consistency ratio, in which the value of RI determined from Table 2, CR is calculated as:

When CR <0.1, the judgment matrix can be considered consistent with satisfaction, however due to the degree of importance of each index mutual determination of the size of subjective factors exist in the process, and therefore can not pass judgment matrix consistency test, you need to on the degree of importance of each index mutual re-assignment until the consistency test through the matrix whose largest eigenvalue eigenvector corresponding to the index is an indicator of the relative importance of the sort.

1.4 overall sort of hierarchical levels in a single sort through the results of each indicator relative importance of indicators on a sorted vector, along the hierarchical structure step by step in order to perform matrix calculations from the bottom up, you can get to the highest of the underlying index layer relative importance weights to each of the underlying index can be sorted priorities, identify key indicators and special attention.

2 Matlab AHP program design ideas

Matlab is a matrix laboratory (Matrix Laboratory) for short, is an American mathematical software MathWorks Inc., for algorithm development, data visualization, data analysis, and numeric computation senior technical computing language and interactive environment. Matlab matrix operations can be performed, drawing functions and data images, design algorithms, creating the user interface, to connect with other programs written in other programming languages. Matlab matrix for the unit, using M language as programming language and C language has many similarities, and can be easily and C / C + +, Microsoft Excel and other tools and software to combine and make code-sharing and data exchange, you can easily numerical analysis, image processing and other functions, with a powerful statistical and financial toolbox, Matlab is already available in probability and statistics, economic management has played a strong role.

I compiled the program that is rich in the use of Matlab functions, matrix operations, and program control functions, to explore its AHP analysis of the application. Program through the three-cycle structure, in accordance with the method shown in Table 1, and rules to implement multiple the level of individual judgment matrix input and generation, and can calculate their eigenvalues, in accordance with the above formula ⑴, ⑵ formulas shown in Table 2, and the matrix method consistency test when all the tests have passed the consistency of judgment matrix , the program will in turn from the bottom of the calculated levels, and ultimately the index of the underlying layer relative to the weight coefficient criterion, thus contributing to choose the best program, the program flow shown in Figure 1, in which said parallelogram input data, diamond indicates judgment, according to the judgment result appears two different branches. Links to free download

procedures used to generate the judgment matrix part of the program are as follows:

for a = 1: mp

for b = 1: mp

A (b, b) = 1;

if a fprintf ("Line% i, Row% i \ n", [a; b]);

A (a, b) = input ("Please input the value:");

A (b, a) = 1 / A (a, b);


Sort generate total weight matrix level part of the program are as follows:

for r = p-1: 1

v = ["vect = vect * vector" int2str (r)];

evalc (v)


fprintf ("The final judging vector is:")

fprintf ("\ n% .4 f", vect)

[M, maxpl] = max (vect);

fprintf ("\ n \ nThe Scheme% i is the best solution. \ n \ n", maxpl)
Wherein, mp within the layer number of indicators that, p is the number of layers indicators, both in the beginning of the program specified by the user; vect empty matrix is ​​initially assigned, the loop index layer generated after the judgment of the first vector; m is vect The maximum vector, maxpl record the maximum position.

Since the restrictions on the structure of the program, the program can only Shangqie various indicators are at the same level for all impact the next level indicators when handling AHP problem, it is assumed that this example also comply with the conduct.

3 Application Examples

Crossroads city a crowded pedestrian crossing is often due to a potential security risk, municipal authorities want to transform the intersection, now presents three sets of transformation program:

Programme 1 (S1): built underground passage;

Programme 2 (S2): Construction footbridge;

Programme 3 (S3): removal of old buildings around, widen street.

Municipal departments, the renovation project need to consider the following aspects of the indicators:

Indicator 1 (P1): The size of the opening of capacity;

Indicator 2 (P2): The level of traffic safety factor;

Indicator 3 (P3): the level of construction costs;

Indicator 4 (P4): The size of the masses convenience degree;

Indicator 5 (P5): The level of cleanliness of the city.
Now you need to make decisions on the above issues, the need to decide on three options (S1 ~ S3) in the selection of the optimal solution and its main steps and actions are as follows.

Step 1: According to the subject to establish a hierarchical model

Since questions require three sets of programs are required to consider the five indicators, it can be shown in Figure 2 indicators architecture diagram.

Step 2: Formation of judgment matrix

Formation of judgment matrix, the need for mutual importance of each indicator scale, the upper triangular part of the matrix with the diagonal of the lower triangular part of the boundary, the reciprocal symmetrically arranged on the diagonal elements are all one, because each index and The importance of itself is "important", different indicators of the importance of A2 and A1 A2 A1 importance of reciprocal rule of thumb in Figure 2 the importance of each of the indicators, after scaling, can be obtained as Several matrix:

Step 3: The above matrix input program, calculated

In the Matlab command window followed by prompt shown in Tables 3 to 8 matrix, the program output after finishing the following table:

Subsequently, the program for each matrix eigenvalue calculation of the maximum eigenvector corresponding to standardize the following formula:

Then give each index eigenvector matrix consisting of:

Then come three options relative to the target weight vector is:

Program By comparison, find the largest program a weighting coefficient, then come to a final conclusion: Scenario 1 (underground passage) dominant.

4 Summary and Analysis

This program starts running, it will ask the user to enter the number of layers and the first layer index number of metrics, at every level of the matrix elements of the input is complete, the program will ask the user to enter the next level of the index number, so this program can be an unlimited number of levels of iteration, of course, can only substitute AHP operation part, due to the subjective judgment matrix assignment is often necessary to be determined by other means, such as the Delphi method, etc. In the set judgment procedure for computing matrix input, the program can ensure the accuracy and efficiency of matrix operations in the code optimization and extension, the process and results can also be exported to Excel data and Eviews, to facilitate subsequent data processing and measurement analysis.

In addition, as mentioned earlier, there is a limitation of this procedure, the need to meet the same level for all the indicators within the next level of impact indicators are assumed to run correctly when the author of the program will be conducted in the future to further improve and enhance its functionality and ease of use, so that it can meet different types, different conditions AHP analysis, computer-aided decision-making in everyday life play a greater role.


[1] Lingze Hua analytic hierarchy process defined in the enterprise core staff in the use of [J]. Managers, 2010, (2).

[2] Liu Wenqi, Xiong Huizhen. Analytic Hierarchy Process in financial indicators Analysis [J]. Auditing and Finance, 2010, (1).

[3] Wang Yi, Wang Xin Ming. MATLAB base and in economics and management science applications [M]. Beijing: Mechanical Industry Press, 2009.7. Links to free download

Computer Application Papers