- Notifications
You must be signed in to change notification settings - Fork0
About fuzzy logic using the Maxwell's pendulum
License
Kristal1ik/FuzzyContApp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The need forfuzzy logic
arises in many areas, includingartificial intelligence
,control
anddecision-making
. Fuzziness is an integral part of the real world, so fuzzy logic is actively used to developintelligent systems
capable of processing and analyzing fuzzy information. The main problem of this topic is itsinaccessibility. The fact is that the theory of fuzzy sets is studied at the senior courses of universities, and the materials presented in the public domain include terms, formulas and designations that are incomprehensible toschoolchildren. This project is aimed atpopularizing fuzzy logic by writing an application forAndroid OS
, as well as developing a real prototype of theMaxwell pendulum
(the task is to keep the pendulum within the specified boundaries) to demonstrate the operation of a controller running on fuzzy rules.Next, the functionality that allows the user to study the proposed topic will be described.
"Fuzzy logic is the art of finding beauty in uncertainty" — Lotfi A. Zadeh
To solve this problem, the theory of fuzzy sets is used, since it avoids a large number of calculations in fuzzy modeling problems.Therule base
consists of several fuzzy rules in which each gasified value of the pendulumposition andvelocity corresponds to a fuzzy number. The rule base may look like this:
x is the position of the pendulum;
v is the speed of the pendulum;
w – conclusion.
In the author 's code , the rule looks like this:
x1=Trapezoid([0.09,0.14,0.156,0.175,1]).trapezoid();v1=Trapezoid([0.280,0.351,0.466,0.616,1]).trapezoid();w1=Trapezoid([6.00,9.550,13.550,16.350,1]).trapezoid().
In the example above, there is aTrapezoid
class that has atrapezoid()
method that fuzzifies a number.
Fuzzification
is the process of translating input data into fuzzy data by finding thedegree of belonging of a measurement to a fuzzy set. As input data, we get theposition
of the model (x) and thevelocity
(v). The trapezoidal membership function is given by four numbers and calculated according to the expression:
Oprimization algorithm | Description |
---|---|
basin hopping | A global optimization method used to solve optimization problems that have a complex energy surface. |
genetic algorithm | An optimization method that uses ideas from evolutionary biology and genetics to solve problems. |
particle swarm algorithm | An optimization method that simulates the behavior of a flock of particles in space to find optimal solutions in multidimensional problems. |
This function gets theposition
,speed
andacceleration
from a given time, returnsnew values
by certain transformations.
deff(x,v,w):a= (m*r*r* (g-w))/ (0.5* (m*R*R+maxis*r*r)+ (m+maxis)*r*r)if (x==Randv<0)or (x==landv>0):v=-v* (1-k)xnew=x+v*dt+0.5*dt**2*avnew=v+a*dtifxnew>l:xnew=lifxnew<R:xnew=Rreturnxnew,vnew
The full version of the documentation you can findhere.
Сontrol of the pendulum using the built-in accelerometer with the ability to change the parameters of the model.
Drawing up your rule base using the presented global optimization algorithms in the application (all has a description).
Control of the physical model of the Maxwell pendulum.
The imposition of rules on the mathematical model of the Maxwell pendulum.
- More information about the functionality and work of the physical model you can findhere.
- Java (JDK 11)
- Python 3.10.12
- Android Studio Dolphin (2021.3.1)
- MPAndroidChart
- SciPy (1.10.1)
- Matplotlib (3.6.3)
- MySQL
Project FuzzyContApp is distributed under the MIT license.
About
About fuzzy logic using the Maxwell's pendulum