fcl refactor
This commit is contained in:
parent
88b838b968
commit
6bb53d21fb
@ -0,0 +1,22 @@
|
|||||||
|
package com.resultprediction.polishekstraklasa.Predictions;
|
||||||
|
|
||||||
|
import net.sourceforge.jFuzzyLogic.JFuzzyLogic;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class Fuzzy {
|
||||||
|
|
||||||
|
public static JFuzzyLogic jFuzzyLogic = null;
|
||||||
|
|
||||||
|
public Fuzzy() {
|
||||||
|
File file = new File("Prediction.fcl");
|
||||||
|
String fileName = file.getAbsolutePath();
|
||||||
|
String[] a = new String[2];
|
||||||
|
a[0] = "-c";
|
||||||
|
a[1] = fileName.replace("Prediction.fcl", "src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\Prediction.fcl");
|
||||||
|
jFuzzyLogic = new JFuzzyLogic(a);
|
||||||
|
jFuzzyLogic.run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -105,4 +105,4 @@ RULEBLOCK No1
|
|||||||
RULE 3: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie OR lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis;
|
RULE 3: IF lastMatchesResultBetweenAverage IS slabo OR lastMatchesResultBetweenAverage IS przecietnie OR lastMatchesResultBetweenAverage IS dobrze THEN prediction IS remis;
|
||||||
END_RULEBLOCK
|
END_RULEBLOCK
|
||||||
|
|
||||||
END_FUNCTION_BLOCK
|
END_FUNCTION_BLOCK
|
@ -5,6 +5,7 @@ import lombok.Setter;
|
|||||||
import net.sourceforge.jFuzzyLogic.FIS;
|
import net.sourceforge.jFuzzyLogic.FIS;
|
||||||
import net.sourceforge.jFuzzyLogic.FunctionBlock;
|
import net.sourceforge.jFuzzyLogic.FunctionBlock;
|
||||||
|
|
||||||
|
import net.sourceforge.jFuzzyLogic.JFuzzyLogic;
|
||||||
import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart;
|
import net.sourceforge.jFuzzyLogic.plot.JFuzzyChart;
|
||||||
|
|
||||||
import net.sourceforge.jFuzzyLogic.rule.Variable;
|
import net.sourceforge.jFuzzyLogic.rule.Variable;
|
||||||
@ -27,52 +28,31 @@ public class Prediction {
|
|||||||
|
|
||||||
|
|
||||||
public static void make() {
|
public static void make() {
|
||||||
// Load from 'FCL' file
|
|
||||||
String fileName = "C:\\Users\\Adrian\\Desktop\\Systemy rozmyte\\Back\\src\\main\\java\\com\\resultprediction\\polishekstraklasa\\Predictions\\Prediction.fcl";
|
|
||||||
FIS fis = FIS.load(fileName, true);
|
|
||||||
if( fis == null ) {
|
|
||||||
System.err.println("Nie moge zaladowc pliku: '" + fileName + "'");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pokazuje reguly
|
// Load from 'FCL' file
|
||||||
FunctionBlock functionBlock = fis.getFunctionBlock(null);
|
FIS fis = Fuzzy.jFuzzyLogic.getFis();
|
||||||
JFuzzyChart.get().chart(functionBlock);
|
// Pokazuje reguly
|
||||||
|
FunctionBlock functionBlock = fis.getFunctionBlock(null);
|
||||||
|
JFuzzyChart.get().chart(functionBlock);
|
||||||
|
|
||||||
// Ustawia wejscia
|
// Ustawia wejscia
|
||||||
for (com.resultprediction.polishekstraklasa.Predictions.Variable variable : variables){
|
for (com.resultprediction.polishekstraklasa.Predictions.Variable variable : variables){
|
||||||
fis.setVariable(variable.getName(), variable.getValue());
|
fis.setVariable(variable.getName(), variable.getValue());
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
fis.setVariable("obsluga", 3);
|
|
||||||
fis.setVariable("jedzenie", 8);*/
|
|
||||||
|
|
||||||
// Wylicza zbiory rozmyte
|
// Wylicza zbiory rozmyte
|
||||||
fis.evaluate();
|
fis.evaluate();
|
||||||
|
|
||||||
// Ustawia wyjscia
|
// Ustawia wyjscia
|
||||||
Variable prediction = functionBlock.getVariable("prediction");
|
Variable prediction = functionBlock.getVariable("prediction");
|
||||||
|
|
||||||
// Pokazuje wykres zmiennych wyjsciowych
|
// Pokazuje wykres zmiennych wyjsciowych
|
||||||
|
|
||||||
JFuzzyChart.get().chart(prediction, prediction.getDefuzzifier(), true);
|
JFuzzyChart.get().chart(prediction, prediction.getDefuzzifier(), true);
|
||||||
|
|
||||||
// Drukuje reguly
|
// Drukuje reguly
|
||||||
//System.out.println(fis);
|
//System.out.println(fis);
|
||||||
System.out.println("Prediction:" + fis.getVariable("prediction").getValue());
|
System.out.println("Prediction:" + fis.getVariable("prediction"));
|
||||||
Process proc = null;
|
variables.clear();
|
||||||
try {
|
|
||||||
proc = Runtime.getRuntime().exec("javac -cp jFuzzyLogic.jar Prediction.java");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
proc = Runtime.getRuntime().exec("java -cp jFuzzyLogic.jar;. Prediction");
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
InputStream in = proc.getInputStream();
|
|
||||||
InputStream err = proc.getErrorStream();
|
|
||||||
variables.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.resultprediction.polishekstraklasa.Predictions;
|
package com.resultprediction.polishekstraklasa.Predictions;
|
||||||
|
|
||||||
|
import net.sourceforge.jFuzzyLogic.JFuzzyLogic;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@ -14,7 +15,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ -27,6 +30,8 @@ public class PredictionsApplication {
|
|||||||
builder.headless(false);
|
builder.headless(false);
|
||||||
|
|
||||||
ConfigurableApplicationContext context = builder.run(args);
|
ConfigurableApplicationContext context = builder.run(args);
|
||||||
|
|
||||||
|
Fuzzy fuzzy = new Fuzzy();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -134,10 +134,11 @@ public class PredictService {
|
|||||||
System.out.println("Team2 Form = " + teamForm2);
|
System.out.println("Team2 Form = " + teamForm2);
|
||||||
double calculatedTeam2Form = ((goalkeeperForm2 * gooalkeeperFormValue) + (formationAgainstForm2 * formationFormValue) + (teamForm2 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
double calculatedTeam2Form = ((goalkeeperForm2 * gooalkeeperFormValue) + (formationAgainstForm2 * formationFormValue) + (teamForm2 * teamFormValue)) / (gooalkeeperFormValue + formationFormValue + teamFormValue);
|
||||||
System.out.println("Team2 Calculated Form = " + calculatedTeam2Form);
|
System.out.println("Team2 Calculated Form = " + calculatedTeam2Form);
|
||||||
|
Prediction.make();
|
||||||
System.out.println(match.getTeamsMatchStatistics1().getGoals() + ":" + match.getTeamsMatchStatistics1().getGoals_lost());
|
System.out.println(match.getTeamsMatchStatistics1().getGoals() + ":" + match.getTeamsMatchStatistics1().getGoals_lost());
|
||||||
|
|
||||||
|
|
||||||
Prediction.make();
|
|
||||||
|
|
||||||
//int winner = whoWillWin(calculatedTeam1Form, calculatedTeam2Form);
|
//int winner = whoWillWin(calculatedTeam1Form, calculatedTeam2Form);
|
||||||
/* LeagueTable leagueTable = new LeagueTable(matchRepository.findAllByDateBeforeAndSeason(match.getDate(), match.getSeason()));
|
/* LeagueTable leagueTable = new LeagueTable(matchRepository.findAllByDateBeforeAndSeason(match.getDate(), match.getSeason()));
|
||||||
@ -162,8 +163,18 @@ public class PredictService {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
private int calculateTeamForm(List<Match> matches, Team team, Team enemy, Date actualMatchDate) {
|
private int calculateTeamForm(List<Match> matches, Team team, Team enemy, Date actualMatchDate) {
|
||||||
if (matches.size() == 0)
|
if (matches.size() == 0) {
|
||||||
|
Prediction.addToList(new Variable("shootsOnTargetAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("possessionAverage", (double)50));
|
||||||
|
Prediction.addToList(new Variable("goalsAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("goalsLostAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("redCardsAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("penaltyAreaEntriesAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("penaltiesAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("lastMatchesResultAverage", (double)0));
|
||||||
|
Prediction.addToList(new Variable("lastMatchesResultBetweenAverage", (double)0));
|
||||||
return 100;
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
double shootsOnTargetAverage = 0;
|
double shootsOnTargetAverage = 0;
|
||||||
double possessionAverage = 0;
|
double possessionAverage = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user