#80 -- fix forecasting

This commit is contained in:
Anton Romanov 2023-02-01 01:40:34 +04:00
parent 237a4f9980
commit 4d7f0f38b8
2 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,7 @@ public class FuzzyInferenceService {
output.setName(OUTPUT_VARIABLE_NAME);
output.setDescription("");
output.setEnabled(true);
output.setRange(-0.1, antecedentValues.size() + 0.1);
output.setRange(-0.1, consequentValues.size() + 0.1);
output.setAggregation(new Maximum());
output.setDefuzzifier(new Centroid(100));
output.setDefaultValue(Double.NaN);
@ -98,7 +98,6 @@ public class FuzzyInferenceService {
mamdani.setDisjunction(new BoundedSum());
mamdani.setImplication(new AlgebraicProduct());
mamdani.setActivation(new Highest());
getRulesFromDb(variableValues).forEach(System.out::println);
getRulesFromDb(variableValues).forEach(r -> mamdani.addRule(Rule.parse(r, engine)));
return mamdani;
}

View File

@ -5,6 +5,7 @@
package ru.ulstu.extractor.ts.service;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -12,6 +13,7 @@ import org.springframework.stereotype.Service;
import ru.ulstu.extractor.branch.model.Branch;
import ru.ulstu.extractor.http.HttpService;
import ru.ulstu.extractor.http.JsonTimeSeries;
import ru.ulstu.extractor.http.SmoothingTimeSeries;
import ru.ulstu.extractor.ts.model.TimeSeries;
import ru.ulstu.extractor.ts.model.TimeSeriesType;
import ru.ulstu.extractor.ts.model.TimeSeriesValue;
@ -114,9 +116,13 @@ public class TimeSeriesService {
}
public Double getLastTimeSeriesTendency(TimeSeries ts) {
//JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
if (ts != null && ts.getValues().size() > 5) {
JSONObject response = httpService.post(TIME_SERIES_TENDENCY_URL, new JSONObject(new SmoothingTimeSeries(ts)));
LOG.debug("Успешно отправлен на сервис сглаживания");
//response.get("timeSeries");
response.get("timeSeries");
JSONArray jsonArray = response.getJSONObject("timeSeries").getJSONArray("values");
return jsonArray.getJSONObject(jsonArray.length() - 1).getDouble("value");
}
return 0.0;
}
}