The main stages of fuzzy logical inference. Direct fuzzy logical inference. Fuzzy neural networks

In problems of mathematical modeling, the problem of describing variables that represent qualitative values ​​of indicators that are weakly formalized into a discrete set of values ​​Koroteev, M.V. often arises. Analytical defuzzification of fuzzy numbers / Koroteev M.V. // News of VolgSTU. Series “Current problems of management, computer technology and informatics in technical systems.” Vol. 14: interuniversity. Sat. scientific Art. / VolgSTU. - Volgograd, 2012. - No. 10 (97). - P. 32-35.. An example of such indicators is the quality of the product, the efficiency of the institution, the qualifications of employees and many others. At the same time, traditionally the levels of such indicators are assessed qualitatively, using expert assessments formulated using the linguistic concepts of “low”, “high”, “very high”. Operating with linguistic concepts presents a certain complexity, overcoming which requires the use of a certain mathematical apparatus.

In our research, we chose the fuzzy logic apparatus, since it provides a flexible possibility of calculations in linguistic terms, handling uncertainty in conditions of lack of information. Linguistic variables Zadeh L. The concept of a linguistic variable and its application to approximate decision making. M.: Mir, 1976. 166c. can formalize imprecise, ambiguous and vague concepts. This property is very useful for use in expert systems, as it provides a methodology that allows experts to express their knowledge in a linguistic form familiar to them and operate with them as strict mathematical objects. Next, we adapt the fuzzy inference algorithm for use in Bayesian networks.

The central concept of fuzzy inference is a linguistic variable - a variable that has a certain set of linguistic values ​​(terms), built on a certain domain of definition (usually a real interval) Murphy, Kevin (2002). Dynamic Bayesian Networks: Representation, Inference and Learning. UC Berkeley, Computer Science Division. Jensen Finn V. Bayesian Networks and Decision Graphs. -- Springer, 2001.. For example, consider the linguistic variable “QUALITY”. We can define a certain integral quality indicator that evaluates quality on a certain scale. By normalization, we can reduce almost any scale to a segment. In the future, we will use this particular segment as an illustration of the medium due to its universality and general use.

Each quality level can be characterized as low, medium or high, but to varying degrees. This set is the set of values ​​of a linguistic variable. Thus, each value of a linguistic variable corresponds to a membership function where x is an element of the domain of definition defined on the domain of definition of this variable. This function shows how applicable a given value is at a given point in the domain of definition. The membership function usually takes values ​​from the interval , where a value of 0 indicates that a given value is absolutely not applicable at a given point, and a value of 1 indicates that a given value is absolutely applicable. The set of these functions is called a fuzzy classifier Koroteev, M.V. Design of software implementation of carriers of fuzzy sets / Koroteev M.V. // Object systems - 2011 (Winter session): material. V international scientific-practical conf. (Rostov-on-Don, December 10-12, 2011) / Shakhtinsky Institute (branch) of the State Educational Institution of Higher Professional Education SRSTU (NPI) [and others]. - Rostov n/d, 2011. - pp. 44-49.. In the case of an ordinary clear variable, each point in the domain of definition can belong to one and only one value. In fuzzy logic, each point belongs to all values, but to varying degrees.

Simple fuzzy classifier

The figure shows a fuzzy classifier with three terms (from left to right: “low level”, “medium level”, “high level”). The carrier of this linguistic variable is the segment (horizontal axis). The range of values ​​of the membership function is also a segment (vertical axis). You can see that a point, for example, 0.3 belongs to the term “low level” with a membership degree of 0.5; “middle level” - also with membership 0.5, “high level” - with membership 0. We can loosely say that this point does not belong to the term “high level” at all.

For each point in the domain of definition, the sum of its membership in all terms of the variable is equal to 1

For each point in the domain of definition, there are no more than two and no less than one terms to which the given point belongs positively.

For each term of a linguistic variable, there is at least one point whose membership in this term is equal to 1.

A fuzzy classifier that is not a fuzzy partition.

Let's consider the fuzzy logical inference algorithm using the example of the Mamdani Koroteev algorithm, M.V. Development of arithmetic of fuzzy numbers in general form / Koroteev M.V. // News of VolgSTU. Series “Current problems of management, computer technology and informatics in technical systems.” Vol. 13: interuniversity. Sat. scientific Art. / VolgSTU. - Volgograd, 2012. - No. 4 (91). - pp. 122-127. . Let’s say there are two linguistic variables A and B, each of which is defined on an interval and takes values ​​from a set (“low”, “middle”, “high”), characterizing the qualitative level of the indicator. The values ​​of variable B vaguely depend on the values ​​of variable A according to the following set of logical inference rules (similar to the rules of clear logical inference):

System of fuzzy logical inference rules

Based on this data, each inference rule is assigned a weight indicating the extent to which the rule applies to a given observation:

Weighted system of fuzzy logical inference rules

In this simple example, we use the values ​​of the membership functions as the weights of the rules. Based on the results obtained, variable B will take a value equal to the value of the expression |0.7*”high” + 0.3*”middle”|. Considering each term as an NPM, we can calculate the value of a given expression. and it is guaranteed to be an element of the domain of definition of the linguistic variable B. In addition to the numerical value, a fuzzy set representation in the form of NPM C = 0.7*”high” + 0.3*”middle” can also be considered as a result of the inference process. In general, to calculate the result of fuzzy logical inference, it is enough to calculate the weights of all terms of the target variable.

Let's look at an example of a more complex fuzzy inference. We have three similar variables, A, B and C, where the value of C depends on the values ​​of A and B according to the following set of rules:

