Class QNMinimizer


  • public class QNMinimizer
    extends Object
    Implementation of L-BFGS which supports L1-, L2-regularization and Elastic Net for solving convex optimization problems.

    Usage example:

      // Quadratic function f(x) = (x-1)^2 + 10
      // f obtains its minimum value 10 at x = 1
      Function f = new Function() {
    
        @Override
        public int getDimension() {
          return 1;
        }
    
        @Override
        public double valueAt(double[] x) {
          return StrictMath.pow(x[0]-1, 2) + 10;
        }
    
        @Override
        public double[] gradientAt(double[] x) {
          return new double[] { 2*(x[0]-1) };
        }
    
      };
    
      QNMinimizer minimizer = new QNMinimizer();
      double[] x = minimizer.minimize(f);
      double min = f.valueAt(x);
     
    • Constructor Detail

      • QNMinimizer

        public QNMinimizer()
        Initializes a QNMinimizer with default parameters.
      • QNMinimizer

        public QNMinimizer​(double l1Cost,
                           double l2Cost)
        Initializes a QNMinimizer.
        Parameters:
        l1Cost - The L1-regularization cost.
        l2Cost - The L2-regularization cost.
      • QNMinimizer

        public QNMinimizer​(double l1Cost,
                           double l2Cost,
                           int iterations)
        Initializes a QNMinimizer.
        Parameters:
        l1Cost - The L1-regularization cost.
        l2Cost - The L2-regularization cost.
        iterations - The maximum number of iterations.
      • QNMinimizer

        public QNMinimizer​(double l1Cost,
                           double l2Cost,
                           int iterations,
                           int m,
                           int maxFctEval)
        Initializes a QNMinimizer.
        Parameters:
        l1Cost - The L1-regularization cost.
        l2Cost - The L2-regularization cost.
        iterations - The maximum number of iterations.
        m - The number of Hessian updates to store.
        maxFctEval - The maximum number of function evaluations.
      • QNMinimizer

        public QNMinimizer​(double l1Cost,
                           double l2Cost,
                           int iterations,
                           int m,
                           int maxFctEval,
                           boolean verbose)
        Initializes a QNMinimizer.
        Parameters:
        l1Cost - The L1-regularization cost.
        l2Cost - The L2-regularization cost.
        iterations - The maximum number of iterations.
        m - The number of Hessian updates to store.
        maxFctEval - The maximum number of function evaluations.
        verbose - Whether verbose output is printed, or not.
    • Method Detail

      • minimize

        public double[] minimize​(Function function)
        Finds the parameters that minimize the objective function.
        Parameters:
        function - The objective Function.
        Returns:
        The minimizing parameters.