Python-Fuzzylogic / fuzzylogic

Fuzzy Logic and Fuzzy Inference for Python 3
MIT License
123 stars 26 forks source link

Rule explaination #31

Closed nhan-dang closed 1 year ago

nhan-dang commented 1 year ago

In the Showcase.ipnb, i have seen the initialization of rules as: R1 = Rule({(temp.hot, hum.dry): motor.fast}). Does this mean it equivalent to If temp is hot and hum is dry, then the motor is fast? Is there any difference between R1 | R2 | R3 | R4 and sum([R1, R2, R3, R4]) Thank you

amogorkon commented 1 year ago

Does this mean it equivalent to If temp is hot and hum is dry, then the motor is fast?

Yes.

Is there any difference between R1 | R2 | R3 | R4 and sum([R1, R2, R3, R4])

No.

nhan-dang commented 1 year ago

Thank you for your response. What if i want to setup If temp is hot or hum is dry, then the motor is fast?, or more complex rules like If (temp is hot and hum is dry) or (temp is hot and hum is not wet)

amogorkon commented 1 year ago

You could use simple conditions and compose them via rules like

Rule({(temp.hot,): motor.fast,
         (hum.dry,): motor.fast,
})

and you can use the ability to compose complex conditions (as long as it's on a single domain) like

hum.medium = ~hum.wet & ~hum.dry

Rule({(temp.hot, hum.dry): motor.fast,
         (temp.hot, hum.medium): motor.fast,
})

I hope that helps.

nhan-dang commented 1 year ago

Thank you for your reply