System of inference rules for two conditional variables

As can be seen from the table, the fuzzy inference rule system uses a similar mechanism when all possible assignments of conditional variables are listed in the IF section, and each assignment of them is listed. The purpose of the subconditional variable in the TO section has been adjusted.

Let's calculate the values ​​of the rule weights as the product of the corresponding accessories: As a combination operator when calculating the rule weights in fuzzy inference, various triangular norms are used, but we will use the simplest function.

A weighted system of rules for inferring two conditional variables

Concept fuzzy inference occupies an important place in fuzzy logic Mamdani algorithm, Tsukamoto algorithm, Sugeno algorithm, Larsen algorithm, Simplified fuzzy inference algorithm, Clarity methods.

The fuzzy inference mechanism used in various expert and control systems is based on a knowledge base formed by subject matter experts in the form of a set of fuzzy predicate rules of the form:

P1: if X there is A 1 , then at there is B 1,

P2: if X there is A 2, then at there is B 2,

·················································

P n: If X There is An, Then at there is B n, Where X— input variable (name for known data values), at— output variable (name for the data value that will be calculated); A and B are membership functions defined respectively on x And at.

An example of such a rule

If X- low, then at- high.

Let's give a more detailed explanation. Expert knowledge A → B reflects a fuzzy causal relationship between premises and conclusion, so it can be called a fuzzy relationship and denoted by R:

R= A → B,

where “→” is called fuzzy implication.

Attitude R can be considered as a fuzzy subset of the direct product X×Y full set of prerequisites X and conclusions Y. Thus, the process of obtaining a (fuzzy) output result B" using a given observation A" and knowledge A → B can be represented as a formula

B" = A"ᵒ R= A"ᵒ (A → B),

where “o” is the convolution operation introduced above.

Both the composition operation and the implication operation in the algebra of fuzzy sets can be implemented in different ways (in this case, naturally, the final result obtained will also differ), but in any case, the general logical conclusion is carried out in the following four stages.

1. Fuzzy(introduction of fuzziness, phasification, fuzzifica-tion). Membership functions defined on the input variables are applied to their actual values ​​to determine the degree of truth of each premise of each rule.

2. Logical conclusion. The calculated truth value for the premises of each rule is applied to the conclusions of each rule. This results in one fuzzy subset that will be assigned to each output variable for each rule. As rules of logical inference, only the operations min(MINIMUM) or prod(MULTIPLICATION) are usually used. In the logical inference of MINIMUM, the inference membership function is “cut off” at a height corresponding to the calculated degree of truth of the premise of the rule (fuzzy logic “AND”). In MULTIPLY inference, the output membership function is scaled by the calculated degree of truth of the rule's premises.

3. Composition. All fuzzy subsets assigned to each output variable (in all rules) are combined together to form one fuzzy subset for each output variable. When combining such a combination, the operations max(MAXIMUM) or sum(SUM) are usually used. With the composition of MAXIMUM, the combined output of a fuzzy subset is constructed as a pointwise maximum over all fuzzy subsets (fuzzy logic “OR”). In SUM composition, the combined output of a fuzzy subset is constructed as a pointwise sum over all fuzzy subsets assigned to the output variable by the inference rules.

4. In conclusion (optional) - bringing to clarity(defuzzification), which is used when it is useful to convert a fuzzy set of outputs into a clear number. There are a large number of methods for bringing clarity, some of which are discussed below.

Example.Let some system be described by the following fuzzy rules:

P1: if X there is A, then ω there is D,

P2: if at is B, then ω there is E,

P3: if z is C, then ω is F, where x, y And z— names of input variables, ω is the name of the output variable, and A, B, C, D, E, F are the specified membership functions (triangular in shape).

The procedure for obtaining logical inference is illustrated in Fig. 1.9.

It is assumed that the input variables have taken on some specific (clear) values ​​- xo,yO And z O.

In accordance with the above stages, at stage 1, for given values ​​and based on the membership functions A, B, C, degrees of truth are found α (x o), α (y o)And α (z o) for the premises of each of the three rules given (see Fig. 1.9).

At stage 2, the membership functions of the rule conclusions (i.e. D, E, F) are “cut off” at the levels α (x o), α (y o) And α (z o).

At stage 3, the membership functions truncated at the second stage are considered and they are combined using the max operation, resulting in a combined fuzzy subset described by the membership function μ ∑ (ω) and corresponding to the logical conclusion for the output variable ω .

Finally, at the 4th stage - if necessary - a clear value of the output variable is found, for example, using the centroid method: the clear value of the output variable is defined as the center of gravity for the curve μ ∑ (ω), i.e.

Let us consider the following most frequently used modifications of the fuzzy inference algorithm, assuming, for simplicity, that the knowledge base is organized by two fuzzy rules of the form:

P1: if X there is A 1 and at there is B 1, then z there is C 1,

P2: if X there is A 2 and at there is B 2, then z is C 2, where x And at— names of input variables, z- name of the output variable, A 1, A 2, B 1, B 2, C 1, C 2 - some specified accessory functions, with a clear meaning z 0 must be determined based on the information given and clear values x 0 and at 0 .

Rice. 1.9. Illustration of the inference procedure

Mamdani algorithm

This algorithm corresponds to the considered example and Fig. 1.9. In the situation under consideration, it can be mathematically described as follows.

1. Fuzzy: degrees of truth are found for the premises of each rule: A 1 ( x 0), A 2 ( x 0), B 1 ( y 0), B 2 ( y 0).

2. Fuzzy inference: the “cut-off” levels for the preconditions of each of the rules are found (using the MINIMUM operation)

