Java Code Examples for org.apache.commons.math.linear.RealMatrix#operate()
The following examples show how to use
org.apache.commons.math.linear.RealMatrix#operate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares2() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new double[] { 10.0, 0.1 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 5.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 2
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares3() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2, -3 }, new Array2DRowRealMatrix(new double [][] { { 1, 1.2 }, { 1.2, 2 } })); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); Assert.assertEquals( 2, optimum.getPointRef()[0], 2e-3); Assert.assertEquals(-3, optimum.getPointRef()[1], 8e-4); Assert.assertTrue(optimizer.getEvaluations() > 60); Assert.assertTrue(optimizer.getEvaluations() < 80); Assert.assertTrue(optimum.getValue() < 1e-6); }
Example 3
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares2() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new double[] { 10.0, 0.1 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 5.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 4
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 5
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 6
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); Assert.assertEquals( 2, optimum.getPointRef()[0], 3e-5); Assert.assertEquals(-3, optimum.getPointRef()[1], 4e-4); Assert.assertTrue(optimizer.getEvaluations() > 60); Assert.assertTrue(optimizer.getEvaluations() < 80); Assert.assertTrue(optimum.getValue() < 1.0e-6); }
Example 7
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares2() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new double[] { 10.0, 0.1 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 5.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 8
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 9
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); Assert.assertEquals( 2, optimum.getPointRef()[0], 3e-5); Assert.assertEquals(-3, optimum.getPointRef()[1], 4e-4); Assert.assertTrue(optimizer.getEvaluations() > 60); Assert.assertTrue(optimizer.getEvaluations() < 80); Assert.assertTrue(optimum.getValue() < 1.0e-6); }
Example 10
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 11
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxEvaluations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 12
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares3() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2, -3 }, new Array2DRowRealMatrix(new double [][] { { 1, 1.2 }, { 1.2, 2 } })); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); assertEquals( 2, optimum.getPointRef()[0], 2e-3); assertEquals(-3, optimum.getPointRef()[1], 8e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1e-6); }
Example 13
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares2() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2, -3 }, new double[] { 10, 0.1 }); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); assertEquals( 2, optimum.getPointRef()[0], 5e-5); assertEquals(-3, optimum.getPointRef()[1], 8e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1e-6); }
Example 14
Source File: SimplexOptimizerNelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1, 0 }, { 0, 1 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); SimplexOptimizer optimizer = new SimplexOptimizer(-1, 1e-6); optimizer.setSimplex(new NelderMeadSimplex(2)); RealPointValuePair optimum = optimizer.optimize(200, ls, GoalType.MINIMIZE, new double[] { 10, 10 }); assertEquals( 2, optimum.getPointRef()[0], 3e-5); assertEquals(-3, optimum.getPointRef()[1], 4e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 15
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void testLeastSquares1() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 3.0e-5); assertEquals(-3.0, optimum.getPointRef()[1], 4.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 16
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testLeastSquares3() throws FunctionEvaluationException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] { { 1.0, 1.2 }, { 1.2, 2.0 } })); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxEvaluations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 2.0e-3); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 17
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testLeastSquares3() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] { { 1.0, 1.2 }, { 1.2, 2.0 } })); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 2.0e-3); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 18
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testLeastSquares3() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] { { 1.0, 1.2 }, { 1.2, 2.0 } })); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 2.0e-3); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 19
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testLeastSquares3() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] { { 1.0, 1.2 }, { 1.2, 2.0 } })); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 2.0e-3); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }
Example 20
Source File: NelderMeadTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void testLeastSquares3() throws FunctionEvaluationException, ConvergenceException { final RealMatrix factors = new Array2DRowRealMatrix(new double[][] { { 1.0, 0.0 }, { 0.0, 1.0 } }, false); LeastSquaresConverter ls = new LeastSquaresConverter(new MultivariateVectorialFunction() { public double[] value(double[] variables) { return factors.operate(variables); } }, new double[] { 2.0, -3.0 }, new Array2DRowRealMatrix(new double [][] { { 1.0, 1.2 }, { 1.2, 2.0 } })); NelderMead optimizer = new NelderMead(); optimizer.setConvergenceChecker(new SimpleScalarValueChecker(-1.0, 1.0e-6)); optimizer.setMaxIterations(200); RealPointValuePair optimum = optimizer.optimize(ls, GoalType.MINIMIZE, new double[] { 10.0, 10.0 }); assertEquals( 2.0, optimum.getPointRef()[0], 2.0e-3); assertEquals(-3.0, optimum.getPointRef()[1], 8.0e-4); assertTrue(optimizer.getEvaluations() > 60); assertTrue(optimizer.getEvaluations() < 80); assertTrue(optimum.getValue() < 1.0e-6); }