we Journal of JET v°lume 8 (2015) p.p. 35-50 Issue 1, September 2015 Energy Technology www.fe.um.si/en/jet.html SYSTEM CONTROL IN CONDITIONS OF FUZZY DYNAMIC PROCESSES UPRAVLJANJE SISTEMA V POGOJIH MEHKIH DINAMIČNIH PROCESOV Janez UsenikR Keywords: dynamic system, control, random process, fuzzy reasoning, neuro-fuzzy training Abstract In this article, a mathematical model of controlling the system in conditions of fuzzy processes is presented. Such a system can also be a power supply system. Analytical approaches that can be used to describe the mutual impact of output and stocks (additional capacities) on hierarchically distributed occurrence/usage/variation or demand already exist. We add dynamics to the system with the use of continuous and discrete dynamic processes, which are of a random (stochastic) form. The dynamic discrete model of control for this system is built with a system of difference equations, and the dynamic continuous model is built with a system of differential equations. These systems of equations can be solved with a one-part z-transform in discrete situations in with Laplace transform in the continuous systems. Fuzzy system control follows a continuous and discrete stochastic mathematical closed-loop model of control of stocks (additional capacities) in production systems. The fuzzy model is demonstrated with a numerical example. Povzetek V članku je predstavljeno upravljanja sistema v pogojih mehkih dinamičnih procesov. Takšen sistem je lahko tudi energetski sistem. Razviti so analitični pristopi, s katerimi opišemo medsebojni vpliv proizvodnje ter zalog (dodatnih kapacitet) na hierarhično porazdeljeno prostorsko dogajanje/ porabo/spremembo oziroma povpraševanje. V sistem vpeljemo dinamiko, kar storimo z uporabo zveznih in diskretnih dinamičnih procesov, ki so zaradi zahteve po čim tesnejšem približku opisova- R Corresponding author: Prof. Janez Usenik, PhD., University of Maribor, Faculty of Energy Technology, Tel.: +386 40 647 689, Fax: +386 7 620 2222, Mailing address: Hočevarjev trg 1, SI8270 Krško, Slovenia, e-mail address: janez. usenik@um.si JET 35 Janez Usenik JET Vol. 8 (2015) Issue 1 nja dejanskega sistema, slučajnostne (stohastične) narave. Dinamični diskretni model upravljanja takšnega sistema izgradimo s sistemom diferenčnih enačb, zvezni model pa opišemo s sistemom diferencialnih enačb. Za reševanje uporabimo enostrano z-transformacijo pri diskretnih sistemih in Laplaceovo transformacijo pri zveznih sistemih. Mehko upravljanje sistema izhaja iz zveznega in diskretnega slučajnostnega matematičnega modela upravljanja zalog v proizvodnem sistemu. V članku je prikazan mehki pristop, ki ga vpeljemo z uporabo dvofaznega sistema mehkega sklepanja in pomeni približek zaprtozančnemu sistemu upravljanja. Mehki algoritem je ilustriran z numerič-nim primerom. 1 INTRODUCTION A production system (power supply, logistics, traffic, etc.) is a complex dynamic system. If we could create a theoretical mathematical dynamic model of it, we would have to take into consideration a great many variables and their interrelationships. However, with methods of logical and methodological decomposition, every system may be divided into a finite set of simpler subsystems, which are then studied and analysed separately, [1]. A model of optimal control is determined with a system, its input/output variables, and the optimality criterion function. The system represents a regulation circle, which generally consists of a regulator, a control process, a feed-back loop, and input and output information. In this article, dynamic systems will be studied. The optimality criterion is the standard against which the control quality is evaluated. The term 'control quality' means the optimal and synchronized balancing of planned and actual output functions, [2, 3]. Let us consider a production model in a linear stationary dynamic system in which the input variables indicate the demand for products manufactured by a company. These variables, i.e. the demand, in this case, can either be a one-dimensional or multi-dimensional vector functions or they can be deterministic, stochastic or fuzzy. In this article, a system with fuzzy variables is presented. 2 DEFINING THE PROBLEM Demand for a product should be met, if possible, by the current production. The difference between the current production and demand is the input function for the control process; the output function is the current stock/additional capacities. When the difference is positive, the surplus will be stocked, and when it is negative, the demand will also be covered by stock. In the case of a power supplier, stock in the usual sense does not exist (such as cars or computers, etc.); energy cannot be produced in advance for a known customer, nor can stock be built up for unknown customers. The demand for energy services is neither uniform in time nor known in advance. It varies, has its ups (maxima) and downs (minima), and can only be met by installing and activating additional proper technological capacities. Because of this, the function of stock in the energy supply process is held by all the additional technological potential/capacities large enough to meet periods of extra demand. The demand for energy services is not given and precisely known in advance. Demand is not given with explicitly expressed mathematical functions; it is a random process for which the statistical indicators are known. The system input is the demand for the products/services that a given subject offers. Any given demand should be met with current production. The difference between the current 36 JET System control in conditions of fuzzy dynamic processes capacity of production/services and demand is the input function for the object of control. The output function measures the amount of unsatisfied customers or unsatisfied demand in general. When this difference is positive, i.e. when the power supply capacity exceeds the demand, a surplus of energy will be made. When the difference is negative, i.e. when the demand surpasses the capacities, extra capacities will have to be added or, if they are not sufficient, extra external purchasing will have to be done. Otherwise, there will be delays, queues, etc. In the new cycle, there will be a system regulator, which will contain all the necessary data about the true state and that will, according to given demand, provide basic information for the production process. In this way, the regulation circuit is closed. With optimal control, we will understand the situation in which all customers are satisfied with the minimum involvement of additional facilities. On the basis of the described regulation circuit, we can establish a mathematical model of power supply control, i.e. a system of difference equations for discrete systems or a system or differential equations for continuous systems, [2]. For this model, the regulation circuit is given in Figure 1, [4]. The task is to determine the optimum production and stock/capacities so that the total cost will be as low as possible, [3]. Figurel: Regulation circuit of the power supply system 3. A MATHEMATICAL MODEL OF THE SYSTEM CONTROL In the building of the model, we will restrict ourselves to a dynamic linear system, in which the input is a random process with known statistical properties. The system provides the output, which is, due to the condition of linearity, also a random process. These processes could be continuous or discrete. The model and its solution for continuous processes is obtained in [1] and for discrete processes in [5]. 3.1 Continuous processes Notations for t £ 0 are as follows: Z(t) - additional capacities (stocks) at a given time t, u(t) - production at time t, d(t) - demand for product at time t, X - lead time, v (t) - delivery to storehouse at time t, Q(t) - criterion function, complete costs. JET 37 Janez Usenik JET Vol. 8 (2015) Issue 1 Let Z(t), u(t) and d(t) be stationary continuous random variables/functions; they are characteristics of continuous stationary random processes. Now the system will be modelled with the known equations [1]: 0 In the last equation, the function G(t) is the weight of the regulation that must be determined at optimum control, so that the criterion of the minimum total cost is satisfied. The lead time X is the time period needed to activate the additional capacities in the power supply process. Assuming that the input variable demand is a stationary random process, we can also consider production and stock/additional capacities to be stationary random processes for reasons of the linearity of the system. Let us consider the functions Z(t), u(t) and d(t) to be continuous stationary random processes. From this point of view, let us express the total cost, the minimum of which we are trying to define, with the mathematical expectation of the square of the random variables Z(t) and u(t) : Q(t)=KZE(Z2 (t))+KuE(u2 (t)) (3.4) Equations represent a linear model of control in which the minimum of the mean square error has to be determined. KZ and Ku are positive constant factors, attributing greater or smaller weight to individual costs. Both factors have been determined empirically for the product and are therefore in the separate plant [9]: KZ - constant coefficient, dependent on activated resources, derived empirically, Ku - constant coefficient, dependent on performed services and derived empirically. 3.2 Discrete processes Similar to the continuous system, we have in similar notations in the discrete system. Let us denote: (3.1) (3.2) (3.3) 38 JET System control in conditions of fuzzy dynamic processes Z (k) - activated facilities (resources, stocks) at given moment (output), u (k) - the amount of services performed (production) at a given moment, d (k) - the demand for services at a given moment (input), k - time elapsed between the moment the data are received and the carrying out of a service, Q (k) - criterion function, complete costs, KZ - constant coefficient, dependent on activated resources, derived empirically, Ku - constant coefficient, dependent on performed services and derived empirically, G (k) - operator (weight) of regulation. k e {0,1, 2,...} The dynamic linear system will then be modelled with the following difference equations: Z (k)-Z (k-1)=4v (k)-d (k)],WeR+ (3.5) v(k) = u(k — k), k e N (3.6) u (k ) = —£ G (k) Z (k — K) (3.7) k=0 Q(k) = KzE{(Z2 (k))} + KuE{(u2(k — 1))} minimum (3.8) 4 FUZZY SYSTEM Construction of a fuzzy system takes several steps [6], [7]: selection of decision variables and their fuzzification, establishing the goal and the construction of the algorithm (base of rules of fuzzy reasoning), inference and defuzzification of the results of fuzzy inference. A graphic presentation of a fuzzy system is given in Figure 2, [5]. The entire system demonstrates the course of inference from input variables against output; it is built on the basis of 'if-then' fuzzy rules. The fuzzy inference consists of three phases: 1. Fuzzification, 2. Fuzzy inference, 3. Defuzzification. JET 39 Janez Usenik JET Vol. 8 (2015) Issue 1 Figure 2: The fuzzy system In our closed-loop model we designed a two-phase fuzzy system, given in Figure 3. Figure 3: The two-phased fuzzy system Let us assume that the demand d depends on [1]: ■ the market area, ■ the density of the area, ■ the price, ■ the season, and ■ the uncertainty. The demand is, in fact, the basic variable, on which the behaviour of all retailers depends. We assume that all expressions are fuzzy variables, market area, density of the area, price, season and uncertainty are input fuzzy variables, and demand is an output fuzzy variable in the first phase and in the same time also an input fuzzy variable for the second phase, Figure 4. 40 JET System control in conditions of fuzzy dynamic processes Figure 4: The two-phased fuzzy system with fuzzy demand in the first phase 4.1 Fuzzification In the fuzzification phase, fuzzy sets for all fuzzy variables (input and output) must be defined, as well as their membership functions. Every fuzzy variable is presented by more terms/fuzzy sets. In this system, there are eight fuzzy variables: the market area, the density of the area, the price, the season, the uncertainty and the demand in the first phase and the demand, and the production and the capacity in the second phase. The fuzzy variable demand is the output of the first rules block while simultaneously being the input for the second phase (i.e. rules block 2). Fuzzy sets are given by terms below. ■ In the first rules block: a) the input fuzzy variable MARKET AREA is represented by: SMALL, BIG, b) the input fuzzy variable DENSITY OF THE AREA is represented by: WEAK, MEDIUM, STRONG, c) the input fuzzy variable PRICE is represented by: LOW, MEDIUM, HIGH, d) the input fuzzy variable SEASON is represented by: LOW, HIGH, e) the input fuzzy variable UNCERTAINTY is represented by: SMALL, MEDIUM, BIG, VERY_BIG, f) the output fuzzy variable DEMAND is represented by: VERY_LOW, LOW, MEDIUM, HIGH, EXTREMELY_HIGH. JET 41 Janez Usenik JET Vol. 8 (2015) Issue 1 ■ In the second rule block: g) the input fuzzy variable DEMAND is represented by: VERY_LOW, LOW, MEDIUM, HIGH, EXTREMELY_HIGH. h) the input fuzzy variable PRODUCTION is represented by: LOW, MEDIUM, HIGH, i) the output fuzzy variable CAPACITY is represented by: VERY_LOW, LOW, MEDIUM, HIGH, EXTREMELY_HIGH. This fuzzy system is a two-phased system. The final output is CAPACITY (i.e. STOCKS) which depends on inputs DEMAND and PRODUCTION. This means that the control system is, in fact, the closed-loop system. For every fuzzy set and for every fuzzy variable, we have to create membership functions, see Figures 5 to 12. On the x-axis, the measures are given in units such as the number of customers, EUR, EUR/ kWh, MWh and so on, depending on the data. On the y-axis, membership is measured for every possible fuzzy variable and for every fuzzy set. Due to the simplicity in this model, we suppose that all units for all fuzzy variables are given in relative measure, i.e. percentages from 0 to 100. Of course, the expert knows what, for example, 30% for 'market area' or 80 % of the 'price' etc. means. 42 JET System control in conditions of fuzzy dynamic processes 1.0 SMALL BIG - 04 0.2 < - - 0 U 100 \ / \ / X / ..... X 20 45 Units Figure 5: MBF of 'MARKET' Figure 6: MBF of 'DENSITY' LGW MEDIUM HIGH \ -- 1 N N 0.4 > > ---- X -v. X ■5 70 100 Unit? Figure 7: MBF of 'PRICE' Figure 8: MBF of 'SEASON' Figure 9: MBF of ' UNCERTAINTY ' Figure 10: MBF of 'DEMAND' Figure 11: MBF of ' PRODUCTION ' VERY_L0W LOW MEDIUM HIGH EXTR_ HIGH / / X / / \ \ / \ . X \ \ -10 Units Figure 12: MBF of ' CAPACITY ' JET 43 Janez Usenik JET Vol. 8 (2015) Issue 1 4.2 Fuzzy inference Fuzzy inference is a process in which a certain conclusion is derived from a set of fuzzy statements. In addition to linguistic variables, there are basic widgets of a fuzzy logic system as well as sets of rules that define the behaviour of a system. A single fuzzy rule (implication) assumes the form: if x is A, then y is B, where A and B are linguistic values defined by fuzzy sets on the universes of discourse X and Y, respectively. The if part of the rule is called the antecedent or premise, while the then part is called the consequent or conclusion. Variables x and y are defined by the sets X and Y. With the assembly of a base of rules, the question always appears of how to obtain the rules. Usually, this is written down as a base of knowledge within the framework of 'if-then' rules by an expert for a definite system based on his own knowledge and experiences. An expert must also define entry and exit fuzzy functions, as well as their shape and position. However, it often occurs that the expert's knowledge is not sufficient, and he cannot define an adequate number of rules. Therefore, the procedures of forming or supplementation to the base of rules based on available numerical data were developed. With fuzzy inference, we must put all values and facts in a definite order and connect them to the procedure of inference execution, so that will be feasible do so with a computer. This order is given as a list or system of rules. In our work, we applied FuzzyTech software (FuzzyTech, 2001), [8]. In accordance with this software tool, 144 rules in the first phase (Rule block 1) and 15 rules in the second phase (Rule block 2) were automatically created. Some of them are represented in Tables 1 and 2. Table 1: Some rules Rules of the Rule Block 'RB1' IF THEN DENSITY MARKET PRICE SEASON UNCERTAIN^ DoS DEMAND WEAK SMALL LOW LOW SMALL 0.97 LOW WEAK SMALL MEDIUM HIGH SMALL 1.00 LOW WEAK SMALL HIGH LOW MEDIUM 0.64 VERY_LOW WEAK SMALL HIGH HIGH VERY_BIG 1.00 LOW WEAK BIG MEDIUM LOW BIG 1.00 LOW WEAK BIG HIGH HIGH BIG 1.00 MEDIUM MEDIUM SMALL LOW LOW SMALL 1.00 LOW MEDIUM SMALL MEDIUM HIGH BIG 1.00 MEDIUM MEDIUM SMALL HIGH LOW MEDIUM 0.75 LOW MEDIUM BIG LOW LOW VERY_BIG 1.00 HIGH MEDIUM BIG HIGH HIGH MEDIUM 0.63 MEDIUM MEDIUM BIG HIGH HIGH VERY_BIG 0.20 HIGH STRONG SMALL LOW LOW SMALL 1.00 MEDIUM 44 JET System control in conditions of fuzzy dynamic processes IF THEN STRONG SMALL LOW HIGH MEDIUM 1.00 HIGH STRONG SMALL HIGH LOW MEDIUM 1.00 LOW STRONG SMALL HIGH LOW VERY_BIG 1.00 MEDIUM STRONG BIG MEDIUM HIGH MEDIUM 0.98 HIGH STRONG BIG MEDIUM HIGH VERY_BIG 0.73 EXTR_HIGH Table 2: Rules of the Rule Block 'RB2' IF THEN DEMAND PRODUCTION DoS CAPACITY VERY_LOW LOW 1.00 VERY_LOW VERY_LOW MEDIUM 1.00 LOW VERY_LOW HIGH 1.00 LOW LOW LOW 1.00 LOW LOW MEDIUM 1.00 LOW LOW HIGH 1.00 MEDIUM MEDIUM LOW 1.00 LOW MEDIUM MEDIUM 1.00 MEDIUM MEDIUM HIGH 1.00 HIGH HIGH LOW 1.00 MEDIUM HIGH MEDIUM 1.00 HIGH HIGH HIGH 1.00 HIGH EXTR_HIGH LOW 1.00 HIGH EXTR_HIGH MEDIUM 1.00 HIGH EXTR_HIGH HIGH 1.00 EXTR_HIGH 4.3 Defuzzification Results from the evaluation of fuzzy rules is fuzzy. Defuzzification is the conversion of a given fuzzy quantity to a precise, crisp quantity. In the procedure of defuzzification, fuzzy output variables are changed into crisp numerical values. There are many procedures for defuzzification, which give different results. The most frequently method used in praxis is CoM-defuzzification (the Centre of Maximum). As more than one output term can be accepted as valid, the defuzzification method should be a compromise between different results. The CoM method does this by computing the crisp output as a weighted average of the term membership maxima, weighted by the inference results, [6]. CoM is a type of compromise between the aggregated results of different terms j of a linguistic output variable, and is based on the maximum Yj of each term j. JET 45 Janez Usenik JET Vol. 8 (2015) Issue 1 As already mentioned, there are many methods of defuzzification that generally give various results. In our example, our model is created by FuzzyTech 5.55i software, and we use the Centre of Maximum (CoM) defuzzification method. 4.4 Optimisation When the system structure is set and all elements of the system are defined, the model must also be tested and checked for its fit to data and for whether it produces the desired results. In our case, we have tasks with relatively simple optimization, because we have limited the problem to concrete conditions. We simplified the system so that it is well defined and gives the desired results. During optimization, we verify the entire definition area of input data. For each point of the definition area, we check whether the system is giving the desired result and if this result is logical. If we are not satisfied with the results, we can change any of the membership functions or any of the fuzzy inference rules. For optimisation, there are various methods, such as trial and error, or using graphic tools that can visually demonstrate system activity. Such a graphic demonstration shows us the response to a change of data or change in the definition of the system elements, [8]. One of the most efficient methods is using neural nets during the neuro-fuzzy training to obtain good and regular results. 4.5 Neuro-fuzzy training To optimise our results and to obtain a stable and robust fuzzy model, we have to perform neuro-fuzzy training, [9], [10]. At this point, help from an expert who knows the system very well is required. Suppose that we have a base of knowledge and we can start our neuro-fuzzy procedure. We have used FuzzyTech software's option for neuro-fuzzy learning in the first phase, [1]. Making 500 iterations in the phase of training (35 samples) and 500 iterations in the phase of checking (also 35 samples), we have changed the shapes of the membership functions for all fuzzy variables and also changed the weights (DoS) for some rules for fuzzy inference in Rules block 1. When comparing expert and fuzzy results, the statistical data are the following: the average deviation (expert results vs. fuzzy results) is 1.74%, 16 data points (samples) between 0 and 1%, 9 data points between 1 and 2%, 5 between 2 and 4% and 5 data points between 4 and 8%. 5 NUMERICAL EXAMPLE When we have a robust fuzzy system, we can start numerical simulations. Using FuzzyTech software, we can simulate all possible situations interactively. Some results in Phase 1 are given in Table 3. The first five columns represent input fuzzy variables; the last column 'demand' as output of the fuzzy system is divided into two sub-columns. In the first, we can see crisp values of demand before neuro-fuzzy training and, in the second, values after neuro-fuzzy training. 46 JET System control in conditions of fuzzy dynamic processes Table 3: Some numerical results in phase 1 Demand Density Market Price Season Uncertainty before training after training 0 0 100 0 0 0 1 50 50 50 50 50 60 50 100 100 1 100 100 100 100 30 30 80 80 50 50 42 70 50 90 20 90 45 58 60 100 40 50 50 77 73 60 60 30 50 50 71 67 70 70 90 90 70 72 76 90 50 100 100 100 74 78 50 30 80 20 20 31 28 19 33 49 66 66 53 52 39 70 60 60 50 52 54 78 78 39 78 78 88 80 Of course, in the table, we merely have some results, but with the interactive simulation that is possible with FuzzyTech software, we can simulate every situation. The quality of the results depends on the expert who prepares a data file for the neuro-training procedure. After optimization of the first subsystem (Phase 1), we can also run the fuzzy system in Phase 2. Some numerical results are presented in Table 4, in which the fuzzy variables of density, market, price, season, uncertainty and production are inputs, and the fuzzy variable capacity is the output of a two-phased fuzzy system. The fuzzy variable demand is an output in the first subsystem while simultaneously being an input to the second subsystem, i.e. the second phase in the entire fuzzy system. JET 47 Janez Usenik JET Vol. 8 (2015) Issue 1 Table 4: Some numerical results in two-phased fuzzy system Density Market Price Season Uncertainty Production Capacity 90 98 10 100 95 90 116 50 50 50 50 50 50 50 100 100 1 100 100 100 90 30 30 80 80 50 50 34 70 50 90 20 90 90 68 60 100 40 50 50 80 90 60 60 30 50 50 80 60 70 70 90 90 70 70 72 90 50 100 100 100 70 82 50 30 80 20 20 30 23 20 40 40 60 50 80 65 40 70 60 60 50 100 70 78 78 39 78 78 10 41 6 CONCLUSION A theoretical mathematical model of system control can also be used in an energy technology system and in all its subsystems. Input-output signals are discrete or continuous functions. For operations, many conditions have to be fulfilled. During the control process, a great deal of information must be processed, which can only be done if a transparent and properly developed information system is available. The solution, i.e. optimal control, depends on many numerical parameters. All data and numerical analysis can only be processed into information for control if high quality and sophisticated software and powerful hardware are available. For the study of the structure, interrelationships and operation of a phenomenon with system characteristics, the best method is the general systems theory. When we refer to system technology as a synthesis of organization, information technology and operations, we have to consider its dynamic dimension when creating a mathematical model. As each such complex phenomenon makes up a system, the technology in this article is again dealt with as a dynamic system. Elements of the technological system compose an ordered entity of interrelationships and thus allow the system to perform production functions. During the control process, a great deal of information must be processed, which can only be done if a transparent and properly developed information system is available. Models of optimum control can also be used in the power station system. The fuzzy approach in creating the mathematical model with which we are describing the system can be successful in the case that we have a good robust base of expert knowledge. With appropriate computer tools, an algorithm can be used for concrete numerical examples. 48 JET System control in conditions of fuzzy dynamic processes References [1] J. Usenik: Mathematical model of the power supply system control. Journal of Energy Technology, Aug. 2009, vol. 2, iss. 3, str. 29-46 [2] J.J. DiStefano, A.R. Stubberud, I.J.Williams: Theory and Problems of Feedback and Control Systems, McGraw-Hill Book Company, 1987 [3] J. Usenik: Control of Traffic System in Conditions of Random or Fuzzy Input Processes, Prom-et-Traffic-Traffico, 2001, Vol. 13 no. 1, pp. 1-8 [4] J. Usenik: Fuzzy dynamic linear programming in energy supply planning, Journal of energy technology, 2011, vol. 4, iss. 4, pp. 45-62 [5] J. Usenik, M. Repnik: System control in conditions of discrete stochastic input processes, Journal of energy technology, Feb. 2012, Vol. 5, iss. 1, pp. 37-53 [6] J. T. Ross: Fuzzy Logic with Engineering Applications, second edition, John Wiley&Sons Ltd,The Atrium, Southern Gate, Chichester, 2004 [7] H. J. Zimmermann: Fuzzy Set Theory - and Its Applications, 4th edition, Kluwer Academic Publishers, Dordrecht, 2001 [8] FuzzyTech, Users Manual, 2001, INFORM GmbH, Inform Software Corporation [9] J. Usenik, M. Bogataj: A fuzzy set approach for a location-inventory model.Transp. plann. technol., 2005, vol. 28, no. 6, pp. 447-464 [10] J. Usenik, T. Turnsek: Modelling conflict dynamics in an energy supply system. Journal of energy technology, Aug. 2013, Vol. 6, iss. 3, pp. 35-45 JET 49