From 61b2a21e2d0ffea68312ec3f62132ff4906644ae Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Sat, 29 May 2021 10:53:32 +0400 Subject: [PATCH] use brute force for pages --- src/main/java/ru/ulstu/pages/IndexView.java | 12 ++++++++++-- .../ru/ulstu/services/TimeSeriesService.java | 17 ++++++++--------- .../tsMethods/exponential/parameter/Alpha.java | 8 +++----- .../tsMethods/exponential/parameter/Beta.java | 8 +++----- .../parameter/ExponentialMethodParameter.java | 8 ++++---- .../tsMethods/exponential/parameter/Gamma.java | 8 +++----- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/main/java/ru/ulstu/pages/IndexView.java b/src/main/java/ru/ulstu/pages/IndexView.java index dfffcd4..98bba42 100644 --- a/src/main/java/ru/ulstu/pages/IndexView.java +++ b/src/main/java/ru/ulstu/pages/IndexView.java @@ -1,3 +1,9 @@ +/* + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. + * + */ + package ru.ulstu.pages; import org.primefaces.model.chart.AxisType; @@ -24,8 +30,6 @@ import java.time.format.DateTimeFormatter; @ViewScoped public class IndexView implements Serializable { private final static Logger LOG = LoggerFactory.getLogger(IndexView.class); - private LineChartModel model; - private String timeSeriesString = "1,2,3,2,1,2,3,2,1,2,3"; @Autowired private transient TimeSeriesService timeSeriesService; @@ -33,8 +37,12 @@ public class IndexView implements Serializable { @Autowired private transient UtilService utilService; + private LineChartModel model; + private String timeSeriesString; + @PostConstruct public void init() { + timeSeriesString = utilService.getTimeSeriesToString(utilService.getRandomTimeSeries(50)); createChart(); } diff --git a/src/main/java/ru/ulstu/services/TimeSeriesService.java b/src/main/java/ru/ulstu/services/TimeSeriesService.java index 5c34d3e..168332a 100644 --- a/src/main/java/ru/ulstu/services/TimeSeriesService.java +++ b/src/main/java/ru/ulstu/services/TimeSeriesService.java @@ -1,8 +1,6 @@ /* - * - * * Copyright (C) 2021 Anton Romanov - All Rights Reserved - * * You may use, distribute and modify this code, please write to: romanov73@gmail.com. - * + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ @@ -23,6 +21,11 @@ import ru.ulstu.tsMethods.exponential.parameter.ExponentialMethodParamValue; @Service public class TimeSeriesService { private static final Logger LOGGER = LoggerFactory.getLogger(TimeSeriesService.class); + private final MethodParamBruteForce methodParamBruteForce; + + public TimeSeriesService(MethodParamBruteForce methodParamBruteForce) { + this.methodParamBruteForce = methodParamBruteForce; + } public TimeSeries getForecast(TimeSeries timeSeries, int countPoints) throws ModelingException { TimeSeriesMethod method; @@ -32,10 +35,6 @@ public class TimeSeriesService { } public TimeSeries smoothTimeSeries(TimeSeries timeSeries) throws ModelingException { - //NoTrendNoSeason nn = new NoTrendNoSeason(timeSeries, ExponentialMethodParams.of(ExponentialParamName.ALPHA, 0.8)); - TimeSeriesMethod method; - method = new NoTrendNoSeason().createFor(timeSeries); - method = new AddTrendAddSeason().createFor(timeSeries); - return method.getModel(); + return methodParamBruteForce.getSmoothedTimeSeries(timeSeries).getTimeSeries(); } } diff --git a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Alpha.java b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Alpha.java index 1e6b442..264a113 100644 --- a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Alpha.java +++ b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Alpha.java @@ -1,8 +1,6 @@ /* - * - * * Copyright (C) 2021 Anton Romanov - All Rights Reserved - * * You may use, distribute and modify this code, please write to: romanov73@gmail.com. - * + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ @@ -10,7 +8,7 @@ package ru.ulstu.tsMethods.exponential.parameter; public class Alpha extends ExponentialMethodParameter { public Alpha() { - super("ALPHA", 0, 1, DEFAULT_OPTIMIZATION_STEP); + super("ALPHA", DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_OPTIMIZATION_STEP); } public static Alpha getInstance() { diff --git a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Beta.java b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Beta.java index 7ea9ead..aa58665 100644 --- a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Beta.java +++ b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Beta.java @@ -1,8 +1,6 @@ /* - * - * * Copyright (C) 2021 Anton Romanov - All Rights Reserved - * * You may use, distribute and modify this code, please write to: romanov73@gmail.com. - * + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ @@ -10,7 +8,7 @@ package ru.ulstu.tsMethods.exponential.parameter; public class Beta extends ExponentialMethodParameter { public Beta() { - super("BETA", 0, 1, DEFAULT_OPTIMIZATION_STEP); + super("BETA", DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_OPTIMIZATION_STEP); } public static Beta getInstance() { diff --git a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/ExponentialMethodParameter.java b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/ExponentialMethodParameter.java index e9a68b0..61e1c8f 100644 --- a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/ExponentialMethodParameter.java +++ b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/ExponentialMethodParameter.java @@ -1,8 +1,6 @@ /* - * - * * Copyright (C) 2021 Anton Romanov - All Rights Reserved - * * You may use, distribute and modify this code, please write to: romanov73@gmail.com. - * + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ @@ -16,6 +14,8 @@ import java.util.List; public abstract class ExponentialMethodParameter extends MethodParameter { public static final Float DEFAULT_OPTIMIZATION_STEP = 0.1f; + public static final Float DEFAULT_MIN_VALUE = 0.1f; + public static final Float DEFAULT_MAX_VALUE = 0.99f; private final Number minValue; private final Number maxValue; private final Number optimizationStep; diff --git a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Gamma.java b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Gamma.java index e319fc1..95a3bc3 100644 --- a/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Gamma.java +++ b/src/main/java/ru/ulstu/tsMethods/exponential/parameter/Gamma.java @@ -1,8 +1,6 @@ /* - * - * * Copyright (C) 2021 Anton Romanov - All Rights Reserved - * * You may use, distribute and modify this code, please write to: romanov73@gmail.com. - * + * Copyright (C) 2021 Anton Romanov - All Rights Reserved + * You may use, distribute and modify this code, please write to: romanov73@gmail.com. * */ @@ -10,7 +8,7 @@ package ru.ulstu.tsMethods.exponential.parameter; public class Gamma extends ExponentialMethodParameter { public Gamma() { - super("Gamma", 0, 1, DEFAULT_OPTIMIZATION_STEP); + super("Gamma", DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, DEFAULT_OPTIMIZATION_STEP); } public static Gamma getInstance() {