From aa9ac3ce5d5822e351c027ff485344017d450086 Mon Sep 17 00:00:00 2001 From: = Date: Sun, 24 May 2020 16:29:52 +0200 Subject: [PATCH] c --- .../Predictions/Prediction.fcl | 19 +++++++++----- .../Predictions/Prediction.java | 26 +++++++++++++++++-- .../Predictions/PredictionsApplication.java | 2 +- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.fcl b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.fcl index f6aed00..df65ba9 100644 --- a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.fcl +++ b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.fcl @@ -89,9 +89,9 @@ FUZZIFY lastMatchesResultBetweenAverage END_FUZZIFY DEFUZZIFY prediction - TERM przegrana := (-1,1) (0,0); - TERM remis := (-0.5,0) (0,1) (0.5,0); - TERM wygrana := (0,0) (1,1); + TERM przegrana := (0,1) (10,0); + TERM remis := (10,0) (15,1) (20,0); + TERM wygrana := (20,0) (30,1); DEFAULT := 0; END_DEFUZZIFY @@ -100,10 +100,15 @@ RULEBLOCK No1 ACT : MIN; ACCU : MAX; - RULE 1: IF goalkeeperForm IS zla AND possessionAverage IS malo THEN prediction IS przegrana; - RULE 2: IF possessionAverage IS duzo AND shootsOnTargetAverage IS duzo THEN prediction IS wygrana; - RULE 3: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie OR lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis; - RULE 4: IF goalkeeperForm IS znakomita AND shootsOnTargetAverage IS malo THEN prediction IS przegrana; + RULE 1: IF goalkeeperForm IS znakomita AND shootsOnTargetAverage IS malo THEN prediction IS przegrana; + RULE 2: IF goalkeeperForm IS zla AND possessionAverage IS malo THEN prediction IS przegrana; + RULE 3: IF possessionAverage IS duzo AND shootsOnTargetAverage IS duzo THEN prediction IS wygrana; + RULE 4: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie OR lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis; + RULE 5: IF goalkeeperForm IS znakomita AND goalsLostAverage IS malo OR goalsLostAverage IS przecietnie AND goalsAverage IS malo OR goalsAverage IS przecietnie THEN prediction IS remis; + RULE 6: IF lastMatchesResultBetweenAverage IS bardzo_slabo OR lastMatchesResultBetweenAverage IS slabo AND goalsLostAverage IS przecietnie OR goalsLostAverage IS duzo THEN prediction IS przegrana; + RULE 7: IF shootsOnTargetAverage IS duzo and possessionAverage IS duzo THEN prediction IS wygrana; + + END_RULEBLOCK END_FUNCTION_BLOCK \ No newline at end of file diff --git a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.java b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.java index a9749da..cac637f 100644 --- a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.java +++ b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/Prediction.java @@ -10,6 +10,7 @@ import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart; import net.sourceforge.jFuzzyLogic.rule.Variable; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -30,7 +31,15 @@ public class Prediction { public static void make() { // Load from 'FCL' file - FIS fis = Fuzzy.jFuzzyLogic.getFis(); + //FIS fis = Fuzzy.jFuzzyLogic.getFis(); + File file = new File("Prediction.fcl"); + String fileName = file.getAbsolutePath().replace("Prediction.fcl", "src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\Prediction.fcl"); + FIS fis = FIS.load(fileName, true); + + if (fis == null) { + System.err.println("Can't load file: '" + fileName + "'"); + System.exit(1); + } // Pokazuje reguly FunctionBlock functionBlock = fis.getFunctionBlock(null); JFuzzyChart.get().chart(functionBlock); @@ -39,6 +48,18 @@ public class Prediction { for (com.resultprediction.polishekstraklasa.Predictions.Variable variable : variables){ fis.setVariable(variable.getName(), variable.getValue()); } + /* + fis.setVariable("goalkeeperForm", 85); + fis.setVariable("formationAgainstForm", 60); + fis.setVariable("shootsOnTargetAverage", 8); + fis.setVariable("possessionAverage", 80); + fis.setVariable("goalsAverage", 2); + fis.setVariable("goalsLostAverage", 0); + fis.setVariable("redCardsAverage", 0.1); + fis.setVariable("penaltyAreaEntriesAverage", 1); + fis.setVariable("penaltiesAverage", 0.1); + fis.setVariable("lastMatchesResultAverage", 8); + fis.setVariable("lastMatchesResultBetweenAverage", 8);*/ // Wylicza zbiory rozmyte fis.evaluate(); @@ -52,7 +73,8 @@ public class Prediction { // Drukuje reguly //System.out.println(fis); - System.out.println("Prediction:" + fis.getVariable("prediction")); + System.out.println(fis); + System.out.println("Napiwek:" + fis.getVariable("prediction")); variables.clear(); } } \ No newline at end of file diff --git a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/PredictionsApplication.java b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/PredictionsApplication.java index c57c4a7..b948056 100644 --- a/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/PredictionsApplication.java +++ b/Back/src/main/java/com/resultprediction/polishekstraklasa/Predictions/PredictionsApplication.java @@ -31,7 +31,7 @@ public class PredictionsApplication { ConfigurableApplicationContext context = builder.run(args); - Fuzzy fuzzy = new Fuzzy(); + //Fuzzy fuzzy = new Fuzzy(); } }