Python-Fuzzylogic/fuzzylogic

Rule explaination

nhan-dang opened this issue · 4 comments

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

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.

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)

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.

Thank you for your reply