|
|
@ -18,7 +18,6 @@ import java.util.List;
|
|
|
|
public class GenerationService {
|
|
|
|
public class GenerationService {
|
|
|
|
private final TimeSeriesService timeSeriesService;
|
|
|
|
private final TimeSeriesService timeSeriesService;
|
|
|
|
private final BranchService branchService;
|
|
|
|
private final BranchService branchService;
|
|
|
|
private final static double RANDOM_WEIGHT = 0.1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public GenerationService(TimeSeriesService timeSeriesService,
|
|
|
|
public GenerationService(TimeSeriesService timeSeriesService,
|
|
|
|
BranchService branchService) {
|
|
|
|
BranchService branchService) {
|
|
|
@ -44,18 +43,20 @@ public class GenerationService {
|
|
|
|
double newValue;
|
|
|
|
double newValue;
|
|
|
|
int maxTryCount = 10;
|
|
|
|
int maxTryCount = 10;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
|
|
|
|
double oneStepDiff = generationForm.getRandomWeight() * (Math.random() - 0.5) * (generationForm.getMax() - generationForm.getMin()) / (generationForm.getTsLength() + 10);
|
|
|
|
if (timeSeriesValues.isEmpty()) {
|
|
|
|
if (timeSeriesValues.isEmpty()) {
|
|
|
|
if (generationForm.getBaseTendency() > 0) {
|
|
|
|
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 {
|
|
|
|
} else {
|
|
|
|
newValue = generationForm.getMax() - 0.1 * Math.random() * (generationForm.getMax() - generationForm.getMin());
|
|
|
|
newValue = generationForm.getBase();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
newValue = timeSeriesValues.get(timeSeriesValues.size() - 1).getValue()
|
|
|
|
newValue = timeSeriesValues.get(timeSeriesValues.size() - 1).getValue()
|
|
|
|
+ Math.random() * generationForm.getBaseTendency()
|
|
|
|
+ (generationForm.getRandomWeight() > 0.0 ? oneStepDiff : 1.0) * generationForm.getBaseTendency()
|
|
|
|
* ((generationForm.getMax() - generationForm.getMin()) / generationForm.getTsLength())
|
|
|
|
* ((generationForm.getMax() - generationForm.getMin()) / (generationForm.getTsLength() + 10))
|
|
|
|
* generationForm.getTendencyDynamic()
|
|
|
|
* generationForm.getTendencyDynamic();
|
|
|
|
+ RANDOM_WEIGHT * (Math.random() - 0.5) * (generationForm.getMax() - generationForm.getMin());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
maxTryCount--;
|
|
|
|
maxTryCount--;
|
|
|
|
} while (((newValue <= generationForm.getMin())
|
|
|
|
} while (((newValue <= generationForm.getMin())
|
|
|
|