α 1 = A 1 ( x 0) ˄ B 1 ( y 0)

α 2 = A 2 ( x 0) ˄ B 2 ( y 0)

where “˄” denotes the logical minimum operation (min), then “truncated” membership functions are found

3. Composition: using the MAXIMUM operation (max, hereinafter denoted as “˅”), the found truncated functions are combined, which leads to obtaining final fuzzy subset for an output variable with a membership function

4. Finally, bringing to clarity (to find z 0 ) carried out, for example, by the centroid method.

Tsukamoto algorithm

The initial premises are the same as in the previous algorithm, but in this case it is assumed that the functions C 1 ( z), C 2 ( z) are monotonic.

1. The first stage is the same as in the Mamdani algorithm.

2. At the second stage, the “cut-off” levels α 1 and α 2 are first found (as in the Mam-dani algorithm), and then by solving the equations

α 1 = C 1 ( z 1), α 2 = C2( z 2)

- clear values ​​( z 1 And z 2 )for each of the original rules.

3. A clear value of the output variable is determined (as a weighted average z 1 And z 2 ):

in the general case (discrete version of the centroid method)

Example. Let us have A 1 ( x 0) = 0.7, A 2 ( x 0) = 0.6, B 1 ( y 0) = 0.3, V 2 ( y 0) = 0.8, corresponding cutoff levels

a 1 = min (A 1 ( x 0), B 1 ( y 0)) = min(0.7; 0.3) = 0.3,

a 2 = min (A 2 ( x 0), B 2 ( y 0)) = min (0.6; 0.8) = 0.6

and meanings z 1 = 8 and z 2 = 4 found by solving the equations

C 1 ( z 1) = 0.3, C 2 ( z 2) = 0,6.


Rice. 1.10. Illustrations for the Tsukamoto algorithm

In this case, the clear value of the output variable (see Fig. 1.10)

z 0 = (8 0.3 + 4 0.6) / (0.3 + 0.6) = 6.

Sugeno algorithm

Sugeno and Takagi used a set of rules in the following form (as before, here is an example of two rules):

P 1: if X there is A 1 and at there is B 1, then z 1 = A 1 X + b 1 y,

P 2: if X there is A 2 and at there is B 2, then z 2 = a 2 x+ b 2 y.

Algorithm presentation

2. At the second stage there are α 1 = A 1 ( x 0) ˄ B 1 ( y 0), α 2 = A 2 ( x 0) ˄ V 2 ( at 0) and individual rule outputs:

H. At the third stage, a clear value of the output variable is determined:

The algorithm is illustrated in Fig. 1.11.

Rice. 1.11. Illustration for the Sugeno algorithm

Larsen algorithm

In the Larsen algorithm, fuzzy implication is modeled using a multiplication operator.

Description of the algorithm

1. The first stage is as in the Mamdani algorithm.

2. At the second stage, as in the Mamdani algorithm, the values ​​are first found

α 1 = A 1 ( x 0) ˄ B 1 ( y 0),

α 2 = A 2 ( x 0) ˄ V 2 ( y 0),

and then - private fuzzy subsets

α 1 C 1 ( z), a 2 C 2 (z).

3. Find the final fuzzy subset with the membership function

μs(z)= WITH(z)= (a 1 C 1 ( z)) ˅ ( a 2 C 2(z))

(in general n rules).

4. If necessary, reduction to clarity is carried out (as in the previously discussed algorithms).

Larsen's algorithm is illustrated in Fig. 1.12.


Rice. 1.12. Illustration of the Larsen algorithm

Simplified fuzzy inference algorithm

The initial rules in this case are given in the form:

P 1: if X there is A 1 and at there is B 1, then z 1 = c 1 ,

P 2: if X there is A 2 and at there is B 2, then z 2 = With 2 , Where c 1 and from 2- some ordinary (clear) numbers.

Description of the algorithm

1. The first stage is as in the Mamdani algorithm.

2. At the second stage, the numbers α 1 = A 1 ( x 0) ˄ B 1 ( y 0), α 2 = A 2 ( x 0) ˄ B 2 ( y 0).

3. At the third stage, a clear value of the output variable is found using the formula

or - in the general case of availability n rules - according to the formula

An illustration of the algorithm is shown in Fig. 1.13.


Rice. 1.13. Illustration of a simplified fuzzy inference algorithm

Clarity Methods

1. One of these methods has already been discussed above—troid. Let us present the corresponding formulas again.

For the continuous option:

for discrete option:

2. First-of-Maxima. The clear value of the output variable is found as the smallest value at which the maximum of the final fuzzy set is achieved, i.e. (see Fig. 1.14a)


Rice. 1.14. Illustration of methods for bringing clarity: α - first maximum; b - average maximum

3. Middle-of-Maxima. The exact value is found by the formula

where G is a subset of elements that maximize C (see Fig. 1.14 b).

Discrete option (if C is discrete):

4. Maximum criterion (Max-Criterion). A clear value is chosen arbitrarily among the set of elements that deliver the maximum C, i.e.

5. Heightdefuzzification. Elements of the domain of definition Ω for which the values ​​of the membership function are less than a certain level α are not taken into account, and the exact value is calculated using the formula

where Сα is a fuzzy set α -level (see above).

Top-down fuzzy inference

The fuzzy inferences discussed so far are bottom-up inferences from premises to a conclusion. In recent years, top-down inference has begun to be used in diagnostic fuzzy systems. Let's look at the mechanism of such an inference using an example.

Let's take a simplified model for diagnosing a car malfunction with variable names:

X 1—battery malfunction;

x 2 - engine oil waste;

