#14 -- Fix triangle generation
This commit is contained in:
parent
77158d0be8
commit
6ee5c0ac6a
@ -1,5 +1,6 @@
|
|||||||
package ru.ulstu.method.fuzzy;
|
package ru.ulstu.method.fuzzy;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import ru.ulstu.datamodel.Model;
|
import ru.ulstu.datamodel.Model;
|
||||||
import ru.ulstu.datamodel.exception.ModelingException;
|
import ru.ulstu.datamodel.exception.ModelingException;
|
||||||
import ru.ulstu.datamodel.ts.TimeSeries;
|
import ru.ulstu.datamodel.ts.TimeSeries;
|
||||||
@ -12,6 +13,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class PlainFuzzy extends Method {
|
public class PlainFuzzy extends Method {
|
||||||
@Override
|
@Override
|
||||||
public List<MethodParameter> getAvailableParameters() {
|
public List<MethodParameter> getAvailableParameters() {
|
||||||
@ -37,11 +39,11 @@ public class PlainFuzzy extends Method {
|
|||||||
.max(Comparator.comparing(TimeSeriesValue::getValue))
|
.max(Comparator.comparing(TimeSeriesValue::getValue))
|
||||||
.map(TimeSeriesValue::getValue)
|
.map(TimeSeriesValue::getValue)
|
||||||
.orElseThrow(() -> new RuntimeException("Максимальное значение не найдено"));
|
.orElseThrow(() -> new RuntimeException("Максимальное значение не найдено"));
|
||||||
double delta = (max - min) / numberOfFuzzyTerms;
|
double delta = ((max - min) / numberOfFuzzyTerms) * 2;
|
||||||
for (int i = 0; i < numberOfFuzzyTerms; i++) {
|
for (int i = 0; i < numberOfFuzzyTerms; i++) {
|
||||||
fuzzySets.add(new Triangle(min + i * numberOfFuzzyTerms,
|
fuzzySets.add(new Triangle(min + i * delta - delta,
|
||||||
min + i * numberOfFuzzyTerms + delta / 2,
|
min + i * delta,
|
||||||
min + i * numberOfFuzzyTerms + delta));
|
min + i * delta + delta));
|
||||||
}
|
}
|
||||||
return fuzzySets;
|
return fuzzySets;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||||||
public class NumberOfFuzzyTerms extends MethodParameter {
|
public class NumberOfFuzzyTerms extends MethodParameter {
|
||||||
private final static int MIN_NUMBER_OF_FUZZY_TERMS = 2;
|
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 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() {
|
public NumberOfFuzzyTerms() {
|
||||||
super("Number of fuzzy terms");
|
super("Number of fuzzy terms");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user