ArgumentChecker.isTrue(nbInstruments % _nbInstrumentsBlock == 0, "Number of instruments incompatible with block size");
final int nbBlocks = nbInstruments / _nbInstrumentsBlock;
computeCalibrationPrice(curves);
getCalibrationObjective().setCurves(curves);
final SwaptionPhysicalLMMDDSuccessiveLeastSquareCalibrationObjective objective = (SwaptionPhysicalLMMDDSuccessiveLeastSquareCalibrationObjective) getCalibrationObjective();
final NonLinearLeastSquare ls = new NonLinearLeastSquare(DecompositionFactory.SV_COMMONS, MatrixAlgebraFactory.OG_ALGEBRA, DEFAULT_PRECISION);
// final NonLinearLeastSquare ls = new NonLinearLeastSquare();
for (int loopblock = 0; loopblock < nbBlocks; loopblock++) {
final InstrumentDerivative[] instruments = new InstrumentDerivative[_nbInstrumentsBlock];
final double[] prices = new double[_nbInstrumentsBlock];
for (int loopins = 0; loopins < _nbInstrumentsBlock; loopins++) {
instruments[loopins] = getBasket().get(loopblock * _nbInstrumentsBlock + loopins);
prices[loopins] = getCalibrationPrice().get(loopblock * _nbInstrumentsBlock + loopins);
}
getCalibrationObjective().setInstruments(instruments);
getCalibrationObjective().setPrice(prices);
objective.setStartIndex(_instrumentIndex.get(loopblock * _nbInstrumentsBlock));
objective.setEndIndex(_instrumentIndex.get((loopblock + 1) * _nbInstrumentsBlock) - 1);
// Implementation note: the index start is from the first instrument of the block and the index end is from the last instrument of the block.
final DoubleMatrix1D observedValues = new DoubleMatrix1D(_nbInstrumentsBlock, 0.0);
@SuppressWarnings("unused")
final
LeastSquareResults result = ls.solve(observedValues, getCalibrationObjective(), new DoubleMatrix1D(1.0, 0.0));
// Implementation note: the start value is a multiplicative factor of one and an additive term of 0 (parameters unchanged).
// The observed values are 0 as the function returns the difference between the calculated prices and the targets.
}
}