stochasticRKIntegratorBase

class StochasticRKIntegratorBase : public StateVecStochasticIntegrator
#include <stochasticRKIntegratorBase.h>

Shared base for the native stochastic Runge-Kutta integrators (Euler-Maruyama, the SRI/SRA strong methods, the weak W2Ito/DRI1/RI/RS/SIESME families, RDI1WM and Euler-Heun/RKMil).

It factors out the machinery every one of these integrators needs, so each concrete method only has to implement its own integrate() step recurrence:

Every native stochastic integrator derives from this base. Methods that need only the Wiener increment (Euler-Maruyama, Euler-Heun, RKMil) simply ignore the second increment dZ the generator also draws.

Warning

Stochastic integration is in beta.

Subclassed by svIntegratorStrongStochasticRungeKuttaSRA< numberStages >, svIntegratorStrongStochasticRungeKuttaSRI< numberStages >, svIntegratorWeakSIESME

Public Functions

inline void setRNGSeed(size_t seed)

Sets the seed for the (default) Random Number Generator used by this integrator.

As a stochastic integrator, random numbers are drawn during each time step. By default a randomly generated seed is used. Setting the seed makes the integrator draw the same sequence each run. Has no effect if a custom noise generator that does not honour the seed was installed via setNoiseGenerator.

inline void setNoiseGenerator(std::shared_ptr<GaussianNoiseGenerator> generator)

Replaces the noise generator used by this integrator. This is primarily useful for testing, where a PrescribedGaussianNoiseGenerator can be installed so the integrator replays a known sequence of Wiener increments.

Public Members

std::shared_ptr<GaussianNoiseGenerator> rvGenerator = std::make_shared<RandomGaussianNoiseGenerator>()

Random Number Generator for the integrator (supplies dW and dZ per noise source).

Protected Functions

const std::vector<StateIdToIndexMap> &noiseIndexMaps()

Returns the (cached) state-id -> noise-index maps. The topology is fixed for the run, so it is computed once on first use and reused thereafter.

ExtendedStateVector computeDerivatives(double time, double timeStep)

Computes f at the current state/time (sets states, calls equationsOfMotion).

ExtendedStateVector computeDiffusion(double time, double timeStep, const StateIdToIndexMap &stateIdToNoiseIndexMap)

Computes g for a single noise source at the current state/time.

std::vector<ExtendedStateVector> computeDiffusions(double time, double timeStep, const std::vector<StateIdToIndexMap> &stateIdToNoiseIndexMaps)

Computes g for every noise source at the current state/time.

Private Members

std::vector<StateIdToIndexMap> cachedNoiseIndexMaps

Cached noise-index maps (empty until first noiseIndexMaps() call).

bool noiseIndexMapsCached = false