0
$\begingroup$

I am currently doing a fuzzy inference system project in Python, however, a question came up. I have to do it the hard way, that is, do it step by step, as done here: https://pythonhosted.org/scikit-fuzzy/auto_examples/plot_tipping_problem.html. When we define the rules we use IF-THEN rules which I suppose is an implication (a->b = ~a OR b). However, on this website they do the following;

For the rules:
If the food is bad OR the service is poor, then the tip will be low
If the service is acceptable, then the tip will be medium
If the food is great OR the service is amazing, then the tip will be high.

They write:

```python
# Now we take our rules and apply them. Rule 1 concerns bad food OR 
service.
# The OR operator means we take the maximum of these two.
active_rule1 = np.fmax(qual_level_lo, serv_level_lo)

# Now we apply this by clipping the top off the corresponding output
# membership function with `np.fmin`
tip_activation_lo = np.fmin(active_rule1, tip_lo)  # removed entirely to 0

# For rule 2 we connect acceptable service to medium tipping
tip_activation_md = np.fmin(serv_level_md, tip_md)

# For rule 3 we connect high service OR high food with high tipping
active_rule3 = np.fmax(qual_level_hi, serv_level_hi)
tip_activation_hi = np.fmin(active_rule3, tip_hi)
tip0 = np.zeros_like(x_tip)
```

This code gives the result it is supposed to. However, the line where they compute "active_rule" doesn't make sense to me, because they are doing "np.min" which is not an implication. I tried replacing it with "np.fmax(~a,b)" but the defuzzification result gives wrong. Any idea how to know if they are actually making an implication or not?

Thank you in advance

$\endgroup$
4
  • $\begingroup$ They defined the fuzzy equivalent of or as max because if one of the conditions is high enough, the result is high enough. Given this equivalation, the equivalent of and would be min because if one of the conditions is not high enough, the result should not be high enough. not: 1-x. Personally, I would not use min, max instead of and, or but instead write the formula from the start (not based on binary logic) as an equation that take all inputs into account, as having both inputs high might indicate a better result than having one high which is better than neither high. $\endgroup$ Dec 26, 2022 at 15:56
  • $\begingroup$ Hi! Thank you for your answer, but I understood the use of OR and AND as MAX and MIN. And I actually have to use this because it is requested to use T-norms or T-co-norms (S-norms). My question is in the implication part (a->b), they traduce this to min(a,b) instead of max(~a,b) as I intuitively thought was right. And I don't understand why substituting a->b = min(a,b) is right and a->b= not (a) OR b = max(~a,b) is wrong $\endgroup$
    – bdzh
    Dec 27, 2022 at 11:02
  • $\begingroup$ Check if they used Demorgan's law x nand y = not x or not y, x nor y = not x and not y $\endgroup$ Dec 28, 2022 at 9:16
  • $\begingroup$ I don't think they did $\endgroup$
    – bdzh
    Dec 30, 2022 at 22:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.