#91 -- Fix fuzzy inference
This commit is contained in:
parent
4596a25a59
commit
d03cb194ee
@ -29,7 +29,8 @@ public class AssessmentController {
|
||||
public String getAssessments(Model model, @RequestParam Optional<Integer> branchId) {
|
||||
model.addAttribute("branches", branchService.findAllValid());
|
||||
if (branchId.isPresent()) {
|
||||
model.addAttribute("assessments", assessmentService.getAssessmentsByForecastTendencies(branchId.get()));
|
||||
model.addAttribute("assessments", assessmentService.getAssessments(branchId.get()));
|
||||
model.addAttribute("singleAssessment", assessmentService.getSingleAssessment(branchId.get()));
|
||||
model.addAttribute("filterBranchForm", new FilterBranchForm(branchId.get()));
|
||||
} else {
|
||||
model.addAttribute("filterBranchForm", new FilterBranchForm());
|
||||
|
@ -34,24 +34,24 @@ public class AssessmentService {
|
||||
this.fuzzyInferenceService = fuzzyInferenceService;
|
||||
}
|
||||
|
||||
public List<Assessment> getAssessmentsByForecastTendencies(Integer branchId) {
|
||||
public List<Assessment> getAssessments(Integer branchId) {
|
||||
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
||||
List<DbRule> dbRules = ruleService.getList();
|
||||
try {
|
||||
return getAssessmentsByTimeSeriesTendencies(dbRules, timeSeries);
|
||||
return getAssessments(dbRules, timeSeries);
|
||||
} catch (AssessmentException ex) {
|
||||
ex.printStackTrace();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Assessment> getAssessmentsByLastValues(Integer branchId) {
|
||||
public List<Assessment> getSingleAssessment(Integer branchId) throws AssessmentException {
|
||||
List<TimeSeries> timeSeries = timeSeriesService.getByBranch(branchId);
|
||||
List<DbRule> dbRules = ruleService.getList();
|
||||
return getAssessmentsByLastValues(dbRules, timeSeries);
|
||||
return getSingleAssessment(dbRules, timeSeries);
|
||||
}
|
||||
|
||||
private List<Assessment> getSingleAssessmentByTimeSeriesTendencies(List<DbRule> dbRules, List<TimeSeries> timeSeries) throws AssessmentException {
|
||||
private List<Assessment> getSingleAssessment(List<DbRule> dbRules, List<TimeSeries> timeSeries) throws AssessmentException {
|
||||
Map<String, Double> variableValues = new HashMap<>();
|
||||
timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), timeSeriesService.getLastTimeSeriesTendency(ts)));
|
||||
return fuzzyInferenceService.getFuzzyInference(dbRules,
|
||||
@ -59,7 +59,7 @@ public class AssessmentService {
|
||||
variableValues);
|
||||
}
|
||||
|
||||
private List<Assessment> getAssessmentsByTimeSeriesTendencies(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
||||
private List<Assessment> getAssessments(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
||||
return dbRules
|
||||
.stream()
|
||||
.flatMap(dbRule -> {
|
||||
@ -77,12 +77,4 @@ public class AssessmentService {
|
||||
.sorted(Comparator.comparing(Assessment::getDegree))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<Assessment> getAssessmentsByLastValues(List<DbRule> dbRules, List<TimeSeries> timeSeries) {
|
||||
Map<String, Double> variableValues = new HashMap<>();
|
||||
timeSeries.forEach(ts -> variableValues.put(ts.getTimeSeriesType().name(), ts.getValues().get(ts.getValues().size() - 1).getValue()));
|
||||
return fuzzyInferenceService.getFuzzyInference(dbRules,
|
||||
antecedentValueService.getList(),
|
||||
variableValues);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<div th:if="*{branchId == null}">Выбрерите ветку для получения оценки репозитория</div>
|
||||
</form>
|
||||
<div th:if="${assessments != null && #lists.size(assessments) > 0}">
|
||||
<h5>Состояние репозитория описывается следующими выражениями:</h5>
|
||||
<h5>Состояние репозитория по нескольким правилам описывается следующими выражениями:</h5>
|
||||
<div th:each="assessment: ${assessments}">
|
||||
<span th:text="${assessment.consequent}"></span>
|
||||
вследствие тенденции '<span th:text="${assessment.firstAntecedentTendency}"></span>' показателя '<span
|
||||
@ -46,5 +46,22 @@
|
||||
<div th:if="${assessments != null && #lists.size(assessments) == 0}">
|
||||
<h5>Нет результатов</h5>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div th:if="${singleAssessment != null && #lists.size(assessments) > 0}">
|
||||
<h5>Состояние репозитория по лидирующему правилу описывается следующими выражениями:</h5>
|
||||
<div th:each="assessment: ${singleAssessment}">
|
||||
<span th:text="${assessment.consequent}"></span>
|
||||
вследствие тенденции '<span th:text="${assessment.firstAntecedentTendency}"></span>' показателя '<span
|
||||
th:text="${assessment.firstAntecedent.description}"></span>'
|
||||
и тенденции '<span th:text="${assessment.secondAntecedentTendency}"></span>' показателя '<span
|
||||
th:text="${assessment.secondAntecedent.description}"></span>';
|
||||
<span class="badge badge-warning" th:text="${assessment.degree}"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div th:if="${singleAssessment != null && #lists.size(singleAssessment) == 0}">
|
||||
<h5>Нет результатов</h5>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user