Group Technical Paper

Fuzzy Control System Optimization

Submitted To

The 2012 Academic Year NSF AY-REU Program Part of NSF Type 1 STEP Grant

Sponsored By The National Science Foundation Grant ID No.: DUE-0756921

College of Engineering and Applied Science University of Cincinnati Cincinnati, Ohio

Prepared By

Andrew Janson, Senior, Computer Science Nicklas Stockton, Sophomore, Aerospace Engineering

Report Reviewed By:

______Dr. Kelly Cohen REU Faculty Mentor University of Cincinnati September 9 – December 5, 2013

Introduction Fuzzy logic systems are used as control systems that need to handle the vagueness of the real world. Fuzzy logic can model and control nuances overlooked by the binary logic of conventional computers.1 In fuzzy logic, the truth of any statement becomes a matter of degree. Take for example, determining the timespan of your weekend. As seen in Fig. 1, binary logic only allows a yes/no answer to the question: “Is this day part of my weekend?” However, in the real world we do not consider exactly 12am Saturday to be the start of our weekend. We usually view most of Friday a part of the weekend, determined by when we decide to quit working. Fuzzy logic allows us to specify that most of Friday is considered the weekend as well by assigning it a value of less than one but greater than 0. This distinction gives the fuzzy logic system much more robustness compared to binary logic.

Figure 1. Comparison between binary and multivalued membership of a weekend.1 Many of structural dynamics problems may be represented by a coupled set of second-order dynamic systems. Coupled rigid-body and flexible body dynamics are sensitive to gust loads and low flutter speeds. The best solution is to use active control to augment structural dynamics. The objective for this research project is to develop an effective non-linear active structural control methodology to provide stability in large flexible structures. This goal also takes into consideration performance and managing this stability with minimum cost. An emulation of a minimum time controller using a fuzzy logic universal approximator will be used in order to develop this methodology. The simplified model will consist of two rigid bodies connected by a spring, which must travel a specified distance in minimum time. This is shown in Fig. 2. The output of the fuzzy inference system (FIS) is the force on car 2 that accelerates and decelerates the spring-mass system.

Figure 2. Diagram of two rigid bodies connected by a spring traversing distance L in minimum time.

Materials and Methods Simulation A simulated environment of the model depicted in Figure 2 above is necessary to test the efficacy of the proposed fuzzy inference systems. The constants for the model are the weight (mass) of the cars, the spring constant of the spring connecting the two cars, and the distance to the wall that must be traversed.

The modeled system contains displacement and velocity sensors on each cart. Therefore, the four inputs to the FIS are the distances traveled and the velocities of both car 1 and car 2. The output of the system is the force to be applied to car 2, limited to ±1N. At each time instant the FIS will use the four inputs and determine the force that must be applied to cart 2, governed by a set of fuzzy rules. Input: Output: The initial conditions at time t=0 are that both car 1 and car 2 are at rest and are starting at position zero. The maximum runtime for the simulation was 500 seconds. The final conditions for the simulation stipulate that the distance traveled by the two cars should not exceed 100m and they should be at rest without oscillating. , The acceleration of car 1 is determined by the displacement between the two cars, the spring constant, and the mass of the car. The acceleration of car 2 is also determined by these factors in addition to the output force exerted on the car over its mass. Car 1: Car 2: MATLAB’s ode45 differential equation solver and Fuzzy Tool Box were utilized to simulate the spring- mass system and integrate with the fuzzy controller. Data Evaluation The efficiency of a FIS’s control of the system will be based upon how fast it traverses the distance to the wall and how close the cars settle to the wall without hitting it. The cost function J is then defined by the settling time tf, the time taken to settle the cars within 1m of the wall and the steady state error, the distance between the front car and the wall. The control system that produces the lowest value of J will be proven to be the best solution.

In order to provide a frame of reference for the performance of any control system the theoretical limits of the simulation were calculated to provide a lower bound. This lower bound is the minimum cost that an ideal, optimal solution can obtain. For a rigid body, the mass of the two cars is 3kg and the maximum possible force exerted on car 2 is 1N. From these values the maximum average acceleration of the system is defined as:

From the maximum acceleration of the system the minimum time to traverse the distance to the wall, 100m, can be calculated. There are two different scenarios to consider. (1) Applying maximum force over the entire distance and instantaneously stopping the cars at the wall. This scenario is not feasible, but will serve as the absolute minimum time it will take for the cars to approach the wall.

