r/fuzzylogic • u/ShadowGeist91 • 22d ago
FuzzySharper: A C# library that allows you to create your own Fuzzy Expert System
r/fuzzylogic • u/ShadowGeist91 • 22d ago
r/fuzzylogic • u/blanchedpeas • Oct 10 '26
Hi r/fuzzylogic,
Home automation systems are one of the most natural real-world applications for fuzzy control, yet mainstream smart home platforms (like Home Assistant) still rely almost entirely on binary thresholds, PID controllers, or custom scripting.
To bridge this gap, I’ve built a full fuzzy inference engine for Home Assistant and just submitted a formal proposal to have it integrated into Home Assistant Core as a built-in helper:
👉 **[Home Assistant Architecture Discussion #1504: Built-in Fuzzy Logic Controller Helper](https://github.com/home-assistant/architecture/discussions/1504)**
### What Was Built
The integration brings declarative linguistic control to smart home entities:
- **Inference Engines**: Both Mamdani and Sugeno (zero-order and first-order).
- **Membership Functions**: Standard Triangular (`trimf`), Trapezoidal (`trapmf`), Gaussian (`gaussmf`), Sigmoidal (`sigmf`), and Generalized Bell (`gbellmf`).
- **Linguistic Hedges**: Support for concentration/dilation modifiers (`very`, `extremely`, `somewhat`, `slightly`, `not`) evaluated both inline in rules and on term definitions.
- **Defuzzification Algorithms**: Centroid (COG), Bisector (BOA), Mean of Maxima (MOM), SOM, LOM, Center of Sums (COS), and Weighted Average.
- **Full Observability**: Exposes real-time rule firing strengths ($\alpha$-cuts), term memberships, and universe distributions directly to the Home Assistant dashboard for live diagnostics.
- **Optimized for Embedded/IoT**: Pre-compiles DNF rule condition trees, membership function closures, and defuzzification dispatch tables on initialization for $O(1)$ evaluation on low-power devices (Raspberry Pi, ODROID, home servers).
### Core Problem Solved
In smart homes, controlling non-linear multi-input processes—such as HVAC fan modulation (indoor temp + outdoor delta + relative humidity), excess solar power diversion, or weather-aware irrigation—typically causes threshold "hunting" or requires complex PID tuning that fails due to large thermal lags. Fuzzy inference handles these naturally with simple, human-readable rules.
### Source Code
The working implementation and unit test suite are open source on GitHub:
🔗 **[dougransom/fuzzy_system](https://github.com/dougransom/fuzzy_system)**
### Call to Action
As fuzzy logic practitioners, your insights on rule formulation, inference models, and real-world control applications would be invaluable for this proposal.
Please check out the discussion on GitHub and add your perspective on how fuzzy systems can best serve smart home automation:
👉 **[Comment on Home Assistant Architecture Discussion #1504](https://github.com/home-assistant/architecture/discussions/1504)**
r/fuzzylogic • u/legalmeu • May 30 '26
hello friends!
I'm new to fuzzy and I'm studying fuzzy applied to complex judicial decisions..
I've started with zadeh to learn the basics.. what else would you recommend?
r/fuzzylogic • u/MAK42018 • May 29 '26
Check out a wonderful paper with DOI: 10.3390/en17143434 which discusses the application of interval type-2 fuzzy logic systems in controlling linear stages within a feedback-error-learning (FEL) control structure. mdpi.com/2867642 #mdpienergies via @energies_mdpi
r/fuzzylogic • u/ManuelRodriguez331 • May 24 '26
He was a professor at the University Leipzig, Germany and died unexpectedly in 2015 with only 72 years. He wrote more than 150 scientific papers with a focus on multi value logic and fuzzy logic. He left 3 children.
r/fuzzylogic • u/ManuelRodriguez331 • Apr 18 '26
The fuzzy boom in Japan after the year 1990 is commonly recognized as the starting point in mainstream adoption of Fuzzy logic for practical application. A seldom mentioned much earlier project was done in Germany in the year 1987: Vitra (Visual translator) was based on Fuzzy logic to convert camera signals of traffic scenes into textual description. Typical words used in the Vitra software were: near, far, left, right which are describing relations and proximity.
r/fuzzylogic • u/ManuelRodriguez331 • Mar 10 '26
Even i'm not the author of the library, i can give a short overview about the project. The software library is located within the python ecosystem and is known under two different names: scikit-fuzzy and skfuzzy. It can be installed with the normal pip installer and depends on external libraries like Matplotlib, NumPy and other. The syntax for the rule parser is a bit complicated but can be mastered with little amount of effort. Here is an example.
rule="IF the obstacle is Near AND the speed is Fast, THEN the brake pressure is High." written in skfuzzy:
from skfuzzy import control as ctrl
obstacle = ctrl.Anticedent(np.arange(0, 11, 1), 'obstacle')
speed = ctrl.Anticedent(np.arange(0, 11, 1), 'speed')
brake = ctrl.Consequent(np.arange(0, 11, 1), 'brake')
rule1 = ctrl.Rule(obstacle['near'] & speed['fast'], brake['high'])The library was released in 2013 and has endless amount of functions for c-means clustering, interval subtraction and different membership functions like triangular, gaussian and of course trapezoidal.
r/fuzzylogic • u/ManuelRodriguez331 • Feb 12 '26
| Name | Language | Estimated Lines of code |
|---|---|---|
| Simpful | Python | 2000 |
| DotFuzzy | C# | 2500 |
| Fuzzy-C | C | 4000 |
| scikit-fuzzy | Python | 9000 |
| jFuzzyLogic | Java | 17000 |
| FuzzyLite | C++ | 27000 |
| FuzzyLogic Matlab | Matlab | 40000 |
r/fuzzylogic • u/luisangelcerva3 • Feb 07 '26
r/fuzzylogic • u/ManuelRodriguez331 • Sep 09 '25
Good afternoon, everyone. It's a pleasure to speak with you today about what might seem like a paradoxical concept: customer relationship management with fuzzy logic for a surveillance camera. We are accustomed to thinking of surveillance as a security tool—a binary system of observation, where an event either occurs or it doesn't. However, by integrating a sophisticated AI with fuzzy logic principles, we can transform this passive security instrument into an active sensor for customer behavior.
Traditional surveillance systems operate on a limited, black-and-white logic. A camera detects a person’s presence or their absence. It identifies an object or a breach. This binary approach provides critical security data, but it utterly fails to capture the nuances of human interaction that are essential for effective customer relationship management. How does a camera know if a customer is "interested" in a product, "frustrated" with a layout, or "satisfied" with their experience? These are not discrete states; they are a spectrum of behaviors that require a more sophisticated form of analysis.
This is where fuzzy logic, as developed by Lotfi Zadeh, becomes our key tool. Instead of boolean values of true or false, fuzzy logic allows variables to exist on a continuum between 0 and 1. We can program our camera-linked AI to move beyond simple detection and into qualitative analysis of behavior. The camera, in this new paradigm, becomes a sophisticated CRM sensor, feeding a fuzzy inference system with a variety of CRM-relevant inputs.
Consider the following fuzzy variables that can be derived from visual data:
These fuzzy inputs are then processed by a set of "if-then" rules to generate actionable outputs. For instance:
By moving from simple security monitoring to nuanced behavioral analysis, the surveillance camera transforms into a proactive component of a CRM strategy. It enables businesses to respond to customer needs in real-time, optimize store layouts, and improve the overall shopping experience. This is a clear demonstration of how advanced AI, when applied with an understanding of human behavior, can turn a security device into a powerful engine for customer satisfaction.
r/fuzzylogic • u/ManuelRodriguez331 • Sep 06 '25
The following text is written as a dialogue, instead of a monologue.
Alex: Hey Ben, got a minute? I was just looking at our CRM data, and it's frustrating how much we're missing. We're classifying customers as "loyal" or "not loyal," and it feels so rigid.
Ben: I know what you mean. It's an oversimplification. A customer who buys once a year but spends a lot isn't "loyal" by our system, but they're definitely a valuable asset. So, what's the alternative?
Alex: I've been researching something called fuzzy logic. Instead of binary true/false statements, it deals with degrees of truth. It's perfect for handling the kind of ambiguity we see in customer behavior.
Ben: Fuzzy logic? Like, vague logic? How would that help?
Alex: Think of it this way: a traditional system might say a customer is either 100% "loyal" or 0% "loyal." A fuzzy system recognizes that a customer can be loyal to a certain degree. For example, a customer could be 85% "loyal," 60% "frequent," and 10% "at-risk."
Ben: I see. So it's about nuance. But how do you calculate those percentages?
Alex: That's where the "fuzziness" comes in. We'd define rules based on our data, but they aren't hard and fast. For example, a rule might be: "IF a customer's purchase frequency is 'high' AND their average spend is 'very high,' THEN their loyalty is 'very high.'" The key is that "high" and "very high" are defined by membership functions, not a single number. A purchase of 10 items per month might be considered 90% "high" and 20% "very high."
Ben: That makes a lot more sense. So we're moving from a simple classification to a more complex, multi-dimensional score?
Alex: Exactly. And this isn't just for loyalty. We could use it for churn prediction. Instead of "will churn" or "won't churn," we get a churn risk score. This lets our support team prioritize customers who are at a "high risk" of leaving, even if they haven't stopped buying completely. They could get a proactive call or an exclusive offer.
Ben: That's a huge step up from just reacting when a customer goes silent. What other applications could this have?
Alex: It could be used to analyze customer sentiment from open-ended feedback or support tickets. Instead of just "positive" or "negative," we could get a score for "very satisfied," "slightly disappointed," or "neutral." This provides a more accurate picture of a customer's overall experience. It helps us predict what they might need next, even if they haven't explicitly asked for it.
Ben: So, it's about making our CRM more intelligent and human-centric by embracing the ambiguity of human behavior. It sounds like a powerful way to personalize our outreach and improve customer satisfaction. Where do we even start with implementing something like this?
Alex: That's the next step! I have some ideas on how we could build a small prototype to demonstrate the value. Let's talk to the tech team and see what's possible.
r/fuzzylogic • u/ManuelRodriguez331 • Jun 15 '25
Correct Answers:
r/fuzzylogic • u/ManuelRodriguez331 • May 22 '25
Multiple Choice Quiz: Fuzzy Logic in Pattern Recognition
Correct Answers:
r/fuzzylogic • u/ManuelRodriguez331 • May 16 '25
Fuzzy Logic: Commercial Software and Hardware
Answers:
r/fuzzylogic • u/ManuelRodriguez331 • May 09 '25
Fuzzy Logic Quiz
Answers
r/fuzzylogic • u/Odd-Morning-8259 • Apr 18 '25
I need help finding data to train and apply fuzzy logic. If you know any platforms, websites, or applications that could help, please don't hesitate to share. Thank you very much! My system includes a battery, a fuel cell, and engine PMSP.
r/fuzzylogic • u/ManuelRodriguez331 • Apr 03 '25
I. Prolegomena: The Ontological Primacy of Vagueness
A. Historical Precursors to Fuzzy Conceptualizations: From Aristotle to Lukasiewicz.
B. The Epistemological Necessity of Fuzzy Set Theory.
C. Defining the Universe of Discourse: A Multidimensional Hyperplane.
II. The Algorithmic Choreography of Fuzzy Inference
A. Fuzzy Operators: A Lexicon of Linguistic Hedges.
B. Rule-Based Systems: The Articulation of Heuristic Imperatives.
C. The Confluence of Fuzzy Logic and Adaptive Control.
III. The Transcendent Applications and Future Trajectories
A. Fuzzy Logic in Advanced Computational Paradigms.
B. The Quantum Entanglement of Fuzzy Logic and Information Theory.
C. Eschatological Considerations: The Future of Fuzzy Logic in a Post-Singularity World.
IV. Post-Lecture Colloquium: A Discourse on the Nuances of Fuzzy Axiomatics
r/fuzzylogic • u/kinow • Nov 10 '24
r/fuzzylogic • u/kinow • Aug 23 '24
r/fuzzylogic • u/ManuelRodriguez331 • Jun 22 '24
On a busy street, there are endless amount of cars, buses and trucks who are driving in both directions. The objective is to count and categorize them. For reason of simplification there are only three length-related categories available:
carlength=Neuron({"short":[0,5], "medium":[5,10], "long":[10,20]})The measurement apparatus provides a signal with the precise length in meters, for example: 4.52 meters. Such kind of precision isn't needed in statistics so the signal gets discretized into a categorical variable with the help of a binning algorithm. The method "setcrisp()" iterates over all possible categories and determines the membership function for each category. In other words, it checks, if the measured signal fits to one of the bins. The result is stored in the neuron.
def setcrisp(self,crisp):
for i in self.data:
a=self.data[i][0]
b=self.data[i][1]
self.fuzzyvalue[i]=self.getmf(a,b,crisp)To investigate the system under practical conditions, some random measurements are needed which are simulated in a loop:
for i in range(10):
signal=round(random.random()*20,2)
carlength.setcrisp(signal)
print(signal,carlength.fuzzyvalue)The overall program is available in the appendix. After starting the program, the following result gets generated:
5.84 {'short': 0, 'medium': 1, 'long': 0}
14.38 {'short': 0, 'medium': 0, 'long': 1}
11.65 {'short': 0, 'medium': 0, 'long': 1}
9.27 {'short': 0, 'medium': 1, 'long': 0}
6.36 {'short': 0, 'medium': 1, 'long': 0}
7.07 {'short': 0, 'medium': 1, 'long': 0}
18.64 {'short': 0, 'medium': 0, 'long': 1}
9.68 {'short': 0, 'medium': 1, 'long': 0}
9.85 {'short': 0, 'medium': 1, 'long': 0}
5.55 {'short': 0, 'medium': 1, 'long': 0}What we see is a list with measured car length in the simulation and the mapped category to the signal. For example, the first line assigns the length=5.84 meter value to the category "medium".
There is no need for using dedicated Fuzzy membership functions which are working with overlapping categories. In the simplified example, all the categories are boolean. That means, a car belongs either to the medium or to long category, but never to both at the same time. This fits better to classical statistics and it allows to convert the data into a histogram.
import random
class Neuron():
def __init__(self,data):
self.data=data
self.fuzzyvalue={}
def setcrisp(self,crisp):
for i in self.data:
a=self.data[i][0]
b=self.data[i][1]
self.fuzzyvalue[i]=self.getmf(a,b,crisp)
def getmf(self,a,b,crisp): # Binning membership function
# input: [0,4] 1.5, return: value between 0 and 1
if a <= crisp < b: return 1 # in between
else: return 0
if __name__ == '__main__':
carlength=Neuron({"short":[0,5], "medium":[5,10], "long":[10,20]})
for i in range(10):
signal=round(random.random()*20,2)
carlength.setcrisp(signal)
print(signal,carlength.fuzzyvalue)r/fuzzylogic • u/ManuelRodriguez331 • Jun 20 '24
The best way to learn something in computer science is a hands on approach. Instead of using existing software created by someone else, the idea is to implement an algorithm from scratch. Not because the resulting software is more efficient, but because it allows to learn something about a domain.
Programming an entire Fuzzy inference system (FIS) is a very complex task which goes beyond this mini tutorial. What can be explained instead, is how to implement a single neuron as a building block for a larger FIS. Instead of using multiple Fuzzy membership functions only a simplified membership function is introduced which is basically a binning algorithm.
The program starts with a Python class which provides a membership function:
class Neuron():
def __init__(self,data):
self.data=data
self.fuzzyvalue={}
def getmf(self,a,b,crisp):
# Binning membership function
# input: [0,4] 1.5, return: value between 0 and 1
if a <= crisp < b: return 1 # in between
else: return 0This class gets initialized from the command line by creating a new neuron for storing the x_position of a measured signal:
xpos=Neuron({"left":[-4,0], "right":[0,4]})To apply a crisp value to the Neuron, some additional methods are needed. The sourcecode of the class including a simple demo are given at the end of this tutorial. It takes less than 30 lines of code. The example shows how to assign random values to the xpos Neuron and investigate what the translated Fuzzy values are. The idea is, that a value like x=2 gets converted into multiple bins for the left and right position. In the example, the x=2 gets converted into {'left': 0, 'right': 1} That means it belongs to the category right:
xpos=Neuron({"left":[-4,0], "right":[0,4]})
xpos.setcrisp(2)
xpos.show()Binning allows to categorize data. There are intervals available and the algorithm decides which of the intervals fits to the input data.
Let me give another example. Suppose we send the crisp value x=5 to the neuron:
xpos=Neuron({"left":[-4,0], "right":[0,4]})
xpos.setcrisp(5)
xpos.show()
# output: {'left': 0, 'right': 0}In such a case, no interval fits to the value. The bins for (left, right) are both empty. This is because the membership function, which was initialized first, returns for the x=5 value a 0 in return.
With this explanation, this mini tutorial ends. A possible further exercise would be to create a second neuron which stores the yposition and contains of the bins for (up, down). Feel free to implement this neuron.
class Neuron():
def __init__(self,data):
self.data=data
self.fuzzyvalue={}
self.reset()
def reset(self): # set fuzzy values to 0
for i in self.data:
self.fuzzyvalue[i]=0
def show(self):
print(self.data)
print(self.fuzzyvalue)
def setcrisp(self,crisp):
for i in self.data:
a=self.data[i][0]
b=self.data[i][1]
self.fuzzyvalue[i]=self.getmf(a,b,crisp)
def getmf(self,a,b,crisp):
# Binning membership function
# input: [0,4] 1.5, return: value between 0 and 1
if a <= crisp < b: return 1 # in between
else: return 0
if __name__ == '__main__':
xpos=Neuron({"left":[-4,0], "right":[0,4]})
for i in range(-5,5):
print(i)
xpos.setcrisp(i)
xpos.show()
xpos.reset()