Class AbstractADI3D

java.lang.Object
net.finmath.finitedifference.solvers.adi.AbstractADI3D
All Implemented Interfaces:
FDMSolver
Direct Known Subclasses:
FDMAsianHestonADI3D, FDMAsianSabrADI3D

public abstract class AbstractADI3D extends Object implements FDMSolver
Generic three-dimensional alternating direction implicit finite difference solver.

The solver works on three state variables and applies a stabilized Douglas- type ADI splitting. The operator is split into:

  • A0: mixed derivative terms plus discount term, treated explicitly,
  • A1: first-direction drift and diffusion terms, treated implicitly,
  • A2: second-direction drift and diffusion terms, treated implicitly,
  • A3: third-direction drift and diffusion terms, treated implicitly.

The flattening convention is

k = i0 + n0 * (i1 + n1 * i2)

where i0 is the index in the first spatial direction.

This class provides the generic explicit operator application, boundary handling, obstacle projection and time stepping. The directional implicit line solves are left abstract, so subclasses may use a dedicated 3D stencil builder or a custom transport discretization.

Author:
Alessandro Gnoatto
  • Constructor Details

  • Method Details

    • getValues

      public double[][] getValues(double time, DoubleUnaryOperator valueAtMaturity)
      Description copied from interface: FDMSolver
      Returns the full time history of the solution on the space-time grid.

      Typical shapes are:

      • 1D: [nT][nS]
      • 2D: [nT][nS * nV]
      Specified by:
      getValues in interface FDMSolver
      Parameters:
      time - The maturity (time to maturity).
      valueAtMaturity - The payoff function applied at maturity.
      Returns:
      The full time-space solution.
    • getValues

      public double[][] getValues(double time, DoubleBinaryOperator valueAtMaturity)
      Returns the value.
      Specified by:
      getValues in interface FDMSolver
      Parameters:
      time - The value.
      valueAtMaturity - The value.
      Returns:
      The value.
    • getValues

      public double[][] getValues(double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity)
      Returns the value.
      Parameters:
      time - The value.
      valueAtMaturity - The value.
      Returns:
      The value.
    • getValues

      public double[][] getValues(double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity, AbstractADI3D.DoubleQuaternaryOperator exerciseValue)
      Returns the value.
      Parameters:
      time - The value.
      valueAtMaturity - The value.
      exerciseValue - The value.
      Returns:
      The value.
    • getValue

      public double[] getValue(double evaluationTime, double time, DoubleUnaryOperator valueAtMaturity)
      Description copied from interface: FDMSolver
      Returns the solution at a given evaluation time.

      This is a legacy return type. Typical shapes are:

      • 1D: [nS] representing values at the evaluation time.
      • 2D: [nS * nV] representing values at the evaluation time.
      Specified by:
      getValue in interface FDMSolver
      Parameters:
      evaluationTime - The evaluation time.
      time - The maturity (time to maturity).
      valueAtMaturity - The payoff function applied at maturity.
      Returns:
      The solution at the specified evaluation time.
    • getValue

      public double[] getValue(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity)
      Returns the value.
      Specified by:
      getValue in interface FDMSolver
      Parameters:
      evaluationTime - The value.
      time - The value.
      valueAtMaturity - The value.
      Returns:
      The value.
    • getValue

      public double[] getValue(double evaluationTime, double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity)
      Returns the value.
      Parameters:
      evaluationTime - The value.
      time - The value.
      valueAtMaturity - The value.
      Returns:
      The value.
    • getValue

      public double[] getValue(double evaluationTime, double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity, AbstractADI3D.DoubleQuaternaryOperator exerciseValue)
      Returns the value.
      Parameters:
      evaluationTime - The value.
      time - The value.
      valueAtMaturity - The value.
      exerciseValue - The value.
      Returns:
      The value.
    • performStableDouglasStep

      protected double[] performStableDouglasStep(double[] u, double currentTime, double dt)
    • performDouglasHalfStep

      protected double[] performDouglasHalfStep(double[] u, double currentTime, double dt)
    • applyFullExplicitOperator

      protected double[] applyFullExplicitOperator(double[] u, double time)
    • applyA0Explicit

      protected double[] applyA0Explicit(double[] u, double time)
      Explicit application of A0 containing all mixed derivative terms and the discount term.
      Parameters:
      u - The value.
      time - The value.
      Returns:
      The value.
    • applyA1Explicit

      protected double[] applyA1Explicit(double[] u, double time)
    • applyA2Explicit

      protected double[] applyA2Explicit(double[] u, double time)
    • applyA3Explicit

      protected double[] applyA3Explicit(double[] u, double time)
    • solveFirstDirectionLines

      protected abstract double[] solveFirstDirectionLines(double[] rhs, double time, double dt)
    • solveSecondDirectionLines

      protected abstract double[] solveSecondDirectionLines(double[] rhs, double time, double dt)
    • solveThirdDirectionLines

      protected abstract double[] solveThirdDirectionLines(double[] rhs, double time, double dt)
    • applyOuterBoundaries

      protected void applyOuterBoundaries(double time, double[] u)
    • applyInternalConstraints

      protected void applyInternalConstraints(double time, double[] u)
    • applyExerciseObstacleIfNeeded

      protected void applyExerciseObstacleIfNeeded(double runningTime, double tau, double[] u, AbstractADI3D.DoubleQuaternaryOperator exerciseValue)
    • isInternalConstraintActive

      protected boolean isInternalConstraintActive(double time, double x0, double x1, double x2)
    • getLowerBoundaryValueForFirstDirection

      protected double getLowerBoundaryValueForFirstDirection(double time, int secondIndex, int thirdIndex, double fallback)
    • getUpperBoundaryValueForFirstDirection

      protected double getUpperBoundaryValueForFirstDirection(double time, int secondIndex, int thirdIndex, double fallback)
    • getLowerBoundaryValueForSecondDirection

      protected double getLowerBoundaryValueForSecondDirection(double time, int firstIndex, int thirdIndex, double fallback)
    • getUpperBoundaryValueForSecondDirection

      protected double getUpperBoundaryValueForSecondDirection(double time, int firstIndex, int thirdIndex, double fallback)
    • getLowerBoundaryValueForThirdDirection

      protected double getLowerBoundaryValueForThirdDirection(double time, int firstIndex, int secondIndex, double fallback)
    • getUpperBoundaryValueForThirdDirection

      protected double getUpperBoundaryValueForThirdDirection(double time, int firstIndex, int secondIndex, double fallback)
    • extractBoundaryValue

      protected double extractBoundaryValue(BoundaryCondition[] conditions, int index, double fallback)
    • overwriteBoundaryRow

      protected void overwriteBoundaryRow(TridiagonalMatrix m, double[] rhs, int row, double value)
    • flatten

      protected int flatten(int i0, int i1, int i2)
    • add

      protected double[] add(double[] a, double[] b)
    • subtract

      protected double[] subtract(double[] a, double[] b)
    • scale

      protected double[] scale(double[] a, double c)
    • sanitize

      protected double[] sanitize(double[] u)
    • getN

      protected int getN()
    • getN2

      protected int getN2()
    • getN1

      protected int getN1()
    • getN0

      protected int getN0()
    • getX2Grid

      protected double[] getX2Grid()
    • getX1Grid

      protected double[] getX1Grid()
    • getX0Grid

      protected double[] getX0Grid()
    • getTheta

      protected double getTheta()
    • getExercise

      protected Exercise getExercise()
    • getSpaceTimeDiscretization

      protected SpaceTimeDiscretization getSpaceTimeDiscretization()
    • getProduct

      protected FiniteDifferenceEquityProduct getProduct()
    • getModel

      protected FiniteDifferenceEquityModel getModel()