Package wsh.opt

Class ScalarSolver


  • public class ScalarSolver
    extends java.lang.Object
    Search a single variable for a value that minimizes a function
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  ScalarSolver.Function
      Implement a function of one variable to be minimized
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double solve​(double scalarMin, double scalarMax, double okError, double okFraction, int numberIterations, Monitor monitor)
      Minimize a function of scalar and return the optimum value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScalarSolver

        public ScalarSolver​(ScalarSolver.Function function)
        Constructor
        Parameters:
        function - Objective function to be minimized.
    • Method Detail

      • solve

        public double solve​(double scalarMin,
                            double scalarMax,
                            double okError,
                            double okFraction,
                            int numberIterations,
                            Monitor monitor)
        Minimize a function of scalar and return the optimum value.
        Parameters:
        scalarMin - The minimum value allowed for the argument scalar.
        scalarMax - The maximum value allowed for the argument scalar.
        okError - The unknown error in scalar should be less than this fraction of the range: dscalar/(scalarMax-scalarMin) <= okError, where dscalar is the error bound on the returned value of scalar.
        okFraction - The error in scalar should be less than this fraction of the minimum possible range for scalar: dscalar <= okFraction*(scalar-scalarMin), where dscalar is the error bound on the returned value of scalar.
        numberIterations - The maximum number of iterations if greater than 6. The optimization performs at least 6 iterations -- the minimum necessary for a genuinely parabolic function. I recommend at least 20.
        monitor - For reporting progress. Ignored if null.
        Returns:
        The optimum value minimizing the function.