Download PCAIM User`s Manual - Tectonics Observatory at Caltech

Transcript
9.2. DECOMPOSITIONS
99
m-File Summary for conjugate_gradient.m
File Name: conjugate_gradient.m
File Type: function
Author: Martin King; heavily modified by Andrew Kositsky
Maintainer: Hugo Perfettini
Contact E-mail: [email protected]
Version: 1.0.0.0
File Description:
1. Conjugate Gradient Method with Flecther-Reeves (or PolakRibiere) to find a vector x that gives a MINIMUM of a function
(a scalar).
2. Ideas taken from J.R. Shewchuk and Numerical Recipes.
3. You must modify your own function to minimise in a Matlab
function file called func.m (scalar output) and the first derivative of that function in a matlab function file called dfunc.m,
which has a vector output in (del/del(x1) del/del(x2)
... etc)’.
4. If you want to MAXIMISE a function, multiply -1 to the output of func.m and dfunc.m (be careful here, dfunc.m may use
func.m; to be safe, give dfunc.m the original output of func.m
and then multiply -1 to dfunc.m at the end). If you are brave,
reverse the search direction r and d for maximisation.
5. If the method is not converging or is giving you a solution that
doesn’t make sense, change the initial guess.
6. As an example, a simple function is given in func.m and its
gradient vector in dfunc.m. Change the initial guess to x = [1
; 1] for example, the solution it gives is incorrect. The reason
is obvious if you plot the function (it is the saddle points).
7. I have used these scripts to optimise a fairly complicated function. They seem to work well. If you notice any bug or have
any comment, please email me king at ictp at it.
Input
conjugate_gradient(X_dat,x,func,dfunc,iter_max,ftol,
func_options,dfunc_options)