#96 -- Fix time series generation
This commit is contained in:
parent
8bcdff3ba1
commit
1192201a69
@ -2,11 +2,12 @@ package ru.ulstu.extractor.generation.model;
|
||||
|
||||
public class GenerationForm {
|
||||
private int tsLength;
|
||||
private int min;
|
||||
private int max;
|
||||
private int base;
|
||||
private int baseTendency;
|
||||
private int tendencyDynamic;
|
||||
private double min;
|
||||
private double max;
|
||||
private double base;
|
||||
private double baseTendency;
|
||||
private double tendencyDynamic;
|
||||
private double randomWeight;
|
||||
|
||||
public int getTsLength() {
|
||||
return tsLength;
|
||||
@ -16,43 +17,51 @@ public class GenerationForm {
|
||||
this.tsLength = tsLength;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
public double getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public void setMin(int min) {
|
||||
public void setMin(double min) {
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
public double getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
public void setMax(double max) {
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
public int getBase() {
|
||||
public double getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(int base) {
|
||||
public void setBase(double base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public int getBaseTendency() {
|
||||
public double getBaseTendency() {
|
||||
return baseTendency;
|
||||
}
|
||||
|
||||
public void setBaseTendency(int baseTendency) {
|
||||
public void setBaseTendency(double baseTendency) {
|
||||
this.baseTendency = baseTendency;
|
||||
}
|
||||
|
||||
public int getTendencyDynamic() {
|
||||
public double getTendencyDynamic() {
|
||||
return tendencyDynamic;
|
||||
}
|
||||
|
||||
public void setTendencyDynamic(int tendencyDynamic) {
|
||||
public void setTendencyDynamic(double tendencyDynamic) {
|
||||
this.tendencyDynamic = tendencyDynamic;
|
||||
}
|
||||
|
||||
public double getRandomWeight() {
|
||||
return randomWeight;
|
||||
}
|
||||
|
||||
public void setRandomWeight(double randomWeight) {
|
||||
this.randomWeight = randomWeight;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
||||
public class GenerationService {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final BranchService branchService;
|
||||
private final static double RANDOM_WEIGHT = 0.1;
|
||||
|
||||
public GenerationService(TimeSeriesService timeSeriesService,
|
||||
BranchService branchService) {
|
||||
@ -44,18 +43,20 @@ public class GenerationService {
|
||||
double newValue;
|
||||
int maxTryCount = 10;
|
||||
do {
|
||||
double oneStepDiff = generationForm.getRandomWeight() * (Math.random() - 0.5) * (generationForm.getMax() - generationForm.getMin()) / (generationForm.getTsLength() + 10);
|
||||
if (timeSeriesValues.isEmpty()) {
|
||||
if (generationForm.getBaseTendency() > 0) {
|
||||
newValue = 0.1 * Math.random() * (generationForm.getMax() - generationForm.getMin());
|
||||
newValue = 0.1 * (generationForm.getRandomWeight() > 0.0 ? oneStepDiff : 1.0) * (generationForm.getMax() - generationForm.getMin());
|
||||
} else if (generationForm.getBaseTendency() < 0) {
|
||||
newValue = generationForm.getMax() - 0.1 * (generationForm.getRandomWeight() > 0.0 ? oneStepDiff : 1.0) * (generationForm.getMax() - generationForm.getMin());
|
||||
} else {
|
||||
newValue = generationForm.getMax() - 0.1 * Math.random() * (generationForm.getMax() - generationForm.getMin());
|
||||
newValue = generationForm.getBase();
|
||||
}
|
||||
} else {
|
||||
newValue = timeSeriesValues.get(timeSeriesValues.size() - 1).getValue()
|
||||
+ Math.random() * generationForm.getBaseTendency()
|
||||
* ((generationForm.getMax() - generationForm.getMin()) / generationForm.getTsLength())
|
||||
* generationForm.getTendencyDynamic()
|
||||
+ RANDOM_WEIGHT * (Math.random() - 0.5) * (generationForm.getMax() - generationForm.getMin());
|
||||
+ (generationForm.getRandomWeight() > 0.0 ? oneStepDiff : 1.0) * generationForm.getBaseTendency()
|
||||
* ((generationForm.getMax() - generationForm.getMin()) / (generationForm.getTsLength() + 10))
|
||||
* generationForm.getTendencyDynamic();
|
||||
}
|
||||
maxTryCount--;
|
||||
} while (((newValue <= generationForm.getMin())
|
||||
|
@ -56,6 +56,14 @@
|
||||
<input type="text" class="form-control m-1" th:field="*{tendencyDynamic}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-12">
|
||||
Величина шума
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<input type="text" class="form-control m-1" th:field="*{randomWeight}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<input type="submit" class="btn btn-outline-success form-control" value="Сгенерировать временные ряды"/>
|
||||
|
Loading…
Reference in New Issue
Block a user