Skip to main content

Trust region algorithms for non-linear optimisation.

Project description

This package provides two trust region algorithms (TRA) for finding the minimum of some function, Levenberg-Marquardt and Powell's dogleg.

Levenberg-Marquardt

Example

An example is included within the package, simply call:

import TRA as TRA
def forward_model(x):
    y = np.array(x[0] ** 2 + x[1] ** 2)
    y = y.reshape((1, 1))
    return y

def compute_gradient(x):
    g = np.array(([2 * x[0]], [2 * x[1]]))
    g = g.reshape((2, 1))
    return g

def compute_hessian(x):
    h = np.array(([2, 0], [0, 2]))
    h = h.reshape((2, 2))
    return h


initial_prediction = np.array([5, 2.7])

LM_algorithm = TRA.Levenberg_Marquart(initial_prediction, compute_hessian, compute_gradient,
                                                  forward_model, d_param=1e-50,
                                                  lower_constraint=-np.inf,
                                                  upper_constraint=np.inf,
                                                  num_iterations=5)

minimum = LM_algorithm.optimisation_main()



image

This is a simple example, but shows how to use the Levenberg_Marquart class.

Function calls and arguments

There are a number of default values within the Levenberg_Marqaurdt class, including constraints on the solution, the number of iterations amd the damping parameter corresponding to the trust region. Three functions are required when instantiating a class object, one for computing the gradient, one for the Hessian and one for the mapping of the input to ouput (forward model).

:
def forward_model(x)
    :
    return f(x)
def compute_gradient(x):
    :
return grad

def compute_hessian(x):
    :
return hessian

initial_prediction = x0

LM_object = TRA.Levenberg_Marquart(initial_prediction, compute_hessian, compute_gradient,
                                                  forward_model, d_param=1e-50,
                                                  lower_constraint=-np.inf,
                                                  upper_constraint=np.inf,
                                                  num_iterations=5)



Theory

For the theory behind the code see [1] and [2].

References

[1] Jorge Nocedal and Stephen J. Wright (2006). Numerical Optimization.

[2] Andrew R. Conn, Nicholas I. M. Gould, and P.L. Toint (2000). Trust Region Methods.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TRA-2.15.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TRA-2.15-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file TRA-2.15.tar.gz.

File metadata

  • Download URL: TRA-2.15.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.4

File hashes

Hashes for TRA-2.15.tar.gz
Algorithm Hash digest
SHA256 c703b2863c2a0c7c700d7fd7f3adf77602c9952699d5a1f80422807aaf92c0e3
MD5 b7c163ac170b96b1bd729b6d05a1ba4c
BLAKE2b-256 4c2634900b2905cafb77d0634cedde441e59de33ebce43097b069cbc4977c11e

See more details on using hashes here.

File details

Details for the file TRA-2.15-py3-none-any.whl.

File metadata

  • Download URL: TRA-2.15-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.4

File hashes

Hashes for TRA-2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 5add6ce1adb85d70f59845572697badbc7332e948408da524497c753bb402570
MD5 cb0008a97af8dce5c4da75d7040a8953
BLAKE2b-256 cf5a611a10c7c43b847259c792bf3badc960b8fb2edcb5db19973565ab5810c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page