41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
import net.sourceforge.jFuzzyLogic.FIS;
|
|
import net.sourceforge.jFuzzyLogic.FunctionBlock;
|
|
import net.sourceforge.jFuzzyLogic.Gpr;
|
|
import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart;
|
|
import net.sourceforge.jFuzzyLogic.rule.Variable;
|
|
|
|
public class dopasowanie {
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
// Laduje plik 'FCL'
|
|
String fileName = "dopasowanie.fcl";
|
|
FIS fis = FIS.load(fileName, true);
|
|
if (fis == null) { // Error while loading?
|
|
System.err.println("Can't load file: '" + fileName + "'");
|
|
return;
|
|
}
|
|
|
|
// Pokazuje reguly
|
|
FunctionBlock functionBlock = fis.getFunctionBlock(null);
|
|
JFuzzyChart.get().chart(functionBlock);
|
|
|
|
// Ustawia zmienne wejsciowe
|
|
functionBlock.setVariable("wiek", 28);
|
|
functionBlock.setVariable("wzrost", 185);
|
|
functionBlock.setVariable("wartosc_rynkowa", 2.5);
|
|
functionBlock.setVariable("czestotliwosc_strzalow", 165);
|
|
|
|
// Uruchamia blok wniskujący
|
|
functionBlock.evaluate();
|
|
|
|
// Wyswietla wykres
|
|
Variable match = functionBlock.getVariable("dopasowanie");
|
|
JFuzzyChart.get().chart(match, match.getDefuzzifier(), true);
|
|
Gpr.debug("poor[service]: " + functionBlock.getVariable("wartosc_rynkowa").getMembership("niska"));
|
|
|
|
// Wyswietla reguly
|
|
System.out.println(functionBlock);
|
|
System.out.println("DOPASOWANIE:" + functionBlock.getVariable("dopasowanie").getValue());
|
|
}
|
|
}
|