# RULE BASE rb = MamdaniRuleBaseType("rulebase1") # RULE 1 r1 = FuzzyRuleType("rule1", connector="and", connectorMethod="MIN", weight=1.) ant1 = AntecedentType() ant1.addClause(ClauseType(pcc, pcc_low)) ant1.addClause(ClauseType(pcp, pcp_low)) ant1.addClause(ClauseType(pcf, pcf_low)) ant1.addClause(ClauseType(pcr, pcr_low)) ant1.addClause(ClauseType(fgb, fgb_low)) con1 = ConsequentType() con1.addThenClause(variable=dhl, term=dhl_verylow) r1.setAntecedent(ant1) r1.setConsequent(con1) rb.addRule(r1) # RULE 243 r243 = FuzzyRuleType("rule243", connector="and", connectorMethod="MIN", weight=1.) ant243 = AntecedentType() ant243.addClause(ClauseType(pcc, pcc_high)) ant243.addClause(ClauseType(pcp, pcp_high)) ant243.addClause(ClauseType(pcf, pcf_high)) ant243.addClause(ClauseType(pcr, pcr_high)) ant243.addClause(ClauseType(fgb, fgb_high)) con243 = ConsequentType() con243.addThenClause(variable=dhl, term=dhl_low) r243.setAntecedent(ant243)
kb.addVariable(irisClass) # RULE BASE rb = MamdaniRuleBaseType("rulebase-iris") # RULE 1 r1 = FuzzyRuleType("rule1", connector="and", connectorMethod="MIN", weight=1.0) ant1 = AntecedentType() ant1.addClause(ClauseType(pw, pw_low)) con1 = ConsequentType() con1.addThenClause(ClauseType(irisClass, irisClass_setosa)) r1.setAntecedent(ant1) r1.setConsequent(con1) rb.addRule(r1) # RULE 2 r2 = FuzzyRuleType("rule2", connector="and", connectorMethod="MIN", weight=1.0) ant2 = AntecedentType() ant2.addClause(ClauseType(sw, sw_not_high)) ant2.addClause(ClauseType(pl, pl_medium)) ant2.addClause(ClauseType(pw, pw_medium)) con2 = ConsequentType() con2.addThenClause(ClauseType(irisClass, irisClass_virginica)) r2.setAntecedent(ant2) r2.setConsequent(con2) rb.addRule(r2); # RULE 3
kb.addVariable(var=force) #RULE BASE rb = MamdaniRuleBaseType(name="rulebase1") #RULE 1 r1 = FuzzyRuleType(name="rule1", connector="and", connectorMethod="MIN", weight=1.0) ant1 = AntecedentType() ant1.addClause(c=ClauseType(ang, ang_vneg_or_neg)) ant1.addClause(c=ClauseType(ca, ca_vneg_or_neg)) con1 = ConsequentType() con1.addThenClause(variable=force, term=force_vneg) r1.setAntecedent(value=ant1) r1.setConsequent(value=con1) rb.addRule(rule=r1) #RULE 2 r2 = FuzzyRuleType(name="rule2", connector="and", connectorMethod="MIN", weight=1.0) ant2 = AntecedentType() ant2.addClause(c=ClauseType(ang, ang_vneg)) ant2.addClause(c=ClauseType(ca, ca_neu)) con2 = ConsequentType() con2.addThenClause(variable=force, term=force_vneg) r2.setAntecedent(value=ant2) r2.setConsequent(value=con2) rb.addRule(rule=r2) #RULE 3 r3 = FuzzyRuleType(name="rule3", connector="and", connectorMethod="MIN", weight=1.0) ant3 = AntecedentType()
kb.addVariable(force) # RULE BASE rb = MamdaniRuleBaseType("rulebase1") # RULE1 r1 = FuzzyRuleType("rule1", connector="and", connectorMethod="MIN", weight=1.0) ant1 = AntecedentType() ant1.addClause(ClauseType(ang, ang_vneg_or_neg)) ant1.addClause(ClauseType(ca, ca_vneg_or_neg)) con1 = ConsequentType() con1.addThenClause(variable=force, term=force_vneg) r1.setAntecedent(ant1) r1.setConsequent(con1) rb.addRule(r1) # RULE2 r2 = FuzzyRuleType("rule2", connector="and", connectorMethod="MIN", weight=1.0) ant2 = AntecedentType() ant2.addClause(ClauseType(ang, ang_vneg)) ant2.addClause(ClauseType(ca, ca_neu)) con2 = ConsequentType() con2.addThenClause(variable=force, term=force_vneg) r2.setAntecedent(ant2) r2.setConsequent(con2) rb.addRule(r2) # RULE3 r3 = FuzzyRuleType("rule3", connector="and", connectorMethod="MIN", weight=1.0) ant3 = AntecedentType()
# RULE BASE rb = MamdaniRuleBaseType("rulebase1") # RULE1 rule1 = FuzzyRuleType("rule1", connector="or", connectorMethod="MAX", weight=1.) ant1 = AntecedentType() ant1.addClause(ClauseType(food, rancid)) ant1.addClause(ClauseType(service, poor, "very")) con1 = ConsequentType() con1.addThenClause(variable=tip, term=cheap) rule1.setAntecedent(ant1) rule1.setConsequent(con1) rb.addRule(rule1) # RULE2 rule2 = FuzzyRuleType("rule2", connector="or", connectorMethod="MAX", weight=1.) ant2 = AntecedentType() ant2.addClause(ClauseType(service, good)) con2 = ConsequentType() con2.addThenClause(variable=tip, term=average) rule2.setAntecedent(ant2) rule2.setConsequent(con2) rb.addRule(rule2) # RULE3
#RULE BASE rb = MamdaniRuleBaseType("rulebase-iris") #RULE 1 r1 = FuzzyRuleType(name="rule1", connector="and", connectorMethod="MIN", weight=1.0) ant1 = AntecedentType() ant1.addClause(c=ClauseType(pw, pw_lowLIN)) con1 = ConsequentType() con1.addThenClause(c=ClauseType(variable=irisClass, term=irisClass_setosa)) r1.setAntecedent(value=ant1) r1.setConsequent(value=con1) rb.addRule(r1) #RULE 2 r2 = FuzzyRuleType("rule2", connector="and", connectorMethod="MIN", weight=1.0) ant2 = AntecedentType() ant2.addClause(c=ClauseType(pw, pw_lowGAU)) con2 = ConsequentType() con2.addThenClause(c=ClauseType(irisClass, irisClass_setosa)) r2.setAntecedent(value=ant2) r2.setConsequent(value=con2) rb.addRule(r2) #RULE 3 r3 = FuzzyRuleType(name="rule3", connector="and", connectorMethod="MIN",