Class Minimizer

java.lang.Object
ai.kognition.pilecv4j.nr.Minimizer

public class Minimizer extends Object

This class encapsulates the running of Powell's Method on a given function in order to determine a local minimum.

The function to be minimized can have a domain of any dimension as it takes an array of doubles and returns the value that needs to be minimized.

For example, to minimize the function (x - 2)^2 - 3 you would:

 {
     @code
     final Minimizer m = new Minimizer(x -> ((x[0] - 2.0) * (x[0] - 2.0)) - 3.0);
     final double minVal = m.minimize(new double[] {-45.0});
     final double minParam = m.getFinalPostion()[0];
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
    static interface 
    Interface representing the function/lambda to be minimized.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static double
    Default float tolerance.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct the minimizer with the function to be minimized.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Return the final domain value of the minimized solution.
    double
    minimize(double[] p)
    Minimize the function that the Minimizer was instantiated with using the identity matrix as the starting position.
    double
    minimize(double[] p, double[][] xi)
    Minimize the function that the Minimizer was instantiated with using the supplied starting position.
    minimize(Minimizer.Func functionToMinimize, double[] startingPosition)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ftol

      public static double ftol
      Default float tolerance.
  • Constructor Details

    • Minimizer

      public Minimizer(Minimizer.Func f)
      Construct the minimizer with the function to be minimized.
  • Method Details

    • minimize

      public double minimize(double[] p) throws MinimizerException
      Minimize the function that the Minimizer was instantiated with using the identity matrix as the starting position.
      Throws:
      MinimizerException
    • minimize

      public double minimize(double[] p, double[][] xi) throws MinimizerException
      Minimize the function that the Minimizer was instantiated with using the supplied starting position.
      Throws:
      MinimizerException
    • minimize

      public static Minimizer.FinalPosition minimize(Minimizer.Func functionToMinimize, double[] startingPosition)
    • getFinalPostion

      public double[] getFinalPostion()
      Return the final domain value of the minimized solution.