From 38fb4d376ae86c2d2549529f7752b97a9d4304fa Mon Sep 17 00:00:00 2001 From: Christopher Teubert Date: Mon, 31 Jul 2023 14:28:14 -0700 Subject: [PATCH] MC horizon issue --- src/prog_algs/predictors/monte_carlo.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/prog_algs/predictors/monte_carlo.py b/src/prog_algs/predictors/monte_carlo.py index 8a1bd125..ec2ac94c 100644 --- a/src/prog_algs/predictors/monte_carlo.py +++ b/src/prog_algs/predictors/monte_carlo.py @@ -74,6 +74,7 @@ def predict(self, state: UncertainData, future_loading_eqn: Callable, **kwargs) # Perform prediction t0 = params.get('t0', 0) + HORIZON = params.get('horizon', float('inf')) # Save the horizon to be used later for x in state: first_output = self.model.output(x) @@ -82,6 +83,7 @@ def predict(self, state: UncertainData, future_loading_eqn: Callable, **kwargs) params['t0'] = t0 params['x'] = x + params['horizon'] = HORIZON # reset to initial horizon if 'save_freq' in params and not isinstance(params['save_freq'], tuple): params['save_freq'] = (params['t0'], params['save_freq']) @@ -93,6 +95,12 @@ def predict(self, state: UncertainData, future_loading_eqn: Callable, **kwargs) **params ) else: + # Since horizon is relative to t0 (the simulation starting point), + # we must subtract the difference in current t0 from the initial (i.e., prediction t0) + # each subsequent simulation + params['horizon'] = HORIZON - (params['t0'] - t0) + + # Simulate events_remaining = params['events'].copy() times = []