The velocity is the average velocity of the cars over the distance traversed, 100m. If a constant force of 1N is applied to the cars and the initial velocity is zero, the traversal time can be calculated. , vi = 0

(2) Applying maximum force over half the distance and then applying maximum negative force in the second half to slow the velocity of the cars to zero right at the wall. First Half:

Decelerating back to rest over the next fifty meters takes the same amount of time; therefore the total time taken to reach 100m is 34.46 seconds. However, we want the time taken to reach the 99m mark. The time taken to travel the last meter is 2.45 seconds. Therefore, the best time to reach the 99m mark and reach zero velocity at the wall is:

If the car stops at exactly 100m the cost function evaluates to:

The latter scenario is the more realistic of the two and will be the limit that the control systems will try to achieve. The actual system is a flexible body structure that will oscillate, so the control systems will not reach this rigid body limit. Fuzzy Controller Development After developing the basic structure for the fuzzy controller, an iterative process was developed which varied each of six chosen membership function parameters to a small degree in order to observe the effect on controller performance and cost. The goal was to accumulate enough data to understand which changes would be most beneficial to lowering the cost function output. Out of 300 iterations, one in particular showed promise of dramatically reducing the overall cost and was chosen as a platform from which to develop an optimum solution. Using these new parameters and the intuition gained from studying the data from the other iterations, certain parameters were varied in a more structured manner to obtain an optimum solution. Robustness Test An initial evaluation of each solution’s robustness, ability to perform under varying conditions, was performed. The three solutions tested were the linear system, the best provided fuzzy system, and the fuzzy system developed during this project. To test the robustness of the systems the spring constant was varied ±20% from its nominal value. The simulations were run with this new value of K and the cost function was calculated and compared to the value obtained at nominal K.

Results Analysis of the provided solutions show similar approaches with nearly identical rule bases. The best three solutions given are: Table 1 - Solutions from former students were provided as a reference point of study Student A1 32.550s 99.998766m 0.32797 B2 32.366s 99.984220m 0.35522 C3 42.000s 99.965200m 0.48960

To better understand the dynamics of the plant model, various means of non-fuzzy control are employed. Fine-tuning of switch point (between acceleration and deceleration) and damping strength are key factors in reducing the cost function. The following table shows the linear (non-fuzzy) attempts at a solution:

Table 2 - Non-fuzzy solutions were developed using simple if-else structures Attempt # Switch pt. Damping force 1 17.2896875s 35.707s 99.9988m 0.35956 2 17.2999299s 32.811s 99.9606m 0.40886 3 17.2999299s 32.269s 99.9983m 0.32590

Using the lessons learned from developing a linear solution, formulation of a Fuzzy Inference System (FIS) begins by defining three membership functions for both the and inputs, namely {far,close,veryclose} and {negative,zero,positive} respectively (see figures 1, 2). The output value was constructed of three membership functions, namely {negative,zero,positive} (see figure 3). The rules for this FIS were obtained using the knowledge gleaned from working with the non-fuzzy model. Due to the minimal number of membership functions, few rules were necessary as shown below in table 3. Table 3 - Rule base for FIS Controller

Negative Zero Positive Far Positive Close Positive Zero Negative VeryClose Positive Zero Negative

The FIS herein demonstrated produced the following results. Table 4 – Final results from successful FIS