y 1 - difficulty starting;

y 2 — deterioration in the color of exhaust gases;

y 3 - lack of power.

Between x i And y j there are unclear causal relationships r ij= x iy j, which can be represented as a matrix R with elements r ijϵ. Specific inputs (premises) and outputs (conclusions) can be considered as fuzzy sets A and B on spaces X And Y. The relations of these sets can be denoted as

IN= AR,

where, as before, the sign “o” denotes the rule for the composition of fuzzy conclusions.

In this case, the direction of the conclusions is the opposite to the direction of the conclusions for the rules, i.e. in case of diagnostics there is (specified) a matrix R(expert knowledge), outputs are observed IN(or symptoms) and inputs are determined A(or factors).

Let the knowledge of an expert auto mechanic have the form

and as a result of examining the car, its condition can be assessed as

IN= 0,9/y 1 + 0,1/at 2 + 0,2/at 3 .

It is necessary to determine the cause of this condition:

A =a 1 /x 1 + a 2 /x 2 .

The relationship of the introduced fuzzy sets can be represented as

or, transposing, in the form of fuzzy column vectors:

When using a (max-mix) composition, the last relation is converted to the form

0.9 = (0.9 ˄ α 1) ˅ (0.6 ˄ α 2),

0.1 = (0.1 ˄ α 1) ˅ (0.5 ˄ α 2),

0.2 = (0.2 ˄ α 1) ˅ (0.5 ˄ α 2).

When solving this system, we note first of all that in the first equation the second term on the right side does not affect the right side, therefore

0.9 = 0.9 ˄ α 1 , α 1 ≥ 0.9.

From the second equation we get:

0.1 ≥ 0.5 ˄ α 2 , α 2 ≤ 0.1.

The resulting solution satisfies the third equation, so we have:

0.9 ≤ α 1 ≤ 1.0, 0 ≤ α 2 ≤ 0.1,

those. it is better to replace the battery (α 1 is the battery malfunction parameter, α 2 is the engine oil waste parameter).

In practice, in problems similar to the one considered, the number of variables can be significant, various compositions of fuzzy inferences can be used simultaneously, and the inference circuit itself can be multi-stage. At present, apparently, there are no general methods for solving such problems.

When talking about fuzzy logic, we most often mean fuzzy inference systems, which are widely used to control technical devices and processes. The development and application of fuzzy inference systems includes a number of stages, the implementation of which is carried out using the previously discussed basic principles of fuzzy logic.

Main stages of fuzzy inference generation:

    Formation of a rule base for fuzzy inference systems.

    Fuzzification of input variables.

    Aggregation of subconditions in fuzzy production rules.

    Activation or composition of subconclusions in fuzzy production rules.

    Accumulation of conclusions of fuzzy production rules.

Below we will consider the main features of each of these stages.

1.2.1 Formation of a base of fuzzy inference rules

The rule base of a fuzzy inference system is intended to formally represent empirical knowledge or knowledge of experts in a particular problem area. Fuzzy inference systems use fuzzy production rules, in which conditions and conclusions are formulated in terms of fuzzy linguistic statements of the types discussed above. We will further call the set of such rules bases of fuzzy production rules.

The base of fuzzy production rules is a finite set of fuzzy production rules that are consistent with respect to the linguistic variables used in them. Most often, the rule base is presented in the form of structured text:

RULE_1: IF "Condition_1", THEN "Conclusion_1"

RULE_2: IF "Condition_2", THEN "Conclusion_2" (1.2)

RULE_N: IF "Condition_N", THEN "Conclusion_N"

The consistency of the rules regarding the used linguistic variables means that only fuzzy linguistic statements presented in paragraph 1.1.2 can be used as conditions and conclusions of the rules, and in each of the fuzzy statements the membership functions of the values ​​of the term set for each of the linguistic variables must be defined.

In fuzzy inference systems, the linguistic variables that are used in fuzzy statements of subconditions of fuzzy production rules are often called input linguistic variables, and the variables that are used in fuzzy statements of subconclusions of fuzzy production rules are often called output linguistic variables.

1.2.2. Fuzzification

In the context of fuzzy logic, fuzzification is understood not only as a separate stage of performing fuzzy inference, but also as the actual process or procedure for finding the values ​​of membership functions of fuzzy sets (terms) based on ordinary input data. Fuzzification is also called introducing fuzziness.

The goal of the fuzzification stage is to establish a correspondence between the specific value of an individual input variable of the fuzzy inference system and the value of the membership function of the corresponding term of the input linguistic variable.

EXAMPLE 1.1 To illustrate the implementation of this stage, consider an example of the fuzzification process of three fuzzy statements: “the speed of the car is low”, “the speed of the car is medium”, “the speed of the car is high” for the input linguistic variable β1 - the speed of the car. They correspond to fuzzy statements of the first type: " β1 There isα1 ", " β2 There isα2 ", " β3 There isα3 ". Suppose that the current speed of the car is 55 km/h. Then the fuzzification of the first fuzzy statement and the third results in the number 0, the second 0.67.

Figure 1.1 - An example of fuzzification of the input linguistic variable “car speed” for three fuzzy statements.

It was defined above that the AII rules are formulated by an expert. But an expert cannot always accurately determine whether an event will occur or not. For example, a doctor makes a certain diagnosis based on his observations of a patient. The doctor’s experience in many cases allows one to determine the patient’s disease with great accuracy. But he may be wrong, so other diagnoses are often considered.

People cannot always answer questions accurately. Is it possible to find out what temperature a person has if he says he is slightly ill? Most likely no. Words such as tall, hot and light represent linguistic variables, which cannot be determined by a single value.

