Class AbstractADI3D
java.lang.Object
net.finmath.finitedifference.solvers.adi.AbstractADI3D
- All Implemented Interfaces:
FDMSolver
- Direct Known Subclasses:
FDMAsianHestonADI3D, FDMAsianSabrADI3D
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis interface is needed for payoff depending explicitly on the time dimension and three state variables.static interfaceTernary payoff operator used for terminal conditions depending on three state variables. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractADI3D(FiniteDifferenceEquityModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise) -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]add(double[] a, double[] b) protected double[]applyA0Explicit(double[] u, double time) Explicit application of A0 containing all mixed derivative terms and the discount term.protected double[]applyA1Explicit(double[] u, double time) protected double[]applyA2Explicit(double[] u, double time) protected double[]applyA3Explicit(double[] u, double time) protected voidapplyExerciseObstacleIfNeeded(double runningTime, double tau, double[] u, AbstractADI3D.DoubleQuaternaryOperator exerciseValue) protected double[]applyFullExplicitOperator(double[] u, double time) protected voidapplyInternalConstraints(double time, double[] u) protected voidapplyOuterBoundaries(double time, double[] u) protected doubleextractBoundaryValue(BoundaryCondition[] conditions, int index, double fallback) protected intflatten(int i0, int i1, int i2) protected Exerciseprotected doublegetLowerBoundaryValueForFirstDirection(double time, int secondIndex, int thirdIndex, double fallback) protected doublegetLowerBoundaryValueForSecondDirection(double time, int firstIndex, int thirdIndex, double fallback) protected doublegetLowerBoundaryValueForThirdDirection(double time, int firstIndex, int secondIndex, double fallback) protected FiniteDifferenceEquityModelgetModel()protected intgetN()protected intgetN0()protected intgetN1()protected intgetN2()protected FiniteDifferenceEquityProductprotected SpaceTimeDiscretizationprotected doublegetTheta()protected doublegetUpperBoundaryValueForFirstDirection(double time, int secondIndex, int thirdIndex, double fallback) protected doublegetUpperBoundaryValueForSecondDirection(double time, int firstIndex, int thirdIndex, double fallback) protected doublegetUpperBoundaryValueForThirdDirection(double time, int firstIndex, int secondIndex, double fallback) double[]getValue(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity) Returns the value.double[]getValue(double evaluationTime, double time, DoubleUnaryOperator valueAtMaturity) Returns the solution at a given evaluation time.double[]getValue(double evaluationTime, double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity) Returns the value.double[]getValue(double evaluationTime, double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity, AbstractADI3D.DoubleQuaternaryOperator exerciseValue) Returns the value.double[][]getValues(double time, DoubleBinaryOperator valueAtMaturity) Returns the value.double[][]getValues(double time, DoubleUnaryOperator valueAtMaturity) Returns the full time history of the solution on the space-time grid.double[][]getValues(double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity) Returns the value.double[][]getValues(double time, AbstractADI3D.DoubleTernaryOperator valueAtMaturity, AbstractADI3D.DoubleQuaternaryOperator exerciseValue) Returns the value.protected double[]protected double[]protected double[]protected booleanisInternalConstraintActive(double time, double x0, double x1, double x2) protected voidoverwriteBoundaryRow(TridiagonalMatrix m, double[] rhs, int row, double value) protected double[]performDouglasHalfStep(double[] u, double currentTime, double dt) protected double[]performStableDouglasStep(double[] u, double currentTime, double dt) protected double[]sanitize(double[] u) protected double[]scale(double[] a, double c) protected abstract double[]solveFirstDirectionLines(double[] rhs, double time, double dt) protected abstract double[]solveSecondDirectionLines(double[] rhs, double time, double dt) protected abstract double[]solveThirdDirectionLines(double[] rhs, double time, double dt) protected double[]subtract(double[] a, double[] b)
-
Constructor Details
-
AbstractADI3D
protected AbstractADI3D(FiniteDifferenceEquityModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise)
-
-
Method Details
-
getValues
Description copied from interface:FDMSolverReturns the full time history of the solution on the space-time grid.Typical shapes are:
- 1D:
[nT][nS] - 2D:
[nT][nS * nV]
- 1D:
-
getValues
Returns the value. -
getValues
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
Description copied from interface:FDMSolverReturns 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.
- 1D:
-
getValue
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
-
overwriteBoundaryRow
-
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
-
getSpaceTimeDiscretization
-
getProduct
-
getModel
-