N-Dimensional Models
The solver crate supports models with arbitrary state dimension through Rust const generics.
Model<N> trait
#![allow(unused)] fn main() { pub trait Model<const N: usize> { fn optimize(&self, ...) -> ControlOutput<N>; fn terminal(&self, ...) -> f64; fn next_step(&self, ...) -> Array1<f64>; fn is_diffusion_dimension(&self, dim: usize) -> bool; fn gradient_step(&self, dim: usize) -> f64; fn transform_noise(&self, ...) -> Array1<f64>; } }
Conventions
- Dimension 0 is always inventory for market-making models.
solve_with_spreadsandNumericalResultextractlambda_plus[0]andlambda_minus[0]-- convenience methods for the trading dimension only.- For full N-dimensional control access, use
BsdeSolution<N>::evaluate_control().
Adding a new model
- Create the model struct implementing
Model<N>. - Register in
models/mod.rs. - For N above 3, increase
num_pathsto 30k or more and consider regularization of1e-4for stability.
Proven: N=3 Heston-Hawkes
The HestonHawkes model implements Model<3> with state [q, v, lambda]:
- dim 0 (inventory): discrete jumps, controlled via bid/ask intensities.
- dim 1 (variance): CIR diffusion,
is_diffusion_dimension(1) = true. - dim 2 (intensity): deterministic mean-reverting drift (Hawkes).
Run the example: cargo run --release --example heston_hawkes_n3