com.github.bruneli.scalaopt.core.leastsquares

LevenbergMarquardt

object LevenbergMarquardt extends Optimizer[MSEFunction, LevenbergMarquardtConfig]

Least squares solution of a non-linear problem with the Levenberg-Marquardt method.

The Levenberg-Marquardt method is equivalent to the Gauss-Newton method but with a trust region strategy meaning that beyond some distance delta, a gradient descent method is used instead of a Gauss-Newton algorithm. The Gauss-Newton method is a modified Newton's method with line search that simplifies via an approximation the computation of the Hessian in case of quadratic Loss function (Least squares problem). Example: find the best exponential curve passing through points

scala> import scala.util.Random
scala> import com.github.bruneli.scalaopt.core._
scala> import leastsquares.LevenbergMarquardt._
scala> import SeqDataSetConverter._
scala> val random = new Random(12345)
scala> val exponential = (x: Variables, t: Variables) => Seq(x(0) * Math.exp(x(1) * t(0)))
scala> val data: DataSet[DataPoint] = for (i <- 1 to 10) yield {
     |   val x = i / 10.0
     |   val y = 2.0 * Math.exp(0.5 * x) + 0.1 * random.nextGaussian()
     |   DataPoint(x, y)
     | }
scala> minimize((exponential, data), Vector(1.0, 1.0))

Although modified, the code implemented below has been inspired from the minpack package licensed under:

Minpack Copyright Notice (1999) University of Chicago. All rights reserved

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment:

"This product includes software developed by the University of Chicago, as Operator of Argonne National Laboratory.

Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear.

4. WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE WOULD NOT INFRINGE PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED.

5. LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDER, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF ANY KIND OR NATURE, INCLUDING BUT NOT LIMITED TO LOSS OF PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, WHETHER SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS BEEN WARNED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGES.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. LevenbergMarquardt
  2. Optimizer
  3. AnyRef
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. implicit val defaultConfig: LevenbergMarquardtConfig

    Definition Classes
    LevenbergMarquardtOptimizer
  9. def eNorm(v: Variables): Double

  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. def lmPar(qr: QR, diag: Variables, delta: Double, par0: Double, maxStepLengthIter: Int): (Double, Variables, Variables)

  17. def minimize(f: MSEFunction, x0: Variables)(implicit pars: LevenbergMarquardtConfig): Try[Variables]

    Minimize an objective function acting on a vector of real values.

    Minimize an objective function acting on a vector of real values.

    f

    real-valued objective function

    x0

    initial Variables

    pars

    algorithm configuration parameters

    returns

    Variables at a local minimum or failure

    Definition Classes
    LevenbergMarquardtOptimizer
  18. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  19. final def notify(): Unit

    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  21. def qrSolve(qr: QR, diag: Variables): (Variables, Variables)

    Solve a constrained linear system with the help of QR factorization.

    Solve a constrained linear system with the help of QR factorization.

    Given an m by n matrix a, an n by n diagonal matrix d, and an m-vector b, the problem is to determine an x which solves the system

    a*x = b and d*x = 0

    in the least squares sense.

    This subroutine completes the solution of the problem if it is provided with the necessary information from the QR factorization, with column pivoting, of a. That is, if a*p = q*r, where p is a permutation matrix, q has orthogonal columns, and r is an upper triangular matrix with diagonal elements of non-increasing magnitude, then qrSolv expects the full upper triangle of r, the permutation matrix p, and the first n components of (q transpose)*b. The system a*x = b, d*x = 0, is then equivalent to

    r*z = qT*b, pT*d*p*z = 0,

    where x = p*z. If this system does not have full rank, then a least squares solution is obtained.

  22. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  23. def toString(): String

    Definition Classes
    AnyRef → Any
  24. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped