Class FDMBarrierSabrADI2D
java.lang.Object
net.finmath.finitedifference.solvers.adi.AbstractADI2D
net.finmath.finitedifference.solvers.adi.FDMBarrierSabrADI2D
- All Implemented Interfaces:
FDMSolver
Barrier-aware ADI finite difference solver for the two-dimensional SABR PDE.
This class supports:
- standard direct barrier solves via
BarrierPDEMode.OUT_STANDARD, - pre-hit continuation solves for direct knock-in pricing via
BarrierPDEMode.IN_PRE_HIT.
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
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractADI2D
AbstractADI2D.DoubleTernaryOperator -
Constructor Summary
ConstructorsConstructorDescriptionFDMBarrierSabrADI2D(FDMSabrModel model, FiniteDifferenceEquityProduct product, SpaceTimeDiscretization spaceTimeDiscretization, Exercise exercise, BarrierPDEMode barrierMode, BarrierPreHitSpecification preHitSpecification) Creates the barrier-aware SABR ADI solver. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyBarrierTraceIfNeeded(double runningTime, double[] u) Applies the barrier trace directly to the flattened solution vector.protected voidapplyOuterBoundaries(double time, double[] u) Returns the barrier PDE mode.protected doublegetBarrierTraceValue(int secondIndex, double runningTime) Returns the activated barrier trace value at the given second-state row and running time.Returns the pre-hit specification, or null if not in pre-hit mode.Returns the SABR model used by this solver.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.protected booleanReturns true if this solver is in pre-hit continuation mode.protected voidoverwriteBarrierTraceRow(TridiagonalMatrix matrix, double[] rhs, int secondIndex, double runningTime) Overwrites the barrier interface row in a first-direction tridiagonal system.protected double[]solveFirstDirectionLines(double[] rhs, double time, double dt) Methods inherited from class AbstractADI2D
add, applyA0Explicit, applyA1Explicit, applyA2Explicit, applyContinuousObstacleIfNeeded, applyExerciseObstacleIfNeeded, applyFullExplicitOperator, applyInternalConstraints, applyProductEventConditionIfNeeded, extractBoundaryValue, flatten, getExercise, getLowerBoundaryValueForFirstDirection, getLowerBoundaryValueForSecondDirection, getModel, getN, getN0, getN1, getProduct, getSpaceTimeDiscretization, getStencilBuilder, getTheta, getUpperBoundaryValueForFirstDirection, getUpperBoundaryValueForSecondDirection, getValue, getValue, getValue, getValuesWithContinuousObstacle, getValueWithContinuousObstacle, getX0Grid, getX1Grid, isInternalConstraintActive, overwriteBoundaryRow, performDouglasHalfStep, performStableDouglasStep, sanitize, scale, solveSecondDirectionLines, subtract
-
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
Description copied from class:AbstractADI2DReturns the full value surface for a terminal payoff depending on the first state variable.- Specified by:
getValuesin interfaceFDMSolver- Overrides:
getValuesin classAbstractADI2D- Parameters:
time- Maturity time.valueAtMaturity- Terminal payoff.- Returns:
- Value surface indexed by flattened space index and time index.
-
getValues
Description copied from class:AbstractADI2DReturns the full value surface for a two-dimensional terminal payoff.- Specified by:
getValuesin interfaceFDMSolver- Overrides:
getValuesin classAbstractADI2D- 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:AbstractADI2DReturns the full value surface under a discrete exercise obstacle.- Overrides:
getValuesin classAbstractADI2D- 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:
solveFirstDirectionLinesin classAbstractADI2D
-
applyOuterBoundaries
protected void applyOuterBoundaries(double time, double[] u) - Overrides:
applyOuterBoundariesin classAbstractADI2D
-
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
Returns the SABR model used by this solver.- Returns:
- The SABR model.
-
getBarrierMode
-
getPreHitSpecification
Returns the pre-hit specification, or null if not in pre-hit mode.- Returns:
- The pre-hit specification.
-