Skip to main content

BsdeSolution

Struct BsdeSolution 

Source
pub struct BsdeSolution<const N: usize> {
    pub coefficients: Vec<Vec<f64>>,
    pub basis_type: BasisFunctionType,
    pub dt: f64,
    pub steps: usize,
    pub x_init: [f64; N],
    pub feature_scale: Vec<f64>,
    pub clamp_range: Option<(f64, f64)>,
    pub gradient_steps: [f64; N],
    pub v0: f64,
    pub control_t0: ControlOutput<N>,
}
Expand description

Complete BSDE solution storing regression coefficients for all time steps.

Enables point evaluation of the value function and optimal controls at any (time_index, state) pair without re-running the solver.

Fields§

§coefficients: Vec<Vec<f64>>

Regression coefficients at each backward time step. coefficients[t] contains the basis weights at time index t.

§basis_type: BasisFunctionType

Basis function configuration.

§dt: f64

Time step size.

§steps: usize

Number of backward time steps.

§x_init: [f64; N]

Initial state used for centering.

§feature_scale: Vec<f64>

Feature scaling per dimension.

§clamp_range: Option<(f64, f64)>

Clamping range for basis inputs.

§gradient_steps: [f64; N]

Gradient step sizes per dimension.

§v0: f64

Value function at t=0 and x_init.

§control_t0: ControlOutput<N>

Optimal control at t=0 and x_init.

Implementations§

Source§

impl<const N: usize> BsdeSolution<N>

Source

pub fn evaluate(&self, time_index: usize, state: &[f64; N]) -> f64

Evaluate the value function at a given time index and state.

time_index ranges from 0 (start) to self.steps (terminal).

Source

pub fn evaluate_control<M: Model<N>>( &self, time_index: usize, state: &[f64; N], model: &M, ) -> ControlOutput<N>

Evaluate optimal control at a given time index and state.

Source

pub fn evaluate_spread_trajectory<M: Model<N>>( &self, state: &[f64; N], model: &M, a: f64, kappa: f64, ) -> Vec<(f64, f64)>

Evaluate optimal spreads across all time steps for a given state.

Returns vectors of (bid_spread, ask_spread) for each time step from 0 to steps-1.

Source

pub fn time_to_index(&self, t: f64) -> usize

Convert a time value to the nearest time index. t is time elapsed from 0 (start of horizon).

Auto Trait Implementations§

§

impl<const N: usize> Freeze for BsdeSolution<N>

§

impl<const N: usize> RefUnwindSafe for BsdeSolution<N>

§

impl<const N: usize> Send for BsdeSolution<N>

§

impl<const N: usize> Sync for BsdeSolution<N>

§

impl<const N: usize> Unpin for BsdeSolution<N>

§

impl<const N: usize> UnsafeUnpin for BsdeSolution<N>

§

impl<const N: usize> UnwindSafe for BsdeSolution<N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V