32.303s 99.999821m 0.32339 Robustness Test Results Tests were run on each controller by varying the spring constant K by 20% and 40%. The linear controller was adjusted to match each new value, and the fuzzy systems were left as they were initially developed. The linear system left unadjusted varied up to 258% while both fuzzy systems varied less than 2% from their nominal costs. Table 5 - Robustness test results. Shown are the cost values obtained from each test and the percent change from nominal values. -40% -20% Nominal 20% 40% 150 N/m 200 N/m 250 N/m 300 N/m 350 N/m Linear 1.1551 0.4817 0.3227 0.7813 0.5835 FIS A 0.3337 0.3269 0.3287 0.3292 0.3257 Project FIS 0.3235 0.3286 0.323 0.3256 0.3245 Linear Adjusted 0.4126 0.3263 0.3227 0.3349 0.3694 Percent Change from Nominal Linear 257.95% 49.27% 0.00% 142.11% 80.82% FIS A 1.52% -0.55% 0.00% 0.15% -0.91% Project FIS 0.15% 1.73% 0.00% 0.80% 0.46% Linear Adjusted 27.86% 1.12% 0.00% 3.78% 14.47% Discussion Significant time was spent on the linear solution to this problem in order to discern what aspects of the system contribute to a minimal cost. It was determined by this process that the final position of far outweighed the settling time in the cost function and much effort was expended in minimizing the distance of from the wall; therefore, the goal became twofold: 1) reach a minimum settling time and 2) minimize final distance from the wall. Initially, this goal of approaching the wall closely was undertaken by attempting to “tweak” the switch point between acceleration and deceleration; the thinking was that if an accurate enough switch point was determined, the damping would bring the system to a stop very near the wall. It was quickly discovered, however, that the damping force is far more important to the final position of the system in the final meter than the switching point. The switch point effectiveness is exhibited in the settling time of the system. As seen in table 2, attempt #2 has a lower settling time due to a more precise switch point, but this improved time does not lead to a lower cost. It was determined from these trials that a damping force needs be proportional to the velocity of the system, but it was unknown by what ratio. By means of trial and error a constant was found which settled the system in the requisite distance, but led to a poor overall cost. From this, it was determined that a proportionality constant which varied over distance was necessary in order to effectively damp the oscillations in minimum time. This discovery led to the damping force, as shown in table 2. This force, which increases in magnitude as the system approaches the 100m wall, drastically decreased the value of the cost function because it allows the cart to approach the wall more closely before damping is completed. Having gained the insight from working with a linear control structure, an attempt was then made to develop a FIS structure. Using one of the provided solutions2 as a base, changes were made to reduce the number of membership functions and to reduce the rule base. Because critical damping does not need to occur until the system is very close to the wall, it was decided to consider the system as a rigid body until it at least reached the settling envelope of 1m from the wall, thus the switch point from “far” to “close” is a sharp transition much like a linear solution would produce. The “veryclose” function was given the bounds [99.9 100.1] in order to reduce all of the damping to the final .1m of the system’s movement. The membership functions for the data from were made to be symmetrical for ease of adjustment; being centered on zero, only one parameter was tuned. Again by trial-and-error, the cost was quickly reduced to a near-optimal 0.32339. As can be seen in figure 4, the amplitude of the damping force is kept at a minimum due to these tuned membership functions. The robustness test has shown that fuzzy systems accommodate variations in system parameters. Though the linear solution was finely-tuned to provide a low-cost solution, it proves to be system specific and performs poorly under varied conditions. Conclusion Fuzzy systems are a low-cost, robust control option for active control of flexible structures. It has been shown that a fuzzy system outperformed the nominal linear solution in every test case and did so with less developmental effort expended. The fuzzy system provides near-optimal control even under different conditions than were used in development. This demonstrates the system-independent characteristics of fuzzy control. The control methodology developed from this research can be summarized as follows: 1. Determine in which frames the system behaves like a rigid or flexible body 2. Treat system as flexible body only in those frames where it behaves as such 3. Tune flexible control mechanism to minimize cost The optimal solution arose from the combination of a number of factors. First, the FIS developed in this research provided oscillatory damping in minimal time. This allowed the controller to exert most of its force in linear fashion, accelerating and decelerating the system as a rigid body. Due to optimal damping control, damping was exerted only as the system approached the wall. The extent of the damping increased in proportion to the distance from the wall while factoring in the decrease in velocity of the cart system. Due to the specific application of damping force, more time is allowed for the system to be accelerated and decelerated, which reduces settling time. This results in a system which performs optimally. References 1. Vick, Tyler. (2013). “Fuzzy Logic,” AEEM 6096 Report, College of Engineering and Applied Sciences, University of Cincinnati, Cincinnati, Ohio 2. Walker, Alex. (2013). “Fuzzy Control Systems,” AEEM 6096 Report, College of Engineering and Applied Sciences, University of Cincinnati, Cincinnati, Ohio 3. Carson, Aaron. (2013). “Two Mass System: Fuzzy Logic Control,” AEEM 6096 Report, College of Engineering and Applied Sciences, University of Cincinnati, Cincinnati, Ohio Nomenclature a = acceleration d = distance f = force F(t) = force at time t J = cost function K = spring constant L = distance to wall m1 = mass of car 1 m2 = mass of car 2 t = time tf = settling time v = velocity vi = initial velocity x1 = position of car 1 x2 = position of car 2 1 = velocity of car 1 2 = velocity of car 2 1 = acceleration of car 1 2 = acceleration of car 2 y(t) = input to FIS at time t