|
|
|
@ -19,6 +19,7 @@ import ru.ulstu.extractor.rule.model.DbRule;
|
|
|
|
|
import ru.ulstu.extractor.ts.model.TimeSeries;
|
|
|
|
|
import ru.ulstu.extractor.ts.service.TimeSeriesService;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -31,6 +32,7 @@ public class FuzzyInferenceService {
|
|
|
|
|
private final static String RULE_TEMPLATE = "if %s is %s and %s is %s then "
|
|
|
|
|
+ OUTPUT_VARIABLE_NAME
|
|
|
|
|
+ " is %s";
|
|
|
|
|
private final static String NO_RESULT = "Нет результата";
|
|
|
|
|
private final DbRuleService ruleService;
|
|
|
|
|
private final AntecedentValueService antecedentValueService;
|
|
|
|
|
private final GitRepositoryService gitRepositoryService;
|
|
|
|
@ -130,6 +132,9 @@ public class FuzzyInferenceService {
|
|
|
|
|
List<Integer> consequentValues = dbRules.stream().map(DbRule::getId).collect(Collectors.toList());
|
|
|
|
|
engine.addRuleBlock(getRuleBlock(engine, variableValues, antecedentValues, consequentValues));
|
|
|
|
|
String consequent = getConsequent(engine, variableValues);
|
|
|
|
|
if (consequent.equals(NO_RESULT)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
return dbRules
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(r -> r.getId().equals(Integer.valueOf(consequent)))
|
|
|
|
@ -173,7 +178,7 @@ public class FuzzyInferenceService {
|
|
|
|
|
outputVariable.defuzzify();
|
|
|
|
|
}
|
|
|
|
|
return (outputVariable == null || Double.isNaN(outputVariable.getValue()))
|
|
|
|
|
? "Нет результата"
|
|
|
|
|
? NO_RESULT
|
|
|
|
|
: outputVariable.highestMembership(outputVariable.getValue()).getSecond().getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|