BoundaryCondition upper;
if (isUp) {
sMin = 0.0;
sMax = barrierLevel * Math.exp(-adj); //bring the barrier DOWN slightly to adjust for discrete monitoring
if (isCall) {
lower = new DirichletBoundaryCondition(0.0, sMin);
} else {
final Function1D<Double, Double> lowerValue = new Function1D<Double, Double>() {
@Override
public Double evaluate(final Double tau) {
return Math.exp(-rate * tau) * strike;
}
};
lower = new DirichletBoundaryCondition(lowerValue, sMin);
}
upper = new DirichletBoundaryCondition(rebate, sMax);
} else {
sMin = barrierLevel * Math.exp(adj); //bring the barrier UP slightly to adjust for discrete monitoring
sMax = spot * Math.exp(_z * Math.sqrt(expiry));
lower = new DirichletBoundaryCondition(rebate, sMin);
if (isCall) {
final Function1D<Double, Double> upperValue = new Function1D<Double, Double>() {
@Override
public Double evaluate(final Double tau) {
return Math.exp(-rate * tau) * (spot * Math.exp(carry * tau) - strike);
}
};
upper = new DirichletBoundaryCondition(upperValue, sMax);
} else {
upper = new DirichletBoundaryCondition(0.0, sMax);
}
}
final MeshingFunction tMesh = new ExponentialMeshing(0, expiry, _nTNodes, _lambda);
final MeshingFunction xMesh = new HyperbolicMeshing(sMin, sMax, spot, _nXNodes, _bunching);