#14 -- Fix triangle generation

This commit is contained in:
Anton Romanov 2025-03-19 14:02:48 +04:00
parent 77158d0be8
commit 6ee5c0ac6a
2 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,6 @@
package ru.ulstu.method.fuzzy;
import org.springframework.stereotype.Component;
import ru.ulstu.datamodel.Model;
import ru.ulstu.datamodel.exception.ModelingException;
import ru.ulstu.datamodel.ts.TimeSeries;
@ -12,6 +13,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Component
public class PlainFuzzy extends Method {
@Override
public List<MethodParameter> getAvailableParameters() {
@ -37,11 +39,11 @@ public class PlainFuzzy extends Method {
.max(Comparator.comparing(TimeSeriesValue::getValue))
.map(TimeSeriesValue::getValue)
.orElseThrow(() -> new RuntimeException("Максимальное значение не найдено"));
double delta = (max - min) / numberOfFuzzyTerms;
double delta = ((max - min) / numberOfFuzzyTerms) * 2;
for (int i = 0; i < numberOfFuzzyTerms; i++) {
fuzzySets.add(new Triangle(min + i * numberOfFuzzyTerms,
min + i * numberOfFuzzyTerms + delta / 2,
min + i * numberOfFuzzyTerms + delta));
fuzzySets.add(new Triangle(min + i * delta - delta,
min + i * delta,
min + i * delta + delta));
}
return fuzzySets;
}

View File

@ -9,7 +9,7 @@ import java.util.List;
public class NumberOfFuzzyTerms extends MethodParameter {
private final static int MIN_NUMBER_OF_FUZZY_TERMS = 2;
private final static int MIN_INCREASING_STEP_OF_NUMBER_OF_FUZZY_TERMS = 1;
private final static int MAX_NUMBER_OF_FUZZY_TERMS = 7;
private final static int MAX_NUMBER_OF_FUZZY_TERMS = 3;
public NumberOfFuzzyTerms() {
super("Number of fuzzy terms");