The linguistic variable consists of variable name, for example, INTEREST RATE and its meanings, for example, GROWING, FALLING.

The use of these concepts in formulating rules is called fuzzy logic.

Fuzzy inference can be considered as an extension of ordinary logical inference. In ordinary logical inference, certain rules of inference (which are considered to be true) are applied to some premises (which are also considered to be true), resulting in conclusions that are considered valid. In fuzzy logical inference, both the initial premises and the rules of inference can have an arbitrary level of truth in the range from 0 to 1, respectively, and the results obtained can also be more or less reliable.

As an example, consider the impact of rent and food prices on a family's standard of living. This influence is described by the following statements.

1. IF K_P increases slightly, THEN U_Z_1 decreases slightly. ( m = 0.9)

2. IF K_P grows slightly, THEN U_Z_1 does not fall. ( m = 0.1) (If they stop paying)

3. IF K_P increases significantly, THEN U_Z_1 decreases significantly. ( m = 0.5)

4. IF K_P grows significantly, THEN U_Z_1 does not fall. ( m = 0.5)

5. IF C_P grows slightly, THEN U_Z_2 falls slightly. ( m = 1)

6. IF C_P grows significantly, THEN U_Z_2 drops significantly. ( m = 1)

7. IF U_Zh_1 falls slightly AND U_Zh_2 falls slightly, THEN U_Zh falls slightly. ( m = 1)

8. IF Y_ZH_1 falls slightly AND Y_ZH_2 falls significantly OR Y_ZH_1 falls significantly AND Y_ZH_2 falls significantly, THEN Y_ZH falls significantly. ( m =1)

9. IF Y_ZH_1 falls significantly AND Y_ZH_2 falls significantly, THEN Y_ZH falls very significantly. ( m = 1)

The conditions K_P IS GROWING SLIGHTLY and K_P IS GROWING SIGNIFICANTLY are vague and are expressed depending on the percentage of growth p the following formulas.

At 0< p < 2 m (K_P GROWS SLIGHTLY) = p / 2.

At 2< p < 4 m

At 4< p < 10 m (K_P GROWS SLIGHTLY) = (10 - p ) / 6.

At p > 10 m (K_P IS GROWING SLIGHTLY) = 1.

At p < 5 m (K_P INCREASES SIGNIFICANTLY) = 0.

At 5< p < 15 m (K_P GROWS SIGNIFICANTLY) = ( p - 5) / 10.

At p > 15 m (K_P GROWS SIGNIFICANTLY) = 1.


The conditions C_P GROWING SLIGHTLY and C_P GROWING SIGNIFICANTLY are also vague and expressed by formulas

At 0< p < 1 m (C_P GROWING SLIGHTLY) = p .

At 1< p < 5 m (C_P GROWING SLIGHTLY) = (5 - p ) / 4.

At 0< p < 10 m (C_P GROWING SIGNIFICANTLY) = p / 10.

At p > 10 m (C_P GROW SIGNIFICANTLY) = 1.

When using fuzzy logic, each formula is given a range of possible values ​​between 0 (FALSE) and 1 (TRUE), and rules for calculating these values. The values ​​calculated in this way determine the degree of truth of the formulas. Let's consider the fundamental concepts of a fuzzy set and membership function.

Let's consider concepts such as “growing” and “falling”. Let's refer these concepts to the variables INTEREST RATE and RUBLE. In relation to the INTEREST RATE variable, the concept of growth can mean an increase in the price level on the stock exchange by 10 - 30 points according to the Dow Jones index, and in relation to the RUBLE variable it means an increase in the ruble exchange rate compared to any other currency by 20 - 30 times. In this context, the word "grows" is called the meaning linguistic variable. A linguistic variable can take on different values ​​from a certain interval, the boundaries of which can change depending on the circumstances. For example, the boundaries of the interval for the linguistic variable “cold” may change depending on whether we are talking about winter or spring.

The concept of "falling" is also a linguistic variable used in the rules describing the stock exchange. By using linguistic variables, it is possible to calculate the values ​​of certain probabilities without burdening the user with unnecessary questions. To do this, it is necessary to somewhat specify the linguistic variables. The user of the expert system should be allowed to add definitions to these variables, such as small or medium. The user can set a small increase in the ruble exchange rate, and the expert system must know exactly what this means.

Consider the rule:

IF INTEREST RATES FALL AND TAXES ARE DECREASED, THEN THE PRICE LEVEL ON THE EXCHANGE WILL RISE.

This rule is not always true, so you can assign it the value of a certain number m, varying from 0 to 1. Such a number is called membership function μ.

Let the membership function of this rule be equal to 0.9, i.e. the probability that with a fall in interest rates and a reduction in taxes, the price level on the stock exchange will fall is 0.9.

But the implementation of the rule depends on the fulfillment of the conditions INTEREST RATES FALL and TAXES REDUCED, which does not always happen.

Let the membership function of the linguistic variable INTEREST RATES FALL equal to 0.6, and the membership function of the linguistic variable TAXES DECREASE equal to 0.8.

Then the rule can be written like this:

IF INTEREST RATES FALL (μ - 0.6) AND

TAXES ARE DECREASING (μ - 0.8), THEN THE PRICE LEVEL ON THE EXCHANGE IS RISING (μ rules - 0.9)

The membership function that the price level on the stock exchange will actually increase can be calculated as follows: the minimum membership function for the conditions of the IF part of the rule, separated by the logical operator AND, is selected and multiplied by the membership function for the entire rule. For the example given: (minimum (0.6, 0.8))*0.9=0.54

