From 6823f3499759e7db6b91ab9f86d0b127ce2debb1 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 21 Apr 2023 15:00:14 +0400 Subject: [PATCH] #91 -- Fix fuzzy sets --- .../rule/service/FuzzyInferenceService.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java b/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java index 910dde5..a1a7f53 100644 --- a/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java +++ b/src/main/java/ru/ulstu/extractor/rule/service/FuzzyInferenceService.java @@ -57,20 +57,11 @@ public class FuzzyInferenceService { input.setName(key); input.setDescription(""); input.setEnabled(true); - double delta = antecedentValues.size() > 1 - ? 2.0 / (antecedentValues.size() - 1) - : 2.0; input.setRange(-1, 1); input.setLockValueInRange(false); - for (int i = 0; i < antecedentValues.size(); i++) { - input.addTerm( - new Triangle( - antecedentValues.get(i).getAntecedentValue(), - -1 + i * delta - 0.5 * delta, - -1 + i * delta + delta + 0.5 * delta - ) - ); - } + input.addTerm(new Triangle("спад", -1, 0)); + input.addTerm(new Triangle("стабильно", -0.1, 0.1)); + input.addTerm(new Triangle("рост", 0, 1)); engine.addInputVariable(input); }); @@ -114,6 +105,7 @@ public class FuzzyInferenceService { List antecedentValues, Map variableValues) { validateVariables(variableValues, dbRules); + variableValues.entrySet().forEach(e -> System.out.println(e.getKey() + " " + e.getValue())); Engine engine = getFuzzyEngine(); List consequentValues = dbRules.stream().map(DbRule::getId).collect(Collectors.toList()); engine.addRuleBlock(getRuleBlock(engine, dbRules, variableValues, antecedentValues, consequentValues));