Class AbstractADI2D
- All Implemented Interfaces:
FDMSolver
- Direct Known Subclasses:
FDMAsianADI2D, FDMBarrierHestonADI2D, FDMBarrierSabrADI2D, FDMBatesADI2D, FDMHestonADI2D, FDMMultiAssetBlackScholesADI2D, FDMSabrADI2D
The solver acts on a two-dimensional state vector (x_0,x_1) and computes an approximation of the value function V(t,x_0,x_1) associated with a parabolic pricing equation of the form
\frac{\partial V}{\partial t} + \mathcal{A}_0 V + \mathcal{A}_1 V + \mathcal{A}_2 V = 0,
where the operator is split into:
- \mathcal{A}_0: mixed derivative term together with discounting, treated explicitly,
- \mathcal{A}_1: first-direction drift and diffusion terms, treated implicitly,
- \mathcal{A}_2: second-direction drift and diffusion terms, treated implicitly.
The time stepping uses a stabilized Douglas-type ADI splitting. For a time step \Delta t, the algorithm first forms an explicit predictor and then performs successive implicit solves along the two spatial directions. To improve numerical stability, the implementation applies two half Douglas steps. This yields a scheme which is efficient for two-dimensional problems since each implicit stage reduces to a collection of tridiagonal linear systems along grid lines.
The flattening convention for a grid function is
k = i0 + i1 * n0
where i0 is the index in the first spatial direction and i1 is the index in the second spatial direction. Hence the first state direction is stored as the fastest varying index.
The solver supports:
- terminal conditions depending on one or two state variables,
- discrete exercise obstacles for Bermudan or American-style problems,
- continuous obstacles applied after each backward step,
- internal state constraints supplied by the product,
- vector-level equity event conditions at prescribed event times,
- Dirichlet boundary extraction from the model boundary conditions.
- Author:
- Alessandro Gnoatto
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for payoffs or obstacles depending on time and two state variables. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractADI2D(FiniteDifferenceEquityModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise) Creates the ADI solver. -
Method Summary
Modifier and TypeMethodDescriptionprotected double[]add(double[] a, double[] b) protected double[]applyA0Explicit(double[] u, double time) protected double[]applyA1Explicit(double[] u, double time) protected double[]applyA2Explicit(double[] u, double time) protected voidapplyContinuousObstacleIfNeeded(double runningTime, double[] u, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) protected voidapplyExerciseObstacleIfNeeded(double runningTime, double tau, double[] u, AbstractADI2D.DoubleTernaryOperator exerciseValue) protected double[]applyFullExplicitOperator(double[] u, double time) protected voidapplyInternalConstraints(double time, double[] u) protected voidapplyOuterBoundaries(double time, double[] u) protected double[]applyProductEventConditionIfNeeded(double time, double[] valuesAfterEvent) protected doubleextractBoundaryValue(BoundaryCondition condition, double fallback) protected intflatten(int i0, int i1) protected Exerciseprotected doublegetLowerBoundaryValueForFirstDirection(double time, int secondIndex, double fallback) protected doublegetLowerBoundaryValueForSecondDirection(double time, int firstIndex, double fallback) protected FiniteDifferenceEquityModelgetModel()protected intgetN()protected intgetN0()protected intgetN1()protected FiniteDifferenceEquityProductprotected SpaceTimeDiscretizationprotected ADI2DStencilBuilderprotected doublegetTheta()protected doublegetUpperBoundaryValueForFirstDirection(double time, int secondIndex, double fallback) protected doublegetUpperBoundaryValueForSecondDirection(double time, int firstIndex, double fallback) double[]getValue(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity) Returns the values at the specified evaluation time for a two-dimensional terminal payoff.double[]getValue(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator exerciseValue) Returns the values at the specified evaluation time under a discrete exercise obstacle.double[]getValue(double evaluationTime, double time, DoubleUnaryOperator valueAtMaturity) Returns the values at the specified evaluation time for a one-dimensional terminal payoff.double[][]getValues(double time, DoubleBinaryOperator valueAtMaturity) Returns the full value surface for a two-dimensional terminal payoff.double[][]getValues(double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator exerciseValue) Returns the full value surface under a discrete exercise obstacle.double[][]getValues(double time, DoubleUnaryOperator valueAtMaturity) Returns the full value surface for a terminal payoff depending on the first state variable.double[][]getValuesWithContinuousObstacle(double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) Returns the full value surface under a continuous obstacle.double[]getValueWithContinuousObstacle(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) Returns the values at a given evaluation time under a continuous obstacle.protected double[]protected double[]protected booleanisInternalConstraintActive(double time, double x0, double x1) protected voidoverwriteBoundaryRow(TridiagonalMatrix m, double[] rhs, int row, double value) protected double[]performDouglasHalfStep(double[] u, double currentTime, double dt) Performs one half Douglas step.protected double[]performStableDouglasStep(double[] u, double currentTime, double dt) Performs one stabilized Douglas time step by splitting it into two half steps.protected double[]sanitize(double[] values) protected double[]scale(double[] a, double scalar) protected double[]solveFirstDirectionLines(double[] rhs, double time, double dt) protected double[]solveSecondDirectionLines(double[] rhs, double time, double dt) protected double[]subtract(double[] a, double[] b)
-
Constructor Details
-
AbstractADI2D
protected AbstractADI2D(FiniteDifferenceEquityModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise) Creates the ADI solver.- Parameters:
model- The finite-difference model.product- The product to be valued.spaceTimeDiscretization- The space-time discretization.exercise- The exercise specification.
-
-
Method Details
-
getValues
Returns the full value surface for a terminal payoff depending on the first state variable. -
getValues
Returns the full value surface for a two-dimensional terminal payoff. -
getValuesWithContinuousObstacle
public double[][] getValuesWithContinuousObstacle(double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) Returns the full value surface under a continuous obstacle.- Parameters:
time- Maturity time.valueAtMaturity- Terminal payoff.continuousObstacleValue- Continuous obstacle value.- Returns:
- Value surface indexed by flattened space index and time index.
-
getValueWithContinuousObstacle
public double[] getValueWithContinuousObstacle(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) Returns the values at a given evaluation time under a continuous obstacle.- Parameters:
evaluationTime- Evaluation time.time- Maturity time.valueAtMaturity- Terminal payoff.continuousObstacleValue- Continuous obstacle value.- Returns:
- Value vector on the flattened space grid.
-
getValues
public double[][] getValues(double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator exerciseValue) Returns the full value surface under a discrete exercise obstacle.- Parameters:
time- Maturity time.valueAtMaturity- Terminal payoff.exerciseValue- Exercise payoff.- Returns:
- Value surface indexed by flattened space index and time index.
-
getValue
Returns the values at the specified evaluation time for a one-dimensional terminal payoff. -
getValue
Returns the values at the specified evaluation time for a two-dimensional terminal payoff. -
getValue
public double[] getValue(double evaluationTime, double time, DoubleBinaryOperator valueAtMaturity, AbstractADI2D.DoubleTernaryOperator exerciseValue) Returns the values at the specified evaluation time under a discrete exercise obstacle.- Parameters:
evaluationTime- Evaluation time.time- Maturity time.valueAtMaturity- Terminal payoff.exerciseValue- Exercise payoff.- Returns:
- Value vector on the flattened space grid.
-
performStableDouglasStep
protected double[] performStableDouglasStep(double[] u, double currentTime, double dt) Performs one stabilized Douglas time step by splitting it into two half steps.- Parameters:
u- Current solution vector.currentTime- Current running time.dt- Time-step size.- Returns:
- Updated solution vector.
-
performDouglasHalfStep
protected double[] performDouglasHalfStep(double[] u, double currentTime, double dt) Performs one half Douglas step.- Parameters:
u- Current solution vector.currentTime- Current running time.dt- Time-step size.- Returns:
- Updated solution vector.
-
applyFullExplicitOperator
protected double[] applyFullExplicitOperator(double[] u, double time) -
applyA0Explicit
protected double[] applyA0Explicit(double[] u, double time) -
applyA1Explicit
protected double[] applyA1Explicit(double[] u, double time) -
applyA2Explicit
protected double[] applyA2Explicit(double[] u, double time) -
solveFirstDirectionLines
protected double[] solveFirstDirectionLines(double[] rhs, double time, double dt) -
solveSecondDirectionLines
protected double[] solveSecondDirectionLines(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, AbstractADI2D.DoubleTernaryOperator exerciseValue) -
applyContinuousObstacleIfNeeded
protected void applyContinuousObstacleIfNeeded(double runningTime, double[] u, AbstractADI2D.DoubleTernaryOperator continuousObstacleValue) -
isInternalConstraintActive
protected boolean isInternalConstraintActive(double time, double x0, double x1) -
getLowerBoundaryValueForFirstDirection
protected double getLowerBoundaryValueForFirstDirection(double time, int secondIndex, double fallback) -
getUpperBoundaryValueForFirstDirection
protected double getUpperBoundaryValueForFirstDirection(double time, int secondIndex, double fallback) -
getLowerBoundaryValueForSecondDirection
protected double getLowerBoundaryValueForSecondDirection(double time, int firstIndex, double fallback) -
getUpperBoundaryValueForSecondDirection
protected double getUpperBoundaryValueForSecondDirection(double time, int firstIndex, double fallback) -
extractBoundaryValue
-
overwriteBoundaryRow
-
flatten
protected int flatten(int i0, int i1) -
sanitize
protected double[] sanitize(double[] values) -
add
protected double[] add(double[] a, double[] b) -
subtract
protected double[] subtract(double[] a, double[] b) -
scale
protected double[] scale(double[] a, double scalar) -
applyProductEventConditionIfNeeded
protected double[] applyProductEventConditionIfNeeded(double time, double[] valuesAfterEvent) -
getStencilBuilder
-
getN
protected int getN() -
getN1
protected int getN1() -
getN0
protected int getN0() -
getX1Grid
protected double[] getX1Grid() -
getX0Grid
protected double[] getX0Grid() -
getTheta
protected double getTheta() -
getExercise
-
getSpaceTimeDiscretization
-
getProduct
-
getModel
-