Public API
HighDimPDE.PIDEProblem — Type
PIDEProblemProblem definition for a partial integro-differential equation solved by HighDimPDE.
Fields
u0: initial PDE state evaluated atx.g: terminal or initial condition function.f: nonlinear local or nonlocal PDE contribution.μ: drift function.σ: diffusion function.x: PDE evaluation point.tspan: start and end times.p: user-supplied model parameters.x0_sample: strategy used to sample initial states.neumann_bc: optional lower and upper Neumann boundary vectors.kwargs: additional solver-specific problem metadata.
HighDimPDE.PIDEProblem — Method
PIDEProblem(μ, σ, x0, tspan, g, f; p = nothing, x0_sample = NoSampling(), neumann_bc = nothing, kwargs...)Define a partial integro-differential equation problem of the form
\[\begin{aligned} \frac{du}{dt} &= \tfrac{1}{2} \text{Tr}(\sigma \sigma^T) \Delta u(x, t) + \mu \nabla u(x, t) \\ &\quad + \int f(x, y, u(x, t), u(y, t), ( \nabla_x u )(x, t), ( \nabla_x u )(y, t), p, t) dy, \end{aligned}\]
with $u(x,0) = g(x)$.
Arguments
g: initial condition, of the formg(x, p, t).f: nonlinear function, of the formf(x, y, u(x, t), u(y, t), ∇u(x, t), ∇u(y, t), p, t).μ: drift function, of the formμ(x, p, t).σ: diffusion functionσ(x, p, t).x: point whereu(x,t)is approximated. Is required even in the case wherex0_sampleis provided. Determines the dimensionality of the PDE.tspan: timespan of the problem.p: the parameter vector.x0_sample: sampling method forx0. Can beUniformSampling(a,b),NormalSampling(σ_sampling, shifted), orNoSampling(by default). IfNoSampling, only solution at the single pointxis evaluated.neumann_bc: Neumann boundary conditions on the hypercubeneumann_bc[1] × neumann_bc[2].
Examples
using LinearAlgebra: I
μ(x, p, t) = zero(x)
σ(x, p, t) = I
g(x) = sum(abs2, x)
f(x, y, ux, uy, dux, duy, p, t) = zero(x)
prob = PIDEProblem(μ, σ, zeros(2), (0.0, 1.0), g, f)HighDimPDE.PIDESolution — Type
PIDESolution(x0, ts, losses, usols, ufuns[, limits])Solution container storing the evaluated states, learned solution functions, training losses, and optional domain limits produced by HighDimPDE solvers.
Fields
x0: points at which the solution is evaluated.ts: saved time points.losses: training-loss history.us: solution values evaluated atx0.ufuns: learned solution functions or neural networks.limits: optional lower and upper bounds produced by limit computations.
Examples
sol = PIDESolution(zeros(2), [0.0, 1.0], [1.0], [0.0, 1.0], nothing)HighDimPDE.ParabolicPDEProblem — Type
ParabolicPDEProblemProblem definition for a semilinear parabolic PDE solved by HighDimPDE.
Fields
u0: initial PDE state evaluated atx.g: terminal or initial condition function, ornothingfor payoff problems.f: nonlinear PDE contribution, ornothingfor linear equations.μ: drift function.σ: diffusion function.x: PDE evaluation point.tspan: start and end times.p: user-supplied model parameters.x0_sample: strategy used to sample initial states.neumann_bc: optional lower and upper Neumann boundary vectors.kwargs: additional problem metadata such asxspan,payoff, and parameter domains.
HighDimPDE.ParabolicPDEProblem — Method
ParabolicPDEProblem(μ, σ, x0, tspan; g = nothing, f = nothing, p = nothing, kwargs...)Define a semilinear parabolic PDE problem of the form
\[\begin{aligned} \frac{du}{dt} &= \tfrac{1}{2} \text{Tr}(\sigma \sigma^T) \Delta u(x, t) + \mu \nabla u(x, t) \\ &\quad + f(x, u(x, t), ( \nabla_x u )(x, t), p, t) \end{aligned}\]
- Semilinear Parabolic Partial Differential Equation
- f -> f(X, u, σᵀ∇u, p, t)
- Kolmogorov Differential Equation
- f ->
nothing - x0 -> nothing, xspan must be provided.
- f ->
- Obstacle Partial Differential Equation
- f ->
nothing - g ->
nothing - discounted payoff function provided.
- f ->
Arguments
μ: drift function, of the formμ(x, p, t).σ: diffusion functionσ(x, p, t).x: point whereu(x,t)is approximated. Is required even in the case wherex0_sampleis provided. Determines the dimensionality of the PDE.tspan: timespan of the problem.g: initial condition, of the formg(x, p, t).f: nonlinear function, of the formf(X, u, σᵀ∇u, p, t)
Optional Arguments
p: the parameter vector.x0_sample: sampling method forx0. Can beUniformSampling(a,b),NormalSampling(σ_sampling, shifted), orNoSampling(by default). IfNoSampling, only solution at the single pointxis evaluated.neumann_bc: if provided, Neumann boundary conditions on the hypercubeneumann_bc[1] × neumann_bc[2].xspan: The domain of the independent variablexpayoff: The discounted payoff function. Required when solving for optimal stopping problem (Obstacle PDEs).
Examples
using LinearAlgebra: I
μ(x, p, t) = zero(x)
σ(x, p, t) = I
g(x) = sum(abs2, x)
f(x, u, du, p, t) = zero(u)
prob = ParabolicPDEProblem(μ, σ, zeros(2), (0.0, 1.0); g, f)HighDimPDE.NoSampling — Type
NoSampling()Sampling strategy that disables Monte Carlo integration and evaluates the PDE at the provided state only.
Examples
NoSampling()(zeros(2)) === nothingHighDimPDE.NormalSampling — Type
NormalSampling(σ)
NormalSampling(σ, shifted)Normal sampling method for the Monte Carlo integration.
Fields
σ: standard deviation applied to each normally distributed sample.shifted::Bool: whether sampling adds the evaluation point after drawing a sample.
Arguments
σ: the standard deviation of the samplingshifted: if true, the integration is shifted byx. Defaults to false.
Examples
sampler = NormalSampling(0.1)
samples = sampler(zeros(2))HighDimPDE.UniformSampling — Type
UniformSampling(a, b)Uniform sampling for the Monte Carlo integration, in the hypercube [a, b]^2.
Fields
a: lower bounds of the sampling hypercube.b: upper bounds of the sampling hypercube.
Examples
sampler = UniformSampling(fill(-1.0, 2), fill(1.0, 2))
samples = sampler(zeros(2))HighDimPDE.MLP — Type
Multi level Picard algorithm.
Fields
M: number of Monte Carlo integrations at each Picard level.L: number of Picard levels.K: number of samples used for the nonlocal term at each integration.mc_sample!: Monte Carlo sampling strategy for the nonlocal term.
Arguments
L: number of Picard iterations (Level),M: number of Monte Carlo integrations (at each levell,M^(L-l)integrations),K: number of Monte Carlo integrations for the non-local termmc_sample::MCSampling: sampling method for Monte Carlo integrations of the non local term.
Can be UniformSampling(a,b), NormalSampling(σ_sampling), or NoSampling (by default).
Examples
alg = MLP(M = 2, L = 2, K = 1)HighDimPDE.DeepSplitting — Type
DeepSplitting(nn; K = 1, opt = Flux.Adam(0.01), λs = nothing, mc_sample = NoSampling())Deep splitting algorithm.
Fields
nn: trainable neural-network approximation for one splitting step.K: number of Monte Carlo samples used for the nonlocal contribution.opt: Flux optimizer rule used for each training phase.λs: optional learning rates applied in sequence;nothingretains the optimizer rule's rate.mc_sample!: Monte Carlo sampling strategy for the nonlocal term.
Arguments
nn: a Flux.Chain, or more generally a functor.K: the number of Monte Carlo integrations.opt: optimizer to be used. By default,Flux.Adam(0.01).λs: the learning rates, used sequentially. Defaults to a single value taken fromopt.mc_sample::MCSampling: sampling method for Monte Carlo integrations of the non-local term. Can beUniformSampling(a,b),NormalSampling(σ_sampling, shifted), orNoSampling(by default).
Examples
d = 10 # size of the sample
hls = d + 50 # hidden layer size
# Neural network used by the scheme
nn = Flux.Chain(Flux.Dense(d, hls, tanh),
Flux.Dense(hls, hls, tanh), Flux.Dense(hls, 1, x -> x^2))
alg = DeepSplitting(nn; K = 10, opt = Flux.Adam(), λs = [5e-3, 1e-3],
mc_sample = UniformSampling(zeros(d), ones(d)))HighDimPDE.DeepBSDE — Type
DeepBSDE(u0, σᵀ∇u; opt = Flux.Adam(0.1))DeepBSDE algorithm, from J. Han, A. Jentzen and Weinan E.
Fields
u0: neural network approximating the initial value of the backward SDE.σᵀ∇u: neural network approximating the diffusion-weighted solution gradient.opt: Flux optimizer rule used to train both networks.
Arguments
u0: a Flux.jlChainwith a d-dimensional input and a 1-dimensional output for the solytion guess.σᵀ∇u: a Flux.jlChainfor the BSDE value guess.opt: the optimization algorithm to be used to optimize the neural networks. Defaults toFlux.Adam(0.1).
Example
Black-Scholes-Barenblatt equation
d = 30 # number of dimensions
x0 = repeat([1.0f0, 0.5f0], div(d,2))
tspan = (0.0f0,1.0f0)
dt = 0.2
m = 30 # number of trajectories (batch size)
r = 0.05f0
sigma = 0.4f0
f(X,u,σᵀ∇u,p,t) = r * (u - sum(X.*σᵀ∇u))
g(X) = sum(X.^2)
μ_f(X,p,t) = zero(X) #Vector d x 1
σ_f(X,p,t) = Diagonal(sigma*X) #Matrix d x d
prob = PIDEProblem(μ_f, σ_f, x0, tspan, g, f)
hls = 10 + d #hidden layer size
opt = Flux.Adam(0.001)
u0 = Flux.Chain(Flux.Dense(d, hls, relu), Flux.Dense(hls, hls, relu), Flux.Dense(hls, 1))
σᵀ∇u = Flux.Chain(Flux.Dense(d + 1, hls, relu), Flux.Dense(hls, hls, relu),
Flux.Dense(hls, hls, relu), Flux.Dense(hls, d))
pdealg = DeepBSDE(u0, σᵀ∇u; opt = opt)
solve(prob,
pdealg,
EM(),
verbose=true,
maxiters=150,
trajectories=m,
sdealg=StochasticDiffEq.,
dt=dt,
pabstol = 1f-6)HighDimPDE.NNStopping — Type
NNStopping(models, opt)Deep Optimal Stopping, S Becker, P Cheridito, A Jentzen3, and T Welti.
Fields
m: collection of neural networks, one for each exercise time.opt: Flux optimizer rule used to train the stopping models.
Arguments
models::Vector{Flux.Chain}: A vector of Flux.Chain where each model corresponds to a specific timestep from the timespan (tspan). The overall length of the vector should belength(timesteps) - 1.opt: the optimization algorithm to be used to optimize the neural networks. Defaults toADAM(0.1).
Example
d = 3 # Number of assets in the stock r = 0.05 # interest rate beta = 0.2 # volatility T = 3 # maturity u0 = fill(90.0, d) # initial stock value delta = 0.1 # delta f(du, u, p, t) = du .= (r - delta) * u # drift sigma(du, u, p, t) = du .= beta * u # diffusion tspan = (0.0, T) N = 9 # discretization parameter dt = T / (N) K = 100.00 # strike price
payoff function
function g(x, t) return exp(-r * t) * (max(maximum(x) - K, 0)) end
prob = PIDEProblem(f, sigma, u0, tspan; payoff = g) models = [Chain(Dense(d + 1, 32, tanh), BatchNorm(32, tanh), Dense(32, 1, sigmoid)) for i in 1:N]
opt = Flux.Adam(0.01) alg = NNStopping(models, opt)
sol = solve(prob, alg, SRIW1(); dt = dt, trajectories = 1000, maxiters = 1000, verbose = true) ```
HighDimPDE.NNKolmogorov — Type
Algorithm for solving Kolmogorov Equations.
Fields
chain: neural network trained to approximate the terminal-value expectation.opt: Flux optimizer rule used to trainchain.
Arguments
chain: neural network with a d-dimensional output.opt: optimizer used to train the neural network.
Examples
alg = NNKolmogorov(Flux.Chain(Flux.Dense(2, 1)))[1]Beck, Christian, et al. "Solving stochastic differential equations and Kolmogorov equations by means of deep learning." arXiv preprint arXiv:1806.00421 (2018).
HighDimPDE.NNParamKolmogorov — Type
Algorithm for solving paramateric families of Kolmogorov Equations.
Fields
chain: neural network trained over state, time, and sampled PDE parameters.opt: Flux optimizer rule used to trainchain.
Arguments
chain: neural network with a d-dimensional output.opt: optimizer used to train the neural network.
Examples
alg = NNParamKolmogorov(Flux.Chain(Flux.Dense(5, 1)))[1] Berner Julius et al. "Numerically solving parametric families of high-dimensional Kolmogorov partial differential equations via deep learning."