Class System<TShared, TInternal, TData>

Implementation of SystemInterface for continuous or discrete systems. Manages particle states generated by stateless generators.

Type Parameters

  • TShared

    Values which are shared between all particles in a group and are not mutated by them - the model parameter values for that group

  • TInternal

    Internal state values which can be mutated by generators, used to improve efficiency of the system by e.g. caching calculation results for use by other particles.

  • TData

    Type of each data point which will be compared with system state.

Implements

Accessors

Methods

  • Compares the state of all particles in the syatem with observed data, and returns an NdArray of log likelihoods of each particle state given the data, where the NdArray has shape [nGroups, nParticles]

    Parameters

    • data: TData | TData[]

      Observed data to compare against system state

    Returns NdArray<any[]>

  • Runs the system from its current time to the given time, causing its state to be updated. Calls the update method on the generator for each particle.

    Parameters

    • time: number

      The time to run to

    Returns void

  • Sets new values in the system state

    Parameters

    • newState: SystemSubState

      The new state values for all or part of the state. If partial state, the shape must match the values provided in the indices parameters

    • groupIndices: number[] = []

      The group indices, in order, which the first dimension of newState are setting values for. If empty, this means newState provides values for all groups.

    • particleIndices: number[] = []

      The particle indices, in order, which the second dimension of newState are setting values for. If empty, this means newState provides values for all particles.

    • stateElementIndices: number[] = []

      The state element indices, in order, which the second dimension of newState are setting values for. If empty, this means newState provides values for all state elements.

    Returns void

  • Initialises each particle by calling the initial method on the generator and initialises the Dopri solvers if this is a continuous system.

    Returns void

  • Runs the system from its current time to a series of times given by the parameter times and returns state values for all particles at each of these times.

    Parameters

    • times: number[]

      The times to run to and return state for. Must be in increasing order, with no value less than the current time.

    • stateElementIndices: number[] = []

      Indices of the state elements to return in the result. If an empty array is provided, all values are returned.

    Returns SystemSimulateResult

  • Updates shared (parameter) values for all groups in the system.

    Parameters

    • newShared: TShared[]

      Updated parameter values. The length must match the existing number of groups in the system.

    Returns void

  • Type Parameters

    • TShared
    • TInternal
    • TData = null

    Parameters

    • generator: ContinuousGeneratorDDE<TShared, TInternal, TData>

      Continuous DDE generator (model) implementation for the System

    • shared: TShared[]

      Array of TShared, each representing the parameters for a group of particles

    • time: number

      Initial time for the system

    • dt: number

      Time step to be used when updating the system. If the generator does not have an update method or a zeroEvery method then this parameter will be ignored in favour of a more optimised dt that the solver picks. Additionally, if dt <= 0 or dt is Infinity the solver will ignore any update or zeroEvery method on the generator and let the solver run the continuous system.

    • nParticles: number

      Number of particles per group

    • OptionalnRhsVariables: number

      Number of variables to feed into the rhs function of the generator. This may be less than the number of variables of the system if some variables are calculated from the output function of the generator

    • Optionalrandom: Random

      Random number generator which may be used by the generator

    Returns System<TShared, TInternal, TData>

  • Type Parameters

    • TShared
    • TInternal
    • TData = null

    Parameters

    • generator: DiscreteGenerator<TShared, TInternal, TData>

      Discrete generator (model) implementation for the System

    • shared: TShared[]

      Array of TShared, each representing the parameters for a group of particles

    • time: number

      Initial time for the system

    • dt: number

      Time step to be used when updating the system, will error if dt <= 0 or dt is Infinity

    • nParticles: number

      Number of particles per group

    • OptionalnRhsVariables: number

      Number of variables to feed into the rhs function of the generator. This may be less than the number of variables of the system if some variables are calculated from the output function of the generator

    • Optionalrandom: Random

      Random number generator which may be used by the generator

    Returns System<TShared, TInternal, TData>

  • Type Parameters

    • TShared
    • TInternal
    • TData = null

    Parameters

    • generator: ContinuousGeneratorODE<TShared, TInternal, TData>

      Continuous ODE generator (model) implementation for the System

    • shared: TShared[]

      Array of TShared, each representing the parameters for a group of particles

    • time: number

      Initial time for the system

    • dt: number

      Time step to be used when updating the system. If the generator does not have an update method or a zeroEvery method then this parameter will be ignored in favour of a more optimised dt that the solver picks. Additionally, if dt <= 0 or dt is Infinity the solver will ignore any update or zeroEvery method on the generator and let the solver run the continuous system.

    • nParticles: number

      Number of particles per group

    • OptionalnRhsVariables: number

      Number of variables to feed into the rhs function of the generator. This may be less than the number of variables of the system if some variables are calculated from the output function of the generator

    • Optionalrandom: Random

      Random number generator which may be used by the generator

    Returns System<TShared, TInternal, TData>