Fuzzy Logic Controller Simulation

7 次查看(过去 30 天)
Eymen Kosar
Eymen Kosar 2022-4-29
回答: Hari 2024-1-10
Hello,
I designed a fuzzy logic controller for my system, it has 2 inputs which is error and derivative of error.
3 inputs, Kp, Ki, Kd. And all have 7 membership functions so I need to have 49 rules which is not a problem.
But, when it comes to simulate in simulink with 0.001 stepsize, somehow it can not simulate properly.
I mean, it is so slow that I can not see the result of the simulation. It moves forward like in 10e-13 ranks. And sometimes its stuck in a specific time, no matter how much I wait, simulation needs to be stopped by me.
I am using Fuzzy Logic Toolbox and my Matlab version is 2020a. I writed a script to create my FIS. And I dont think the problem is causing from my script or from my system. Because I designed a simple fuzzy and it works properly for a any DC motor model. I want to simulate fastly in my intended system in the first place. Solver and stepsize choice is up to simulink.
So what do you think, What should I change or should I write my own script to simulate FLC, if this slowness causing from the Toolbox?

回答(1 个)

Hari
Hari 2024-1-10
Hi Eymen Kosar,
I understand that you have a fuzzy logic controller (FLC) with two inputs (error and derivative of error) and three parameters (Kp, Ki, Kd), each with seven membership functions and have 49 rules for the FLC. When simulating in Simulink with a step size of 0.001, you are experiencing an issue of simuliation being slow.
Assuming the FLC design is correct and the problem lies with the simulation setup, one possible reason for the slow simulation could be the complexity of the fuzzy inference system (FIS) combined with a small step size, which can significantly increase computation time. Here are some steps you can try to improve simulation speed:
  1. Increase the Step Size: A step size of 0.001 might be too small and causing the solver to take very fine steps through the simulation. Try increasing the step size to see if the simulation speed improves without sacrificing accuracy.
  2. Optimize the FIS: Simplify the FIS if possible. Reducing the number of membership functions or rules can decrease the computational load.
  3. Solver Configuration: Check the solver settings in Simulink. For stiff systems or systems with discontinuities, solvers like 'ode15s' or 'ode23t' might be more appropriate.
  4. Use Fixed-Step Solver: Switching to a fixed-step solver can sometimes improve simulation speed, but be aware that it may affect simulation accuracy.
  5. Profile the Simulation: Use MATLAB's built-in profiler to identify which parts of the simulation are consuming the most time. This can help you pinpoint where optimizations are needed.
  6. Implement FLC in MATLAB Script: If the slowness is due to the Fuzzy Logic Toolbox's simulation blocks, consider implementing the FLC logic in a MATLAB script using functions like "evalfis".
% Assuming 'fis' is your fuzzy inference system and 'input' is a two-element vector [error, dError]
output = evalfis(fis, input);
Refer to the documentation of the Fuzzy Logic Toolbox for more information on creating and simulating fuzzy inference systems:
Fuzzy Logic Toolbox Documentation - https://www.mathworks.com/help/fuzzy/index.html
For choosing and configuring solvers in Simulink, refer the documentation:
To learn more about MATLAB's profiler and how it can be used to analyze performance issues, refer to the documention:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Fuzzy Logic in Simulink 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by