🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Rollout: learning the solution vs the simulation

User: "Eamon Whalen"
Altair Employee
Updated by Eamon Whalen

I keep learning about new ways to model time – that’s what makes working with dynamical systems so interesting. Today we’ll walk through two of the more common methods: time-dependent models and rollout models, and assess the benefits of each.

Suppose we want to predict the dynamic behavior of a spring system parametrized by its spring constant, k. A time-dependent model takes in design parameters (k) and the current time (t) as inputs and predicts the displacement (u).

In contrast, a rollout model takes as inputs the current state of the model, represented in our case by the displacement (u) and velocity (v). The output of a rollout model is actually the change in the state, which then has to be fed through a numerical integrator to get the next state:


image


Three observations thus far:

  1. The time-dependent model explicitly parametrizes time while rollout does not
  2. While it may appear that both models require one prediction per time step, the time-dependent predictions can occur in parallel, which makes them faster
  3. There's nothing special about the function f, it could be any regression model. The difference is in how it's used


Model training

Let’s take these models for a test drive.

For training data, we’ll simulate seven spring systems with random k-values ranging from k=[0.2-3.0] for 1 unit of time. Note that we also have to compute du and dv, the change in position and velocity between each step. I chose a fully connected neural network (NN) with three hidden layers of width 200 and relu activations for both models. For the integrator I used the trusty Forward Euler method.  Now let’s test the models with some new springs:


image


Both methods to a pretty good job within the range of the training data. The rollout might extrapolate a bit better, but overall, I’d say both models do what we’ve asked them to.


Forecasting

What happens if we take these same two models and attempt to forecast the system’s behavior past the training window? Here we test the models on k=1.2 and for 5 units of time:


image


The time-dependent model fails miserably here because it is extrapolating in time. The rollout model does not have this problem. Rather than memorize the solution of the dynamical system, it appears to know a bit more about its behavior which is innately time independent. Note the accumulation of error as the rollout model progresses.


Changing the initial conditions

All of the training data had the same initial conditions of u=1 and v=0. Can our models generalize to new initial conditions? Here we test the models on k=1.2 with various initial positions (u). The initial velocity is always zero:


image


The rollout model does quite well here, which should not be a surprise. After all, it is completely unaware of the current time and it has seen this initial state before. On the other hand, the time-dependent model knows only this one trajectory for k=1.2 and has embarrassed itself. You could certainly add the initial conditions to the inputs of the time-dependent model but this would increase the dimensionality of the problem and require more training data.


What did the rollout model learn?

We’ve seen that the rollout model generalizes significantly better than the time-dependent model in time and in initial conditions. It would seem as if the rollout model has captured a more fundamental pattern about the system's behavior.

Since we’re working with such a simple system, we can actually peek inside the rollout model and see if what it has learned is similar to the underlying physics of the problem.

Recall that our spring system’s state is 2D and that rollout predicts the change in this state between steps. By sweeping the state space and dividing the outputs by the timestep, we can compare what rollout “knows” to the ODE which governs our springs (recall that the acceleration at the end of the spring can be derived from Hooke’s Law and Newton’s 2nd Law):


image


For me this is reassuring. The rollout model seems to have learned some rules which are quite similar to the governing equations of a spring. You might say that the rollout model has learned the transfer function of the system.


Recap

Let’s review some of the pros and cons of using rollout to model dynamical systems:

Pros of rollout:

  • Improved generalization in time
  • Improved generalization in initial conditions

Cons of rollout:

  • Requires tracking the full state of the system. Even if we only care about displacement, we must track the velocity as well
  • Speed: rollout predictions occur sequentially within an integration loop which makes them slower than time-dependent models
  • Numerical stability: the accumulation of errors over the rollout can lead to instability just like with classical solvers

 

There are even more ways of modeling time, including one-step, recurrent neural networks (RNNs), and modeling in frequency space. Which do you think are the most promising methods for dynamical systems in CAE?


Find more posts tagged with

Comments

No comments on this post.