Therefore, with μ - 0.54, we can say that the price level on the stock exchange will fall.

If the conditional part of the rule contains a logical OR operator, then μ for this output must be selected as the maximum from μ for outputting the first rule and μ for outputting the second rule. At first glance, all this seems very complicated, so let's look at an example. First of all, let us formulate general principles.

1.Select the maximum value μ from μ for the rule conditions separated by the logical AND operator.

2.If the rule has an OR operator, select the maximum value from μ for all conditions of the rule separated by the AND operator for all conditions connected by the OR operator.

3.Multiply the selected μ by the rule μ.

4.If there are several rules with the same logical conclusion, choose the maximum one from all received μ.

Consider two rules with the same logical conclusion C:

IF A (μ =0.3) AND B (μ =0.6), THEN C (μ=0.5)

IF D (μ =0.4) AND E (μ =0.7), THEN C (μ=0.9)

In the above rules, μ for logical inference C is calculated as follows:

maximum ((minimum(0.3,0.6)*0.5), (minimum (0.4,0.7) *0.9)) =

Maximum (03*0.5),(0.4*0.9)) = maximum (0.15,0.36) = 0.36

Let's take an example using the logical OR operator:

IF A (μ=0.3) AND B (μ=0.6) OR D (μ=0.5), THEN C (μ=0.4)

In this example, μ for logical output C is calculated as follows:

maximum (minimum (0.3,0.6), 0.5)*0.4)= maximum (0.3,0.5)*0.4=0.5*0.4=0.2.

In many cases, the boundary values ​​of the membership function are initially specified. A logical inference is considered valid only if its μ exceeds predefined boundary values. Work with the knowledge base continues as long as the value of the logical inference membership function is greater than the boundary value. During operation, certain calculations are performed. For private inference, assume μ is 0.4. This value is remembered. It is then compared with the cutoff value μ (let's say it's 0.8). The stored value turned out to be less than the limit value, which means that work with the knowledge base continues. If, when working with the knowledge base, the same logical conclusion is encountered, μ for a new μ and the result is added to the previously memorized μ. A value of μ equal to 1 indicates absolute confidence in the correctness of the conclusion. Then the newly stored value μ is compared with the boundary value, and if it is greater, logical inference is performed, otherwise, work with the knowledge base continues. The above can be written using the equality:

Remembered μ = Previously remembered μ + (1-Previously remembered μ)*μ of the new rule.

For example:

Limit value μ=0.8

Rule: IF A, THEN B (μ=0.6)

Stored μ: 0.6

New rule: IF C, THEN B (μ=0.7)

Stored μ=0.6+(1-0.6)*0.7=0.88 (limit values ​​exceeded and output is performed).

Self-test questions for Chapter 3:

1.Can there be several target states in reasoning problems in the state space of the environment?

2. Is it possible to solve the problem of reasoning in the state space of the environment, considering at each step two actions out of four possible?

3. Can possible actions change in the process of solving a problem in the state space of the environment?

4. When solving a fuzzy reasoning problem in the state space of the environment, do we get a deterministic or probabilistic answer?

5.Can the membership function take a value greater than one?

Tests for chapter 3.

1. Purpose of search:

A) finding the target state, B) finding an intermediate state, C) finding the next state.

2.Search, inference and reasoning are

A) the same action, B) different actions, C) have nothing in common with the actions.

3. With fuzzy logic, a linguistic variable can take

A) one of two values ​​“true” or “false”, B) many values ​​within a given interval, C) one value.

4.The problem statement is called

A) Specifying all possible states, B) specifying all possible actions, C) specifying all possible actions and states.

5. If the conditional part of the rule contains a logical OR operator, then the membership function μ must be selected for output

A) the maximum of μ for deriving the first rule and μ for deriving the second rule, B) the minimum, C) the membership function of the output does not depend on the membership functions of the functions of the first and second rules

Concept fuzzy inference occupies an important place in fuzzy logic Mamdani algorithm, Tsukamoto algorithm, Sugeno algorithm, Larsen algorithm, Simplified fuzzy inference algorithm, Clarity methods.

The fuzzy inference mechanism used in various expert and control systems is based on a knowledge base formed by subject matter experts in the form of a set of fuzzy predicate rules of the form:

P1: if X there is A 1 , then at there is B 1,

P2: if X there is A 2, then at there is B 2,

·················································

P n: If X There is An, Then at there is B n, Where X— input variable (name for known data values), at— output variable (name for the data value that will be calculated); A and B are membership functions defined respectively on x And at.

An example of such a rule

If X- low, then at- high.

Let's give a more detailed explanation. Expert knowledge A → B reflects a fuzzy causal relationship between premises and conclusion, so it can be called a fuzzy relationship and denoted by R:

R= A → B,

where “→” is called fuzzy implication.

Attitude R can be considered as a fuzzy subset of the direct product X×Y full set of prerequisites X and conclusions Y. Thus, the process of obtaining a (fuzzy) output result B" using a given observation A" and knowledge A → B can be represented as a formula

B" = A"ᵒ R= A"ᵒ (A → B),

where “o” is the convolution operation introduced above.

Both the composition operation and the implication operation in the algebra of fuzzy sets can be implemented in different ways (in this case, naturally, the final result obtained will also differ), but in any case, the general logical conclusion is carried out in the following four stages.

1. Fuzzy(introduction of fuzziness, phasification, fuzzifica-tion). Membership functions defined on the input variables are applied to their actual values ​​to determine the degree of truth of each premise of each rule.

