#3 -- some fixes

This commit is contained in:
Anton Romanov 2022-10-08 11:56:36 +04:00
parent 371dfe5665
commit 0a017f8667

View File

@ -9,7 +9,9 @@ import ru.ulstu.method.MethodParamValue;
import ru.ulstu.method.MethodParameter; import ru.ulstu.method.MethodParameter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
@Component @Component
public class FTransform extends Method { public class FTransform extends Method {
@ -77,7 +79,7 @@ public class FTransform extends Method {
List<AComponent> fuzzyValues = new ArrayList<>(); List<AComponent> fuzzyValues = new ArrayList<>();
double diff = (maxValue - minValue) / NUMBER_OF_FUZZY_VALUES; double diff = (maxValue - minValue) / NUMBER_OF_FUZZY_VALUES;
for (int i = 0; i < NUMBER_OF_FUZZY_VALUES; i++) { for (int i = 0; i < NUMBER_OF_FUZZY_VALUES; i++) {
fuzzyValues.add(new AComponent(i * diff, i * diff + diff / 2, i * diff + diff)); fuzzyValues.add(new AComponent(minValue + i * diff, minValue + i * diff + diff / 2, minValue + i * diff + diff));
} }
List<AComponent> fuzzyTimeSeries = new ArrayList<>(); List<AComponent> fuzzyTimeSeries = new ArrayList<>();
@ -90,6 +92,7 @@ public class FTransform extends Method {
} }
} }
for (int t = 1; t < forecast.getLength(); t++) { for (int t = 1; t < forecast.getLength(); t++) {
forecast.getValues().get(t).setValue(fTransformModel.getPiecewiseLinearTrend().getLastValue().getValue()); forecast.getValues().get(t).setValue(fTransformModel.getPiecewiseLinearTrend().getLastValue().getValue());
} }
@ -101,6 +104,16 @@ public class FTransform extends Method {
return FTransformModel.getAvailableParameters(); return FTransformModel.getAvailableParameters();
} }
private AComponent findFuzzyValueByPrevious(List<AComponent> fuzzyTimeSeries, AComponent currentFuzzyValue) {
Map<AComponent, Integer> mostFrequentValues = new HashMap<>();
for (int i = 0; i < fuzzyTimeSeries.size() - 1; i++) {
if (fuzzyTimeSeries.get(i).equals(currentFuzzyValue)) {
mostFrequentValues.put(fuzzyTimeSeries.get(i + 1), mostFrequentValues.getOrDefault(fuzzyTimeSeries.get(i + 1), 0) + 1);
}
}
mostFrequentValues.entrySet().stream()
}
@Override @Override
public String getName() { public String getName() {
return "F - преобразование"; return "F - преобразование";