#5 -- Fix validation
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m10s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 1m10s
This commit is contained in:
parent
c33680fd66
commit
202d8cd0d3
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,3 +1,4 @@
|
||||
{
|
||||
"java.configuration.updateBuildConfiguration": "interactive"
|
||||
"java.configuration.updateBuildConfiguration": "interactive",
|
||||
"java.compile.nullAnalysis.mode": "disabled"
|
||||
}
|
@ -29,7 +29,6 @@ public class RuleController {
|
||||
(id != null && id != 0)
|
||||
? new FuzzyRuleForm(id, ruleService.getById(id))
|
||||
: new FuzzyRuleForm(id, projectId));
|
||||
|
||||
return "rule/edit";
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,10 @@ public class VariableController {
|
||||
public String edit(@PathVariable(value = "projectId") Integer projectId,
|
||||
@PathVariable(value = "varId") Integer id, Model model) {
|
||||
model.addAttribute("projectId", projectId);
|
||||
model.addAttribute("variableForm",
|
||||
new VariableForm(id, (id != null && id != 0)
|
||||
? variableService.getById(id).getProject().getId()
|
||||
: projectId));
|
||||
|
||||
model.addAttribute("variableForm",
|
||||
(id != null && id != 0)
|
||||
? new VariableForm(id, variableService.getById(id))
|
||||
: new VariableForm(id, projectId));
|
||||
return "var/edit";
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,14 @@ import ru.ulstu.fc.core.model.BaseEntity;
|
||||
@Entity
|
||||
public class FuzzyTerm extends BaseEntity {
|
||||
private String description;
|
||||
private Double value;
|
||||
private Double crispValue;
|
||||
|
||||
public FuzzyTerm() {
|
||||
}
|
||||
|
||||
public FuzzyTerm(String description, Double value) {
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.crispValue = value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
@ -24,12 +24,11 @@ public class FuzzyTerm extends BaseEntity {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
public Double getCrispValue() {
|
||||
return crispValue;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
public void setCrispValue(Double crispValue) {
|
||||
this.crispValue = crispValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ public class VariableForm {
|
||||
@Size(min = 3, max = 250, message = "Длина должна быть от 3 до 250")
|
||||
private String name;
|
||||
|
||||
private boolean isInput = true;
|
||||
|
||||
public VariableForm() {
|
||||
}
|
||||
|
||||
@ -18,6 +20,13 @@ public class VariableForm {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public VariableForm(Integer id, Variable variable) {
|
||||
this.id = id;
|
||||
this.projectId = variable.getProject().getId();
|
||||
this.name = variable.getName();
|
||||
this.isInput = variable.isInput();
|
||||
}
|
||||
|
||||
public Integer getProjectId() {
|
||||
return projectId;
|
||||
}
|
||||
@ -42,4 +51,11 @@ public class VariableForm {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isInput() {
|
||||
return isInput;
|
||||
}
|
||||
|
||||
public void setInput(boolean isInput) {
|
||||
this.isInput = isInput;
|
||||
}
|
||||
}
|
||||
|
@ -45,15 +45,15 @@ public class FuzzyInferenceService {
|
||||
final InputVariable input = new InputVariable();
|
||||
input.setName(variable.getName());
|
||||
input.setDescription("");
|
||||
input.setRange(0, variable.getFuzzyTerms().get(variable.getFuzzyTerms().size() - 1).getValue());
|
||||
input.setRange(0, variable.getFuzzyTerms().get(variable.getFuzzyTerms().size() - 1).getCrispValue());
|
||||
input.setEnabled(true);
|
||||
input.setLockValueInRange(false);
|
||||
double prev = 0;
|
||||
for (int i = 0; i < variable.getFuzzyTerms().size(); i++) {
|
||||
Triangle term = new Triangle(variable.getFuzzyTerms().get(i).getDescription(),
|
||||
prev,
|
||||
variable.getFuzzyTerms().get(i).getValue(),
|
||||
variable.getFuzzyTerms().get(i).getValue() + variable.getFuzzyTerms().get(i).getValue() - prev);
|
||||
variable.getFuzzyTerms().get(i).getCrispValue(),
|
||||
variable.getFuzzyTerms().get(i).getCrispValue() + variable.getFuzzyTerms().get(i).getCrispValue() - prev);
|
||||
prev = term.getVertexB();
|
||||
input.addTerm(term);
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class FuzzyInferenceService {
|
||||
final OutputVariable output = new OutputVariable();
|
||||
output.setName(variable.getName());
|
||||
output.setDescription("");
|
||||
output.setRange(0, variable.getFuzzyTerms().get(variable.getFuzzyTerms().size() - 1).getValue());
|
||||
output.setRange(0, variable.getFuzzyTerms().get(variable.getFuzzyTerms().size() - 1).getCrispValue());
|
||||
output.setEnabled(true);
|
||||
output.setAggregation(new Maximum());
|
||||
output.setDefuzzifier(new WeightedAverage());
|
||||
@ -75,8 +75,8 @@ public class FuzzyInferenceService {
|
||||
Triangle term = new Triangle(
|
||||
variable.getFuzzyTerms().get(i).getDescription(),
|
||||
prev,
|
||||
variable.getFuzzyTerms().get(i).getValue(),
|
||||
variable.getFuzzyTerms().get(i).getValue() + variable.getFuzzyTerms().get(i).getValue() - prev);
|
||||
variable.getFuzzyTerms().get(i).getCrispValue(),
|
||||
variable.getFuzzyTerms().get(i).getCrispValue() + variable.getFuzzyTerms().get(i).getCrispValue() - prev);
|
||||
prev = term.getVertexB();
|
||||
output.addTerm(term);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user