/**
* Tests the correctness of LMM DD calibration to swaptions with SABR price.
*/
public void calibration() {
final LiborMarketModelDisplacedDiffusionParameters lmmParameters = LMM_PARAM_INIT.copy();
final SuccessiveLeastSquareLMMDDCalibrationObjective objective = new SuccessiveLeastSquareLMMDDCalibrationObjective(lmmParameters, EUR);
final CalibrationEngineWithCalculators<SABRSwaptionProviderInterface> calibrationEngine = new SuccessiveLeastSquareLMMDDCalibrationEngine<>(objective, NB_STRIKE);
final SwaptionPhysicalFixedIbor[] swaptionCalibration = METHOD_BASKET.calibrationBasketFixedLegPeriod(SWAPTION_AMORTIZED, MONEYNESS);
calibrationEngine.addInstrument(swaptionCalibration, PVSSC);
calibrationEngine.calibrate(SABR_MULTICURVES);
final MultipleCurrencyAmount[][] pvSabr = new MultipleCurrencyAmount[SWAP_TENOR_YEAR.length][NB_STRIKE];
final MultipleCurrencyAmount[][] pvLmm = new MultipleCurrencyAmount[SWAP_TENOR_YEAR.length][NB_STRIKE];
final double[][] pvDiff = new double[SWAP_TENOR_YEAR.length][NB_STRIKE];
final double[] pvDiffTot = new double[SWAP_TENOR_YEAR.length];
for (int loopexp = 0; loopexp < SWAP_TENOR_YEAR.length; loopexp++) {
for (int loopstrike = 0; loopstrike < NB_STRIKE; loopstrike++) {
pvSabr[loopexp][loopstrike] = METHOD_SABR.presentValue(swaptionCalibration[loopexp * NB_STRIKE + loopstrike], SABR_MULTICURVES);
pvLmm[loopexp][loopstrike] = METHOD_LMM.presentValue(swaptionCalibration[loopexp * NB_STRIKE + loopstrike], objective.getLMMProvider());
pvDiff[loopexp][loopstrike] = pvSabr[loopexp][loopstrike].getAmount(EUR) - pvLmm[loopexp][loopstrike].getAmount(EUR);
pvDiffTot[loopexp] += pvDiff[loopexp][loopstrike];
}
assertEquals("LMM calibration least-square: swaption " + loopexp, 0, pvDiffTot[loopexp], TOLERANCE_LS);
}
// Comparison with method
final MultipleCurrencyAmount pvDirect = METHOD_LMM.presentValue(SWAPTION_AMORTIZED, objective.getLMMProvider());
final MultipleCurrencyAmount pvMethod = METHOD_CALIBRATION.presentValue(SWAPTION_AMORTIZED, SABR_MULTICURVES);
assertEquals("LMM calibration least-square: swaption ", pvDirect.getAmount(EUR), pvMethod.getAmount(EUR), TOLERANCE_PV);
}