2. Logical conclusion. The calculated truth value for the premises of each rule is applied to the conclusions of each rule. This results in one fuzzy subset that will be assigned to each output variable for each rule. As rules of logical inference, only the operations min(MINIMUM) or prod(MULTIPLICATION) are usually used. In the logical inference of MINIMUM, the inference membership function is “cut off” at a height corresponding to the calculated degree of truth of the premise of the rule (fuzzy logic “AND”). In MULTIPLY inference, the output membership function is scaled by the calculated degree of truth of the rule's premises.

3. Composition. All fuzzy subsets assigned to each output variable (in all rules) are combined together to form one fuzzy subset for each output variable. When combining such a combination, the operations max(MAXIMUM) or sum(SUM) are usually used. With the composition of MAXIMUM, the combined output of a fuzzy subset is constructed as a pointwise maximum over all fuzzy subsets (fuzzy logic “OR”). In SUM composition, the combined output of a fuzzy subset is constructed as a pointwise sum over all fuzzy subsets assigned to the output variable by the inference rules.

4. In conclusion (optional) - bringing to clarity(defuzzification), which is used when it is useful to convert a fuzzy set of outputs into a clear number. There are a large number of methods for bringing clarity, some of which are discussed below.

Example.Let some system be described by the following fuzzy rules:

P1: if X there is A, then ω there is D,

P2: if at is B, then ω there is E,

P3: if z is C, then ω is F, where x, y And z— names of input variables, ω is the name of the output variable, and A, B, C, D, E, F are the specified membership functions (triangular in shape).

The procedure for obtaining logical inference is illustrated in Fig. 1.9.

It is assumed that the input variables have taken on some specific (clear) values ​​- xo,yO And z O.

In accordance with the above stages, at stage 1, for given values ​​and based on the membership functions A, B, C, degrees of truth are found α (x o), α (y o)And α (z o) for the premises of each of the three rules given (see Fig. 1.9).

At stage 2, the membership functions of the rule conclusions (i.e. D, E, F) are “cut off” at the levels α (x o), α (y o) And α (z o).

At stage 3, the membership functions truncated at the second stage are considered and they are combined using the max operation, resulting in a combined fuzzy subset described by the membership function μ ∑ (ω) and corresponding to the logical conclusion for the output variable ω .

Finally, at the 4th stage - if necessary - a clear value of the output variable is found, for example, using the centroid method: the clear value of the output variable is defined as the center of gravity for the curve μ ∑ (ω), i.e.

Let us consider the following most frequently used modifications of the fuzzy inference algorithm, assuming, for simplicity, that the knowledge base is organized by two fuzzy rules of the form:

P1: if X there is A 1 and at there is B 1, then z there is C 1,

P2: if X there is A 2 and at there is B 2, then z is C 2, where x And at— names of input variables, z- name of the output variable, A 1, A 2, B 1, B 2, C 1, C 2 - some specified accessory functions, with a clear meaning z 0 must be determined based on the information given and clear values x 0 and at 0 .

Rice. 1.9. Illustration of the inference procedure

Mamdani algorithm

This algorithm corresponds to the considered example and Fig. 1.9. In the situation under consideration, it can be mathematically described as follows.

1. Fuzzy: degrees of truth are found for the premises of each rule: A 1 ( x 0), A 2 ( x 0), B 1 ( y 0), B 2 ( y 0).

2. Fuzzy inference: the “cut-off” levels for the preconditions of each of the rules are found (using the MINIMUM operation)

α 1 = A 1 ( x 0) ˄ B 1 ( y 0)

α 2 = A 2 ( x 0) ˄ B 2 ( y 0)

where “˄” denotes the logical minimum operation (min), then “truncated” membership functions are found

3. Composition: using the MAXIMUM operation (max, hereinafter denoted as “˅”), the found truncated functions are combined, which leads to obtaining final fuzzy subset for an output variable with a membership function

4. Finally, bringing to clarity (to find z 0 ) carried out, for example, by the centroid method.

Tsukamoto algorithm

The initial premises are the same as in the previous algorithm, but in this case it is assumed that the functions C 1 ( z), C 2 ( z) are monotonic.

1. The first stage is the same as in the Mamdani algorithm.

2. At the second stage, the “cut-off” levels α 1 and α 2 are first found (as in the Mam-dani algorithm), and then by solving the equations

α 1 = C 1 ( z 1), α 2 = C2( z 2)

- clear values ​​( z 1 And z 2 )for each of the original rules.

3. A clear value of the output variable is determined (as a weighted average z 1 And z 2 ):

in the general case (discrete version of the centroid method)

Example. Let us have A 1 ( x 0) = 0.7, A 2 ( x 0) = 0.6, B 1 ( y 0) = 0.3, V 2 ( y 0) = 0.8, corresponding cutoff levels

a 1 = min (A 1 ( x 0), B 1 ( y 0)) = min(0.7; 0.3) = 0.3,

a 2 = min (A 2 ( x 0), B 2 ( y 0)) = min (0.6; 0.8) = 0.6

and meanings z 1 = 8 and z 2 = 4 found by solving the equations

C 1 ( z 1) = 0.3, C 2 ( z 2) = 0,6.


Rice. 1.10. Illustrations for the Tsukamoto algorithm

In this case, the clear value of the output variable (see Fig. 1.10)

z 0 = (8 0.3 + 4 0.6) / (0.3 + 0.6) = 6.

Sugeno algorithm

Sugeno and Takagi used a set of rules in the following form (as before, here is an example of two rules):

P 1: if X there is A 1 and at there is B 1, then z 1 = A 1 X + b 1 y,

P 2: if X there is A 2 and at there is B 2, then z 2 = a 2 x+ b 2 y.

