Package com.opengamma.analytics.math.minimization

Examples of com.opengamma.analytics.math.minimization.ConjugateGradientVectorMinimizer


  }

  public void solveExactFromChiSqTest() {
    final DoubleMatrix1D start = new DoubleMatrix1D(new double[] {1.2, 0.8, -0.2, -0.3 });
    final Function1D<DoubleMatrix1D, Double> f = getChiSqFunction(X, Y, SIGMA, PARAM_FUNCTION);
    final ConjugateGradientVectorMinimizer minimizer = new ConjugateGradientVectorMinimizer(new BrentMinimizer1D());
    final DoubleMatrix1D solution = minimizer.minimize(f, start);
    assertEquals(0.0, f.evaluate(solution), 1e-8);
    assertEquals(1.0, solution.getEntry(0), 1e-8);
    assertEquals(1.0, solution.getEntry(1), 1e-8);
    assertEquals(0.0, solution.getEntry(2), 1e-8);
    assertEquals(0.0, solution.getEntry(3), 1e-8);
View Full Code Here


        return chi2 + 0.0 * plenty; // TODO This is not working with a plenty!!!!
      }
    };

    final ScalarMinimizer lineMinimizer = new BrentMinimizer1D();
    final ConjugateGradientVectorMinimizer minimizer = new ConjugateGradientVectorMinimizer(lineMinimizer, 1e-3, 1000);

        final double[] start = new double[nodePos.size()];
        for (int i = 0; i < start.length; i++) {
          start[i] = VALUE;
        }

    final DoubleMatrix1D res = minimizer.minimize(fom, new DoubleMatrix1D(start));
    final double chiSquare = fom.evaluate(res);
     System.out.println(res);
     System.out.println("chi2: " + chiSquare);

     final List<Pair<double[], Double>> weights = combineWeightsAndPos(nodePos, res);
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.minimization.ConjugateGradientVectorMinimizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.