public void calibration() {
final double[] meanReversion = new double[] {0.01, 0.30 };
final double ratio = 4.0;
final double correlation = -0.50;
final G2ppPiecewiseConstantParameters g2Parameters = new G2ppPiecewiseConstantParameters(meanReversion, new double[][] { {0.01 }, {0.01 / ratio } }, new double[0], correlation);
final SuccessiveRootFinderG2ppCalibrationObjective objective = new SuccessiveRootFinderG2ppCalibrationObjective(g2Parameters, EUR, ratio);
final SuccessiveRootFinderG2ppCalibrationEngine<SABRSwaptionProviderInterface> calibrationEngine = new SuccessiveRootFinderG2ppCalibrationEngine<>(objective);
for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
calibrationEngine.addInstrument(SWAPTION_LONG_PAYER[loopexp], PVSSC);
}
calibrationEngine.calibrate(SABR_MULTICURVES);
final MultipleCurrencyAmount[] pvSabr = new MultipleCurrencyAmount[EXPIRY_TENOR.length];
final MultipleCurrencyAmount[] pvHw = new MultipleCurrencyAmount[EXPIRY_TENOR.length];
for (int loopexp = 0; loopexp < EXPIRY_TENOR.length; loopexp++) {
pvSabr[loopexp] = SWAPTION_LONG_PAYER[loopexp].accept(PVSSC, SABR_MULTICURVES);
pvHw[loopexp] = METHOD_G2PP.presentValue(SWAPTION_LONG_PAYER[loopexp], objective.getG2Provider());
assertEquals("G2++ calibration: swaption " + loopexp, pvSabr[loopexp].getAmount(EUR), pvHw[loopexp].getAmount(EUR), TOLERANCE_PV);
}
}