WIP: страницы для правил #62

Closed
Ghost wants to merge 132 commits from master into 61-rules-pages
3 changed files with 77 additions and 0 deletions
Showing only changes of commit 00119b896c - Show all commits

View File

@ -35,6 +35,9 @@ compileJava {
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven {
url="https://repository.ow2.org/nexus/content/repositories/public"
}
} }
configurations { configurations {
@ -65,6 +68,7 @@ dependencies {
implementation group: 'com.ibm.icu', name: 'icu4j', version: '63.1' implementation group: 'com.ibm.icu', name: 'icu4j', version: '63.1'
implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.9.0.202009080501-r' implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.9.0.202009080501-r'
implementation group: 'net.sourceforge.jFuzzyLogic', name: 'jFuzzyLogic', version: '1.2.1'
implementation group: 'org.webjars', name: 'jquery', version: '3.6.0' implementation group: 'org.webjars', name: 'jquery', version: '3.6.0'
implementation group: 'org.webjars', name: 'bootstrap', version: '4.6.0' implementation group: 'org.webjars', name: 'bootstrap', version: '4.6.0'

View File

@ -3,11 +3,14 @@ package ru.ulstu.extractor;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import ru.ulstu.extractor.rule.service.FuzzyInference;
@SpringBootApplication @SpringBootApplication
@EnableScheduling @EnableScheduling
public class GitExtractorApplication { public class GitExtractorApplication {
public static void main(String[] args) { public static void main(String[] args) {
new FuzzyInference().run();
SpringApplication.run(GitExtractorApplication.class, args); SpringApplication.run(GitExtractorApplication.class, args);
} }
} }

View File

@ -0,0 +1,70 @@
package ru.ulstu.extractor.rule.service;
import net.sourceforge.jFuzzyLogic.defuzzifier.DefuzzifierCenterOfArea;
import net.sourceforge.jFuzzyLogic.membership.MembershipFunctionTriangular;
import net.sourceforge.jFuzzyLogic.rule.FuzzyRule;
import net.sourceforge.jFuzzyLogic.rule.FuzzyRuleExpression;
import net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet;
import net.sourceforge.jFuzzyLogic.rule.FuzzyRuleTerm;
import net.sourceforge.jFuzzyLogic.rule.LinguisticTerm;
import net.sourceforge.jFuzzyLogic.rule.Variable;
import net.sourceforge.jFuzzyLogic.ruleConnection.RuleConnectionMethodAndMin;
import net.sourceforge.jFuzzyLogic.ruleImplication.RuleImplicationMethodMin;
import java.util.Collections;
import java.util.LinkedList;
public class FuzzyInference {
public void run() {
FuzzyRule fuzzyRule = new FuzzyRule("rule 1");
Variable weather = new Variable("Погода");
weather.getLinguisticTerms().put("солнечно",
new LinguisticTerm("солнечно", new MembershipFunctionTriangular(10, 20, 30)));
weather.getLinguisticTerms().put("мороз",
new LinguisticTerm("мороз", new MembershipFunctionTriangular(-50, 0, 10)));
weather.setDefuzzifier(new DefuzzifierCenterOfArea(weather));
Variable suit = new Variable("Одежда");
suit.getLinguisticTerms().put("легко одет",
new LinguisticTerm("легко одет", new MembershipFunctionTriangular(0, 5, 10)));
suit.getLinguisticTerms().put("тепло одет",
new LinguisticTerm("тепло одет", new MembershipFunctionTriangular(5, 10, 20)));
suit.setDefuzzifier(new DefuzzifierCenterOfArea(suit));
Variable feel = new Variable("Ощущение");
feel.getLinguisticTerms().put("Холодно",
new LinguisticTerm("Холодно", new MembershipFunctionTriangular(0, 5, 10)));
feel.getLinguisticTerms().put("Жарко",
new LinguisticTerm("Жарко", new MembershipFunctionTriangular(5, 10, 20)));
feel.setDefuzzifier(new DefuzzifierCenterOfArea(feel));
FuzzyRuleTerm weatherTerm1 = new FuzzyRuleTerm(weather, "солнечно", false);
//FuzzyRuleTerm weatherTerm2 = new FuzzyRuleTerm(weather, "мороз", false);
//FuzzyRuleTerm weatherTerm3 = new FuzzyRuleTerm(weather, "дождливо", false);
//FuzzyRuleTerm suitTerm1 = new FuzzyRuleTerm(suit, "легко одет", false);
FuzzyRuleTerm suitTerm2 = new FuzzyRuleTerm(suit, "тепло одет", false);
//FuzzyRuleTerm suitTerm3 = new FuzzyRuleTerm(suit, "промокающая", false);
//FuzzyRuleTerm feelCold = new FuzzyRuleTerm(feel, "Холодно", false);
FuzzyRuleTerm feelWarm = new FuzzyRuleTerm(feel, "Жарко", false);
//FuzzyRuleTerm feelBad = new FuzzyRuleTerm(feel, "Сыро", false);
FuzzyRuleExpression expression1 = new FuzzyRuleExpression(weatherTerm1, suitTerm2, new RuleConnectionMethodAndMin());
//FuzzyRuleExpression expression2 = new FuzzyRuleExpression(weatherTerm2, suitTerm1, new RuleConnectionMethodAndMin());
fuzzyRule.setAntecedents(expression1);
fuzzyRule.setConsequents(new LinkedList<>(Collections.singleton(feelWarm)));
fuzzyRule.evaluate(new RuleImplicationMethodMin());
FuzzyRuleSet set = new FuzzyRuleSet();
set.add(fuzzyRule);
set.evaluate();
System.out.println(fuzzyRule.toString());
}
}