当前位置: 首页>>代码示例>>Java>>正文


Java SolverException类代码示例

本文整理汇总了Java中net.finmath.optimizer.SolverException的典型用法代码示例。如果您正苦于以下问题:Java SolverException类的具体用法?Java SolverException怎么用?Java SolverException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SolverException类属于net.finmath.optimizer包,在下文中一共展示了SolverException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCloneShifted

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
/**
 * Returns the set curves calibrated to "shifted" market data, that is,
 * the market date of <code>this</code> object, modified by the shifts
 * provided to this methods.
 * 
 * This method will shift all symbols matching a given regular expression <code>Pattern</code>.
 * 
 * @see java.util.regex.Pattern
 * 
 * @param symbolRegExp A pattern, identifying the symbols to shift.
 * @param shift The shift to apply to the symbol(s).
 * @return A new set of calibrated curves, calibrated to shifted market data.
 * @throws SolverException The likely cause of this exception is a failure of the solver used in the calibration.
 * @throws CloneNotSupportedException The likely cause of this exception is the inability to clone or modify a curve.
 */
public CalibratedCurves getCloneShifted(Pattern symbolRegExp, double shift) throws SolverException, CloneNotSupportedException {
	// Clone calibration specs, shifting the desired symbol
	List<CalibrationSpec> calibrationSpecsShifted = new ArrayList<CalibrationSpec>();

	for(CalibrationSpec calibrationSpec : calibrationSpecs) {
		Matcher matcher = symbolRegExp.matcher(calibrationSpec.symbol);
		if(matcher.matches()) {
			calibrationSpecsShifted.add(calibrationSpec.getCloneShifted(shift));
		}
		else {
			calibrationSpecsShifted.add(calibrationSpec);				
		}
	}

	return new CalibratedCurves(calibrationSpecsShifted, model, evaluationTime, calibrationAccuracy);
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:32,代码来源:CalibratedCurves.java

示例2: getCalibratedCurve

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
public AnalyticModelInterface getCalibratedCurve() throws SolverException {
	final String[] maturity					= { "6M", "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y", "45Y", "50Y" };
	final String[] frequency				= { "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual" };
	final String[] frequencyFloat			= { "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual" };
	final String[] daycountConventions		= { "ACT/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360" };
	final String[] daycountConventionsFloat	= { "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360" };
	final double[] rates					= { -0.00216 ,-0.00208 ,-0.00222 ,-0.00216 ,-0.0019 ,-0.0014 ,-0.00072 ,0.00011 ,0.00103 ,0.00196 ,0.00285 ,0.00367 ,0.0044 ,0.00604 ,0.00733 ,0.00767 ,0.00773 ,0.00765 ,0.00752 ,0.007138 ,0.007 };

	HashMap<String, Object> parameters = new HashMap<String, Object>();

	parameters.put("referenceDate", LocalDate.of(2016, Month.SEPTEMBER, 30)); 
	parameters.put("currency", "EUR");
	parameters.put("forwardCurveTenor", "6M");
	parameters.put("maturities", maturity);
	parameters.put("fixLegFrequencies", frequency);
	parameters.put("floatLegFrequencies", frequencyFloat);
	parameters.put("fixLegDaycountConventions", daycountConventions);
	parameters.put("floatLegDaycountConventions", daycountConventionsFloat);
	parameters.put("rates", rates);

	return getCalibratedCurve(null, parameters);
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:23,代码来源:LIBORMarketModelCalibrationTest.java

示例3: getCalibratedCurve

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
public AnalyticModelInterface getCalibratedCurve() throws SolverException {
	final String[] maturity					= { "6M", "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y", "45Y", "50Y" };
	final String[] frequency				= { "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual" };
	final String[] frequencyFloat			= { "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual", "semiannual" };
	final String[] daycountConventions		= { "ACT/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360" };
	final String[] daycountConventionsFloat	= { "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360" };
	final double[] rates					= { -0.00216 ,-0.00208 ,-0.00222 ,-0.00216 ,-0.0019 ,-0.0014 ,-0.00072 ,0.00011 ,0.00103 ,0.00196 ,0.00285 ,0.00367 ,0.0044 ,0.00604 ,0.00733 ,0.00767 ,0.00773 ,0.00765 ,0.00752 ,0.007138 ,0.007 };

	HashMap<String, Object> parameters = new HashMap<String, Object>();

	parameters.put("referenceDate", new LocalDate(2016, DateTimeConstants.SEPTEMBER, 30)); 
	parameters.put("currency", "EUR");
	parameters.put("forwardCurveTenor", "6M");
	parameters.put("maturities", maturity);
	parameters.put("fixLegFrequencies", frequency);
	parameters.put("floatLegFrequencies", frequencyFloat);
	parameters.put("fixLegDaycountConventions", daycountConventions);
	parameters.put("floatLegDaycountConventions", daycountConventionsFloat);
	parameters.put("rates", rates);

	return getCalibratedCurve(null, parameters);
}
 
开发者ID:finmath,项目名称:finmath-experiments,代码行数:23,代码来源:LIBORMarketModelWithTenorRefinementCalibrationTest.java

示例4: fit

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
public static Map<Double, Integer> fit(double[] time,
                                       double[] prices,
                                       int windowSize,
                                       int shrinkWindowBy,
                                       int nrOfShrinks,
                                       int nrOfSolvers,
                                       ExecutorService service) throws SolverException, InterruptedException {
    // here we will then move the window over the whole time series.
    // for every window we also apply the widow shrinkage to collect all the TCs.
    // this is like a backtest and could be plotted like a heatmap
    return null;
}
 
开发者ID:KIC,项目名称:LPPL,代码行数:13,代码来源:Sornette.java

示例5: setValues

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
@Override
public void setValues(double[] parameters, double[] values) throws SolverException {
    double m = parameters[0];
    double w = parameters[1];
    double tc = parameters[2];
    double[] abcc = this.abccSolver.solve((float) tc, (float) m, (float) w);

    lpplKernel.setAbccMwtc(toFloats(abcc), toFloats(parameters));
    lpplKernel.execute(range);
    copyToDouble(lpplKernel.getValues(), values);

    setParameterSteps(Arrays.stream(parameters).map(p -> (Math.abs(p) + 1) * dFact).toArray());
}
 
开发者ID:KIC,项目名称:LPPL,代码行数:14,代码来源:LPPLSolver.java

示例6: solve

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
double[] solve() {
    try {
        run();
        double[] solution = getBestFitParameters();
        double[] abcc = this.abccSolver.solve((float) solution[2], (float) solution[0], (float) solution[1]);
        return new double[]{solution[0], solution[1], round(solution[2]), abcc[0], abcc[1], abcc[2], abcc[3]};
    } catch (SolverException se) {
        throw new IllegalStateException(se);
    }
}
 
开发者ID:KIC,项目名称:LPPL,代码行数:11,代码来源:LPPLSolver.java

示例7: setUpSolver

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
@BeforeClass
public static void setUpSolver() throws SolverException {
    // do not start to close ...
    sornetteSolver = new LPPLSolver(toFloats(time), toFloats(price), price, 0.2, DEFAULT_W, null, null);
    // warm up the solver
    sornetteSolver.solve();
}
 
开发者ID:KIC,项目名称:LPPL,代码行数:8,代码来源:LPPLSolverPerformanceTest.java

示例8: calibrate

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
private int calibrate(double accuracy) throws SolverException {
	Solver solver = new Solver(model, calibrationProducts, evaluationTime, accuracy);
	model = solver.getCalibratedModel(objectsToCalibrate);

	lastAccuracy = solver.getAccuracy();

	return solver.getIterations();
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:9,代码来源:CalibratedCurves.java

示例9: getCloneCalibrated

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
/**
 * Create a clone of this volatility surface using a generic calibration
 * of its parameters to given market data.
 * 
 * @param calibrationModel The model used during calibration (contains additional objects required during valuation, e.g. curves).
 * @param calibrationProducts The calibration products.
 * @param calibrationTargetValues The target values of the calibration products.
 * @param calibrationParameters A map containing additional settings like "evaluationTime" (Double).
 * @param parameterTransformation An optional parameter transformation.
 * @param optimizerFactory The factory providing the optimizer to be used during calibration.
 * @return An object having the same type as this one, using (hopefully) calibrated parameters.
 * @throws CalculationException Exception thrown when evaluation fails.
 * @throws SolverException Exception thrown when solver fails.
 */
public AbstractVolatilitySurfaceParametric getCloneCalibrated(final AnalyticModelInterface calibrationModel, final Vector<AnalyticProductInterface> calibrationProducts, final List<Double> calibrationTargetValues, Map<String,Object> calibrationParameters, final ParameterTransformation parameterTransformation, OptimizerFactoryInterface optimizerFactory) throws CalculationException, SolverException {
	if(calibrationParameters == null) calibrationParameters = new HashMap<String,Object>();
	Integer maxIterationsParameter	= (Integer)calibrationParameters.get("maxIterations");
	Double	accuracyParameter		= (Double)calibrationParameters.get("accuracy");
	Double	evaluationTimeParameter		= (Double)calibrationParameters.get("evaluationTime");

	// @TODO currently ignored, we use the setting form the OptimizerFactoryInterface
	int maxIterations		= maxIterationsParameter != null ? maxIterationsParameter.intValue() : 600;
	double accuracy			= accuracyParameter != null ? accuracyParameter.doubleValue() : 1E-8;
	double evaluationTime	= evaluationTimeParameter != null ? evaluationTimeParameter.doubleValue() : 0.0;

	AnalyticModelInterface model = calibrationModel.addVolatilitySurfaces(this);
	Solver solver = new Solver(model, calibrationProducts, calibrationTargetValues, parameterTransformation, evaluationTime, optimizerFactory);

	Set<ParameterObjectInterface> objectsToCalibrate = new HashSet<ParameterObjectInterface>();
	objectsToCalibrate.add(this);
	AnalyticModelInterface modelCalibrated = solver.getCalibratedModel(objectsToCalibrate);

	// Diagnostic output
	if (logger.isLoggable(Level.FINE)) {
		double lastAccuracy		= solver.getAccuracy();
		int 	lastIterations	= solver.getIterations();

		logger.fine("The solver achived an accuracy of " + lastAccuracy + " in " + lastIterations + ".");
	}

	return (AbstractVolatilitySurfaceParametric)modelCalibrated.getVolatilitySurface(this.getName());
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:43,代码来源:AbstractVolatilitySurfaceParametric.java

示例10: sabrCalibrateParameterForImpliedNormalVols

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
public static double[] sabrCalibrateParameterForImpliedNormalVols(final double underlying, final double maturity, final double[] givenStrikes, final double[] givenVolatilities, final double[] parameterLowerBound, final double[] parameterUpperBound) throws SolverException {
	double alpha = 0.006;
	double beta = 0.05;
	double rho = 0.0;
	double nu = 0.075;
	double displacement = 0.02;

	double[] parameterInitialValues = { alpha, beta, rho, nu, displacement };

	double[] parameterSteps = { 0.5/100.0/100.0, 1.0/100.0, 0.5/100.0, 0.5/100.0, 0.1/100.0 };
	return sabrCalibrateParameterForImpliedNormalVols(underlying, maturity, givenStrikes, givenVolatilities, parameterInitialValues, parameterSteps, parameterLowerBound, parameterUpperBound);
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:13,代码来源:SABRModel.java

示例11: main

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
/**
 * Run some test using discount curves and forward curves and the solver to create a calibrated model.
 * 
 * @param args Arguments - not used.
 * @throws SolverException Thrown if the solver cannot find a solution to the calibration problem.
 */
public static void main(String[] args) throws SolverException {
	
	CalibrationTest calibrationTest = new CalibrationTest(InterpolationMethod.LINEAR);

	calibrationTest.testForwardCurveFromDiscountCurve();
	calibrationTest.testCurvesAndCalibration();
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:14,代码来源:CalibrationTest.java

示例12: main

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
/**
 * Run some test using discount curves and forward curves and the solver to create a calibrated model.
 * 
 * @param args Arguments - not used.
 * @throws SolverException Thrown if the solver cannot find a solution to the calibration problem.
 */
public static void main(String[] args) throws SolverException {

	CalibrationTest calibrationTest = new CalibrationTest(InterpolationMethod.LINEAR);

	calibrationTest.testForwardCurveFromDiscountCurve();
	calibrationTest.testCurvesAndCalibration();
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:14,代码来源:CalibrationTest.java

示例13: testCalibration

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
/**
 * Test the calibration of a Nelson-Siegel-Svensson curve to a given set of swap rates of
 * (self-discounted) swaps.
 * 
 * @throws SolverException Thrown if the solver cannot find a solution.
 */
@Test
public void testCalibration() throws SolverException {
	
	final String[] maturity					= { "3M", "6M", "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y", "50Y" };
	final String[] frequency				= { "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual", "annual" };
	final String[] frequencyFloat			= { "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly", "quarterly" };
	final String[] daycountConventions		= { "ACT/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360", "E30/360" };
	final String[] daycountConventionsFloat	= { "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360", "ACT/360" };
	final double[] rates					= {0.0042, 0.0032, 0.0038, 0.0052, 0.0069, 0.00855, 0.0102, 0.0119, 0.0134, 0.0150, 0.0165, 0.0178, 0.0189, 0.0200, 0.0224, 0.0250, 0.0264, 0.0271, 0.0275, 0.0276, 0.0276 };
	HashMap<String, Object> parameters = new HashMap<String, Object>();

	parameters.put("referenceDate", LocalDate.of(2014, Month.AUGUST, 12)); 
	parameters.put("currency", "EUR");
	parameters.put("forwardCurveTenor", "3M");
	parameters.put("maturities", maturity);
	parameters.put("fixLegFrequencies", frequency);
	parameters.put("floatLegFrequencies", frequencyFloat);
	parameters.put("fixLegDaycountConventions", daycountConventions);
	parameters.put("floatLegDaycountConventions", daycountConventionsFloat);
	parameters.put("rates", rates);

	double[] nssParameters = calibrateNSSCurve(parameters);

	System.out.println(Arrays.toString(nssParameters));
	System.out.println();
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:33,代码来源:NelsonSiegelSvenssonCalibrationTest.java

示例14: main

import net.finmath.optimizer.SolverException; //导入依赖的package包/类
public static void main(String[] args) throws CalculationException, SolverException {
	LIBORMarketModelWithTenorRefinementCalibrationTest test = new LIBORMarketModelWithTenorRefinementCalibrationTest();
	test.testATMSwaptionCalibration();
}
 
开发者ID:finmath,项目名称:finmath-lib,代码行数:5,代码来源:LIBORMarketModelWithTenorRefinementCalibrationTest.java


注:本文中的net.finmath.optimizer.SolverException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。