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_spreads and NumericalResult extract lambda_plus[0] and lambda_minus[0] -- convenience methods for the trading dimension only.
  • For full N-dimensional control access, use BsdeSolution<N>::evaluate_control().

Adding a new model

  1. Create the model struct implementing Model<N>.
  2. Register in models/mod.rs.
  3. For N above 3, increase num_paths to 30k or more and consider regularization of 1e-4 for 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