Skip to content

Commit

Permalink
MC horizon issue
Browse files Browse the repository at this point in the history
  • Loading branch information
teubert committed Jul 31, 2023
1 parent 57546c2 commit 38fb4d3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/prog_algs/predictors/monte_carlo.py
Expand Up @@ -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)

Expand All @@ -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'])
Expand All @@ -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 = []
Expand Down

0 comments on commit 38fb4d3

Please sign in to comment.