Package ai.kognition.pilecv4j.nr
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 - 3you 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 classMinimizer.FinalPositionstatic interfaceMinimizer.FuncInterface representing the function/lambda to be minimized.
-
Field Summary
Fields Modifier and Type Field Description static doubleftolDefault float tolerance.
-
Constructor Summary
Constructors Constructor Description Minimizer(Minimizer.Func f)Construct the minimizer with the function to be minimized.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]getFinalPostion()Return the final domain value of the minimized solution.doubleminimize(double[] p)Minimize the function that theMinimizerwas instantiated with using the identity matrix as the starting position.doubleminimize(double[] p, double[][] xi)Minimize the function that theMinimizerwas instantiated with using the supplied starting position.static Minimizer.FinalPositionminimize(Minimizer.Func functionToMinimize, double[] startingPosition)
-
-
-
Constructor Detail
-
Minimizer
public Minimizer(Minimizer.Func f)
Construct the minimizer with the function to be minimized.
-
-
Method Detail
-
minimize
public double minimize(double[] p) throws MinimizerExceptionMinimize the function that theMinimizerwas instantiated with using the identity matrix as the starting position.- Throws:
MinimizerException
-
minimize
public double minimize(double[] p, double[][] xi) throws MinimizerExceptionMinimize the function that theMinimizerwas 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.
-
-