def write_xml(model, domains, filename): ''' Write an XML representation of an ANFIS model to the given file. ''' jfml_fis = convert(model, domains) Py4jfml.writeFSTtoXML(jfml_fis, filename) print('Written', filename)
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 r3 = FuzzyRuleType("rule3", connector="and", connectorMethod="MIN", weight=1.0) ant3 = AntecedentType() ant3.addClause(ClauseType(sl, sl_not_low)) ant3.addClause(ClauseType(pl, pl_not_low)) ant3.addClause(ClauseType(pw, pw_high)) con3 = ConsequentType() con3.addThenClause(ClauseType(irisClass, irisClass_versicolor)) r3.setAntecedent(ant3) r3.setConsequent(con3) rb.addRule(r3) iris.addRuleBase(rb) print(iris) # WRITTING IRIS EXAMPLE INTO AN XML FILE irisXMLFile = "IrisMamdani2.xml" Py4jfml.writeFSTtoXML(iris, irisXMLFile) Py4jfml.kill()
con2 = ConsequentType() con2.addThenClause(variable=tip, term=average) rule2.setAntecedent(ant2) rule2.setConsequent(con2) rb.addRule(rule2) #RULE 3 rule3 = FuzzyRuleType(name="rule3", connector="or", connectorMethod="MAX", weight=1.0) ant3 = AntecedentType() ant3.addClause(c=ClauseType(service, excellent)) ant3.addClause(c=ClauseType(food, delicious)) con3 = ConsequentType() con3.addThenClause(variable=tip, term=generous) rule3.setAntecedent(ant3) rule3.setConsequent(con3) rb.addRule(rule3) tipper.addRuleBase(rb) #WRITTING TIPPER EXAMPLE INTO AN XML FILE tipperXMLFile = "TipperTsukamoto2.xml" Py4jfml.writeFSTtoXML(tipper, tipperXMLFile) print(tipper) Py4jfml.kill()
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) r243.setConsequent(con243) rb.addRule(r243) japaneseDietAssessment.addRuleBase(rb) print(japaneseDietAssessment) # WRITTING JAPANESE DIET ASSESSMENT EXAMPLE INTO AN XML FILE japaneseDietAssessmentXMLFile = "JapaneseDietAssessmentMamdani.xml" Py4jfml.writeFSTtoXML(japaneseDietAssessment, japaneseDietAssessmentXMLFile) Py4jfml.kill()
#RULE 18 r18 = FuzzyRuleType(name="rule18", connector="and", connectorMethod="MIN", weight=1.0) ant18 = AntecedentType() ant18.addClause(c=ClauseType(ang, ang_vpos)) ant18.addClause(c=ClauseType(ca, ca_neu)) con18 = ConsequentType() con18.addThenClause(variable=force, term=force_vpos) r18.setAntecedent(value=ant18) r18.setConsequent(value=con18) rb.addRule(rule=r18) #RULE 19 r19 = FuzzyRuleType(name="rule19", connector="and", connectorMethod="MIN", weight=1.0) ant19 = AntecedentType() ant19.addClause(c=ClauseType(ang, ang_pos_or_vpos)) ant19.addClause(c=ClauseType(ca, ca_pos_or_vpos)) con19 = ConsequentType() con19.addThenClause(variable=force, term=force_vpos) r19.setAntecedent(value=ant19) r19.setConsequent(value=con19) rb.addRule(r19) invertedPendulum.addRuleBase(rb); print(invertedPendulum) #WRITTING INVERTED PENDULUM EXAMPLE INTO AN XML FILE invertedPendulumXMLFile = "InvertedPendulumMamdani1.xml" Py4jfml.writeFSTtoXML(invertedPendulum, invertedPendulumXMLFile) Py4jfml.kill()
con2.addTskThenClause(variable=tip, term=average) rule2.setAntecedent(ant2) rule2.setTskConsequent(con2) fr.addTskRule(rule2) #RULE 3 rule3 = TskFuzzyRuleType(name="rule3", connector="or", connectorMethod="MAX", weight=1.0) ant3 = AntecedentType() ant3.addClause(c=ClauseType(service, excellent)) ant3.addClause(c=ClauseType(food, delicious)) con3 = TskConsequentType() con3.addTskThenClause(variable=tip, term=generous) rule3.setAntecedent(ant3) rule3.setTskConsequent(con3) fr.addTskRule(rule3) tipper.addRuleBase(fr) #WRITTING TIPPER EXAMPLE INTO AN XML FILE str_xml = "TipperTSK.xml" Py4jfml.writeFSTtoXML(tipper, str_xml) print(tipper) Py4jfml.kill()
weight=1.0) ant11 = AntecedentType() ant11.addClause(c=ClauseType(pw, pw_highSIN)) con11 = ConsequentType() con11.addThenClause(c=ClauseType(irisClass, irisClass_versicolor)) r11.setAntecedent(value=ant11) r11.setConsequent(value=con11) rb.addRule(r11) # RULE 12 r12 = FuzzyRuleType(name="rule12", connector="and", connectorMethod="MIN", weight=1.0) ant12 = AntecedentType() ant12.addClause(c=ClauseType(pw, pw_highS)) con12 = ConsequentType() con12.addThenClause(c=ClauseType(irisClass, irisClass_versicolor)) r12.setAntecedent(value=ant12) r12.setConsequent(value=con12) rb.addRule(r12) iris.addRuleBase(rb) # WRITTING IRIS EXAMPLE INTO AN XML FILE str_xml = os.getcwd() + "/" + "IrisMamdani3.xml" Py4jfml.writeFSTtoXML(iris, str_xml) print(iris) Py4jfml.kill()