#91 -- Fix fuzzy sets
This commit is contained in:
parent
d03cb194ee
commit
6823f34997
@ -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<AntecedentValue> antecedentValues,
|
||||
Map<String, Double> variableValues) {
|
||||
validateVariables(variableValues, dbRules);
|
||||
variableValues.entrySet().forEach(e -> System.out.println(e.getKey() + " " + e.getValue()));
|
||||
Engine engine = getFuzzyEngine();
|
||||
List<Integer> consequentValues = dbRules.stream().map(DbRule::getId).collect(Collectors.toList());
|
||||
engine.addRuleBlock(getRuleBlock(engine, dbRules, variableValues, antecedentValues, consequentValues));
|
||||
|
Loading…
Reference in New Issue
Block a user