List of usage examples for org.apache.commons.math3.optim SimpleBounds unbounded
public static SimpleBounds unbounded(int dim)
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
@Test public void stockingLordTestMixedFormatGradedResponse2() { System.out.println("StockingLordMethod Test 5: Mixed format test, symmetric, Graded Response 2"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items/*from w w w. j a v a2s. c o m*/ irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UserSuppliedDistributionApproximation distX = new UserSuppliedDistributionApproximation(points, xDensity); UserSuppliedDistributionApproximation distY = new UserSuppliedDistributionApproximation(points, yDensity); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, distX, distY, EquatingCriterionType.Q1Q2); sl.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", 0.735177, sl.getIntercept(), 1e-4); assertEquals(" Scale test", 1.213684, sl.getScale(), 1e-4); System.out.println(); }
From source file:com.itemanalysis.psychometrics.irt.equating.StockingLordMethodTest.java
@Test public void stockingLordTestMixedFormatGradedResponse3() { System.out.println("StockingLordMethod Test 5: Mixed format test, backwards, Graded Response 3"); LinkedHashMap<String, ItemResponseModel> irmX = new LinkedHashMap<String, ItemResponseModel>(); LinkedHashMap<String, ItemResponseModel> irmY = new LinkedHashMap<String, ItemResponseModel>(); //3pl items/*from w w w .jav a 2s . c o m*/ irmX.put("v1", new Irm3PL(1.0755, -1.8758, 0.1240, 1.7)); irmX.put("v2", new Irm3PL(0.6428, -0.9211, 0.1361, 1.7)); irmX.put("v3", new Irm3PL(0.6198, -1.3362, 0.1276, 1.7)); irmX.put("v4", new Irm3PL(0.6835, -1.8967, 0.1619, 1.7)); irmX.put("v5", new Irm3PL(0.9892, -0.6427, 0.2050, 1.7)); irmX.put("v6", new Irm3PL(0.5784, -0.8181, 0.1168, 1.7)); irmX.put("v7", new Irm3PL(0.9822, -0.9897, 0.1053, 1.7)); irmX.put("v8", new Irm3PL(1.6026, -1.2382, 0.1202, 1.7)); irmX.put("v9", new Irm3PL(0.8988, -0.5180, 0.1320, 1.7)); irmX.put("v10", new Irm3PL(1.2525, -0.7164, 0.1493, 1.7)); //gpcm items double[] step1 = { -2.1415, 0.0382, 0.6551 }; irmX.put("v11", new IrmGRM(1.1196, step1, 1.7)); double[] step2 = { -1.7523, -1.0660, 0.3533 }; irmX.put("v12", new IrmGRM(1.2290, step2, 1.7)); double[] step3 = { -2.3126, -1.8816, 0.7757 }; irmX.put("v13", new IrmGRM(0.6405, step3, 1.7)); double[] step4 = { -1.9728, -0.2810, 1.1387 }; irmX.put("v14", new IrmGRM(1.1622, step4, 1.7)); double[] step5 = { -2.2207, -0.8252, 0.9702 }; irmX.put("v15", new IrmGRM(1.2249, step5, 1.7)); //3pl items irmY.put("v1", new Irm3PL(0.7444, -1.5617, 0.1609, 1.7)); irmY.put("v2", new Irm3PL(0.5562, -0.1031, 0.1753, 1.7)); irmY.put("v3", new Irm3PL(0.5262, -1.0676, 0.1602, 1.7)); irmY.put("v4", new Irm3PL(0.6388, -1.3880, 0.1676, 1.7)); irmY.put("v5", new Irm3PL(0.8793, -0.2051, 0.1422, 1.7)); irmY.put("v6", new Irm3PL(0.4105, 0.0555, 0.2120, 1.7)); irmY.put("v7", new Irm3PL(0.7686, -0.3800, 0.2090, 1.7)); irmY.put("v8", new Irm3PL(1.0539, -0.7570, 0.1270, 1.7)); irmY.put("v9", new Irm3PL(0.7400, 0.0667, 0.1543, 1.7)); irmY.put("v10", new Irm3PL(0.7479, 0.0281, 0.1489, 1.7)); //gpcm items double[] step6 = { -1.7786, 0.7177, 1.45011 }; irmY.put("v11", new IrmGRM(0.9171, step6, 1.7)); double[] step7 = { -1.4115, -0.4946, 1.15969 }; irmY.put("v12", new IrmGRM(0.9751, step7, 1.7)); double[] step8 = { -1.8478, -1.4078, 1.51339 }; irmY.put("v13", new IrmGRM(0.5890, step8, 1.7)); double[] step9 = { -1.6151, 0.3002, 2.04728 }; irmY.put("v14", new IrmGRM(0.9804, step9, 1.7)); double[] step10 = { -1.9355, -0.2267, 1.88991 }; irmY.put("v15", new IrmGRM(1.0117, step10, 1.7)); UserSuppliedDistributionApproximation distX = new UserSuppliedDistributionApproximation(points, xDensity); UserSuppliedDistributionApproximation distY = new UserSuppliedDistributionApproximation(points, yDensity); StockingLordMethod sl = new StockingLordMethod(irmX, irmY, distX, distY, EquatingCriterionType.Q1); sl.setPrecision(4); double[] startValues = { 0, 1 }; int numIterpolationPoints = 2 * 2;//two dimensions A and B BOBYQAOptimizer underlying = new BOBYQAOptimizer(numIterpolationPoints); RandomGenerator g = new JDKRandomGenerator(); RandomVectorGenerator generator = new UncorrelatedRandomVectorGenerator(2, new GaussianRandomGenerator(g)); MultiStartMultivariateOptimizer optimizer = new MultiStartMultivariateOptimizer(underlying, 10, generator); PointValuePair optimum = optimizer.optimize(new MaxEval(1000), new ObjectiveFunction(sl), GoalType.MINIMIZE, SimpleBounds.unbounded(2), new InitialGuess(startValues)); double[] slCoefficients = optimum.getPoint(); sl.setIntercept(slCoefficients[0]); sl.setScale(slCoefficients[1]); System.out.println(" Iterations: " + optimizer.getEvaluations()); System.out.println(" fmin: " + optimum.getValue()); System.out.println(" B = " + slCoefficients[0] + " A = " + slCoefficients[1]); assertEquals(" Intercept test", 0.739394, sl.getIntercept(), 1e-4); assertEquals(" Scale test", 1.218372, sl.getScale(), 1e-4); System.out.println(); }
From source file:org.hawkular.datamining.forecast.models.performance.OptimizationAlgorithmsTests.java
private long executeBobyQA(ModelData modelData) { long start = System.nanoTime(); BOBYQAOptimizer optimizer = new BOBYQAOptimizer(6); PointValuePair bobyQAResult = optimizer.optimize(GoalType.MINIMIZE, new MaxEval(MAX_EVAL), new MaxIter(MAX_ITER), new InitialGuess(INITIAL_GUESS), new ObjectiveFunction(objectiveFunction), SimpleBounds.unbounded(2)); long executionTime = System.nanoTime() - start; printOptimizationResult(objectiveFunction, bobyQAResult.getPoint(), modelData); return executionTime; }
From source file:uk.ac.diamond.scisoft.ncd.calibration.rcp.views.MultivariateFunctionWithMonitor.java
public void optimize(final double[] startPosition) { final int cmaesLambda = this.cmaesLambda; final double[] cmaesInputSigma = this.cmaesInputSigma; final int cmaesMaxIterations = this.cmaesMaxIterations; final int cmaesCheckFeasableCount = this.cmaesCheckFeasableCount; final ConvergenceChecker<PointValuePair> cmaesChecker = this.cmaesChecker; final MultivariateFunctionWithMonitor function = this; Job job = new Job(jobName) { @Override/* w w w . ja va 2s. c o m*/ protected IStatus run(IProgressMonitor monitor) { function.setInitPeaks(initPeaks); function.setMonitor(monitor); CMAESOptimizer beamPosOptimizer = new CMAESOptimizer(cmaesMaxIterations, 0.0, true, 0, cmaesCheckFeasableCount, new Well19937a(), false, cmaesChecker); final PointValuePair res = beamPosOptimizer.optimize(new MaxEval(cmaesMaxIterations), new ObjectiveFunction(function), GoalType.MAXIMIZE, new CMAESOptimizer.PopulationSize(cmaesLambda), new CMAESOptimizer.Sigma(cmaesInputSigma), SimpleBounds.unbounded(2), new InitialGuess(startPosition)); final double[] newBeamPos = res.getPoint(); logger.info("Optimiser terminated at beam position ({}, {}) with the value {}", new Object[] { newBeamPos[0], newBeamPos[1], res.getValue() }); // Run calculation with optimised beam center to update UI function.value(newBeamPos); return Status.OK_STATUS; } }; job.schedule(); }