Examples of CostFunction


Examples of com.beoui.geocell.model.CostFunction

  public static void main(String[] args)
  {
    BoundingBox bb = new BoundingBox(38.912056, -118.40747, 35.263195, -123.88965);
   
    // This causes an endless loop
    List<String> cells = GeocellManager.bestBboxSearchCells(bb, new CostFunction() {
      @Override
      public double defaultCostFunction(int numCells, int resolution)
      {
        // Here we ensure that we do not try to query more than 30 cells, the limit of a gae IN filter
        return numCells > 30 ? Double.MAX_VALUE : 0;
View Full Code Here

Examples of de.jungblut.math.minimize.CostFunction

   * @param theta initial spot to start the minimizations.
   * @return the cost of the training.
   */
  public final double train(DoubleVector[] features, DoubleVector[] outcome,
      Minimizer minimizer, int maxIterations, double lambda, boolean verbose) {
    CostFunction costFunction = new MultilayerPerceptronCostFunction(this,
        features, outcome);
    return trainInternal(minimizer, maxIterations, verbose, costFunction,
        getFoldedThetaVector());
  }
View Full Code Here

Examples of de.jungblut.math.minimize.CostFunction

  @Test
  public void testNumericalGradient() {
    // our function is f(x,y) = x^2+y^2
    // the derivative is f'(x,y) = 2x+2y
    final CostFunction inlineFunction = new CostFunction() {
      @Override
      public CostGradientTuple evaluateCost(DoubleVector input) {

        double cost = Math.pow(input.get(0), 2) + Math.pow(input.get(1), 2);
        DenseDoubleVector gradient = new DenseDoubleVector(new double[] {
            input.get(0) * 2, input.get(1) * 2 });

        return new CostGradientTuple(cost, gradient);
      }
    };
    DenseDoubleVector v = new DenseDoubleVector(new double[] { 0, 1 });
    CostGradientTuple cost = inlineFunction.evaluateCost(v);
    DoubleVector numericalGradient = MathUtils.numericalGradient(v,
        inlineFunction);
    assertSmallDiff(numericalGradient, cost.getGradient());

    v = new DenseDoubleVector(new double[] { -15, 100 });
    cost = inlineFunction.evaluateCost(v);

    numericalGradient = MathUtils.numericalGradient(v, inlineFunction);
    assertSmallDiff(numericalGradient, cost.getGradient());
  }
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  public NelderMeadTest(String name) {
    super(name);
  }

  public void testCostExceptions() throws ConvergenceException {
      CostFunction wrong =
          new CostFunction() {
            public double cost(double[] x) throws CostException {
                if (x[0] < 0) {
                    throw new CostException("{0}", new Object[] { "oops"});
                } else if (x[0] > 1) {
                    throw new CostException(new RuntimeException("oops"));
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  }

  public void testRosenbrock()
    throws CostException, ConvergenceException, NotPositiveDefiniteMatrixException {

    CostFunction rosenbrock =
      new CostFunction() {
        public double cost(double[] x) {
          ++count;
          double a = x[1] - x[0] * x[0];
          double b = 1.0 - x[0];
          return 100 * a * a + b * b;
 
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  }

  public void testPowell()
    throws CostException, ConvergenceException {

    CostFunction powell =
      new CostFunction() {
        public double cost(double[] x) {
          ++count;
          double a = x[0] + 10 * x[1];
          double b = x[2] - x[3];
          double c = x[1] - 2 * x[2];
 
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  public MultiDirectionalTest(String name) {
    super(name);
  }

  public void testCostExceptions() throws ConvergenceException {
      CostFunction wrong =
          new CostFunction() {
            public double cost(double[] x) throws CostException {
                if (x[0] < 0) {
                    throw new CostException("{0}", new Object[] { "oops"});
                } else if (x[0] > 1) {
                    throw new CostException(new RuntimeException("oops"));
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  }

  public void testRosenbrock()
    throws CostException, ConvergenceException {

    CostFunction rosenbrock =
      new CostFunction() {
        public double cost(double[] x) {
          ++count;
          double a = x[1] - x[0] * x[0];
          double b = 1.0 - x[0];
          return 100 * a * a + b * b;
 
View Full Code Here

Examples of org.apache.commons.math.optimization.CostFunction

  }

  public void testPowell()
    throws CostException, ConvergenceException {

    CostFunction powell =
      new CostFunction() {
        public double cost(double[] x) {
          ++count;
          double a = x[0] + 10 * x[1];
          double b = x[2] - x[3];
          double c = x[1] - 2 * x[2];
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.