revise package structure: always predict from 1am to horizon, dataset not cut at...
[talweg.git] / pkg / R / Forecaster.R
index cefa1ea..5258760 100644 (file)
@@ -52,15 +52,20 @@ Forecaster = R6::R6Class("Forecaster",
                        private$.pjump <- pjump
                        invisible(self)
                },
-               predictSerie = function(data, today, memory, horizon, ...)
+               predictSerie = function(data, today, memory, predict_from, horizon, ...)
                {
                        # Parameters (potentially) computed during shape prediction stage
-                       predicted_shape = self$predictShape(data, today, memory, horizon, ...)
-                       predicted_delta = private$.pjump(data,today,memory,horizon,private$.params,...)
-                       # Predicted shape is aligned it on the end of current day + jump
-                       predicted_shape+tail(data$getSerie(today),1)-predicted_shape[1]+predicted_delta
+                       predicted_shape = self$predictShape(data,today,memory,predict_from,horizon,...)
+                       predicted_delta = private$.pjump(data, today, memory, predict_from, horizon,
+                               private$.params, ...)
+
+                       # Predicted shape is aligned on the end of current day + jump
+                       c( data$getSerie(today)[if (predict_from>=2) 1:(predict_from-1) else c()],
+                               predicted_shape - predicted_shape[1] + predicted_delta +
+                                       ifelse(predict_from>=2,
+                                               data$getSerie(today)[predict_from-1], tail(data$getSerie(today-1),1)) )
                },
-               predictShape = function(data, today, memory, horizon, ...)
+               predictShape = function(data, today, memory, predict_from, horizon, ...)
                        NULL #empty default implementation: to implement in inherited classes
                ,
                getParameters = function()