Header menu logo bristlecone

ScriptNotebook

Integration Methods

Bristlecone supports model systems defined in discrete or continuous time. For continuous-time model systems - defined as ordinary differential equation(s) - Bristlecone applies numerical integration to calculate changes in the modelled properties through time.

Included integration methods

The following integration functions are included within the Bristlecone.Integration namespace:

Solver

Function

Description

Runge-Kutta 4

Integration.RungeKutta.rk4

A fourth-order Runge Kutta method to provide approximate solutions to ODE systems.

Adding a custom integration method

You can add a custom integration routine by wrapping your integration function to match the EstimationEngine.Integration.IntegrationRoutine type signature as follows:

open Bristlecone

let myCustomIntegrator: EstimationEngine.Integration.IntegrationRoutine =
    fun tInitial tEnd tStep initialConditions rhs -> invalidOp "Doesn't actually do anything!"

let engine () =
    Bristlecone.mkContinuous () |> Bristlecone.withContinuousTime myCustomIntegrator

When defining a custom integration routine, the argument rhs is a compiled internally using Base.makeCompiledFunctionForIntegration function from the Bristlecone.Integration namespace. This function is used to compile a 'right-hand side' equation that 'bakes in' the environment (external forcing) data.

Multiple items
module Bristlecone from Bristlecone
<namespacedoc><summary>The core library of Bristlecone, containing model-fitting functions.</summary></namespacedoc>
Main functionality of Bristlecone, including functions to scaffold `ModelSystem`s and for model-fitting (tests and real fits).


--------------------
namespace Bristlecone
val myCustomIntegrator: tInitial: Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> tEnd: Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> tStep: Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> initialConditions: CodedMap<Tensors.TypedTensor<Tensors.Scalar,ModelSystem.state>> -> rhs: EstimationEngine.ParameterisedRHS -> CodedMap<Tensors.TypedTensor<Tensors.Vector,ModelSystem.state>>
module EstimationEngine from Bristlecone
<summary> The estimation engine represents the method used to calculate equations and optimise a likelihood function. The whole estimation engine is tensor-based internally, but may take float-based equations as a legacy option. </summary>
module Integration from Bristlecone.EstimationEngine
type IntegrationRoutine = Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> Tensors.TypedTensor<Tensors.Scalar,Time.time index> -> CodedMap<Tensors.TypedTensor<Tensors.Scalar,ModelSystem.state>> -> EstimationEngine.ParameterisedRHS -> CodedMap<Tensors.TypedTensor<Tensors.Vector,ModelSystem.state>>
<summary> Represents a low-level numerical method used to integrate functions. Takes the intial time, final time, and time step, and returns a function that is compiled to only require the current time and current state. Must return the baseline state plus evolutions. </summary>
val tInitial: Tensors.TypedTensor<Tensors.Scalar,Time.time index>
val tEnd: Tensors.TypedTensor<Tensors.Scalar,Time.time index>
val tStep: Tensors.TypedTensor<Tensors.Scalar,Time.time index>
val initialConditions: CodedMap<Tensors.TypedTensor<Tensors.Scalar,ModelSystem.state>>
val rhs: EstimationEngine.ParameterisedRHS
val invalidOp: message: string -> 'T
val engine: unit -> EstimationEngine.EstimationEngine<System.DateTime,System.TimeSpan,Time.year,'u>
val mkContinuous: unit -> EstimationEngine.EstimationEngine<System.DateTime,System.TimeSpan,Time.year,'u>
<summary>A basic estimation engine for ordinary differential equations, using a Nelder-Mead optimiser.</summary>
val withContinuousTime: t: EstimationEngine.Integration.IntegrationRoutine -> engine: EstimationEngine.EstimationEngine<'a,'b,'u,'v> -> EstimationEngine.EstimationEngine<'a,'b,'u,'v>
<summary> Use a custom integration method </summary>

Type something to start searching.