Algorithm presentation

2. At the second stage there are α 1 = A 1 ( x 0) ˄ B 1 ( y 0), α 2 = A 2 ( x 0) ˄ V 2 ( at 0) and individual rule outputs:

H. At the third stage, a clear value of the output variable is determined:

The algorithm is illustrated in Fig. 1.11.

Rice. 1.11. Illustration for the Sugeno algorithm

Larsen algorithm

In the Larsen algorithm, fuzzy implication is modeled using a multiplication operator.

Description of the algorithm

1. The first stage is as in the Mamdani algorithm.

2. At the second stage, as in the Mamdani algorithm, the values ​​are first found

α 1 = A 1 ( x 0) ˄ B 1 ( y 0),

α 2 = A 2 ( x 0) ˄ V 2 ( y 0),

and then - private fuzzy subsets

α 1 C 1 ( z), a 2 C 2 (z).

3. Find the final fuzzy subset with the membership function

μs(z)= WITH(z)= (a 1 C 1 ( z)) ˅ ( a 2 C 2(z))

(in general n rules).

4. If necessary, reduction to clarity is carried out (as in the previously discussed algorithms).

Larsen's algorithm is illustrated in Fig. 1.12.


Rice. 1.12. Illustration of the Larsen algorithm

Simplified fuzzy inference algorithm

The initial rules in this case are given in the form:

P 1: if X there is A 1 and at there is B 1, then z 1 = c 1 ,

P 2: if X there is A 2 and at there is B 2, then z 2 = With 2 , Where c 1 and from 2- some ordinary (clear) numbers.

Description of the algorithm

1. The first stage is as in the Mamdani algorithm.

2. At the second stage, the numbers α 1 = A 1 ( x 0) ˄ B 1 ( y 0), α 2 = A 2 ( x 0) ˄ B 2 ( y 0).

3. At the third stage, a clear value of the output variable is found using the formula

or - in the general case of availability n rules - according to the formula

An illustration of the algorithm is shown in Fig. 1.13.


Rice. 1.13. Illustration of a simplified fuzzy inference algorithm

Clarity Methods

1. One of these methods has already been discussed above—troid. Let us present the corresponding formulas again.

For the continuous option:

for discrete option:

2. First-of-Maxima. The clear value of the output variable is found as the smallest value at which the maximum of the final fuzzy set is achieved, i.e. (see Fig. 1.14a)


Rice. 1.14. Illustration of methods for bringing clarity: α - first maximum; b - average maximum

3. Middle-of-Maxima. The exact value is found by the formula

where G is a subset of elements that maximize C (see Fig. 1.14 b).

Discrete option (if C is discrete):

4. Maximum criterion (Max-Criterion). A clear value is chosen arbitrarily among the set of elements that deliver the maximum C, i.e.

5. Heightdefuzzification. Elements of the domain of definition Ω for which the values ​​of the membership function are less than a certain level α are not taken into account, and the exact value is calculated using the formula

where Сα is a fuzzy set α -level (see above).

Top-down fuzzy inference

The fuzzy inferences discussed so far are bottom-up inferences from premises to a conclusion. In recent years, top-down inference has begun to be used in diagnostic fuzzy systems. Let's look at the mechanism of such an inference using an example.

Let's take a simplified model for diagnosing a car malfunction with variable names:

X 1—battery malfunction;

x 2 - engine oil waste;

y 1 - difficulty starting;

y 2 — deterioration in the color of exhaust gases;

y 3 - lack of power.

Between x i And y j there are unclear causal relationships r ij= x iy j, which can be represented as a matrix R with elements r ijϵ. Specific inputs (premises) and outputs (conclusions) can be considered as fuzzy sets A and B on spaces X And Y. The relations of these sets can be denoted as

IN= AR,

where, as before, the sign “o” denotes the rule for the composition of fuzzy conclusions.

In this case, the direction of the conclusions is the opposite to the direction of the conclusions for the rules, i.e. in case of diagnostics there is (specified) a matrix R(expert knowledge), outputs are observed IN(or symptoms) and inputs are determined A(or factors).

Let the knowledge of an expert auto mechanic have the form

and as a result of examining the car, its condition can be assessed as

IN= 0,9/y 1 + 0,1/at 2 + 0,2/at 3 .

It is necessary to determine the cause of this condition:

A =a 1 /x 1 + a 2 /x 2 .

The relationship of the introduced fuzzy sets can be represented as

or, transposing, in the form of fuzzy column vectors:

When using a (max-mix) composition, the last relation is converted to the form

0.9 = (0.9 ˄ α 1) ˅ (0.6 ˄ α 2),

0.1 = (0.1 ˄ α 1) ˅ (0.5 ˄ α 2),

0.2 = (0.2 ˄ α 1) ˅ (0.5 ˄ α 2).

When solving this system, we note first of all that in the first equation the second term on the right side does not affect the right side, therefore

0.9 = 0.9 ˄ α 1 , α 1 ≥ 0.9.

From the second equation we get:

0.1 ≥ 0.5 ˄ α 2 , α 2 ≤ 0.1.

The resulting solution satisfies the third equation, so we have:

0.9 ≤ α 1 ≤ 1.0, 0 ≤ α 2 ≤ 0.1,

those. it is better to replace the battery (α 1 is the battery malfunction parameter, α 2 is the engine oil waste parameter).

In practice, in problems similar to the one considered, the number of variables can be significant, various compositions of fuzzy inferences can be used simultaneously, and the inference circuit itself can be multi-stage. At present, apparently, there are no general methods for solving such problems.