Package ai.kognition.pilecv4j.nr
Class Minimizer
java.lang.Object
ai.kognition.pilecv4j.nr.Minimizer
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 ClassesModifier and TypeClassDescriptionstatic classstatic interfaceInterface representing the function/lambda to be minimized. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstruct the minimizer with the function to be minimized. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]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)
-
Field Details
-
ftol
public static double ftolDefault float tolerance.
-
-
Constructor Details
-
Minimizer
Construct the minimizer with the function to be minimized.
-
-
Method Details
-
minimize
Minimize the function that theMinimizerwas instantiated with using the identity matrix as the starting position.- Throws:
MinimizerException
-
minimize
Minimize 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.
-