TaylorTrajectoryN#

class TaylorTrajectoryN(order, time_grid, particle_trajectories, batch_size=None, fit_on_init=True, is_periodic=False)[source]#

Fits a taylor Polynomial of specified order to the given 3D particle trajectories and stores the resulting coefficients per particle. When called, evaluates the Taylor-expansion at given timing in a tf.function compatible definition.

Incrementing particle positions is done by keeping track of the current timing. Batching the particles for all evaluations is done by setting the attributes self.batch_size and self.current_batch_idx. This results in the indexing: [self.batch_size*self.current_batch_idx : self.batch_size*self.current_batch_idx+1]

Example Usage
Instantiation#
ref_timing = ... # shape (T, )
ref_trajectory = ... # shape (N, T, dims)
module = TaylorTrajectoryN(order=3, time_grid=ref_timing,
                          particle_trajectories=ref_trajectory)
Parameters:
  • order (int) – Order of the fitted TaylorPolynomial

  • time_grid (ndarray) – (#timesteps, )

  • particle_trajectories (ndarray) – (#particles, #timesteps, 3)

  • batch_size (int) – used for evaluating the particle trajectories in batches

  • fit_on_init (bool) – If True, the Polynomial is fitted on instantiation of the module.

  • is_periodic (constant) –

Methods:

__call__(initial_positions, timing[, ...])

Evaluates the taylor expansion for the current batch of particles at the specified times t.

fit(t_grid, particle_trajectories)

Fits a Taylor polynomial of order self.order to each particle trajectory.

increment_particles(particle_positions, dt, ...)

Evaluates the particle position for the time self.current_time_ms + dt and adds the delta t to the current_time_ms variable

Attributes:

batch_size

Together with self.current_batch_size determines the subset of particle trajectories that is evaluated on call and increment_particles

current_batch_idx

Allows to only evaluate the position for a batch of stored particle trajectories

current_time_ms

Keeps track of the current timing when increment_particles is called.

end_time

is_periodic

Is periodic

optimal_parameters

Stores the result of fitting the TaylorPolynomial for all particle trajectories

order

Stores the order of the TaylorPolynomial, defined on instantiation

ref_time

__call__(initial_positions, timing, batch_index=0, **kwargs)[source]#

Evaluates the taylor expansion for the current batch of particles at the specified times t.

Parameters:
  • timing (Tensor) – (#timesteps) in milliseconds

  • initial_positions (Tensor) –

  • batch_index (int) –

Return type:

(Tensor, dict)

Returns:

(#particles, #timesteps, 3) in meter

fit(t_grid, particle_trajectories)[source]#

Fits a Taylor polynomial of order self.order to each particle trajectory.

Parameters:
  • t_grid (ndarray) – (T, ) times corresponding to the particle positions

  • particle_trajectories (ndarray) – (N, T, dim)

Returns:

optimal motion parameters (N, order, dim) containing all parameters (r0, v, a, j, …) for N particles

increment_particles(particle_positions: ~tensorflow.python.framework.tensor.Tensor, dt: ~tensorflow.python.framework.tensor.Tensor, **kwargs) -> (<class 'tensorflow.python.framework.tensor.Tensor'>, <class 'dict'>)[source]#

Evaluates the particle position for the time self.current_time_ms + dt and adds the delta t to the current_time_ms variable

Parameters:
  • r – unused parameter (to adhere to calling signature of trajectory modules)

  • dt (Tensor) – temporal step lengths

  • kwargs – unused parameter (to adhere to calling signature of trajectory modules)

  • particle_positions (Tensor) –

Return type:

(Tensor, dict)

Returns:

(#batch, 3)

batch_size: Variable#

Together with self.current_batch_size determines the subset of particle trajectories that is evaluated on call and increment_particles

current_batch_idx: Variable#

Allows to only evaluate the position for a batch of stored particle trajectories

current_time_ms: Variable#

Keeps track of the current timing when increment_particles is called.

end_time: Variable#
is_periodic: constant#

Is periodic

optimal_parameters: Variable#

Stores the result of fitting the TaylorPolynomial for all particle trajectories

order: Variable#

Stores the order of the TaylorPolynomial, defined on instantiation

ref_time: Variable#