Class FDMBarrierSabrADI2D

java.lang.Object
net.finmath.finitedifference.solvers.adi.AbstractADI2D
net.finmath.finitedifference.solvers.adi.FDMBarrierSabrADI2D
All Implemented Interfaces:
FDMSolver

public class FDMBarrierSabrADI2D extends AbstractADI2D
Barrier-aware ADI finite difference solver for the two-dimensional SABR PDE.

This class supports:

In pre-hit mode, the barrier is treated as an interface on the first state variable and the activated post-hit value is injected through an ActivatedBarrierTrace2D. The exercise obstacle is intentionally disabled in that mode.

Author:
Alessandro Gnoatto
  • Constructor Details

    • FDMBarrierSabrADI2D

      public FDMBarrierSabrADI2D(FDMSabrModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise, BarrierPDEMode barrierMode, BarrierPreHitSpecification preHitSpecification)
      Creates the barrier-aware SABR ADI solver.
      Parameters:
      model - The SABR model.
      product - The finite-difference product.
      spaceTimeDiscretization - The discretization to use.
      exercise - The exercise specification.
      barrierMode - The barrier PDE mode.
      preHitSpecification - The pre-hit specification. Required in IN_PRE_HIT mode.
  • Method Details

    • getValues

      public double[][] getValues(double time, DoubleUnaryOperator valueAtMaturity)
      Description copied from class: AbstractADI2D
      Returns the full value surface for a terminal payoff depending on the first state variable.
      Specified by:
      getValues in interface FDMSolver
      Overrides:
      getValues in class AbstractADI2D
      Parameters:
      time - Maturity time.
      valueAtMaturity - Terminal payoff.
      Returns:
      Value surface indexed by flattened space index and time index.
    • getValues

      public double[][] getValues(double time, DoubleBinaryOperator valueAtMaturity)
      Description copied from class: AbstractADI2D
      Returns the full value surface for a two-dimensional terminal payoff.
      Specified by:
      getValues in interface FDMSolver
      Overrides:
      getValues in class AbstractADI2D
      Parameters:
      time - Maturity time.
      valueAtMaturity - Terminal payoff.
      Returns:
      Value surface indexed by flattened space index and time index.
    • getValues

      public double[][] getValues(double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator exerciseValue)
      Description copied from class: AbstractADI2D
      Returns the full value surface under a discrete exercise obstacle.
      Overrides:
      getValues in class AbstractADI2D
      Parameters:
      time - Maturity time.
      valueAtMaturity - Terminal payoff.
      exerciseValue - Exercise payoff.
      Returns:
      Value surface indexed by flattened space index and time index.
    • solveFirstDirectionLines

      protected double[] solveFirstDirectionLines(double[] rhs, double time, double dt)
      Overrides:
      solveFirstDirectionLines in class AbstractADI2D
    • applyOuterBoundaries

      protected void applyOuterBoundaries(double time, double[] u)
      Overrides:
      applyOuterBoundaries in class AbstractADI2D
    • isPreHitMode

      protected boolean isPreHitMode()
      Returns true if this solver is in pre-hit continuation mode.
      Returns:
      True if in pre-hit mode.
    • overwriteBarrierTraceRow

      protected void overwriteBarrierTraceRow(TridiagonalMatrix matrix, double[] rhs, int secondIndex, double runningTime)
      Overwrites the barrier interface row in a first-direction tridiagonal system.
      Parameters:
      matrix - The tridiagonal matrix.
      rhs - The corresponding right-hand side.
      secondIndex - The second-state index.
      runningTime - The running time.
    • applyBarrierTraceIfNeeded

      protected void applyBarrierTraceIfNeeded(double runningTime, double[] u)
      Applies the barrier trace directly to the flattened solution vector.
      Parameters:
      runningTime - The running time.
      u - The solution vector.
    • getBarrierTraceValue

      protected double getBarrierTraceValue(int secondIndex, double runningTime)
      Returns the activated barrier trace value at the given second-state row and running time.
      Parameters:
      secondIndex - The second-state index.
      runningTime - The running time.
      Returns:
      The corresponding trace value.
    • getSabrModel

      public FDMSabrModel getSabrModel()
      Returns the SABR model used by this solver.
      Returns:
      The SABR model.
    • getBarrierMode

      public BarrierPDEMode getBarrierMode()
      Returns the barrier PDE mode.
      Returns:
      The barrier mode.
    • getPreHitSpecification

      public BarrierPreHitSpecification getPreHitSpecification()
      Returns the pre-hit specification, or null if not in pre-hit mode.
      Returns:
      The pre-hit specification.