public RandomVariable getValues(double evaluationTime, LIBORMarketModel model) {
		if(evaluationTime > 0) {
			throw new RuntimeException("Forward start evaluation currently not supported.");
		}

		double swapStart    = swapTenor[0];
		double swapEnd      = swapTenor[swapTenor.length-1];

		int swapStartIndex  = model.getLiborPeriodIndex(swapStart);
		int swapEndIndex    = model.getLiborPeriodIndex(swapEnd);
		int optionMaturityIndex = model.getCovarianceModel().getTimeDiscretization().getTimeIndex(swapStart)-1;

		Map<String, double[]>  logSwaprateDerivative  = getLogSwaprateDerivative(model.getLiborPeriodDiscretization(), model.getForwardRateCurve(), swapTenor);
		double[]    swapCovarianceWeights  = logSwaprateDerivative.get("values");
		double[]    discountFactors        = logSwaprateDerivative.get("discountFactors");
		double[]    swapAnnuities          = logSwaprateDerivative.get("swapAnnuities");

		// Get the integrated libor covariance from the model
		double[][]	integratedLIBORCovariance = model.getIntegratedLIBORCovariance()[optionMaturityIndex];

		// Calculate integrated swap rate covariance
		double integratedSwapRateVariance = 0.0;
		for(int componentIndex1 = swapStartIndex; componentIndex1 < swapEndIndex; componentIndex1++) {
			// Sum the libor cross terms (use symmetry)
			for(int componentIndex2 = componentIndex1+1; componentIndex2 < swapEndIndex; componentIndex2++) {
				integratedSwapRateVariance += 2.0 * swapCovarianceWeights[componentIndex1-swapStartIndex] * swapCovarianceWeights[componentIndex2-swapStartIndex] * integratedLIBORCovariance[componentIndex1][componentIndex2];
			}
			// Add diagonal term (libor variance term)
			integratedSwapRateVariance += swapCovarianceWeights[componentIndex1-swapStartIndex] * swapCovarianceWeights[componentIndex1-swapStartIndex] * integratedLIBORCovariance[componentIndex1][componentIndex1];
		}

		// Return integratedSwapRateVariance if requested
		if(valueUnit == ValueUnit.INTEGRATEDVARIANCELOGNORMAL || valueUnit == ValueUnit.INTEGRATEDVARIANCE) {
			return new Scalar(integratedSwapRateVariance);
		}

		double volatility		= Math.sqrt(integratedSwapRateVariance / swapStart);

		// Return integratedSwapRateVariance if requested
		if(valueUnit == ValueUnit.VOLATILITYLOGNORMAL || valueUnit == ValueUnit.VOLATILITY) {
			return new Scalar(volatility);
		}

		// Use black formula for swaption to calculate the price
		double swapAnnuity      =   swapAnnuities[0];
		double parSwaprate      =   (discountFactors[0] - discountFactors[swapEndIndex-swapStartIndex]) / swapAnnuity;

		double optionMaturity	= swapStart;

		double valueSwaption = AnalyticFormulas.blackModelSwaptionValue(parSwaprate, volatility, optionMaturity, swaprate, swapAnnuity);
		return new Scalar(valueSwaption);
	}
public RandomVariable getValues ( double evaluationTime , LIBORMarketModel model ) { if ( evaluationTime > 0 ) { throw new RuntimeException ( "Forward start evaluation currently not supported." ) ; } double swapStart = swapTenor [ 0 ] ; double swapEnd = swapTenor [ swapTenor . length - 1 ] ; int swapStartIndex = model . getLiborPeriodIndex ( swapStart ) ; int swapEndIndex = model . getLiborPeriodIndex ( swapEnd ) ; int optionMaturityIndex = model . getCovarianceModel ( ) . getTimeDiscretization ( ) . getTimeIndex ( swapStart ) - 1 ; Map < String , double [ ] > logSwaprateDerivative = getLogSwaprateDerivative ( model . getLiborPeriodDiscretization ( ) , model . getForwardRateCurve ( ) , swapTenor ) ; double [ ] swapCovarianceWeights = logSwaprateDerivative . get ( "values" ) ; double [ ] discountFactors = logSwaprateDerivative . get ( "discountFactors" ) ; double [ ] swapAnnuities = logSwaprateDerivative . get ( "swapAnnuities" ) ; double [ ] [ ] integratedLIBORCovariance = model . getIntegratedLIBORCovariance ( ) [ optionMaturityIndex ] ; double integratedSwapRateVariance = 0.0 ; for ( int componentIndex1 = swapStartIndex ; componentIndex1 < swapEndIndex ; componentIndex1 ++ ) { for ( int componentIndex2 = componentIndex1 + 1 ; componentIndex2 < swapEndIndex ; componentIndex2 ++ ) { integratedSwapRateVariance += 2.0 * swapCovarianceWeights [ componentIndex1 - swapStartIndex ] * swapCovarianceWeights [ componentIndex2 - swapStartIndex ] * integratedLIBORCovariance [ componentIndex1 ] [ componentIndex2 ] ; } integratedSwapRateVariance += swapCovarianceWeights [ componentIndex1 - swapStartIndex ] * swapCovarianceWeights [ componentIndex1 - swapStartIndex ] * integratedLIBORCovariance [ componentIndex1 ] [ componentIndex1 ] ; } if ( valueUnit == ValueUnit . INTEGRATEDVARIANCELOGNORMAL || valueUnit == ValueUnit . INTEGRATEDVARIANCE ) { return new Scalar ( integratedSwapRateVariance ) ; } double volatility = Math . sqrt ( integratedSwapRateVariance / swapStart ) ; if ( valueUnit == ValueUnit . VOLATILITYLOGNORMAL || valueUnit == ValueUnit . VOLATILITY ) { return new Scalar ( volatility ) ; } double swapAnnuity = swapAnnuities [ 0 ] ; double parSwaprate = ( discountFactors [ 0 ] - discountFactors [ swapEndIndex - swapStartIndex ] ) / swapAnnuity ; double optionMaturity = swapStart ; double valueSwaption = AnalyticFormulas . blackModelSwaptionValue ( parSwaprate , volatility , optionMaturity , swaprate , swapAnnuity ) ; return new Scalar ( valueSwaption ) ; }
Calculates the approximated integrated instantaneous variance of the swap rate,
using the approximation d log(S(t))/d log(L(t)) = d log(S(0))/d log(L(0)).

@param evaluationTime Time at which the product is evaluated.
@param model A model implementing the LIBORModelMonteCarloSimulationModel
@return Depending on the value of value unit, the method returns either
the approximated integrated instantaneous variance of the swap rate (ValueUnit.INTEGRATEDVARIANCE)
or the value using the Black formula (ValueUnit.VALUE).
@TODO make initial values an arg and use evaluation time.