/** * * @return TS */ protected ITimeSeries<T> prepareForecastTS() { final ITimeSeries<T> history = this.getTsOriginal(); final long startTime = history.getStartTime(); final TimeSeries<T> tsFC = new TimeSeries<T>(startTime, history.getTimeSeriesTimeUnit(), history.getDeltaTime(), history.getDeltaTimeUnit()); return tsFC; }
@Override public String toString() { return this.name + " >> " + super.toString(); } }
/** * Checks whether the requirements for the input TS are met. * This default implementation checks whether the length of the time series is greater or equal to {@value #MIN_TS_SIZE_DEFAULT}. * This method can be overridden by any forecaster if more specific requirements are needed. */ protected boolean satisfiesInputTSRequirements(final ITimeSeries<Double> timeSeries) { return timeSeries.size() >= MIN_TS_SIZE_DEFAULT; }
/** * @param value * value which should append to timeseries * * @return tspoint */ @Override public ITimeSeriesPoint<T> append(final T value) { final ITimeSeriesPoint<T> point; synchronized (value) { point = new TimeSeriesPoint<T>(this.nextTime, value); this.points.add(point); this.startTime = this.points.peek().getTime(); // we have a bounded buffer so the first element might be gone this.nextTime = this.nextTime + this.timeSeriesStepSize; } return point; }
@Override public int size() { return this.points.getSize(); }
@Override public int getSize() { return this.size(); }
/** * @param ts * timeseries * @return maximum value of the time series */ private static double calcMaximum(final ITimeSeries<Double> ts) { final List<Double> values = ts.getValues(); double max = 0; for (final double t : values) { if (t > max) { max = t; } } return max; } }
@Override public synchronized boolean add(final T o) { // NOPMD It would not make sense to sync within this method if (this.unbounded) { return super.add(o); } else { return this.addBounded(o); } }
/** * * @return TS */ protected ITimeSeries<T> prepareForecastTS() { final ITimeSeries<T> history = this.getTsOriginal(); final long startTime = history.getStartTime(); final TimeSeries<T> tsFC = new TimeSeries<>(startTime, history.getTimeSeriesTimeUnit(), history.getDeltaTime(), history.getDeltaTimeUnit()); return tsFC; }
/** * @param value * value which should append to timeseries * * @return tspoint */ @Override public ITimeSeriesPoint<T> append(final T value) { final ITimeSeriesPoint<T> point; synchronized (value) { point = new TimeSeriesPoint<>(this.nextTime, value); this.points.add(point); this.startTime = this.points.peek().getTime(); // we have a bounded buffer so the first element might be gone this.nextTime = this.nextTime + this.timeSeriesStepSize; } return point; }
/** * Checks whether the requirements for the input TS are met. * This default implementation checks whether the length of the time series is greater or equal to {@value #MIN_TS_SIZE_DEFAULT}. * This method can be overridden by any forecaster if more specific requirements are needed. * * @param timeSeries time series * * @return returns true when requirements are met */ protected boolean satisfiesInputTSRequirements(final ITimeSeries<Double> timeSeries) { return timeSeries.size() >= MIN_TS_SIZE_DEFAULT; }
@Override public int size() { return this.points.getSize(); }
@Override public int getSize() { return this.size(); }
@Override public String toString() { return this.name + " >> " + super.toString(); } }
/** * @param ts * timeseries * @return maximum value of the time series */ private static double calcMaximum(final ITimeSeries<Double> ts) { final List<Double> values = ts.getValues(); double max = 0; for (final double t : values) { if (t > max) { max = t; } } return max; } }
private synchronized boolean addBounded(final T o) { // NOPMD It would not make sense to sync within this method if (this.size() == this.capacity) { super.poll(); return super.add(o); } else { return super.add(o); } }